salix/modules/order/back/models/order.js

27 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2019-08-29 11:16:38 +00:00
const UserError = require('vn-loopback/util/user-error');
2018-07-09 11:54:43 +00:00
module.exports = Self => {
require('../methods/order/new')(Self);
2018-07-24 10:57:07 +00:00
require('../methods/order/getTotalVolume')(Self);
require('../methods/order/getVolumes')(Self);
2018-08-07 14:04:42 +00:00
require('../methods/order/getTaxes')(Self);
2018-08-07 13:48:55 +00:00
require('../methods/order/isEditable')(Self);
2018-07-20 14:32:34 +00:00
require('../methods/order/getTotal')(Self);
2018-08-21 11:38:16 +00:00
require('../methods/order/catalogFilter')(Self);
require('../methods/order/summary')(Self);
require('../methods/order/getVAT')(Self);
require('../methods/order/getSourceValues')(Self);
2018-11-12 12:12:25 +00:00
require('../methods/order/newFromTicket')(Self);
2018-11-30 10:45:17 +00:00
require('../methods/order/updateBasicData')(Self);
2019-01-14 10:35:48 +00:00
require('../methods/order/confirm')(Self);
2019-02-27 11:03:54 +00:00
require('../methods/order/filter')(Self);
require('../methods/order/getItemTypeAvailable')(Self);
2019-08-29 11:16:38 +00:00
Self.beforeRemote('deleteById', async function(ctx) {
const targetOrder = await Self.findById(ctx.args.id);
if (targetOrder.isConfirmed === 1)
throw new UserError(`You can't delete a confirmed order`);
});
2018-07-09 11:54:43 +00:00
};