6784-delete-clientTypeFk #2059

Merged
ivanm merged 6 commits from 6784-delete-clientTypeFk into dev 2024-02-23 08:25:42 +00:00
4 changed files with 11 additions and 9 deletions
Showing only changes of commit a0cb32ea10 - Show all commits

View File

@ -47,12 +47,11 @@ BEGIN
JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN itemCategory ic ON ic.id = tp.categoryFk
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN client c ON c.id = t.clientFk 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 warehouse w ON w.id = t.warehouseFk

este join ja sobra

este join ja sobra
Outdated
Review

Sí, es cert, ho canvie en els 3 casos i ho tinc en compte per a canviar-ho en els 2 de access.

Sí, es cert, ho canvie en els 3 casos i ho tinc en compte per a canviar-ho en els 2 de access.
JOIN address ad ON ad.id = t.addressFk JOIN address ad ON ad.id = t.addressFk
LEFT JOIN province p ON p.id = ad.provinceFk LEFT JOIN province p ON p.id = ad.provinceFk
WHERE tm.period BETWEEN vMaxPeriod AND vPeriod WHERE tm.period BETWEEN vMaxPeriod AND vPeriod
AND ct.code <> 'loses' AND c.typeFk <> 'loses'
AND NOT w.code = 'inv' AND NOT w.code = 'inv'
GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk; GROUP BY p.countryFk, s.itemFk, tm.period, t.warehouseFk;
END IF; END IF;

View File

@ -44,10 +44,9 @@ proc:BEGIN
LEFT JOIN saleTracking st ON st.saleFk = s.id LEFT JOIN saleTracking st ON st.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk 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()) WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())

este join ja sobra

este join ja sobra
AND st.saleFk IS NULL AND st.saleFk IS NULL
AND ct.code IN ('normal', 'trust') AND c.typeFk IN ('normal', 'trust')
GROUP BY s.itemFk GROUP BY s.itemFk
Review

c.typeFk , tant ací com en els altres llocs

c.typeFk , tant ací com en els altres llocs
) sub2 ON sub2.itemFk = sub.itemFk ) sub2 ON sub2.itemFk = sub.itemFk
UNION ALL UNION ALL
@ -70,10 +69,9 @@ proc:BEGIN
LEFT JOIN saleTracking st ON st.saleFk = s.id LEFT JOIN saleTracking st ON st.saleFk = s.id
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN client c on c.id = t.clientFk 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()) WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
AND st.saleFk IS NULL AND st.saleFk IS NULL
AND ct.code IN ('normal', 'trust') AND c.typeFk IN ('normal', 'trust')
GROUP BY s.itemFk GROUP BY s.itemFk
) sub5 ON sub5.itemFk = v.item_id ) sub5 ON sub5.itemFk = v.item_id
WHERE v.calc_id = vCalcVisibleFk WHERE v.calc_id = vCalcVisibleFk

View File

@ -120,7 +120,7 @@ BEGIN
TRUE, TRUE,
s.id, s.id,
st.`order`, st.`order`,
ct.`code`, c.typeFk,
cb.claimFk, cb.claimFk,
NULL NULL
FROM sale s FROM sale s
@ -128,7 +128,6 @@ BEGIN
LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN ticketState ts ON ts.ticketFk = t.id
LEFT JOIN state st ON st.`code` = ts.`code` LEFT JOIN state st ON st.`code` = ts.`code`
JOIN client c ON c.id = t.clientFk 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(), JOIN state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(),
'DELIVERED', 'DELIVERED',
IF (t.shipped > util.dayEnd(util.VN_CURDATE()), IF (t.shipped > util.dayEnd(util.VN_CURDATE()),

View File

@ -41,7 +41,13 @@ module.exports = Self => {
include: { include: {
relation: 'client', relation: 'client',
scope: { scope: {
fields: ['id', 'typeFk'] fields: ['id', 'typeFk'],
include: {
relation: 'type',
scope: {
fields: ['code', 'description']
}
}
} }
} }
}, },