Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
20caa5d9a1
|
@ -110,7 +110,7 @@ BEGIN
|
||||||
|
|
||||||
UPDATE itemShelving
|
UPDATE itemShelving
|
||||||
SET isSplit = TRUE
|
SET isSplit = TRUE
|
||||||
WHERE shelvingFk = vShelvingFk;
|
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE cur;
|
CLOSE cur;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`(
|
||||||
|
vSaleGroupFk INT(11)
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Reserva cantidades con ubicaciones para el contenido de una preparación previa
|
||||||
|
* a través del saleGroup
|
||||||
|
*
|
||||||
|
* @param vSaleGroupFk Identificador de saleGroup
|
||||||
|
*/
|
||||||
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
|
DECLARE vSaleFk INT;
|
||||||
|
DECLARE vSectorFk INT;
|
||||||
|
DECLARE vSales CURSOR FOR
|
||||||
|
SELECT s.id
|
||||||
|
FROM saleGroupDetail sgd
|
||||||
|
JOIN sale s ON sgd.saleFk = s.id
|
||||||
|
JOIN saleTracking str ON str.saleFk = s.id
|
||||||
|
JOIN `state` st ON st.id = str.stateFk
|
||||||
|
AND st.code = 'PREVIOUS_PREPARATION'
|
||||||
|
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||||
|
WHERE sgd.saleGroupFk = vSaleGroupFk
|
||||||
|
AND str.workerFk = account.myUser_getId()
|
||||||
|
AND iss.id IS NULL;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SELECT sectorFk INTO vSectorFk
|
||||||
|
FROM operator
|
||||||
|
WHERE workerFk = account.myUser_getId();
|
||||||
|
|
||||||
|
OPEN vSales;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vSales INTO vSaleFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
||||||
|
END LOOP;
|
||||||
|
CLOSE vSales;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -16,7 +16,8 @@ BEGIN
|
||||||
ish.id,
|
ish.id,
|
||||||
s.priority,
|
s.priority,
|
||||||
ish.isChecked,
|
ish.isChecked,
|
||||||
ic.url
|
ic.url,
|
||||||
|
ish.available
|
||||||
FROM itemShelving ish
|
FROM itemShelving ish
|
||||||
JOIN item i ON i.id = ish.itemFk
|
JOIN item i ON i.id = ish.itemFk
|
||||||
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci
|
||||||
|
|
|
@ -14,7 +14,7 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT vSelf saleFk,
|
SELECT vSelf saleFk,
|
||||||
sale_hasComponentLack(vSelf) hasProblem,
|
sale_hasComponentLack(vSelf) hasProblem,
|
||||||
ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded
|
(ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded
|
||||||
FROM sale
|
FROM sale
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ BEGIN
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT saleFk,
|
SELECT saleFk,
|
||||||
sale_hasComponentLack(saleFk) hasProblem,
|
sale_hasComponentLack(saleFk) hasProblem,
|
||||||
ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded
|
(ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.id saleFk, s.ticketFk
|
SELECT s.id saleFk, s.ticketFk, s.quantity
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||||
|
|
|
@ -1,92 +1,81 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`(
|
||||||
vClientFk INT)
|
vClientFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Update the risk for a client with pending tickets
|
* Update the risk for a client with pending tickets.
|
||||||
*
|
*
|
||||||
* @param vClientFk Id cliente
|
* @param vClientFk Id cliente
|
||||||
*/
|
*/
|
||||||
DECLARE vHasDebt BOOL;
|
IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN
|
||||||
DECLARE vStarted DATETIME;
|
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vHasDebt
|
|
||||||
FROM `client`
|
|
||||||
WHERE id = vClientFk
|
|
||||||
AND typeFk = 'normal';
|
|
||||||
|
|
||||||
IF vHasDebt THEN
|
|
||||||
|
|
||||||
SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted
|
|
||||||
FROM clientConfig;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTicketRisk
|
CREATE OR REPLACE TEMPORARY TABLE tTicketRisk
|
||||||
(KEY (ticketFk))
|
(PRIMARY KEY (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
WITH ticket AS(
|
WITH ticket AS (
|
||||||
SELECT id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
companyFk,
|
t.companyFk,
|
||||||
DATE(shipped) dated,
|
DATE(t.shipped) dated,
|
||||||
totalWithVat,
|
t.totalWithVat,
|
||||||
ticket_isProblemCalcNeeded(id) isProblemCalcNeeded
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||||
FROM vn.ticket
|
FROM vn.ticket t
|
||||||
WHERE clientFk = vClientFk
|
JOIN vn.clientConfig cc
|
||||||
AND refFk IS NULL
|
WHERE t.clientFk = vClientFk
|
||||||
AND NOT isDeleted
|
AND t.refFk IS NULL
|
||||||
AND IFNULL(totalWithVat, 0) <> 0
|
AND NOT t.isDeleted
|
||||||
AND shipped > vStarted
|
AND IFNULL(t.totalWithVat, 0) <> 0
|
||||||
), balance AS(
|
AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH)
|
||||||
SELECT SUM(amount)amount, companyFk
|
), uninvoiced AS (
|
||||||
FROM (
|
|
||||||
SELECT amount, companyFk
|
|
||||||
FROM vn.clientRisk
|
|
||||||
WHERE clientFk = vClientFk
|
|
||||||
UNION ALL
|
|
||||||
SELECT -(SUM(amount) / 100) amount, tm.companyFk
|
|
||||||
FROM hedera.tpvTransaction t
|
|
||||||
JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk
|
|
||||||
WHERE clientFk = vClientFk
|
|
||||||
AND receiptFk IS NULL
|
|
||||||
AND status = 'ok'
|
|
||||||
) sub
|
|
||||||
WHERE companyFk
|
|
||||||
GROUP BY companyFk
|
|
||||||
), uninvoiced AS(
|
|
||||||
SELECT companyFk, dated, SUM(totalWithVat) amount
|
SELECT companyFk, dated, SUM(totalWithVat) amount
|
||||||
FROM ticket
|
FROM ticket
|
||||||
GROUP BY companyFk, dated
|
GROUP BY companyFk, dated
|
||||||
), receipt AS(
|
), companies AS (
|
||||||
SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount
|
SELECT DISTINCT companyFk FROM uninvoiced
|
||||||
FROM vn.receipt
|
), balance AS (
|
||||||
WHERE clientFk = vClientFk
|
SELECT SUM(IFNULL(amount, 0))amount, companyFk
|
||||||
AND payed > util.VN_CURDATE()
|
FROM (
|
||||||
GROUP BY companyFk, DATE(payed)
|
SELECT cr.amount, c.companyFk
|
||||||
), risk AS(
|
FROM companies c
|
||||||
|
LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk
|
||||||
|
AND cr.clientFk = vClientFk
|
||||||
|
UNION ALL
|
||||||
|
SELECT -(SUM(t.amount) / 100) amount, c.companyFk
|
||||||
|
FROM companies c
|
||||||
|
LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk
|
||||||
|
LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id
|
||||||
|
AND t.clientFk = vClientFk
|
||||||
|
AND t.receiptFk IS NULL
|
||||||
|
AND t.`status` = 'ok'
|
||||||
|
) sub
|
||||||
|
WHERE companyFk
|
||||||
|
GROUP BY companyFk
|
||||||
|
), receipt AS (
|
||||||
|
SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount
|
||||||
|
FROM vn.receipt r
|
||||||
|
JOIN companies c ON c.companyFk = r.companyFk
|
||||||
|
WHERE r.clientFk = vClientFk
|
||||||
|
AND r.payed > util.VN_CURDATE()
|
||||||
|
GROUP BY r.companyFk, DATE(r.payed)
|
||||||
|
), risk AS (
|
||||||
SELECT b.companyFk,
|
SELECT b.companyFk,
|
||||||
ui.dated,
|
ui.dated,
|
||||||
SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) +
|
SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) +
|
||||||
b.amount +
|
b.amount +
|
||||||
SUM(IFNULL(r.amount, 0)) amount
|
SUM(IFNULL(r.amount, 0)) amount
|
||||||
FROM balance b
|
FROM balance b
|
||||||
JOIN uninvoiced ui ON ui.companyFk = b.companyFk
|
JOIN uninvoiced ui ON ui.companyFk = b.companyFk
|
||||||
LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk
|
LEFT JOIN receipt r ON r.dated > ui.dated
|
||||||
|
AND r.companyFk = ui.companyFk
|
||||||
GROUP BY b.companyFk, ui.dated
|
GROUP BY b.companyFk, ui.dated
|
||||||
)
|
)
|
||||||
SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded
|
SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded
|
||||||
FROM ticket ti
|
FROM ticket ti
|
||||||
JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk;
|
JOIN risk r ON r.dated = ti.dated
|
||||||
|
AND r.companyFk = ti.companyFk;
|
||||||
|
|
||||||
UPDATE ticket t
|
UPDATE ticket t
|
||||||
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
||||||
SET t.risk = tr.amount
|
SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL);
|
||||||
WHERE tr.isProblemCalcNeeded
|
|
||||||
ORDER BY t.id;
|
|
||||||
|
|
||||||
UPDATE ticket t
|
|
||||||
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
|
||||||
SET t.risk = NULL
|
|
||||||
WHERE tr.isProblemCalcNeeded
|
|
||||||
ORDER BY t.id;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tTicketRisk;
|
DROP TEMPORARY TABLE tTicketRisk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -9,9 +9,5 @@ BEGIN
|
||||||
SET NEW.userFk = account.myUser_getId();
|
SET NEW.userFk = account.myUser_getId();
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF (NEW.visible <> OLD.visible) THEN
|
|
||||||
SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -101,7 +101,8 @@ module.exports = Self => {
|
||||||
'groupingMode',
|
'groupingMode',
|
||||||
'inkFk',
|
'inkFk',
|
||||||
'originFk',
|
'originFk',
|
||||||
'producerFk'
|
'producerFk',
|
||||||
|
'comment'
|
||||||
],
|
],
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"isChecked": {
|
"isChecked": {
|
||||||
"type": "boolean"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"packing": {
|
"packing": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
@ -38,6 +38,9 @@
|
||||||
},
|
},
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"available": {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
Loading…
Reference in New Issue