2019-07-03 06:29:40 +00:00
|
|
|
|
2020-10-08 14:00:19 +00:00
|
|
|
const LoopBackContext = require('loopback-context');
|
|
|
|
|
2018-05-04 09:46:03 +00:00
|
|
|
module.exports = Self => {
|
|
|
|
require('../methods/ticket/getVolume')(Self);
|
2018-05-28 07:16:06 +00:00
|
|
|
require('../methods/ticket/getTotalVolume')(Self);
|
2018-04-10 05:48:04 +00:00
|
|
|
require('../methods/ticket/summary')(Self);
|
2019-07-26 09:48:01 +00:00
|
|
|
require('../methods/ticket/priceDifference')(Self);
|
2018-05-16 06:13:39 +00:00
|
|
|
require('../methods/ticket/componentUpdate')(Self);
|
2018-07-11 11:52:04 +00:00
|
|
|
require('../methods/ticket/new')(Self);
|
2018-06-06 14:54:40 +00:00
|
|
|
require('../methods/ticket/isEditable')(Self);
|
2019-09-03 11:27:02 +00:00
|
|
|
require('../methods/ticket/setDeleted')(Self);
|
2020-10-08 11:42:20 +00:00
|
|
|
require('../methods/ticket/restore')(Self);
|
2018-07-04 12:41:01 +00:00
|
|
|
require('../methods/ticket/getSales')(Self);
|
2018-06-28 13:24:27 +00:00
|
|
|
require('../methods/ticket/getSalesPersonMana')(Self);
|
2018-08-08 12:26:54 +00:00
|
|
|
require('../methods/ticket/filter')(Self);
|
2019-01-18 12:36:13 +00:00
|
|
|
require('../methods/ticket/getPossibleStowaways')(Self);
|
2019-04-05 10:24:39 +00:00
|
|
|
require('../methods/ticket/canBeInvoiced')(Self);
|
|
|
|
require('../methods/ticket/makeInvoice')(Self);
|
2019-05-03 10:23:57 +00:00
|
|
|
require('../methods/ticket/updateEditableTicket')(Self);
|
2019-08-09 06:04:44 +00:00
|
|
|
require('../methods/ticket/isEmpty')(Self);
|
2019-06-05 11:39:15 +00:00
|
|
|
require('../methods/ticket/updateDiscount')(Self);
|
2019-06-06 11:59:11 +00:00
|
|
|
require('../methods/ticket/uploadFile')(Self);
|
2019-07-02 10:12:15 +00:00
|
|
|
require('../methods/ticket/addSale')(Self);
|
2019-08-09 06:04:44 +00:00
|
|
|
require('../methods/ticket/transferSales')(Self);
|
2019-09-25 09:26:12 +00:00
|
|
|
require('../methods/ticket/canHaveStowaway')(Self);
|
2019-11-20 05:53:37 +00:00
|
|
|
require('../methods/ticket/recalculateComponents')(Self);
|
2019-12-17 07:38:36 +00:00
|
|
|
require('../methods/ticket/deleteStowaway')(Self);
|
2020-01-15 12:27:14 +00:00
|
|
|
require('../methods/ticket/sendSms')(Self);
|
2020-02-27 11:31:38 +00:00
|
|
|
require('../methods/ticket/isLocked')(Self);
|
2020-09-09 13:49:59 +00:00
|
|
|
require('../methods/ticket/freightCost')(Self);
|
2020-07-21 09:11:09 +00:00
|
|
|
require('../methods/ticket/getComponentsSum')(Self);
|
2019-07-03 06:29:40 +00:00
|
|
|
|
|
|
|
Self.observe('before save', async function(ctx) {
|
2020-10-08 14:00:19 +00:00
|
|
|
const loopBackContext = LoopBackContext.getCurrentContext();
|
|
|
|
const httpCtx = loopBackContext.active;
|
|
|
|
|
2019-07-03 06:29:40 +00:00
|
|
|
if (ctx.isNewInstance) return;
|
|
|
|
|
|
|
|
let changes = ctx.data || ctx.instance;
|
|
|
|
|
|
|
|
if (changes.routeFk === null && ctx.currentInstance.routeFk != null) {
|
|
|
|
let instance = JSON.parse(JSON.stringify(ctx.currentInstance));
|
2020-10-08 14:00:19 +00:00
|
|
|
let userId = httpCtx.accessToken.userId;
|
2019-07-03 06:29:40 +00:00
|
|
|
let logRecord = {
|
|
|
|
originFk: ctx.currentInstance.routeFk,
|
|
|
|
userFk: userId,
|
|
|
|
action: 'delete',
|
|
|
|
changedModel: 'Route',
|
|
|
|
oldInstance: {ticket: instance.id},
|
|
|
|
newInstance: null
|
|
|
|
};
|
|
|
|
await Self.app.models.RouteLog.create(logRecord);
|
|
|
|
}
|
|
|
|
});
|
2017-07-06 07:55:28 +00:00
|
|
|
};
|