Rechnungen
- Artikelsuche - optional weg - Einheit weg - Einzelpreis wird nicht geholt - einzelpreis andere preistypen irgendwie anzeigen - ust weg - -1 menge erlauben - kleiner Speicher bug - mit Rechnungsadresse LS geht nicht übernehmen - pdf herunterladen Status ändern - per Mail verschicken ohne eingetragene Mail geht ned
This commit is contained in:
@@ -179,7 +179,7 @@ Vue.component('manual-invoice-modal', {
|
||||
<tt-textarea label="Einleitender Text" v-model="invoiceData.einleitender_text" rows="3" sm row/>
|
||||
</tt-card>
|
||||
<tt-card><template v-slot:header><h5><i class="fas fa-list-ol mr-2"></i>Positionen</h5></template>
|
||||
<tt-positions-manager group-mode ref="positionsManager" v-model="invoiceData.positions" :config="positionsConfig" @updateField-article_id="onArticleSelected" />
|
||||
<tt-positions-manager group-mode ref="positionsManager" v-model="invoiceData.positions" :config="positionsConfig" @updateField-article_id="onArticleSelected" @updateField-price_type="onPriceTypeChanged" />
|
||||
</tt-card>
|
||||
<tt-card><template v-slot:header><h5><i class="fas fa-paragraph mr-2"></i>Rabatt</h5></template>
|
||||
<tt-input label="Gesamtrabatt (%)" v-model.number="invoiceData.gesamtrabatt" sm row type="number" placeholder="0"/>
|
||||
@@ -222,35 +222,31 @@ Vue.component('manual-invoice-modal', {
|
||||
positionsConfig: {
|
||||
fields: {
|
||||
article_id: {
|
||||
type: 'autocomplete',
|
||||
label: 'Artikel (optional)',
|
||||
type: 'input-article',
|
||||
label: 'Artikel',
|
||||
apiUrl: '/WarehouseArticle/autocomplete',
|
||||
customFieldReference: 'WarehouseArticle'
|
||||
customFieldReference: 'WarehouseArticle',
|
||||
emitDisplayValue: true
|
||||
},
|
||||
product_name: { type: 'input', label: 'Bezeichnung' },
|
||||
product_info: { type: 'input', label: 'Zusatzinfo' },
|
||||
amount: { type: 'input', label: 'Menge', inputType: 'number' },
|
||||
unit: {
|
||||
price_type: {
|
||||
type: 'select',
|
||||
label: 'Einheit',
|
||||
options: [
|
||||
{ value: 'Pau.', text: 'Pau.' },
|
||||
{ value: 'Stk.', text: 'Stk.' },
|
||||
{ value: 'h', text: 'h' },
|
||||
{ value: 'm', text: 'm' }
|
||||
]
|
||||
label: 'Preistyp',
|
||||
options: []
|
||||
},
|
||||
price: { type: 'input', label: 'Einzelpreis (€)', inputType: 'number' },
|
||||
discount: { type: 'input', label: 'Rabatt (%)', inputType: 'number' },
|
||||
vatrate: { type: 'input', label: 'USt. (%)', inputType: 'number' },
|
||||
},
|
||||
validateForm: (d) => {
|
||||
if (!d.product_name) { window.notify('error', 'Bezeichnung ist erforderlich.'); return false; }
|
||||
if (!d.amount) { window.notify('error', 'Menge ist erforderlich.'); return false; }
|
||||
if (d.amount == null || d.amount === '') { window.notify('error', 'Menge ist erforderlich.'); return false; }
|
||||
if (d.price == null) { window.notify('error', 'Preis ist erforderlich.'); return false; }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
articlePrices: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -392,15 +388,21 @@ Vue.component('manual-invoice-modal', {
|
||||
},
|
||||
togglePreviewVisibility() { if (!this.isLargeScreen) this.showPreviewOnSmallScreen = !this.showPreviewOnSmallScreen; },
|
||||
async onArticleSelected(articleId) {
|
||||
if (!articleId) return;
|
||||
if (!articleId) {
|
||||
// Reset price type options when no article selected
|
||||
this.articlePrices = [];
|
||||
this.positionsConfig.fields.price_type.options = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const vatarea = this.customerBillingInfo.vatarea || 'domestic';
|
||||
const { data } = await axios.get(`${window.TT_CONFIG.BASE_PATH}/ManualInvoice/getArticleVatInfo?article_id=${articleId}&vatarea=${vatarea}`);
|
||||
if (data.success && this.$refs.positionsManager) {
|
||||
const pm = this.$refs.positionsManager;
|
||||
if (data.article) {
|
||||
pm.$set(pm.formData, 'product_name', data.article.title);
|
||||
pm.$set(pm.formData, 'product_name', data.article.articleNumber + ' | ' + data.article.title);
|
||||
pm.$set(pm.formData, 'product_info', data.article.description || '');
|
||||
pm.$set(pm.formData, 'unit', data.article.unit || 'Stk.');
|
||||
}
|
||||
pm.$set(pm.formData, 'vatrate', parseFloat(data.vatrate) || 20);
|
||||
pm.$set(pm.formData, 'fibu_cost_account', data.fibu_cost_account);
|
||||
@@ -408,11 +410,30 @@ Vue.component('manual-invoice-modal', {
|
||||
pm.$set(pm.formData, 'fibu_taxcode', data.fibu_taxcode);
|
||||
this.invoiceData.vatgroup_id = data.vatgroup_id;
|
||||
await this.updateTaxText(data.vatgroup_id);
|
||||
|
||||
// Handle prices and price type selection
|
||||
this.articlePrices = data.prices || [];
|
||||
if (this.articlePrices.length > 0) {
|
||||
const priceOptions = this.articlePrices.map(p => ({ value: p.title, text: `${p.title} (${this.formatPrice(p.price)})` }));
|
||||
this.positionsConfig.fields.price_type.options = priceOptions;
|
||||
// Set first price as default
|
||||
pm.$set(pm.formData, 'price_type', this.articlePrices[0].title);
|
||||
pm.$set(pm.formData, 'price', this.articlePrices[0].price);
|
||||
} else {
|
||||
this.positionsConfig.fields.price_type.options = [];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error fetching article VAT info:', e);
|
||||
}
|
||||
},
|
||||
onPriceTypeChanged(priceType) {
|
||||
if (!priceType || !this.articlePrices.length) return;
|
||||
const selectedPrice = this.articlePrices.find(p => p.title === priceType);
|
||||
if (selectedPrice && this.$refs.positionsManager) {
|
||||
this.$refs.positionsManager.$set(this.$refs.positionsManager.formData, 'price', selectedPrice.price);
|
||||
}
|
||||
},
|
||||
async updateTaxText(vatgroupId) {
|
||||
if (!vatgroupId) return;
|
||||
try {
|
||||
@@ -434,7 +455,7 @@ Vue.component('manual-invoice-modal', {
|
||||
this.pdfLoading = true;
|
||||
try {
|
||||
const positions = this.invoiceData.positions
|
||||
.filter(p => p.product_name && (parseFloat(p.amount) || 0) > 0) // Filter out empty positions
|
||||
.filter(p => p.product_name && (parseFloat(p.amount) || 0) !== 0) // Filter out empty positions (allow negative for Gutschrift)
|
||||
.map(p => {
|
||||
const amount = parseFloat(p.amount) || 0;
|
||||
const price = parseFloat(p.price) || 0;
|
||||
@@ -546,7 +567,7 @@ Vue.component('manual-invoice-modal', {
|
||||
Vue.component('gutschrift-modal', {
|
||||
props: ['invoiceId'],
|
||||
template: `
|
||||
<tt-modal :show="true" @close="close" size="lg" title="Gutschrift erstellen">
|
||||
<tt-modal :show="true" @update:show="close" size="lg" title="Gutschrift erstellen">
|
||||
<div v-if="loading" class="text-center py-5"><i class="fas fa-spinner fa-spin fa-3x"></i><p class="mt-3">Lade Rechnungsdaten...</p></div>
|
||||
<div v-else-if="invoice">
|
||||
<div class="alert alert-info"><strong>Originalrechnung:</strong> {{ invoice.invoice_number }} - {{ invoice.customer_name }}</div>
|
||||
@@ -623,7 +644,7 @@ Vue.component('gutschrift-modal', {
|
||||
Vue.component('send-invoice-modal', {
|
||||
props: ['invoiceId'],
|
||||
template: `
|
||||
<tt-modal :show="true" @close="close" @submit="handleAction" :submit-text="actionButtonText" :is-loading="loading" size="md">
|
||||
<tt-modal :show="true" @update:show="close" @submit="handleAction" :submit-text="actionButtonText" :is-loading="loading" size="md">
|
||||
<template v-slot:header>
|
||||
<h5><i class="fas fa-paper-plane mr-2"></i>Rechnung aussenden</h5>
|
||||
</template>
|
||||
@@ -639,11 +660,11 @@ Vue.component('send-invoice-modal', {
|
||||
<div class="form-group">
|
||||
<label>Aktion auswählen:</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" id="action-email" value="email" v-model="selectedAction" :disabled="!invoice.email">
|
||||
<input class="form-check-input" type="radio" id="action-email" value="email" v-model="selectedAction">
|
||||
<label class="form-check-label" for="action-email">
|
||||
<i class="fas fa-envelope mr-2"></i>Per E-Mail versenden
|
||||
<span v-if="invoice.email" class="text-muted d-block ml-4">an {{ invoice.email }}</span>
|
||||
<span v-else class="text-danger d-block ml-4">Keine E-Mail-Adresse vorhanden</span>
|
||||
<span v-if="invoice.email" class="text-muted d-block ml-4">Kunden-E-Mail: {{ invoice.email }}</span>
|
||||
<span v-else class="text-warning d-block ml-4"><i class="fas fa-exclamation-triangle"></i> Keine Kunden-E-Mail - bitte manuell eingeben</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check mt-2">
|
||||
@@ -653,8 +674,8 @@ Vue.component('send-invoice-modal', {
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="selectedAction === 'email' && invoice.email" class="mt-3">
|
||||
<tt-input label="E-Mail-Adresse" v-model="emailAddress" sm/>
|
||||
<div v-if="selectedAction === 'email'" class="mt-3">
|
||||
<tt-input label="E-Mail-Adresse" v-model="emailAddress" sm :placeholder="invoice.email ? 'Standard: ' + invoice.email : 'E-Mail-Adresse eingeben'"/>
|
||||
</div>
|
||||
</div>
|
||||
</tt-modal>
|
||||
@@ -678,7 +699,6 @@ Vue.component('send-invoice-modal', {
|
||||
if (data.success) {
|
||||
this.invoice = data.invoice;
|
||||
this.emailAddress = data.invoice.email || '';
|
||||
this.selectedAction = data.invoice.email ? 'email' : 'download';
|
||||
} else {
|
||||
window.notify('error', data.message || 'Fehler beim Laden der Rechnung');
|
||||
this.close();
|
||||
|
||||
Reference in New Issue
Block a user