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

This commit is contained in:
Alex Moreno 2022-10-18 14:58:38 +02:00
parent eb58839839
commit c9073641aa
8 changed files with 165 additions and 78 deletions

View File

@ -35,10 +35,11 @@ module.exports = Self => {
}); });
Self.invoiceInPdf = async(ctx, id) => { Self.invoiceInPdf = async(ctx, id) => {
console.log(id);
const args = Object.assign({}, ctx.args); const args = Object.assign({}, ctx.args);
const params = {lang: ctx.req.getLocale()}; const params = {lang: ctx.req.getLocale()};
delete args.ctx; delete args.ctx;
console.log(args);
for (const param in args) for (const param in args)
params[param] = args[param]; params[param] = args[param];

View File

@ -6,12 +6,6 @@
<tr> <tr>
<td> <td>
<!-- Incoterms block -->
<invoice-incoterms
v-if="hasIncoterms"
v-bind="$props">
</invoice-incoterms>
<!-- Header block --> <!-- Header block -->
<report-header v-bind="$props" <report-header v-bind="$props"
v-bind:company-code="invoice.companyCode"> v-bind:company-code="invoice.companyCode">
@ -26,16 +20,16 @@
<table class="row-oriented ticket-info"> <table class="row-oriented ticket-info">
<tbody> <tbody>
<tr> <tr>
<td class="font gray uppercase">{{$t('clientId')}}</td> <td class="font gray uppercase">{{$t('supplierId')}}</td>
<th>{{client.id}}</th> <th>{{invoice.supplierId}}</th>
</tr> </tr>
<tr> <tr>
<td class="font gray uppercase">{{$t('invoice')}}</td> <td class="font gray uppercase">{{$t('invoiceId')}}</td>
<th>{{invoice.ref}}</th> <th>{{invoice.id}}</th>
</tr> </tr>
<tr> <tr>
<td class="font gray uppercase">{{$t('date')}}</td> <td class="font gray uppercase">{{$t('date')}}</td>
<th>{{invoice.issued | date('%d-%m-%Y')}}</th> <th>{{invoice.created | date('%d-%m-%Y')}}</th>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -45,22 +39,25 @@
<div class="panel"> <div class="panel">
<div class="header">{{$t('invoiceData')}}</div> <div class="header">{{$t('invoiceData')}}</div>
<div class="body"> <div class="body">
<h3 class="uppercase">{{client.socialName}}</h3> <h3 class="uppercase">{{invoice.name}}</h3>
<div> <div>
{{client.postalAddress}} {{invoice.postalAddress}}
</div> </div>
<div> <div>
{{client.postcodeCity}} {{invoice.postcodeCity}}
</div> </div>
<div> <div>
{{$t('fiscalId')}}: {{client.fi}} {{$t('fiscalId')}}: {{invoice.nif}}
</div>
<div>
{{$t('phone')}}: {{invoice.phone}}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!--
<!-- Rectified invoices block --> Rectified invoices block
<div class="size100 no-page-break" v-if="rectified.length > 0"> <div class="size100 no-page-break" v-if="rectified.length > 0">
<h2>{{$t('rectifiedInvoices')}}</h2> <h2>{{$t('rectifiedInvoices')}}</h2>
<table class="column-oriented"> <table class="column-oriented">
@ -82,81 +79,81 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- End of rectified invoices block --> End of rectified invoices block-->
<!-- Sales block --> <div class="vn-mt-lg" v-for="entry in entries">
<div class="vn-mt-lg" v-for="ticket in tickets">
<div class="table-title clearfix"> <div class="table-title clearfix">
<div class="pull-left"> <div class="pull-left">
<h2>{{$t('deliveryNote')}}</strong> <h2>{{$t('invoiceIn')}}</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">
<span>{{ticket.id}}</span> <span>{{entry.id}}</span>
</div> </div>
</div> </div>
<div class="pull-left"> <div class="pull-left">
<h2>{{$t('shipped')}}</h2> <h2>{{$t('date')}}</h2>
</div> </div>
<div class="pull-left"> <div class="pull-left">
<div class="field rectangle"> <div class="field rectangle">
<span>{{ticket.shipped | date}}</span> <span>{{entry.landed | date}}</span>
</div> </div>
</div> </div>
<span id="nickname" class="pull-right"> <span id="nickname" class="pull-right">
<h2>{{ticket.nickname}}</h2> <div class="pull-left">
<h2>{{$t('reference')}}</h2>
</div>
<div class="pull-left">
<div class="field rectangle">
<span>{{entry.ref}}</span>
</div>
</div>
</span> </span>
</div> </div>
<table class="column-oriented"> <table class="column-oriented">
<thead> <thead>
<tr> <tr>
<th width="5%">{{$t('reference')}}</th> <th width="50%">{{$t('item')}}</th>
<th class="number">{{$t('quantity')}}</th> <th class="number">{{$t('quantity')}}</th>
<th width="50%">{{$t('concept')}}</th> <th class="number">{{$t('buyingValue')}}</th>
<th class="number">{{$t('price')}}</th>
<th class="centered" width="5%">{{$t('discount')}}</th>
<th class="centered">{{$t('vat')}}</th>
<th class="number">{{$t('amount')}}</th> <th class="number">{{$t('amount')}}</th>
</tr> </tr>
</thead> </thead>
<tbody v-for="sale in ticket.sales" class="no-page-break"> <tbody v-for="buy in entry.buys" class="no-page-break">
<tr> <tr>
<td width="5%">{{sale.itemFk | zerofill('000000')}}</td> <td width="50%">{{buy.name}}</td>
<td class="number">{{sale.quantity}}</td> <td class="number">{{buy.quantity}}</td>
<td width="50%">{{sale.concept}}</td> <td class="number">{{buy.buyingValue}}</td>
<td class="number">{{sale.price | currency('EUR', $i18n.locale)}}</td> <td class="number">{{buyImport(buy) | currency('EUR', $i18n.locale)}}</td>
<td class="centered" width="5%">{{(sale.discount / 100) | percentage}}</td>
<td class="centered">{{sale.vatType}}</td>
<td class="number">{{saleImport(sale) | currency('EUR', $i18n.locale)}}</td>
</tr> </tr>
<tr class="description font light-gray"> <tr class="description font light-gray">
<td colspan="7"> <td colspan="4">
<span v-if="sale.value5"> <span v-if="buy.value5">
<strong>{{sale.tag5}}</strong> {{sale.value5}} <strong>{{buy.tag5}}</strong> {{buy.value5}}
</span> </span>
<span v-if="sale.value6"> <span v-if="buy.value6">
<strong>{{sale.tag6}}</strong> {{sale.value6}} <strong>{{buy.tag6}}</strong> {{buy.value6}}
</span> </span>
<span v-if="sale.value7"> <span v-if="buy.value7">
<strong>{{sale.tag7}}</strong> {{sale.value7}} <strong>{{buy.tag7}}</strong> {{buy.value7}}
</span> </span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="6" class="font bold"> <td colspan="3" class="font bold">
<span class="pull-right">{{$t('subtotal')}}</span> <span class="pull-right">{{$t('subtotal')}}</span>
</td> </td>
<td class="number">{{ticketSubtotal(ticket) | currency('EUR', $i18n.locale)}}</td> <td class="number">{{entrySubtotal(entry) | currency('EUR', $i18n.locale)}}</td>
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
</div> </div>
<!-- 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>
@ -208,8 +205,8 @@
</div> </div>
</div> </div>
<!-- End of taxes block --> <!-- End of taxes block -->
<!--
<!-- Phytosanitary block --> Phytosanitary block
<div id="phytosanitary" class="size50 pull-left no-page-break"> <div id="phytosanitary" class="size50 pull-left no-page-break">
<div class="panel"> <div class="panel">
<div class="body"> <div class="body">
@ -225,16 +222,16 @@
</div> </div>
<div class="phytosanitary-info"> <div class="phytosanitary-info">
<div> <div>
<strong>A</strong> <strong>A</strong>
<span>{{botanical}}</span> <span>{{botanical}}</span>
</div> </div>
<div> <div>
<strong>B</strong> <strong>B</strong>
<span>ES17462130</span> <span>ES17462130</span>
</div> </div>
<div> <div>
<strong>C</strong> <strong>C</strong>
<span>{{ticketsId}}</span> <span>{{ticketsId}}</span>
</div> </div>
<div> <div>
<strong>D</strong> <strong>D</strong>
@ -244,11 +241,11 @@
</div> </div>
</div> </div>
</div> </div>
<!-- End of phytosanitary block --> End of phytosanitary block
</div> </div>
<!-- Intrastat block --> Intrastat block
<div class="size100 no-page-break" v-if="intrastat.length > 0"> <div class="size100 no-page-break" v-if="intrastat.length > 0">
<h2>{{$t('intrastat')}}</h2> <h2>{{$t('intrastat')}}</h2>
<table class="column-oriented"> <table class="column-oriented">
@ -286,9 +283,9 @@
</tfoot> </tfoot>
</table> </table>
</div> </div>
<!-- End of intrastat block --> End of intrastat block
<!-- Observations block --> Observations block
<div class="columns vn-mt-xl" v-if="invoice.payMethodCode == 'wireTransfer'"> <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" >
@ -300,20 +297,20 @@
</div> </div>
</div> </div>
</div> </div>
<!-- End of observations block --> End of observations block
</div> </div>
</div> </div>
<!-- Footer block --> Footer block
<report-footer id="pageFooter" <report-footer id="pageFooter"
v-bind:company-code="invoice.companyCode" v-bind:company-code="invoice.companyCode"
v-bind:left-text="$t('invoiceRef', [invoice.ref])" v-bind:left-text="$t('invoiceRef', [invoice.ref])"
v-bind:center-text="client.socialName" v-bind:center-text="client.socialName"
v-bind="$props"> v-bind="$props">
</report-footer> </report-footer> -->
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</body> </body>
</html> </html>

View File

@ -1,28 +1,71 @@
const Component = require(`vn-print/core/component`); const Component = require(`vn-print/core/component`);
const Report = require(`vn-print/core/report`);
const reportHeader = new Component('report-header'); const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer'); const reportFooter = new Component('report-footer');
const invoiceIncoterms = new Report('invoice-incoterms');
module.exports = { module.exports = {
name: 'invoiceIn', name: 'invoiceIn',
async serverPrefetch() { async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.id); this.invoice = await this.fetchInvoice(this.id);
this.taxes = await this.fetchTaxes(this.id);
if (!this.invoice) if (!this.invoice)
throw new Error('Something went wrong'); throw new Error('Something went wrong');
const entries = await this.fetchEntry(this.id);
const buys = await this.fetchBuy(this.id);
const map = new Map();
for (let entry of entries) {
entry.buys = [];
map.set(entry.id, entry);
}
for (let buy of buys) {
const entry = map.get(buy.entryFk);
if (entry) entry.buys.push(buy);
}
this.entries = entries;
}, },
computed: { computed: {
}, },
methods: { methods: {
fetchInvoice(id) { fetchInvoice(id) {
return this.findOneFromDef('invoice', [id]); return this.findOneFromDef('invoice', [id]);
},
fetchEntry(id) {
return this.rawSqlFromDef('entry', [id]);
},
fetchBuy(id) {
return this.rawSqlFromDef('buy', [id]);
},
fetchTaxes(id) {
return this.rawSqlFromDef(`taxes`, [id]);
},
buyImport(buy) {
return buy.quantity * buy.buyingValue;
},
entrySubtotal(entry) {
let subTotal = 0.00;
for (let buy of entry.buys)
subTotal += this.buyImport(buy);
return subTotal;
},
sumTotal(rows, prop) {
let total = 0.00;
for (let row of rows)
total += parseFloat(row[prop]);
return total;
} }
}, },
components: { components: {
'report-header': reportHeader.build(), 'report-header': reportHeader.build(),
'report-footer': reportFooter.build(), 'report-footer': reportFooter.build(),
'invoice-incoterms': invoiceIncoterms.build()
}, },
props: { props: {
id: { id: {

View File

@ -1,7 +1,7 @@
reportName: factura reportName: factura
title: Factura title: Factura Agrícola
invoice: Factura invoiceId: Factura Agrícola
clientId: Cliente supplierId: Proveedor
invoiceData: Datos de facturación invoiceData: Datos de facturación
fiscalId: CIF / NIF fiscalId: CIF / NIF
invoiceRef: Factura {0} invoiceRef: Factura {0}
@ -33,4 +33,4 @@ issued: F. emisión
plantPassport: Pasaporte fitosanitario plantPassport: Pasaporte fitosanitario
observations: Observaciones observations: Observaciones
wireTransfer: "Forma de pago: Transferencia" wireTransfer: "Forma de pago: Transferencia"
accountNumber: "Número de cuenta: {0}" accountNumber: "Número de cuenta: {0}"

View File

@ -0,0 +1,18 @@
SELECT
b.id,
e.id entryFk,
it.name,
b.quantity,
b.buyingValue,
(b.quantity * b.buyingValue) total,
it.tag5,
it.value5,
it.tag6,
it.value6,
it.tag7,
it.value7
FROM entry e
JOIN invoiceIn i ON i.id = e.invoiceInFk
JOIN buy b ON b.entryFk = e.id
JOIN item it ON it.id = b.itemFk
WHERE i.id = ?

View File

@ -0,0 +1,8 @@
SELECT
e.id,
t.landed,
e.ref
FROM entry e
JOIN invoiceIn i ON i.id = e.invoiceInFk
JOIN travel t ON t.id = e.travelFk
WHERE i.id = ?

View File

@ -1,4 +1,11 @@
SELECT * SELECT
i.id,
s.id supplierId,
i.created,
s.name,
s.street AS postalAddress,
s.nif,
s.phone
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

View File

@ -0,0 +1,13 @@
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