This commit is contained in:
parent
a003cd24f6
commit
8c8ec6192a
|
@ -0,0 +1,5 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIALLYDELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);
|
||||||
|
|
|
@ -140,7 +140,16 @@ module.exports = Self => {
|
||||||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
||||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||||
|
|
||||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions);
|
const [{stateForTicket}] = await Self.rawSql(`
|
||||||
|
SELECT
|
||||||
|
IF((SUM(CASE WHEN est.code = 'DELIVERED' THEN 1 ELSE 0 END) = COUNT(*)),
|
||||||
|
'DELIVERED','PARTIALLYDELIVERED') stateForTicket
|
||||||
|
FROM vn.expedition e
|
||||||
|
JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
|
||||||
|
WHERE e.ticketFk = ?;
|
||||||
|
`, [ticketId], myOptions);
|
||||||
|
|
||||||
|
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateForTicket], myOptions);
|
||||||
|
|
||||||
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
|
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
|
||||||
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
||||||
|
|
Loading…
Reference in New Issue