feat: #7120 specialPrice with new fiels

This commit is contained in:
Javi Gallego 2024-03-21 10:25:08 +01:00
parent 2f87ba03b2
commit 20a338f746
2 changed files with 35 additions and 27 deletions

View File

@ -14,7 +14,8 @@ BEGIN
SELECT `value` INTO price
FROM vn.specialPrice
WHERE itemFk = vItemFk
AND clientFk = vClientFk ;
AND (clientFk = vClientFk OR clientFk IS NULL)
AND util.VN_CURDATE() BETWEEN started AND ended;
RETURN price;
END$$
DELIMITER ;

View File

@ -45,7 +45,8 @@ BEGIN
JOIN itemType it ON it.id = i.typeFk
JOIN itemCategory ic ON ic.id = it.categoryFk
LEFT JOIN specialPrice sp ON sp.itemFk = i.id
AND sp.clientFk = vClientFk
AND (sp.clientFk = vClientFk OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
LEFT JOIN (
SELECT * FROM (
SELECT pf.itemFk,
@ -146,7 +147,9 @@ BEGIN
FROM tmp.ticketComponentBase tcb
JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount'
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
LEFT JOIN specialPrice sp ON sp.itemFk = tcc.itemFk
AND (sp.clientFk = vClientFk OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
JOIN vn.item i ON i.id = tcb.itemFk
WHERE sp.value IS NULL
AND i.supplyResponseFk IS NULL;
@ -169,7 +172,9 @@ BEGIN
FROM tmp.ticketComponentCalculate tcc
JOIN vn.component c2 ON c2.code = 'salePerPackage'
JOIN buy b ON b.id = tcc.buyFk
LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
LEFT JOIN specialPrice sp ON sp.itemFk = tcc.itemFk
AND (sp.clientFk = vClientFk OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
WHERE sp.value IS NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.`zone` (INDEX (id))
@ -208,7 +213,9 @@ BEGIN
sp.value - SUM(tcc.cost) sumCost
FROM tmp.ticketComponentCopy tcc
JOIN component c ON c.id = tcc.componentFk
JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk
JOIN specialPrice sp ON sp.itemFk = tcc.itemFk
AND (sp.clientFk = vClientFk OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
JOIN vn.component c2 ON c2.code = 'specialPrices'
WHERE c.classRate IS NULL
AND tcc.warehouseFk = vWarehouseFk