7226-testToMaster_2416 #2320
|
@ -62,14 +62,15 @@ module.exports = Self => {
|
|||
await Self.rawSql(`
|
||||
WITH ticketNotInvoiceable AS(
|
||||
SELECT JSON_OBJECT(
|
||||
'tickets',
|
||||
JSON_ARRAYAGG(
|
||||
JSON_OBJECT(
|
||||
'ticketId', ticketFk,
|
||||
'reason',
|
||||
LEFT(reason,LENGTH(reason) - 2)
|
||||
'tickets',
|
||||
JSON_ARRAYAGG(
|
||||
JSON_OBJECT(
|
||||
'ticketId', ticketFk,
|
||||
'reason',
|
||||
LEFT(reason,LENGTH(reason) - 2)
|
||||
)
|
||||
)
|
||||
))errors
|
||||
)errors
|
||||
FROM (
|
||||
SELECT ticketFk,
|
||||
CONCAT_WS('',
|
||||
|
@ -87,8 +88,8 @@ module.exports = Self => {
|
|||
SUM(itc.id IS NULL) hasErrorItemTaxCountry,
|
||||
SUM(a.id IS NULL) hasErrorAddress,
|
||||
SUM(ios.code IS NOT NULL
|
||||
AND(ad.customsAgentFk IS NULL
|
||||
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld
|
||||
AND(ad.customsAgentFk IS NULL
|
||||
OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld
|
||||
FROM ticket t
|
||||
LEFT JOIN address ad ON ad.id = t.addressFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
|
@ -107,14 +108,13 @@ module.exports = Self => {
|
|||
AND itc.countryFk = su.countryFk
|
||||
LEFT JOIN vn.invoiceOutSerial ios ON ios.taxAreaFk = 'WORLD'
|
||||
AND ios.code = invoiceSerial(t.clientFk, t.companyFk, 'M')
|
||||
WHERE (al.code = 'PACKED'
|
||||
OR (am.code = 'refund' AND al.code != 'delivered'))
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) AND util.dayEnd(?)
|
||||
WHERE (al.code = 'PACKED' OR (am.code = 'refund' AND al.code <> 'delivered'))
|
||||
AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) AND util.dayEnd(?)
|
||||
AND t.refFk IS NULL
|
||||
AND IFNULL(a.hasDailyInvoice, co.hasDailyInvoice)
|
||||
GROUP BY ticketFk
|
||||
HAVING hasErrorToInvoice
|
||||
OR NOT hasErrorTaxDataChecked
|
||||
OR hasErrorTaxDataChecked
|
||||
OR hasErrorDeleted
|
||||
OR hasErrorItemTaxCountry
|
||||
OR hasErrorAddress
|
||||
|
@ -130,12 +130,12 @@ module.exports = Self => {
|
|||
|
||||
await Self.rawSql(`
|
||||
UPDATE ticket t
|
||||
JOIN ticketState ts ON t.id = ts.ticketFk
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
JOIN zone z ON z.id = t.zoneFk
|
||||
SET t.routeFk = NULL
|
||||
JOIN ticketState ts ON t.id = ts.ticketFk
|
||||
JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
JOIN zone z ON z.id = t.zoneFk
|
||||
SET t.routeFk = NULL
|
||||
WHERE DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY)
|
||||
AND util.dayEnd(?)
|
||||
AND al.code NOT IN('DELIVERED','PACKED')
|
||||
|
|
Loading…
Reference in New Issue