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

27 lines
1.1 KiB
JavaScript

const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
require('../methods/order/new')(Self);
require('../methods/order/getTotalVolume')(Self);
require('../methods/order/getVolumes')(Self);
require('../methods/order/getTaxes')(Self);
require('../methods/order/isEditable')(Self);
require('../methods/order/getTotal')(Self);
require('../methods/order/catalogFilter')(Self);
require('../methods/order/summary')(Self);
require('../methods/order/getVAT')(Self);
require('../methods/order/getSourceValues')(Self);
require('../methods/order/newFromTicket')(Self);
require('../methods/order/updateBasicData')(Self);
require('../methods/order/confirm')(Self);
require('../methods/order/filter')(Self);
require('../methods/order/getItemTypeAvailable')(Self);
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`);
});
};