2024-04-17 11:55:07 +00:00
|
|
|
|
|
|
|
module.exports = Self => {
|
|
|
|
Self.remoteMethod('addDropOff', {
|
|
|
|
description: 'Add a dropOff note in a ticket',
|
|
|
|
accessType: 'WRITE',
|
|
|
|
accepts: [{
|
|
|
|
arg: 'ticketFk',
|
|
|
|
type: 'number',
|
|
|
|
required: true,
|
|
|
|
description: 'ticket ID'
|
|
|
|
}, {
|
|
|
|
arg: 'note',
|
|
|
|
type: 'string',
|
|
|
|
required: true,
|
|
|
|
description: 'note text'
|
|
|
|
}],
|
|
|
|
|
|
|
|
http: {
|
|
|
|
path: `/addDropOff`,
|
|
|
|
verb: 'post'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Self.addDropOff = async(ticketFk, note, options) => {
|
|
|
|
const models = Self.app.models;
|
|
|
|
const myOptions = {};
|
|
|
|
|
|
|
|
if (typeof options == 'object')
|
|
|
|
Object.assign(myOptions, options);
|
|
|
|
|
2024-04-18 08:01:22 +00:00
|
|
|
const observationTypeDropOff = await models.ObservationType.findOne({
|
|
|
|
where: {code: 'dropOff'}
|
|
|
|
}, myOptions);
|
2024-04-17 11:55:07 +00:00
|
|
|
|
2024-04-18 08:01:22 +00:00
|
|
|
await models.TicketObservation.create({
|
|
|
|
ticketFk: ticketFk,
|
|
|
|
observationTypeFk: observationTypeDropOff.id,
|
|
|
|
description: note
|
2024-04-17 11:55:07 +00:00
|
|
|
|
2024-04-18 08:01:22 +00:00
|
|
|
}, myOptions);
|
2024-04-17 11:55:07 +00:00
|
|
|
};
|
|
|
|
};
|