51 lines
1.4 KiB
JavaScript
Executable File
51 lines
1.4 KiB
JavaScript
Executable File
const Component = require(`vn-print/core/component`);
|
|
const reportBody = new Component('report-body');
|
|
const reportHeader = new Component('report-header');
|
|
const reportFooter = new Component('report-footer');
|
|
|
|
module.exports = {
|
|
name: 'entry-order',
|
|
async serverPrefetch() {
|
|
this.supplier = await this.fetchSupplier(this.id);
|
|
this.entry = await this.fetchEntry(this.id);
|
|
this.buys = await this.fetchBuys(this.id);
|
|
|
|
if (!this.entry)
|
|
throw new Error('Something went wrong');
|
|
},
|
|
data() {
|
|
return {totalBalance: 0.00};
|
|
},
|
|
methods: {
|
|
fetchSupplier(id) {
|
|
return this.findOneFromDef('supplier', [id]);
|
|
},
|
|
fetchEntry(id) {
|
|
return this.findOneFromDef('entry', [id]);
|
|
},
|
|
fetchBuys(id) {
|
|
return this.rawSqlFromDef('buys', [id]);
|
|
},
|
|
getTotal() {
|
|
let total = 0.00;
|
|
this.buys.forEach(buy => {
|
|
total += buy.quantity * buy.buyingValue;
|
|
});
|
|
|
|
return total;
|
|
}
|
|
},
|
|
components: {
|
|
'report-body': reportBody.build(),
|
|
'report-header': reportHeader.build(),
|
|
'report-footer': reportFooter.build()
|
|
},
|
|
props: {
|
|
id: {
|
|
type: Number,
|
|
required: true,
|
|
description: 'The entry id'
|
|
}
|
|
}
|
|
};
|