6995-testToMaster_2410 #2139
|
@ -47,12 +47,11 @@ BEGIN
|
|||
JOIN itemCategory ic ON ic.id = tp.categoryFk
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN clientType ct ON ct.code = c.typeFk
|
||||
JOIN warehouse w ON w.id = t.warehouseFk
|
||||
JOIN address ad ON ad.id = t.addressFk
|
||||
LEFT JOIN province p ON p.id = ad.provinceFk
|
||||
WHERE tm.period BETWEEN vMaxPeriod AND vPeriod
|
||||
AND ct.code <> 'loses'
|
||||
AND c.typeFk <> 'loses'
|
||||
AND NOT w.code = 'inv'
|
||||
GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk;
|
||||
END IF;
|
||||
|
|
|
@ -44,10 +44,9 @@ proc:BEGIN
|
|||
LEFT JOIN saleTracking st ON st.saleFk = s.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN client c on c.id = t.clientFk
|
||||
JOIN clientType ct ON ct.code = c.typeFk
|
||||
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||
AND st.saleFk IS NULL
|
||||
AND ct.code IN ('normal', 'trust')
|
||||
AND c.typeFk IN ('normal', 'trust')
|
||||
GROUP BY s.itemFk
|
||||
) sub2 ON sub2.itemFk = sub.itemFk
|
||||
UNION ALL
|
||||
|
@ -70,10 +69,9 @@ proc:BEGIN
|
|||
LEFT JOIN saleTracking st ON st.saleFk = s.id
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
JOIN client c on c.id = t.clientFk
|
||||
JOIN clientType ct ON ct.code = c.typeFk
|
||||
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
|
||||
AND st.saleFk IS NULL
|
||||
AND ct.code IN ('normal', 'trust')
|
||||
AND c.typeFk IN ('normal', 'trust')
|
||||
GROUP BY s.itemFk
|
||||
) sub5 ON sub5.itemFk = v.item_id
|
||||
WHERE v.calc_id = vCalcVisibleFk
|
||||
|
|
|
@ -120,7 +120,7 @@ BEGIN
|
|||
TRUE,
|
||||
s.id,
|
||||
st.`order`,
|
||||
ct.`code`,
|
||||
c.typeFk,
|
||||
cb.claimFk,
|
||||
NULL
|
||||
FROM sale s
|
||||
|
@ -128,7 +128,6 @@ BEGIN
|
|||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
LEFT JOIN state st ON st.`code` = ts.`code`
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN clientType ct ON ct.code = c.typeFk
|
||||
JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
|
||||
'DELIVERED',
|
||||
IF (t.shipped > util.dayEnd(util.VN_CURDATE()),
|
||||
|
|
|
@ -41,7 +41,13 @@ module.exports = Self => {
|
|||
include: {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'typeFk']
|
||||
fields: ['id', 'typeFk'],
|
||||
include: {
|
||||
relation: 'type',
|
||||
scope: {
|
||||
fields: ['code', 'description']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue