module.exports = Self => { require('../methods/ticket/changeWorker')(Self); require('../methods/ticket/getVolume')(Self); require('../methods/ticket/getTotalVolume')(Self); 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); require('../methods/ticket/getVAT')(Self); require('../methods/ticket/getSales')(Self); require('../methods/ticket/getSalesPersonMana')(Self); require('../methods/ticket/filter')(Self); require('../methods/ticket/getPossibleStowaways')(Self); require('../methods/ticket/canBeInvoiced')(Self); require('../methods/ticket/makeInvoice')(Self); require('../methods/ticket/updateEditableTicket')(Self); require('../methods/ticket/isEmpty')(Self); require('../methods/ticket/updateDiscount')(Self); require('../methods/ticket/uploadFile')(Self); require('../methods/ticket/addSale')(Self); require('../methods/ticket/transferSales')(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); } }); };