2022-09-26 11:33:27 +00:00
|
|
|
const Component = require(`vn-print/core/component`);
|
2022-11-10 07:57:42 +00:00
|
|
|
const reportBody = new Component('report-body');
|
2020-02-20 08:31:09 +00:00
|
|
|
const reportHeader = new Component('report-header');
|
|
|
|
const reportFooter = new Component('report-footer');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: 'entry-order',
|
|
|
|
async serverPrefetch() {
|
2022-09-26 11:33:27 +00:00
|
|
|
this.supplier = await this.fetchSupplier(this.id);
|
|
|
|
this.entry = await this.fetchEntry(this.id);
|
|
|
|
this.buys = await this.fetchBuys(this.id);
|
2020-02-20 08:31:09 +00:00
|
|
|
|
|
|
|
if (!this.entry)
|
|
|
|
throw new Error('Something went wrong');
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {totalBalance: 0.00};
|
|
|
|
},
|
|
|
|
methods: {
|
2022-09-26 11:33:27 +00:00
|
|
|
fetchSupplier(id) {
|
|
|
|
return this.findOneFromDef('supplier', [id]);
|
2020-02-20 08:31:09 +00:00
|
|
|
},
|
2022-09-26 11:33:27 +00:00
|
|
|
fetchEntry(id) {
|
|
|
|
return this.findOneFromDef('entry', [id]);
|
2020-02-20 08:31:09 +00:00
|
|
|
},
|
2022-09-26 11:33:27 +00:00
|
|
|
fetchBuys(id) {
|
|
|
|
return this.rawSqlFromDef('buys', [id]);
|
2020-02-20 08:31:09 +00:00
|
|
|
},
|
|
|
|
getTotal() {
|
|
|
|
let total = 0.00;
|
|
|
|
this.buys.forEach(buy => {
|
|
|
|
total += buy.quantity * buy.buyingValue;
|
|
|
|
});
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2022-11-10 07:57:42 +00:00
|
|
|
'report-body': reportBody.build(),
|
2020-02-20 08:31:09 +00:00
|
|
|
'report-header': reportHeader.build(),
|
|
|
|
'report-footer': reportFooter.build()
|
|
|
|
},
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|