summary total
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Javi Gallego 2021-06-25 09:30:24 +02:00
parent 82e65ec1c3
commit 02cd2283a7
4 changed files with 34 additions and 19 deletions

View File

@ -74,6 +74,22 @@ module.exports = Self => {
]
};
return Self.app.models.InvoiceIn.findById(id, filter);
let summaryObj = await Self.app.models.InvoiceIn.findById(id, filter);
summaryObj.totals = await getTotals(id);
return summaryObj;
};
async function getTotals(invoiceInFk) {
return (await Self.rawSql(`
SELECT
SUM(iit.taxableBase) totalTaxableBase,
SUM(iit.taxableBase * (1 + (ti.PorcentajeIva / 100))) totalVat,
SUM(iidd.amount) totalDueDay
FROM vn.invoiceIn ii
LEFT JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
LEFT JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
LEFT JOIN vn.invoiceInDueDay iidd ON iidd.invoiceInFk = ii.id
WHERE
ii.id = ?`, [invoiceInFk]))[0];
}
};

View File

@ -5,8 +5,7 @@ Invoice list: Listado de entradas
InvoiceIn deleted: Factura eliminada
Remove tax: Quitar iva
Add tax: Añadir iva
taxable base: bi
sage tax: sage iva
sage transaction: sage transaccion
rate: cuota
foreign value: divisa
Sage tax: Sage iva
Sage transaction: Sage transaccion
Foreign value: Divisa
Due day: Vencimiento

View File

@ -46,13 +46,13 @@
</vn-vertical>
</vn-one>
<vn-one tbody class="taxes">
<span td class="chip"><vn-label translate>taxable base</vn-label> {{1 | currency: 'EUR':2}}</spant>
<p><vn-label translate>total</vn-label> {{3 | currency: $ctrl.summary.currency.code:2}}</p>
<vn-label>Due day</vn-label>
<span td class="chip"><vn-label translate>Taxable base</vn-label> {{$ctrl.summary.totals.totalTaxableBase | currency: 'EUR':2}}</spant>
<p><vn-label translate>Total</vn-label> {{$ctrl.summary.totals.totalVat | currency: 'EUR':2}}</p>
<vn-label translate>Due day</vn-label>
<vn-chip
class="transparent"
translate-attr=" 1 != 2 && 2 != 3 ? {title: 'No coinciden'} : {title: 'Vencimiento'}"
ng-class="{'alert': 1 != 2 && 2 != 3}">{{2 | currency: 'EUR':2}}
translate-attr=" $ctrl.summary.totals.totalDueDay != $ctrl.summary.totals.totalTaxableBase && $ctrl.summary.totals.totalDueDay != $ctrl.summary.totals.totalVat ? {title: 'No coinciden'} : {title: 'Vencimiento'}"
ng-class="{'alert': $ctrl.summary.totals.totalDueDay != $ctrl.summary.totals.totalTaxableBase && $ctrl.summary.totals.totalDueDay != $ctrl.summary.totals.totalVat}">{{$ctrl.summary.totals.totalDueDay | currency: 'EUR':2}}
</vn-chip>
</vn-one>
</vn-horizontal>
@ -73,14 +73,14 @@
<vn-th shrink>Taxable base</vn-th>
<vn-th>Sage vat</vn-th>
<vn-th>Sage transaction</vn-th>
<vn-th number>Rate</vn-th>
<vn-th number>Foreign value</vn-th>
<vn-th number shrink>Rate</vn-th>
<vn-th number shrink>Foreign value</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="tax in $ctrl.summary.invoiceInTax">
<vn-td number expand>{{::tax.expenseFk}}</vn-td>
<vn-td>{{::tax.taxableBase | currency: 'EUR':2}}</vn-td>
<vn-td shrink>{{::tax.taxableBase | currency: 'EUR':2}}</vn-td>
<vn-td>{{::tax.taxTypeSage.vat}}</vn-td>
<vn-td>{{::tax.transactionTypeSage.transaction}}</vn-td>
<vn-td number shrink>{{::0.2 | percentage}}</vn-td>

View File

@ -41,7 +41,7 @@
disabled="$ctrl.invoiceIn.currency.code != 'EUR'"
vn-id="taxableBase"
type="number"
label="taxable base"
label="Taxable base"
ng-model="invoiceInTax.taxableBase"
on-change="$ctrl.setTaxRate = $value"
rule>
@ -49,7 +49,7 @@
<vn-autocomplete vn-three
vn-id="taxTypeSage"
label="sage tax"
label="Sage tax"
ng-model="invoiceInTax.taxTypeSageFk"
data="sageTaxTypes"
show-field="vat"
@ -59,7 +59,7 @@
<tpl-item>{{id}}: {{vat}}</tpl-item>
</vn-autocomplete>
<vn-autocomplete vn-three
label="sage transaction"
label="Sage transaction"
ng-model="invoiceInTax.transactionTypeSageFk"
data="sageTransactionType"
show-field="transaction"
@ -70,7 +70,7 @@
<vn-input-number vn-one
disabled="true"
type="number"
label="rate"
label="Rate"
step="0.01"
tabindex="-1"
ng-model="$ctrl.taxRate">
@ -78,7 +78,7 @@
<vn-input-number vn-one
disabled="$ctrl.invoiceIn.currency.code == 'EUR'"
type="number"
label="foreign value"
label="Foreign value"
ng-model="invoiceInTax.foreignValue"
rule>
</vn-input-number>