salix/print/templates/reports/client-debt-statement/client-debt-statement.js

51 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2023-01-23 12:15:30 +00:00
const vnReport = require('../../../core/mixins/vn-report.js');
module.exports = {
name: 'client-debt-statement',
2023-01-23 12:15:30 +00:00
mixins: [vnReport],
async serverPrefetch() {
2023-01-23 12:15:30 +00:00
this.client = await this.findOneFromDef('client', [this.id]);
this.checkMainEntity(this.client);
this.sales = await this.rawSqlFromDef('sales',
[this.from, this.id, this.from, this.id, this.from, this.id, this.from, this.id, this.from, this.id]);
},
data() {
return {totalBalance: 0.00};
},
methods: {
getBalance(sale) {
if (sale.debtOut)
this.totalBalance += parseFloat(sale.debtOut);
if (sale.debtIn)
this.totalBalance -= parseFloat(sale.debtIn);
return parseFloat(this.totalBalance.toFixed(2));
},
getTotalDebtOut() {
let debtOut = 0.00;
for (let sale of this.sales)
debtOut += sale.debtOut ? parseFloat(sale.debtOut) : 0;
return debtOut.toFixed(2);
},
getTotalDebtIn() {
let debtIn = 0.00;
for (let sale of this.sales)
debtIn += sale.debtIn ? parseFloat(sale.debtIn) : 0;
return debtIn.toFixed(2);
},
},
props: {
2022-09-22 07:42:04 +00:00
id: {
2022-10-28 13:53:57 +00:00
type: Number,
2022-09-26 11:33:27 +00:00
required: true,
description: 'The client id'
},
from: {
required: true
}
}
};