feat: refs #7039 country #2361

Merged
robert merged 18 commits from 7039-country-country into dev 2024-05-14 08:12:14 +00:00
5 changed files with 27 additions and 18 deletions
Showing only changes of commit 1610b9bd0a - Show all commits

View File

@ -131,7 +131,8 @@ BEGIN
DELETE e DELETE e
FROM entry e FROM entry e
JOIN tEntryToDelete tmp ON tmp.id = e.id; JOIN tEntryToDelete tmp ON tmp.id = e.id
WHERE NOT e.isBooked;
-- borrar de route registros menores a 4 años -- borrar de route registros menores a 4 años
CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete

View File

@ -52,6 +52,10 @@ BEGIN
SELECT LAST_INSERT_ID() INTO vSaleFk; SELECT LAST_INSERT_ID() INTO vSaleFk;
UPDATE sale
SET originalQuantity = 0
WHERE id = vSaleFk;
CALL sale_calculateComponent(vSaleFk, NULL); CALL sale_calculateComponent(vSaleFk, NULL);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -21,7 +21,7 @@ BEGIN
SELECT id SELECT id
FROM warehouse FROM warehouse
WHERE isInventory; WHERE isInventory;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
ROLLBACK; ROLLBACK;
@ -38,18 +38,18 @@ BEGIN
INTO vMaxRecentInventories, INTO vMaxRecentInventories,
vWarehouseOutFkInventory, vWarehouseOutFkInventory,
vAgencyModeFkInventory vAgencyModeFkInventory
FROM inventoryConfig FROM inventoryConfig
LIMIT 1; LIMIT 1;
IF vDateLastInventory IS NULL IF vDateLastInventory IS NULL
OR vInventorySupplierFk IS NULL OR vInventorySupplierFk IS NULL
OR vMaxRecentInventories IS NULL OR vMaxRecentInventories IS NULL
OR vInventoryDate IS NULL OR vInventoryDate IS NULL
OR vWarehouseOutFkInventory IS NULL OR vWarehouseOutFkInventory IS NULL
OR vAgencyModeFkInventory IS NULL THEN OR vAgencyModeFkInventory IS NULL THEN
CALL util.throw('Some config parameters are not set'); CALL util.throw('Some config parameters are not set');
END IF; END IF;
START TRANSACTION; START TRANSACTION;
OPEN cWarehouses; OPEN cWarehouses;
@ -77,7 +77,7 @@ BEGIN
LIMIT 1; LIMIT 1;
IF vTravelFk IS NULL THEN IF vTravelFk IS NULL THEN
INSERT INTO travel INSERT INTO travel
SET warehouseOutFk = vWarehouseOutFkInventory, SET warehouseOutFk = vWarehouseOutFkInventory,
warehouseInFk = vWarehouseFk, warehouseInFk = vWarehouseFk,
shipped = vInventoryDate, shipped = vInventoryDate,
@ -94,15 +94,16 @@ BEGIN
SELECT id INTO vEntryFk SELECT id INTO vEntryFk
FROM entry FROM entry
WHERE supplierFk = vInventorySupplierFk WHERE supplierFk = vInventorySupplierFk
AND travelFk = vTravelFk; AND travelFk = vTravelFk
AND typeFk = 'inventory';
IF vEntryFk IS NULL THEN IF vEntryFk IS NULL THEN
INSERT INTO entry INSERT INTO entry
SET supplierFk = vInventorySupplierFk, SET supplierFk = vInventorySupplierFk,
isConfirmed = TRUE, isConfirmed = TRUE,
isOrdered = TRUE, isOrdered = TRUE,
travelFk = vTravelFk; travelFk = vTravelFk,
typeFk = 'inventory';
SELECT LAST_INSERT_ID() INTO vEntryFk; SELECT LAST_INSERT_ID() INTO vEntryFk;
ELSE ELSE
DELETE FROM buy WHERE entryFk = vEntryFk; DELETE FROM buy WHERE entryFk = vEntryFk;
@ -224,15 +225,15 @@ BEGIN
JOIN tInventory i2 ON i2.itemFk = i.id JOIN tInventory i2 ON i2.itemFk = i.id
SET i.lastUsed = NOW() SET i.lastUsed = NOW()
WHERE i2.quantity; WHERE i2.quantity;
DROP TEMPORARY TABLE tInventory; DROP TEMPORARY TABLE tInventory;
END LOOP; END LOOP;
CLOSE cWarehouses; CLOSE cWarehouses;
UPDATE config SET inventoried = vInventoryDate; UPDATE config SET inventoried = vInventoryDate;
CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
(INDEX(entryId)) ENGINE = MEMORY (INDEX(entryId)) ENGINE = MEMORY
SELECT e.id entryId, SELECT e.id entryId,
@ -252,7 +253,7 @@ BEGIN
WHERE e.supplierFk = vInventorySupplierFk WHERE e.supplierFk = vInventorySupplierFk
AND t.shipped IN (sub.shipped); AND t.shipped IN (sub.shipped);
DELETE e DELETE e
FROM `entry` e FROM `entry` e
JOIN tEntryToDelete tmp ON tmp.entryId = e.id; JOIN tEntryToDelete tmp ON tmp.entryId = e.id;

View File

@ -26,7 +26,7 @@ BEGIN
FROM workerTimeControl FROM workerTimeControl
WHERE userFk = vWorkerFk WHERE userFk = vWorkerFk
AND direction = 'middle' AND direction = 'middle'
AND timed BETWEEN vLastIn AND util.VN_NOW(); AND timed BETWEEN vLastIn AND vTimed;
DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection; DROP TEMPORARY TABLE IF EXISTS tmp.workerTimeControlDirection;
CREATE TEMPORARY TABLE tmp.workerTimeControlDirection CREATE TEMPORARY TABLE tmp.workerTimeControlDirection

View File

@ -27,8 +27,11 @@ module.exports = Self => {
const where = filter.where; const where = filter.where;
const query = 'CALL vn.item_getBalance(?, ?, ?)'; const query = 'CALL vn.item_getBalance(?, ?, ?)';
if (where?.date) {
where.date = new Date(where.date);
where.date.setHours(0, 0, 0, 0);
}
const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions); const [diary] = await Self.rawSql(query, [where.itemFk, where.warehouseFk, where.date], myOptions);
for (const entry of diary) for (const entry of diary)
if (entry.clientType === 'loses') entry.highlighted = true; if (entry.clientType === 'loses') entry.highlighted = true;