3520_wareshouse_back #2218

Merged
alexm merged 11 commits from 3520_wareshouse_back into dev 2024-03-28 07:16:57 +00:00
2 changed files with 38 additions and 0 deletions
Showing only changes of commit dc5f588c8e - Show all commits

View File

@ -0,0 +1,35 @@
module.exports = Self => {
Self.remoteMethod('getUncheckedTicket', {
description:
'Get boolean if the collection of ticket has a ticket not checked',
accessType: 'READ',
accepts: [{
arg: 'ticketFk',
type: 'int',
required: true,
description: 'Ticket id'
}],
returns: {
type: 'boolean',
root: true
},
http: {
path: `/getUncheckedTicket`,
verb: 'GET'
}
});
Self.getUncheckedTicket = async ticketFk => {
const result = await Self.rawSql(`
SELECT tc2.ticketFk
FROM vn.ticketCollection tc
JOIN vn.ticketCollection tc2 ON tc2.collectionFk = tc.collectionFk
LEFT JOIN vn.ticketState ts ON ts.ticketFk = tc2.ticketFk
JOIN vn.state s ON s.id = ts.stateFk
JOIN vn.state s2 ON s2.code = 'CHECKED'
WHERE tc.ticketFk = ? AND s.order < s2.id
LIMIT 1;`,
[ticketFk]);
return result.length > 0 && result[0]['ticketFk'] > 0;
};
};

View File

@ -0,0 +1,3 @@
module.exports = Self => {
require('../methods/ticket-collection/getUncheckedTicket')(Self);
};