fix: refs #7844 salesFilter and tmp.ticket_problems.totalProblems
This commit is contained in:
parent
bd06bed570
commit
3cc19549e4
|
@ -9,7 +9,7 @@ BEGIN
|
||||||
* @param vBuyFk Buy id
|
* @param vBuyFk Buy id
|
||||||
*/
|
*/
|
||||||
DECLARE vItemFk INT;
|
DECLARE vItemFk INT;
|
||||||
DECLARE vWareHouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vMaxDated DATE;
|
DECLARE vMaxDated DATE;
|
||||||
DECLARE vMinDated DATE;
|
DECLARE vMinDated DATE;
|
||||||
DECLARE vLanding DATE;
|
DECLARE vLanding DATE;
|
||||||
|
@ -18,12 +18,13 @@ BEGIN
|
||||||
DECLARE vGrouping INT;
|
DECLARE vGrouping INT;
|
||||||
|
|
||||||
SELECT b.itemFk, t.warehouseInFk
|
SELECT b.itemFk, t.warehouseInFk
|
||||||
INTO vItemFk, vWareHouseFk
|
INTO vItemFk, vWarehouseFk
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE b.id = vBuyFk;
|
WHERE b.id = vBuyFk;
|
||||||
|
|
||||||
|
IF vItemFk AND vWarehouseFk THEN
|
||||||
SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped))
|
SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped))
|
||||||
INTO vMaxDated, vMinDated
|
INTO vMaxDated, vMinDated
|
||||||
FROM sale s
|
FROM sale s
|
||||||
|
@ -32,7 +33,7 @@ BEGIN
|
||||||
AND s.itemFk = vItemFk
|
AND s.itemFk = vItemFk
|
||||||
AND s.quantity > 0;
|
AND s.quantity > 0;
|
||||||
|
|
||||||
CALL buy_getUltimate(vItemFk, vWareHouseFk, vMinDated);
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, vMinDated);
|
||||||
|
|
||||||
SELECT bu.buyFk, b.grouping INTO vLastBuy, vGrouping
|
SELECT bu.buyFk, b.grouping INTO vLastBuy, vGrouping
|
||||||
FROM tmp.buyUltimate bu
|
FROM tmp.buyUltimate bu
|
||||||
|
@ -45,7 +46,7 @@ BEGIN
|
||||||
WHILE vCurrentBuy <> vLastBuy OR vLanding > vMinDated DO
|
WHILE vCurrentBuy <> vLastBuy OR vLanding > vMinDated DO
|
||||||
SET vMaxDated = vLanding - INTERVAL 1 DAY;
|
SET vMaxDated = vLanding - INTERVAL 1 DAY;
|
||||||
|
|
||||||
CALL buy_getUltimate(vItemFk, vWareHouseFk, vMaxDated);
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, vMaxDated);
|
||||||
|
|
||||||
SELECT buyFk, landing
|
SELECT buyFk, landing
|
||||||
INTO vCurrentBuy, vLanding
|
INTO vCurrentBuy, vLanding
|
||||||
|
@ -69,5 +70,6 @@ BEGIN
|
||||||
CALL sale_setProblem('hasRounding');
|
CALL sale_setProblem('hasRounding');
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.sale;
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -264,7 +264,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
UPDATE tmp.ticket_problems
|
UPDATE tmp.ticket_problems
|
||||||
SET risk = IF(hasRisk AND risk > 0, risk, 0)
|
SET risk = IF(hasRisk, risk, 0)
|
||||||
`);
|
`);
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
|
|
@ -308,7 +308,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
UPDATE tmp.ticket_problems
|
UPDATE tmp.ticket_problems
|
||||||
SET risk = IF(hasRisk AND risk > 0, risk, 0)
|
SET risk = IF(hasRisk, risk, 0)
|
||||||
`);
|
`);
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
UPDATE tmp.ticket_problems
|
UPDATE tmp.ticket_problems
|
||||||
SET risk = IF(hasRisk AND risk > 0, risk, 0)
|
SET risk = IF(hasRisk, risk, 0)
|
||||||
`);
|
`);
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,9 @@
|
||||||
},
|
},
|
||||||
"cmrFk": {
|
"cmrFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"problem": {
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Client has debt"
|
vn-tooltip="Client has debt"
|
||||||
icon="icon-risk"
|
icon="icon-risk"
|
||||||
ng-if="$ctrl.ticket.client.debt > $ctrl.ticket.client.credit">
|
ng-if="$ctrl.ticket.problem.includes('hasRisk')">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
vn-tooltip="Client not checked"
|
vn-tooltip="Client not checked"
|
||||||
|
|
Loading…
Reference in New Issue