2023-01-23 12:15:30 +00:00
|
|
|
const vnReport = require('../../../core/mixins/vn-report.js');
|
2024-03-01 14:05:12 +00:00
|
|
|
const UserError = require('vn-loopback/util/user-error');
|
2021-03-01 10:25:37 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
name: 'invoice-incoterms',
|
2023-01-23 12:15:30 +00:00
|
|
|
mixins: [vnReport],
|
2021-03-01 10:25:37 +00:00
|
|
|
async serverPrefetch() {
|
2023-01-23 12:15:30 +00:00
|
|
|
this.invoice = await this.findOneFromDef('invoice', [this.reference]);
|
|
|
|
this.checkMainEntity(this.invoice);
|
|
|
|
this.client = await this.findOneFromDef('client', [this.reference]);
|
2024-03-01 14:05:12 +00:00
|
|
|
this.incoterms =
|
2024-06-20 11:45:38 +00:00
|
|
|
await this.findOneFromDef('incoterms', [this.reference]);
|
2024-03-01 14:05:12 +00:00
|
|
|
if (!this.incoterms)
|
|
|
|
throw new UserError(`The address of the customer must have information about Incoterms and Customs Agent`);
|
2021-03-01 10:25:37 +00:00
|
|
|
},
|
|
|
|
props: {
|
2022-09-29 05:35:20 +00:00
|
|
|
reference: {
|
2023-04-20 08:43:35 +00:00
|
|
|
type: String,
|
2022-09-26 11:33:27 +00:00
|
|
|
required: true,
|
|
|
|
description: 'The invoice ref'
|
2021-03-01 10:25:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|