7199-devToTest_2316 #2287
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -5,22 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [24.16.01] - 2024-04-18
|
||||||
|
|
||||||
## [2414.01] - 2024-04-04
|
## [2414.01] - 2024-04-04
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
## [2408.01] - 2024-02-22
|
## [2408.01] - 2024-02-22
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
## [2406.01] - 2024-02-08
|
## [2406.01] - 2024-02-08
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -13,8 +13,11 @@ BEGIN
|
||||||
|
|
||||||
SELECT `value` INTO price
|
SELECT `value` INTO price
|
||||||
FROM vn.specialPrice
|
FROM vn.specialPrice
|
||||||
WHERE itemFk = vItemFk
|
WHERE itemFk = vItemFk
|
||||||
AND clientFk = vClientFk ;
|
AND (clientFk = vClientFk OR clientFk IS NULL)
|
||||||
|
AND started <= util.VN_CURDATE()
|
||||||
|
AND (ended >= util.VN_CURDATE() OR ended IS NULL)
|
||||||
|
ORDER BY id DESC LIMIT 1;
|
||||||
RETURN price;
|
RETURN price;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -25,6 +25,19 @@ BEGIN
|
||||||
FROM address
|
FROM address
|
||||||
WHERE id = vAddressFk;
|
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
|
||||||
|
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
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate
|
||||||
(PRIMARY KEY (itemFk, warehouseFk))
|
(PRIMARY KEY (itemFk, warehouseFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -44,8 +57,7 @@ BEGIN
|
||||||
JOIN item i ON i.id = tl.itemFk
|
JOIN item i ON i.id = tl.itemFk
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
LEFT JOIN specialPrice sp ON sp.itemFk = i.id
|
LEFT JOIN tSpecialPrice sp ON sp.itemFk = i.id
|
||||||
AND sp.clientFk = vClientFk
|
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT * FROM (
|
SELECT * FROM (
|
||||||
SELECT pf.itemFk,
|
SELECT pf.itemFk,
|
||||||
|
@ -146,7 +158,7 @@ BEGIN
|
||||||
FROM tmp.ticketComponentBase tcb
|
FROM tmp.ticketComponentBase tcb
|
||||||
JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount'
|
JOIN vn.component c2 ON c2.code = 'lastUnitsDiscount'
|
||||||
JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tcb.itemFk AND tcc.warehouseFk = tcb.warehouseFk
|
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 tSpecialPrice sp ON sp.itemFk = tcc.itemFk
|
||||||
JOIN vn.item i ON i.id = tcb.itemFk
|
JOIN vn.item i ON i.id = tcb.itemFk
|
||||||
WHERE sp.value IS NULL
|
WHERE sp.value IS NULL
|
||||||
AND i.supplyResponseFk IS NULL;
|
AND i.supplyResponseFk IS NULL;
|
||||||
|
@ -169,7 +181,7 @@ BEGIN
|
||||||
FROM tmp.ticketComponentCalculate tcc
|
FROM tmp.ticketComponentCalculate tcc
|
||||||
JOIN vn.component c2 ON c2.code = 'salePerPackage'
|
JOIN vn.component c2 ON c2.code = 'salePerPackage'
|
||||||
JOIN buy b ON b.id = tcc.buyFk
|
JOIN buy b ON b.id = tcc.buyFk
|
||||||
LEFT JOIN specialPrice sp ON sp.clientFk = vClientFk AND sp.itemFk = tcc.itemFk
|
LEFT JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
|
||||||
WHERE sp.value IS NULL;
|
WHERE sp.value IS NULL;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.`zone` (INDEX (id))
|
CREATE OR REPLACE TEMPORARY TABLE tmp.`zone` (INDEX (id))
|
||||||
|
@ -208,7 +220,7 @@ BEGIN
|
||||||
sp.value - SUM(tcc.cost) sumCost
|
sp.value - SUM(tcc.cost) sumCost
|
||||||
FROM tmp.ticketComponentCopy tcc
|
FROM tmp.ticketComponentCopy tcc
|
||||||
JOIN component c ON c.id = tcc.componentFk
|
JOIN component c ON c.id = tcc.componentFk
|
||||||
JOIN specialPrice sp ON sp.clientFk = vClientFK AND sp.itemFk = tcc.itemFk
|
JOIN tSpecialPrice sp ON sp.itemFk = tcc.itemFk
|
||||||
JOIN vn.component c2 ON c2.code = 'specialPrices'
|
JOIN vn.component c2 ON c2.code = 'specialPrices'
|
||||||
WHERE c.classRate IS NULL
|
WHERE c.classRate IS NULL
|
||||||
AND tcc.warehouseFk = vWarehouseFk
|
AND tcc.warehouseFk = vWarehouseFk
|
||||||
|
@ -289,6 +301,7 @@ BEGIN
|
||||||
tmp.ticketComponentSum,
|
tmp.ticketComponentSum,
|
||||||
tmp.ticketComponentBase,
|
tmp.ticketComponentBase,
|
||||||
tmp.ticketComponentRate,
|
tmp.ticketComponentRate,
|
||||||
tmp.ticketComponentCopy;
|
tmp.ticketComponentCopy,
|
||||||
|
tSpecialPrice;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -30,6 +30,7 @@ BEGIN
|
||||||
DELETE IGNORE FROM expedition WHERE created < v26Months;
|
DELETE IGNORE FROM expedition WHERE created < v26Months;
|
||||||
DELETE FROM sms WHERE created < v18Months;
|
DELETE FROM sms WHERE created < v18Months;
|
||||||
DELETE FROM saleTracking WHERE created < v1Years;
|
DELETE FROM saleTracking WHERE created < v1Years;
|
||||||
|
DELETE FROM productionError WHERE dated < v1Years;
|
||||||
DELETE FROM ticketTracking WHERE created < v18Months;
|
DELETE FROM ticketTracking WHERE created < v18Months;
|
||||||
DELETE tobs FROM ticketObservation tobs
|
DELETE tobs FROM ticketObservation tobs
|
||||||
JOIN ticket t ON tobs.ticketFk = t.id
|
JOIN ticket t ON tobs.ticketFk = t.id
|
||||||
|
|
|
@ -7,81 +7,81 @@ BEGIN
|
||||||
* @param vSelf company id
|
* @param vSelf company id
|
||||||
* @param vMonthAgo time interval to be consulted
|
* @param vMonthAgo time interval to be consulted
|
||||||
*/
|
*/
|
||||||
DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE());
|
DECLARE vStartingDate DATETIME DEFAULT TIMESTAMPADD (MONTH,- vMonthsAgo,util.VN_CURDATE());
|
||||||
DECLARE vCurrencyEuroFk INT;
|
DECLARE vCurrencyEuroFk INT;
|
||||||
DECLARE vStartDate DATE;
|
DECLARE vStartDate DATE;
|
||||||
DECLARE vInvalidBalances DOUBLE;
|
DECLARE vInvalidBalances DOUBLE;
|
||||||
|
|
||||||
SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig;
|
SELECT dated, invalidBalances INTO vStartDate, vInvalidBalances FROM supplierDebtConfig;
|
||||||
SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR';
|
SELECT id INTO vCurrencyEuroFk FROM currency WHERE code = 'EUR';
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tOpeningBalances;
|
DROP TEMPORARY TABLE IF EXISTS tOpeningBalances;
|
||||||
CREATE TEMPORARY TABLE tOpeningBalances (
|
CREATE TEMPORARY TABLE tOpeningBalances (
|
||||||
supplierFk INT NOT NULL,
|
supplierFk INT NOT NULL,
|
||||||
companyFk INT NOT NULL,
|
companyFk INT NOT NULL,
|
||||||
openingBalances DOUBLE NOT NULL,
|
openingBalances DOUBLE NOT NULL,
|
||||||
closingBalances DOUBLE NOT NULL,
|
closingBalances DOUBLE NOT NULL,
|
||||||
currencyFk INT NOT NULL,
|
currencyFk INT NOT NULL,
|
||||||
PRIMARY KEY (supplierFk, companyFk, currencyFk)
|
PRIMARY KEY (supplierFk, companyFk, currencyFk)
|
||||||
) ENGINE = MEMORY;
|
) ENGINE = MEMORY;
|
||||||
|
|
||||||
-- Calculates the opening and closing balance for each supplier
|
-- Calculates the opening and closing balance for each supplier
|
||||||
INSERT INTO tOpeningBalances
|
INSERT INTO tOpeningBalances
|
||||||
SELECT supplierFk,
|
SELECT supplierFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
SUM(amount * isBeforeStarting) AS openingBalances,
|
SUM(amount * isBeforeStarting) AS openingBalances,
|
||||||
SUM(amount) closingBalances,
|
SUM(amount) closingBalances,
|
||||||
currencyFk
|
currencyFk
|
||||||
FROM (
|
FROM (
|
||||||
SELECT p.supplierFk,
|
SELECT p.supplierFk,
|
||||||
p.companyFk,
|
p.companyFk,
|
||||||
IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
|
IF (p.currencyFk = vCurrencyEuroFk, p.amount, p.divisa) AS amount,
|
||||||
p.dueDated < vStartingDate isBeforeStarting,
|
p.dueDated < vStartingDate isBeforeStarting,
|
||||||
p.currencyFk
|
p.currencyFk
|
||||||
FROM payment p
|
FROM payment p
|
||||||
WHERE p.received > vStartDate
|
WHERE p.received > vStartDate
|
||||||
AND p.companyFk = vSelf
|
AND p.companyFk = vSelf
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.supplierFk,
|
SELECT r.supplierFk,
|
||||||
r.companyFk,
|
r.companyFk,
|
||||||
- IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
|
- IF (r.currencyFk = vCurrencyEuroFk, rv.amount, rv.foreignValue) AS Total,
|
||||||
rv.dueDated < vStartingDate isBeforeStarting,
|
rv.dueDated < vStartingDate isBeforeStarting,
|
||||||
r.currencyFk
|
r.currencyFk
|
||||||
FROM invoiceIn r
|
FROM invoiceIn r
|
||||||
INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
|
INNER JOIN invoiceInDueDay rv ON r.id = rv.invoiceInFk
|
||||||
WHERE r.issued > vStartDate
|
WHERE r.issued > vStartDate
|
||||||
AND r.isBooked
|
AND r.isBooked
|
||||||
AND r.companyFk = vSelf
|
AND r.companyFk = vSelf
|
||||||
) sub GROUP BY companyFk, supplierFk, currencyFk;
|
) sub GROUP BY companyFk, supplierFk, currencyFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tPendingDuedates;
|
DROP TEMPORARY TABLE IF EXISTS tPendingDuedates;
|
||||||
CREATE TEMPORARY TABLE tPendingDuedates (
|
CREATE TEMPORARY TABLE tPendingDuedates (
|
||||||
id INT auto_increment,
|
id INT auto_increment,
|
||||||
expirationId INT,
|
expirationId INT,
|
||||||
dated DATE,
|
dated DATE,
|
||||||
supplierFk INT NOT NULL,
|
supplierFk INT NOT NULL,
|
||||||
companyFk INT NOT NULL,
|
companyFk INT NOT NULL,
|
||||||
amount DECIMAL(10, 2) NOT NULL,
|
amount DECIMAL(10, 2) NOT NULL,
|
||||||
currencyFk INT NOT NULL,
|
currencyFk INT NOT NULL,
|
||||||
pending DECIMAL(10, 2) DEFAULT 0,
|
pending DECIMAL(10, 2) DEFAULT 0,
|
||||||
balance DECIMAL(10, 2) DEFAULT 0,
|
balance DECIMAL(10, 2) DEFAULT 0,
|
||||||
endingBalance DECIMAL(10, 2) DEFAULT 0,
|
endingBalance DECIMAL(10, 2) DEFAULT 0,
|
||||||
isPayment BOOLEAN,
|
isPayment BOOLEAN,
|
||||||
isReconciled BOOLEAN,
|
isReconciled BOOLEAN,
|
||||||
PRIMARY KEY (id),
|
PRIMARY KEY (id),
|
||||||
INDEX (supplierFk, companyFk, currencyFk)
|
INDEX (supplierFk, companyFk, currencyFk)
|
||||||
) ENGINE = MEMORY;
|
) ENGINE = MEMORY;
|
||||||
|
|
||||||
INSERT INTO tPendingDuedates (
|
INSERT INTO tPendingDuedates (
|
||||||
expirationId,
|
expirationId,
|
||||||
dated,
|
dated,
|
||||||
supplierFk,
|
supplierFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
amount,
|
amount,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
isPayment,
|
isPayment,
|
||||||
isReconciled
|
isReconciled
|
||||||
)SELECT p.id,
|
)SELECT p.id,
|
||||||
p.dueDated,
|
p.dueDated,
|
||||||
p.supplierFk,
|
p.supplierFk,
|
||||||
p.companyFk,
|
p.companyFk,
|
||||||
|
@ -111,69 +111,69 @@ BEGIN
|
||||||
AND r.isBooked
|
AND r.isBooked
|
||||||
AND r.companyFk = vSelf
|
AND r.companyFk = vSelf
|
||||||
ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
|
ORDER BY supplierFk, companyFk, companyFk, dueDated, isPayment DESC, id;
|
||||||
-- Now, we calculate the outstanding amount for each receipt in descending order
|
-- Now, we calculate the outstanding amount for each receipt in descending order
|
||||||
SET @risk := 0.0;
|
SET @risk := 0.0;
|
||||||
SET @supplier := 0.0;
|
SET @supplier := 0.0;
|
||||||
SET @company := 0.0;
|
SET @company := 0.0;
|
||||||
SET @moneda := 0.0;
|
SET @moneda := 0.0;
|
||||||
SET @pending := 0.0;
|
SET @pending := 0.0;
|
||||||
SET @day := util.VN_CURDATE();
|
SET @day := util.VN_CURDATE();
|
||||||
|
|
||||||
UPDATE tPendingDuedates vp
|
UPDATE tPendingDuedates vp
|
||||||
LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk
|
LEFT JOIN tOpeningBalances si ON vp.companyFk = si.companyFk
|
||||||
AND vp.supplierFk = si.supplierFk
|
AND vp.supplierFk = si.supplierFk
|
||||||
AND vp.currencyFk = si.currencyFk
|
AND vp.currencyFk = si.currencyFk
|
||||||
SET vp.balance = @risk := (
|
SET vp.balance = @risk := (
|
||||||
IF (
|
IF (
|
||||||
@company <> vp.companyFk
|
@company <> vp.companyFk
|
||||||
OR @supplier <> vp.supplierFk
|
OR @supplier <> vp.supplierFk
|
||||||
OR @moneda <> vp.currencyFk,
|
OR @moneda <> vp.currencyFk,
|
||||||
IFNULL(si.openingBalances, 0),
|
IFNULL(si.openingBalances, 0),
|
||||||
@risk
|
@risk
|
||||||
) +
|
) +
|
||||||
vp.amount
|
vp.amount
|
||||||
),
|
),
|
||||||
-- if there is a change of company or supplier or currency, the balance is reset
|
-- if there is a change of company or supplier or currency, the balance is reset
|
||||||
vp.pending = @pending := IF (
|
vp.pending = @pending := IF (
|
||||||
@company <> vp.companyFk
|
@company <> vp.companyFk
|
||||||
OR @supplier <> vp.supplierFk
|
OR @supplier <> vp.supplierFk
|
||||||
OR @moneda <> vp.currencyFk
|
OR @moneda <> vp.currencyFk
|
||||||
OR @day <> vp.dated,
|
OR @day <> vp.dated,
|
||||||
vp.amount * (NOT vp.isPayment),
|
vp.amount * (NOT vp.isPayment),
|
||||||
@pending + vp.amount
|
@pending + vp.amount
|
||||||
),
|
),
|
||||||
vp.companyFk = @company := vp.companyFk,
|
vp.companyFk = @company := vp.companyFk,
|
||||||
vp.supplierFk = @supplier := vp.supplierFk,
|
vp.supplierFk = @supplier := vp.supplierFk,
|
||||||
vp.currencyFk = @moneda := vp.currencyFk,
|
vp.currencyFk = @moneda := vp.currencyFk,
|
||||||
vp.dated = @day := vp.dated,
|
vp.dated = @day := vp.dated,
|
||||||
vp.balance = @risk,
|
vp.balance = @risk,
|
||||||
vp.pending = @pending;
|
vp.pending = @pending;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY
|
CREATE OR REPLACE TEMPORARY TABLE tRowsToDelete ENGINE = MEMORY
|
||||||
SELECT expirationId,
|
SELECT expirationId,
|
||||||
dated,
|
dated,
|
||||||
supplierFk,
|
supplierFk,
|
||||||
companyFk,
|
companyFk,
|
||||||
currencyFk,
|
currencyFk,
|
||||||
balance
|
balance
|
||||||
FROM tPendingDuedates
|
FROM tPendingDuedates
|
||||||
WHERE balance < vInvalidBalances
|
WHERE balance < vInvalidBalances
|
||||||
AND balance > - vInvalidBalances;
|
AND balance > - vInvalidBalances;
|
||||||
|
|
||||||
DELETE vp.*
|
DELETE vp.*
|
||||||
FROM tPendingDuedates vp
|
FROM tPendingDuedates vp
|
||||||
JOIN tRowsToDelete rd ON (
|
JOIN tRowsToDelete rd ON (
|
||||||
vp.dated < rd.dated
|
vp.dated < rd.dated
|
||||||
OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId)
|
OR (vp.dated = rd.dated AND vp.expirationId <= rd.expirationId)
|
||||||
)
|
)
|
||||||
AND vp.supplierFk = rd.supplierFk
|
AND vp.supplierFk = rd.supplierFk
|
||||||
AND vp.companyFk = rd.companyFk
|
AND vp.companyFk = rd.companyFk
|
||||||
AND vp.currencyFk = rd.currencyFk
|
AND vp.currencyFk = rd.currencyFk
|
||||||
WHERE vp.isPayment = FALSE;
|
WHERE NOT vp.isPayment;
|
||||||
|
|
||||||
SELECT vp.expirationId,
|
SELECT vp.expirationId,
|
||||||
vp.dated,
|
vp.dated,
|
||||||
vp.supplierFk,
|
vp.supplierFk,
|
||||||
vp.companyFk,
|
vp.companyFk,
|
||||||
vp.currencyFk,
|
vp.currencyFk,
|
||||||
vp.amount,
|
vp.amount,
|
||||||
|
@ -183,15 +183,19 @@ BEGIN
|
||||||
vp.isPayment,
|
vp.isPayment,
|
||||||
vp.isReconciled,
|
vp.isReconciled,
|
||||||
vp.endingBalance,
|
vp.endingBalance,
|
||||||
cr.amount clientRiskAmount
|
cr.amount clientRiskAmount,
|
||||||
FROM tPendingDuedates vp
|
co.CEE
|
||||||
LEFT JOIN supplier s ON s.id = vp.supplierFk
|
FROM tPendingDuedates vp
|
||||||
LEFT JOIN client c ON c.fi = s.nif
|
LEFT JOIN supplier s ON s.id = vp.supplierFk
|
||||||
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
LEFT JOIN client c ON c.fi = s.nif
|
||||||
AND cr.companyFk = vp.companyFk;
|
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
||||||
|
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
||||||
|
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
|
||||||
|
LEFT JOIN country co ON co.id = be.countryFk
|
||||||
|
AND cr.companyFk = vp.companyFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tOpeningBalances;
|
DROP TEMPORARY TABLE tOpeningBalances;
|
||||||
DROP TEMPORARY TABLE tPendingDuedates;
|
DROP TEMPORARY TABLE tPendingDuedates;
|
||||||
DROP TEMPORARY TABLE tRowsToDelete;
|
DROP TEMPORARY TABLE tRowsToDelete;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`()
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Devuelve el riesgo de los clientes que estan asegurados
|
||||||
|
*/
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.client_list
|
||||||
|
(PRIMARY KEY (Id_Cliente))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT * FROM (
|
||||||
|
SELECT cc.client Id_Cliente, ci.grade
|
||||||
|
FROM creditClassification cc
|
||||||
|
JOIN creditInsurance ci ON cc.id = ci.creditClassification
|
||||||
|
WHERE dateEnd IS NULL
|
||||||
|
ORDER BY ci.creationDate DESC
|
||||||
|
LIMIT 10000000000000000000) t1
|
||||||
|
GROUP BY Id_Cliente;
|
||||||
|
|
||||||
|
CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
c.id,
|
||||||
|
c.name,
|
||||||
|
c.credit clientCredit,
|
||||||
|
c.creditInsurance solunion,
|
||||||
|
CAST(r.risk AS DECIMAL(10,0)) risk,
|
||||||
|
CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive,
|
||||||
|
cac.invoiced billedAnnually,
|
||||||
|
c.dueDay,
|
||||||
|
ci.grade,
|
||||||
|
c2.country
|
||||||
|
FROM tmp.client_list ci
|
||||||
|
LEFT JOIN tmp.risk r ON r.Id_Cliente = ci.Id_Cliente
|
||||||
|
JOIN client c ON c.id = ci.Id_Cliente
|
||||||
|
JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk
|
||||||
|
JOIN country c2 ON c2.id = c.countryFk
|
||||||
|
GROUP BY c.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,31 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`solunionRiskRequest`()
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
|
||||||
CREATE TEMPORARY TABLE tmp.client_list
|
|
||||||
(PRIMARY KEY (Id_Cliente))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc
|
|
||||||
JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification
|
|
||||||
WHERE dateEnd IS NULL
|
|
||||||
ORDER BY ci.creationDate DESC
|
|
||||||
LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente;
|
|
||||||
|
|
||||||
CALL vn2008.risk_vs_client_list(util.VN_CURDATE());
|
|
||||||
|
|
||||||
SELECT
|
|
||||||
c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo,
|
|
||||||
cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo,
|
|
||||||
f.Consumo consumo_anual, c.Vencimiento, ci.grade
|
|
||||||
FROM
|
|
||||||
vn2008.Clientes c
|
|
||||||
JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente
|
|
||||||
JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente
|
|
||||||
JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente
|
|
||||||
GROUP BY Id_cliente;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.risk;
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.client_list;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.entry CHANGE isBlocked isBlocked__ tinyint(4) DEFAULT 0 NOT NULL COMMENT '@deprecated 27/03/2024';
|
|
@ -0,0 +1,10 @@
|
||||||
|
ALTER TABLE vn.specialPrice MODIFY COLUMN clientFk int(11) NULL;
|
||||||
|
ALTER TABLE vn.specialPrice ADD started date NOT NULL DEFAULT '2024-01-01';
|
||||||
|
ALTER TABLE vn.specialPrice ADD ended date NULL;
|
||||||
|
ALTER TABLE vn.specialPrice MODIFY COLUMN itemFk int(11) NOT NULL;
|
||||||
|
ALTER TABLE vn.specialPrice MODIFY COLUMN value DECIMAL(10,2) NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE vn.`specialPrice`
|
||||||
|
ADD CONSTRAINT `check_date_range`
|
||||||
|
CHECK (`ended` IS NULL OR `ended` >= `started`);
|
|
@ -126,20 +126,5 @@
|
||||||
"allowedContentTypes": [
|
"allowedContentTypes": [
|
||||||
"application/x-7z-compressed"
|
"application/x-7z-compressed"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"supplierStorage": {
|
|
||||||
"name": "supplierStorage",
|
|
||||||
"connector": "loopback-component-storage",
|
|
||||||
"provider": "filesystem",
|
|
||||||
"root": "./storage/dms",
|
|
||||||
"maxFileSize": "31457280",
|
|
||||||
"allowedContentTypes": [
|
|
||||||
"image/png",
|
|
||||||
"image/jpeg",
|
|
||||||
"image/jpg",
|
|
||||||
"image/webp",
|
|
||||||
"video/mp4",
|
|
||||||
"application/pdf"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,6 @@
|
||||||
"columnName": "evaNotes"
|
"columnName": "evaNotes"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"isBlocked": {
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"loadPriority": {
|
"loadPriority": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
"SupplierDms": {
|
"SupplierDms": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"SupplierContainer": {
|
|
||||||
"dataSource": "supplierStorage"
|
|
||||||
},
|
|
||||||
"SupplierAddress": {
|
"SupplierAddress": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "24.14.0",
|
"version": "24.16.0",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "Salix backend",
|
"description": "Salix backend",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue