feat: report invoiceInPdf
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2022-10-19 15:15:54 +02:00
parent 9ef835a077
commit 4b12405586
7 changed files with 66 additions and 176 deletions

View File

@ -14,10 +14,10 @@ INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`)
('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66);
INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`)
VALUES VALUES
(1, 'it@gotamcity.com', 'incidences@gotamcity.com'); (1, 'it@gotamcity.com', 'incidences@gotamcity.com');
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
VALUES VALUES
('1', '6'); ('1', '6');
@ -349,7 +349,7 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`)
INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`) INSERT INTO `vn`.`clientConfig`(`riskTolerance`, `maxCreditRows`)
VALUES VALUES
(200, 10); (200, null);
INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`)
VALUES VALUES

View File

@ -46,45 +46,21 @@
<div> <div>
{{invoice.postcodeCity}} {{invoice.postcodeCity}}
</div> </div>
<div> <div v-if="invoice.nif">
{{$t('fiscalId')}}: {{invoice.nif}} {{$t('fiscalId')}}: {{invoice.nif}}
</div> </div>
<div> <div v-if="invoice.phone">
{{$t('phone')}}: {{invoice.phone}} {{$t('phone')}}: {{invoice.phone}}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!--
Rectified invoices block
<div class="size100 no-page-break" v-if="rectified.length > 0">
<h2>{{$t('rectifiedInvoices')}}</h2>
<table class="column-oriented">
<thead>
<tr>
<th>{{$t('invoice')}}</th>
<th>{{$t('issued')}}</th>
<th class="number">{{$t('amount')}}</th>
<th width="50%">{{$t('description')}}</th>
</tr>
</thead>
<tbody>
<tr v-for="row in rectified">
<td>{{row.ref}}</td>
<td>{{row.issued | date}}</td>
<td class="number">{{row.amount | currency('EUR', $i18n.locale)}}</td>
<td width="50%">{{row.description}}</td>
</tr>
</tbody>
</table>
</div>
End of rectified invoices block-->
<div class="vn-mt-lg" v-for="entry in entries"> <div class="vn-mt-lg" v-for="entry in entries">
<div class="table-title clearfix"> <div class="table-title clearfix">
<div class="pull-left"> <div class="pull-left">
<h2>{{$t('invoiceIn')}}</strong> <h2>{{$t('invoiceId')}}</strong>
</div> </div>
<div class="pull-left vn-mr-md"> <div class="pull-left vn-mr-md">
<div class="field rectangle"> <div class="field rectangle">
@ -153,7 +129,7 @@
<!-- End of sales block --> <!-- End of sales block -->
<div class="columns vn-mt-xl"> <div class="columns vn-mt-xl">
Taxes block <!-- Taxes block -->
<div id="taxes" class="size50 pull-right no-page-break" v-if="taxes"> <div id="taxes" class="size50 pull-right no-page-break" v-if="taxes">
<table class="column-oriented"> <table class="column-oriented">
<thead> <thead>
@ -175,9 +151,9 @@
<tr v-for="tax in taxes"> <tr v-for="tax in taxes">
<td width="45%">{{tax.name}}</td> <td width="45%">{{tax.name}}</td>
<td width="25%" class="number"> <td width="25%" class="number">
{{tax.base | currency('EUR', $i18n.locale)}} {{tax.taxableBase | currency('EUR', $i18n.locale)}}
</td> </td>
<td>{{tax.vatPercent | percentage}}</td> <td>{{tax.rate | percentage}}</td>
<td class="number">{{tax.vat | currency('EUR', $i18n.locale)}}</td> <td class="number">{{tax.vat | currency('EUR', $i18n.locale)}}</td>
</tr> </tr>
</tbody> </tbody>
@ -185,14 +161,14 @@
<tr class="font bold"> <tr class="font bold">
<td width="45%">{{$t('subtotal')}}</td> <td width="45%">{{$t('subtotal')}}</td>
<td width="20%" class="number"> <td width="20%" class="number">
{{sumTotal(taxes, 'base') | currency('EUR', $i18n.locale)}} {{sumTotal(taxes, 'taxableBase') | currency('EUR', $i18n.locale)}}
</td> </td>
<td></td> <td></td>
<td class="number">{{sumTotal(taxes, 'vat') | currency('EUR', $i18n.locale)}}</td> <td class="number">{{sumTotal(taxes, 'vat') | currency('EUR', $i18n.locale)}}</td>
</tr> </tr>
<tr class="font bold"> <tr class="font bold">
<td colspan="2">{{$t('total')}}</td> <td colspan="2">{{$t('total')}}</td>
<td colspan="2" class="number">{{taxTotal | currency('EUR', $i18n.locale)}}</td> <td colspan="2" class="number">{{taxTotal() | currency('EUR', $i18n.locale)}}</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
@ -205,109 +181,30 @@
</div> </div>
</div> </div>
<!-- End of taxes block --> <!-- End of taxes block -->
<!--
Phytosanitary block
<div id="phytosanitary" class="size50 pull-left no-page-break">
<div class="panel">
<div class="body">
<div class="flag">
<div class="columns">
<div class="size25">
<img v-bind:src="getReportSrc('europe.png')"/>
</div>
<div class="size75 flag-text">
<strong>{{$t('plantPassport')}}</strong><br/>
</div>
</div>
</div>
<div class="phytosanitary-info">
<div>
<strong>A</strong>
<span>{{botanical}}</span>
</div>
<div>
<strong>B</strong>
<span>ES17462130</span>
</div>
<div>
<strong>C</strong>
<span>{{ticketsId}}</span>
</div>
<div>
<strong>D</strong>
<span>ES</span>
</div>
</div>
</div>
</div>
</div>
End of phytosanitary block
</div>
<!-- Observations block -->
Intrastat block <div class="columns vn-mt-xl">
<div class="size100 no-page-break" v-if="intrastat.length > 0">
<h2>{{$t('intrastat')}}</h2>
<table class="column-oriented">
<thead>
<tr>
<th>{{$t('code')}}</th>
<th width="50%">{{$t('description')}}</th>
<th class="number">{{$t('stems')}}</th>
<th class="number">{{$t('netKg')}}</th>
<th class="number">{{$t('amount')}}</th>
</tr>
</thead>
<tbody>
<tr v-for="row in intrastat">
<td>{{row.code}}</td>
<td width="50%">{{row.description}}</td>
<td class="number">{{row.stems | number($i18n.locale)}}</td>
<td class="number">{{row.netKg | number($i18n.locale)}}</td>
<td class="number">{{row.subtotal | currency('EUR', $i18n.locale)}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td class="number">
<strong>{{sumTotal(intrastat, 'stems') | number($i18n.locale)}}</strong>
</td>
<td class="number">
<strong>{{sumTotal(intrastat, 'netKg') | number($i18n.locale)}}</strong>
</td>
<td class="number">
<strong>{{sumTotal(intrastat, 'subtotal') | currency('EUR', $i18n.locale)}}</strong>
</td>
</tr>
</tfoot>
</table>
</div>
End of intrastat block
Observations block
<div class="columns vn-mt-xl" v-if="invoice.payMethodCode == 'wireTransfer'">
<div class="size50 pull-left no-page-break" > <div class="size50 pull-left no-page-break" >
<div class="panel" > <div class="panel" >
<div class="header">{{$t('observations')}}</div> <div class="header">{{$t('observations')}}</div>
<div class="body"> <div class="body">
<div>{{$t('wireTransfer')}}</div> <div>{{$t('payMethod')}}</div>
<div>{{$t('accountNumber', [invoice.iban])}}</div> <div>{{invoice.payMethod}}</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
End of observations block <!-- End of observations block -->
</div> </div>
</div> </div>
Footer block </div>
<report-footer id="pageFooter" <!-- Footer block -->
v-bind:company-code="invoice.companyCode" <report-footer id="pageFooter"
v-bind:left-text="$t('invoiceRef', [invoice.ref])" v-bind:left-text="$t('invoice', [invoice.id])"
v-bind:center-text="client.socialName" v-bind:center-text="invoice.name"
v-bind="$props"> v-bind="$props">
</report-footer> --> </report-footer>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -42,8 +42,9 @@ module.exports = {
fetchBuy(id) { fetchBuy(id) {
return this.rawSqlFromDef('buy', [id]); return this.rawSqlFromDef('buy', [id]);
}, },
fetchTaxes(id) { async fetchTaxes(id) {
return this.rawSqlFromDef(`taxes`, [id]); const taxes = await this.rawSqlFromDef(`taxes`, [id]);
return this.taxVat(taxes);
}, },
buyImport(buy) { buyImport(buy) {
return buy.quantity * buy.buyingValue; return buy.quantity * buy.buyingValue;
@ -61,6 +62,23 @@ module.exports = {
total += parseFloat(row[prop]); total += parseFloat(row[prop]);
return total; 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: { components: {

View File

@ -1,17 +1,16 @@
reportName: invoice reportName: invoice
title: Invoice title: Agrobusiness invoice
invoice: Invoice invoiceId: Agrobusiness invoice
clientId: Client supplierId: Proveedor
invoiceData: Invoice data invoiceData: Invoice data
reference: Reference
fiscalId: FI / NIF fiscalId: FI / NIF
invoiceRef: Invoice {0} phone: Phone
deliveryNote: Delivery note
shipped: Shipped
date: Date date: Date
reference: Ref. item: Item
quantity: Qty. quantity: Qty.
concept: Concept concept: Concept
price: PSP/u buyingValue: PSP/u
discount: Disc. discount: Disc.
vat: VAT vat: VAT
amount: Amount amount: Amount
@ -22,15 +21,5 @@ fee: Fee
total: Total total: Total
subtotal: Subtotal subtotal: Subtotal
taxBreakdown: Tax breakdown 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 observations: Observations
wireTransfer: "Pay method: Transferencia" payMethod: Pay method
accountNumber: "Account number: {0}"

View File

@ -3,15 +3,14 @@ title: Factura Agrícola
invoiceId: Factura Agrícola invoiceId: Factura Agrícola
supplierId: Proveedor supplierId: Proveedor
invoiceData: Datos de facturación invoiceData: Datos de facturación
reference: Referencia
fiscalId: CIF / NIF fiscalId: CIF / NIF
invoiceRef: Factura {0} phone: Tlf
deliveryNote: Albarán
shipped: F. envío
date: Fecha date: Fecha
reference: Ref. item: Artículo
quantity: Cant. quantity: Cant.
concept: Concepto concept: Concepto
price: PVP/u buyingValue: PVP/u
discount: Dto. discount: Dto.
vat: IVA vat: IVA
amount: Importe amount: Importe
@ -22,15 +21,5 @@ fee: Cuota
total: Total total: Total
subtotal: Subtotal subtotal: Subtotal
taxBreakdown: Desglose impositivo 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 observations: Observaciones
wireTransfer: "Forma de pago: Transferencia" payMethod: Método de pago
accountNumber: "Número de cuenta: {0}"

View File

@ -5,8 +5,10 @@ SELECT
s.name, s.name,
s.street AS postalAddress, s.street AS postalAddress,
s.nif, s.nif,
s.phone s.phone,
p.name payMethod
FROM invoiceIn i FROM invoiceIn i
JOIN supplier s ON s.id = i.supplierFk JOIN supplier s ON s.id = i.supplierFk
JOIN company c ON c.id = i.companyFk JOIN company c ON c.id = i.companyFk
JOIN payMethod p ON p.id = s.payMethodFk
WHERE i.id = ? WHERE i.id = ?

View File

@ -1,13 +1,8 @@
SELECT SELECT
id, ti.iva as name,
invoiceInFk, ti.PorcentajeIva as rate,
taxableBase, iit.taxableBase
expenseFk, FROM invoiceIn ii
taxTypeSageFk, JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk
transactionTypeSageFk, JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
foreignValue WHERE ii.id = ?;
FROM invoiceInTax iit
JOIN transactionTypeSage ts ON iit.transactionTypeSageFk = ts.id
JOIN taxTypeSage tts ON tts.id =
WHERE io.ref = ?
ORDER BY iot.id