salix/modules/ticket/back/models/ticket.js

54 lines
2.3 KiB
JavaScript
Raw Normal View History

module.exports = Self => {
require('../methods/ticket/changeWorker')(Self);
require('../methods/ticket/getVolume')(Self);
require('../methods/ticket/getTotalVolume')(Self);
2018-04-10 05:48:04 +00:00
require('../methods/ticket/summary')(Self);
require('../methods/ticket/getTotal')(Self);
require('../methods/ticket/getTaxes')(Self);
require('../methods/ticket/subtotal')(Self);
require('../methods/ticket/priceDifference')(Self);
require('../methods/ticket/componentUpdate')(Self);
require('../methods/ticket/new')(Self);
require('../methods/ticket/isEditable')(Self);
require('../methods/ticket/setDeleted')(Self);
2018-06-19 10:10:38 +00:00
require('../methods/ticket/getVAT')(Self);
require('../methods/ticket/getSales')(Self);
require('../methods/ticket/getSalesPersonMana')(Self);
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);
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);
require('../methods/ticket/uploadFile')(Self);
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);
Self.observe('before save', async function(ctx) {
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));
let userId = ctx.options.accessToken.userId;
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
};