Merge branch '2071-ticket_sale_split' of verdnatura/salix into dev
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
commit
5d56ed8f88
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('lastActiveTickets', {
|
||||
description: 'Returns the last three tickets of a client that have the alertLevel at 0 and the shiped day is gt today',
|
||||
description: 'Returns the last three active tickets of a client',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
|
@ -24,16 +24,18 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.lastActiveTickets = async(id, ticketId) => {
|
||||
const ticket = await Self.app.models.Ticket.findById(ticketId);
|
||||
const query = `
|
||||
SELECT t.id, t.shipped, a.name AS agencyName, w.name AS warehouseName
|
||||
FROM vn.ticket t
|
||||
JOIN vn.ticketState ts ON t.id = ts.ticketFk
|
||||
JOIN vn.agencyMode a ON t.agencyModeFk = a.id
|
||||
JOIN vn.warehouse w ON t.warehouseFk = w.id
|
||||
WHERE t.shipped >= CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0 AND t.id <> ?
|
||||
WHERE t.shipped >= CURDATE() AND t.clientFk = ? AND ts.alertLevel = 0
|
||||
AND t.id <> ? AND t.warehouseFk = ?
|
||||
ORDER BY t.shipped
|
||||
LIMIT 3`;
|
||||
|
||||
return Self.rawSql(query, [id, ticketId]);
|
||||
return Self.rawSql(query, [id, ticketId, ticket.warehouseFk]);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue