6784-delete-clientTypeFk #2059
|
@ -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
|
||||||
|
|||||||
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;
|
||||||
|
|
|
@ -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())
|
||||||
jgallego
commented
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
|
||||||
jgallego
commented
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
|
||||||
|
|
|
@ -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()),
|
||||||
|
|
|
@ -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']
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
este join ja sobra
Sí, es cert, ho canvie en els 3 casos i ho tinc en compte per a canviar-ho en els 2 de access.