diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7e59c1a54..8e1113781 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -14,10 +14,10 @@ INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) - VALUES + VALUES (1, 'it@gotamcity.com', 'incidences@gotamcity.com'); -INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -349,7 +349,7 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`) INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`) VALUES - (200, 10); + (200, null); INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES diff --git a/print/templates/reports/invoiceIn/invoiceIn.html b/print/templates/reports/invoiceIn/invoiceIn.html index a1d488560..4bc6d8ee0 100644 --- a/print/templates/reports/invoiceIn/invoiceIn.html +++ b/print/templates/reports/invoiceIn/invoiceIn.html @@ -46,45 +46,21 @@
{{invoice.postcodeCity}}
-
+
{{$t('fiscalId')}}: {{invoice.nif}}
-
+
{{$t('phone')}}: {{invoice.phone}}
-
-

{{$t('invoiceIn')}} +

{{$t('invoiceId')}}

@@ -153,7 +129,7 @@
- Taxes block +
@@ -175,9 +151,9 @@ - + @@ -185,14 +161,14 @@ - +
{{tax.name}} - {{tax.base | currency('EUR', $i18n.locale)}} + {{tax.taxableBase | currency('EUR', $i18n.locale)}} {{tax.vatPercent | percentage}}{{tax.rate | percentage}} {{tax.vat | currency('EUR', $i18n.locale)}}
{{$t('subtotal')}} - {{sumTotal(taxes, 'base') | currency('EUR', $i18n.locale)}} + {{sumTotal(taxes, 'taxableBase') | currency('EUR', $i18n.locale)}} {{sumTotal(taxes, 'vat') | currency('EUR', $i18n.locale)}}
{{$t('total')}}{{taxTotal | currency('EUR', $i18n.locale)}}{{taxTotal() | currency('EUR', $i18n.locale)}}
@@ -205,109 +181,30 @@
- +
{{$t('observations')}}
-
{{$t('wireTransfer')}}
-
{{$t('accountNumber', [invoice.iban])}}
+
{{$t('payMethod')}}
+
{{invoice.payMethod}}
- End of observations block +
- Footer block - - --> +
+ + + diff --git a/print/templates/reports/invoiceIn/invoiceIn.js b/print/templates/reports/invoiceIn/invoiceIn.js index 103f36d1c..cfad062ed 100755 --- a/print/templates/reports/invoiceIn/invoiceIn.js +++ b/print/templates/reports/invoiceIn/invoiceIn.js @@ -42,8 +42,9 @@ module.exports = { fetchBuy(id) { return this.rawSqlFromDef('buy', [id]); }, - fetchTaxes(id) { - return this.rawSqlFromDef(`taxes`, [id]); + async fetchTaxes(id) { + const taxes = await this.rawSqlFromDef(`taxes`, [id]); + return this.taxVat(taxes); }, buyImport(buy) { return buy.quantity * buy.buyingValue; @@ -61,6 +62,23 @@ module.exports = { total += parseFloat(row[prop]); return total; + }, + taxVat(taxes) { + for (tax of taxes) { + let vat = 0; + if (tax.rate && tax.taxableBase) + vat = (tax.rate / 100) * tax.taxableBase; + + tax.vat = vat; + } + + return taxes; + }, + taxTotal() { + const base = this.sumTotal(this.taxes, 'taxableBase'); + const vat = this.sumTotal(this.taxes, 'vat'); + + return base + vat; } }, components: { diff --git a/print/templates/reports/invoiceIn/locale/en.yml b/print/templates/reports/invoiceIn/locale/en.yml index 4e4688b55..7a8767ad3 100644 --- a/print/templates/reports/invoiceIn/locale/en.yml +++ b/print/templates/reports/invoiceIn/locale/en.yml @@ -1,17 +1,16 @@ reportName: invoice -title: Invoice -invoice: Invoice -clientId: Client +title: Agrobusiness invoice +invoiceId: Agrobusiness invoice +supplierId: Proveedor invoiceData: Invoice data +reference: Reference fiscalId: FI / NIF -invoiceRef: Invoice {0} -deliveryNote: Delivery note -shipped: Shipped +phone: Phone date: Date -reference: Ref. +item: Item quantity: Qty. concept: Concept -price: PSP/u +buyingValue: PSP/u discount: Disc. vat: VAT amount: Amount @@ -22,15 +21,5 @@ fee: Fee total: Total subtotal: Subtotal taxBreakdown: Tax breakdown -notes: Notes -intrastat: Intrastat -code: Code -description: Description -stems: Stems -netKg: Net kg -rectifiedInvoices: Rectified invoices -issued: Issued -plantPassport: Plant passport observations: Observations -wireTransfer: "Pay method: Transferencia" -accountNumber: "Account number: {0}" \ No newline at end of file +payMethod: Pay method diff --git a/print/templates/reports/invoiceIn/locale/es.yml b/print/templates/reports/invoiceIn/locale/es.yml index 6386c611a..f2fb28e64 100644 --- a/print/templates/reports/invoiceIn/locale/es.yml +++ b/print/templates/reports/invoiceIn/locale/es.yml @@ -3,15 +3,14 @@ title: Factura Agrícola invoiceId: Factura Agrícola supplierId: Proveedor invoiceData: Datos de facturación +reference: Referencia fiscalId: CIF / NIF -invoiceRef: Factura {0} -deliveryNote: Albarán -shipped: F. envío +phone: Tlf date: Fecha -reference: Ref. +item: Artículo quantity: Cant. concept: Concepto -price: PVP/u +buyingValue: PVP/u discount: Dto. vat: IVA amount: Importe @@ -22,15 +21,5 @@ fee: Cuota total: Total subtotal: Subtotal taxBreakdown: Desglose impositivo -notes: Notas -intrastat: Intrastat -code: Código -description: Descripción -stems: Tallos -netKg: KG Neto -rectifiedInvoices: Facturas rectificadas -issued: F. emisión -plantPassport: Pasaporte fitosanitario observations: Observaciones -wireTransfer: "Forma de pago: Transferencia" -accountNumber: "Número de cuenta: {0}" +payMethod: Método de pago diff --git a/print/templates/reports/invoiceIn/sql/invoice.sql b/print/templates/reports/invoiceIn/sql/invoice.sql index 8913a833b..fe9ef1e9e 100644 --- a/print/templates/reports/invoiceIn/sql/invoice.sql +++ b/print/templates/reports/invoiceIn/sql/invoice.sql @@ -5,8 +5,10 @@ SELECT s.name, s.street AS postalAddress, s.nif, - s.phone + s.phone, + p.name payMethod FROM invoiceIn i JOIN supplier s ON s.id = i.supplierFk JOIN company c ON c.id = i.companyFk + JOIN payMethod p ON p.id = s.payMethodFk WHERE i.id = ? diff --git a/print/templates/reports/invoiceIn/sql/taxes.sql b/print/templates/reports/invoiceIn/sql/taxes.sql index 18ca6db09..20df33f83 100644 --- a/print/templates/reports/invoiceIn/sql/taxes.sql +++ b/print/templates/reports/invoiceIn/sql/taxes.sql @@ -1,13 +1,8 @@ SELECT - id, - invoiceInFk, - taxableBase, - expenseFk, - taxTypeSageFk, - transactionTypeSageFk, - foreignValue - FROM invoiceInTax iit - JOIN transactionTypeSage ts ON iit.transactionTypeSageFk = ts.id - JOIN taxTypeSage tts ON tts.id = - WHERE io.ref = ? - ORDER BY iot.id + ti.iva as name, + ti.PorcentajeIva as rate, + iit.taxableBase + FROM invoiceIn ii + JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk + JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + WHERE ii.id = ?;