feat: refs #8098 closureDaysAgo
This commit is contained in:
parent
e0b252e6bb
commit
f2d1aa5f16
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE `vn`.`ticketConfig`
|
||||
ADD COLUMN `closureDaysAgo` int(11) NOT NULL DEFAULT 2 COMMENT 'Number of days to look back for ticket closure',
|
||||
ADD CONSTRAINT `closureDaysAgo_check` CHECK (`closureDaysAgo` > 0);
|
|
@ -45,17 +45,18 @@ module.exports = Self => {
|
|||
eu.email salesPersonEmail,
|
||||
t.addressFk
|
||||
FROM ticket t
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN warehouse wh ON wh.id = t.warehouseFk AND wh.hasComission
|
||||
JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
JOIN ticketConfig tc ON TRUE
|
||||
WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered'))
|
||||
AND DATE(t.shipped) BETWEEN ? - INTERVAL 7 DAY AND util.dayEnd(?)
|
||||
AND t.refFk IS NULL
|
||||
AND DATE(t.shipped) BETWEEN ? - INTERVAL tc.closureDaysAgo DAY AND util.dayEnd(?)
|
||||
AND t.refFk IS NULL
|
||||
GROUP BY t.id
|
||||
`, [toDate, toDate]);
|
||||
const ticketIds = tickets.map(ticket => ticket.id);
|
||||
|
|
|
@ -12,10 +12,7 @@ module.exports = async function(ctx, Self, tickets, options) {
|
|||
Object.assign(myOptions, options);
|
||||
|
||||
let tx;
|
||||
// if (!myOptions.transaction) {
|
||||
// tx = await Self.beginTransaction({});
|
||||
// myOptions.transaction = tx;
|
||||
// }
|
||||
// IMPORTANT: Due to its high cost in production, wrapping this process in a transaction may cause timeouts.
|
||||
|
||||
if (tickets.length == 0) return;
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ describe('Ticket closure functionality', () => {
|
|||
|
||||
expect(ticketStateBefore.code).not.toBe(ticketStateAfter.code);
|
||||
|
||||
const ticketAfter = await models.TicketState.findById(ticketId, null, options);
|
||||
const ticketAfter = await models.Ticket.findById(ticketId, null, options);
|
||||
|
||||
expect(ticketAfter.refFk).toBeUndefined();
|
||||
expect(ticketAfter.refFk).toBeNull();
|
||||
});
|
||||
|
||||
it('should send Incoterms authorization email on first order', async() => {
|
||||
|
|
Loading…
Reference in New Issue