7120-specialPrice #2213

Merged
jgallego merged 4 commits from 7120-specialPrice into dev 2024-03-28 08:01:46 +00:00
3 changed files with 31 additions and 16 deletions
Showing only changes of commit c99de95b33 - Show all commits

View File

@ -15,7 +15,9 @@ BEGIN
FROM vn.specialPrice
WHERE itemFk = vItemFk
AND (clientFk = vClientFk OR clientFk IS NULL)
AND util.VN_CURDATE() BETWEEN started AND ended;
AND started <= util.VN_CURDATE()
jgallego marked this conversation as resolved
Review

La columna aunque está declarada NOTNULL, la mayoría de los valores es NULL

La columna aunque está declarada NOTNULL, la mayoría de los valores es NULL
AND (ended >= util.VN_CURDATE() OR ended IS NULL)
ORDER BY id DESC LIMIT 1;
RETURN price;
END$$
DELIMITER ;

View File

@ -25,6 +25,19 @@ BEGIN
FROM address
WHERE id = vAddressFk;
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
(INDEX (itemFk))
ENGINE = MEMORY
SELECT * FROM (
SELECT *
FROM specialPrice
WHERE (clientFk = vClientFk OR clientFk IS NULL)
AND started <= vShipped
jgallego marked this conversation as resolved
Review

La columna aunque está declarada NOTNULL, la mayoría de los valores es NULL

La columna aunque está declarada NOTNULL, la mayoría de los valores es NULL
Review

si ho mires en php no eren null eren 0000-00-00 pero dbeaver ho mostra com a null. De totes formes he creat un valor per defecte.

si ho mires en php no eren null eren 0000-00-00 pero dbeaver ho mostra com a null. De totes formes he creat un valor per defecte.
AND (ended >= vShipped OR ended IS NULL)
ORDER BY (clientFk = vClientFk) DESC, id DESC
LIMIT 10000000000000000000) t
GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
(PRIMARY KEY (itemFk, warehouseFk))
ENGINE = MEMORY
@ -44,9 +57,7 @@ BEGIN
JOIN item i ON i.id = tl.itemFk
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 OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
LEFT JOIN tSpecialPrice sp ON sp.itemFk = i.id
LEFT JOIN (
SELECT * FROM (
SELECT pf.itemFk,
@ -147,9 +158,7 @@ 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.itemFk = tcc.itemFk
AND (sp.clientFk = vClientFk OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
JOIN vn.item i ON i.id = tcb.itemFk
WHERE sp.value IS NULL
AND i.supplyResponseFk IS NULL;
@ -172,9 +181,7 @@ 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.itemFk = tcc.itemFk
AND (sp.clientFk = vClientFk OR sp.clientFk IS NULL)
AND vShipped BETWEEN sp.started AND sp.ended
LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
WHERE sp.value IS NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.`zone` (INDEX (id))
@ -213,9 +220,7 @@ BEGIN
sp.value - SUM(tcc.cost) sumCost
FROM tmp.ticketComponentCopy tcc
JOIN component c ON c.id = tcc.componentFk
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 tSpecialPrice sp ON sp.itemFk = tcc.itemFk
JOIN vn.component c2 ON c2.code = 'specialPrices'
WHERE c.classRate IS NULL
AND tcc.warehouseFk = vWarehouseFk
@ -296,6 +301,7 @@ BEGIN
tmp.ticketComponentSum,
tmp.ticketComponentBase,
tmp.ticketComponentRate,
tmp.ticketComponentCopy;
tmp.ticketComponentCopy,
tSpecialPrice;
END$$
DELIMITER ;

View File

@ -0,0 +1,7 @@
ALTER TABLE vn.specialPrice MODIFY COLUMN clientFk int(11) DEFAULT 0 NULL;
ALTER TABLE vn.specialPrice ADD started date NOT NULL;
jgallego marked this conversation as resolved Outdated

Hay que actualizar los valores antes de hacer este cambio para que no falle?

Hay que actualizar los valores antes de hacer este cambio para que no falle?
ALTER TABLE vn.specialPrice ADD ended date NULL;
ALTER TABLE `specialPrice`
ADD CONSTRAINT `check_date_range`
CHECK (`ended` IS NULL OR `ended` >= `started`);