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) => {
console.log(id);
const args = Object.assign({}, ctx.args);
const params = {lang: ctx.req.getLocale()};
delete args.ctx;
console.log(args);
for (const param in args)
params[param] = args[param];

View File

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

View File

@ -1,28 +1,71 @@
const Component = require(`vn-print/core/component`);
const Report = require(`vn-print/core/report`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
const invoiceIncoterms = new Report('invoice-incoterms');
module.exports = {
name: 'invoiceIn',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.id);
this.taxes = await this.fetchTaxes(this.id);
if (!this.invoice)
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: {
},
methods: {
fetchInvoice(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: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build(),
'invoice-incoterms': invoiceIncoterms.build()
},
props: {
id: {

View File

@ -1,7 +1,7 @@
reportName: factura
title: Factura
invoice: Factura
clientId: Cliente
title: Factura Agrícola
invoiceId: Factura Agrícola
supplierId: Proveedor
invoiceData: Datos de facturación
fiscalId: CIF / NIF
invoiceRef: Factura {0}
@ -33,4 +33,4 @@ issued: F. emisión
plantPassport: Pasaporte fitosanitario
observations: Observaciones
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
JOIN supplier s ON s.id = i.supplierFk
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