salix/print/templates/reports/entry-order/entry-order.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-01-23 12:15:30 +00:00
const vnReport = require('../../../core/mixins/vn-report.js');
2020-02-20 08:31:09 +00:00
module.exports = {
name: 'entry-order',
2023-01-23 12:15:30 +00:00
mixins: [vnReport],
2020-02-20 08:31:09 +00:00
async serverPrefetch() {
2023-01-23 12:15:30 +00:00
this.entry = await this.findOneFromDef('entry', [this.id]);
this.checkMainEntity(this.entry);
this.supplier = await this.findOneFromDef('supplier', [this.id]);
this.buys = await this.rawSqlFromDef('buys', [this.id]);
2020-02-20 08:31:09 +00:00
},
data() {
return {totalBalance: 0.00};
},
methods: {
getTotalBy(property) {
return this.buys.reduce((total, buy) => {
switch (property) {
case 'amount':
return total + buy.quantity * buy.buyingValue;
case 'quantity':
return total + buy.quantity;
case 'stickers':
return total + buy.stickers;
}
}, 0);
2020-02-20 08:31:09 +00:00
}
},
props: {
2022-09-26 11:33:27 +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 entry id'
2020-02-20 08:31:09 +00:00
}
}
};