Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
625922275c
|
@ -1,23 +1,6 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('loopback model MailAliasAccount', () => {
|
describe('loopback model MailAliasAccount', () => {
|
||||||
it('should fail to add a mail Alias if the worker doesnt have ACLs', async() => {
|
|
||||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
|
||||||
let error;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx, accessToken: {userId: 57}};
|
|
||||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
|
||||||
await tx.rollback();
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(error.message).toEqual('The alias cant be modified');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add a mail Alias', async() => {
|
it('should add a mail Alias', async() => {
|
||||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||||
let error;
|
let error;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"lastPull": "2024-02-15T08:58:24.000Z",
|
||||||
|
"shaSums": {}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
DELETE FROM salix.ACL
|
||||||
|
WHERE model = 'MailAliasAccount'
|
||||||
|
AND property = 'canEditAlias'
|
||||||
|
AND principalType = 'ROLE'
|
||||||
|
AND principalId = 'marketingBoss';
|
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(isTx BOOL)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Confirma los cambios asociados a una transacción.
|
||||||
|
*
|
||||||
|
* @param isTx es true si existe transacción asociada
|
||||||
|
*/
|
||||||
|
IF isTx THEN
|
||||||
|
COMMIT;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(isTx BOOL)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Deshace los cambios asociados a una transacción.
|
||||||
|
*
|
||||||
|
* @param isTx es true si existe transacción asociada
|
||||||
|
*/
|
||||||
|
IF isTx THEN
|
||||||
|
ROLLBACK;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,13 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(isTx BOOL)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Inicia una transacción.
|
||||||
|
*
|
||||||
|
* @param isTx es true si existe transacción asociada
|
||||||
|
*/
|
||||||
|
IF isTx THEN
|
||||||
|
START TRANSACTION;
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -4,32 +4,25 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`(
|
||||||
DETERMINISTIC
|
DETERMINISTIC
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
/* Calcula si existe alguna base imponible negativa
|
/**
|
||||||
* Requiere la tabla temporal tmp.ticketToInvoice(id)
|
* Calcula si existe alguna base imponible negativa
|
||||||
|
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
||||||
*
|
*
|
||||||
* returns BOOLEAN
|
* returns BOOLEAN
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE hasAnyNegativeBase BOOLEAN;
|
DECLARE hasAnyNegativeBase BOOLEAN;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
CALL getTaxBases();
|
||||||
CREATE TEMPORARY TABLE tmp.ticket
|
|
||||||
(KEY (ticketFk))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT id ticketFk
|
|
||||||
FROM tmp.ticketToInvoice;
|
|
||||||
|
|
||||||
CALL ticket_getTax(NULL);
|
SELECT negative INTO hasAnyNegativeBase
|
||||||
|
FROM tmp.taxBases
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO hasAnyNegativeBase
|
DROP TEMPORARY TABLE
|
||||||
FROM(
|
tmp.ticketTax,
|
||||||
SELECT SUM(taxableBase) as taxableBase
|
tmp.ticket,
|
||||||
FROM tmp.ticketTax
|
tmp.taxBases;
|
||||||
GROUP BY pgcFk
|
|
||||||
HAVING taxableBase < 0
|
|
||||||
) t;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticketTax;
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket;
|
|
||||||
|
|
||||||
RETURN hasAnyNegativeBase;
|
RETURN hasAnyNegativeBase;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`()
|
||||||
|
RETURNS tinyint(1)
|
||||||
|
DETERMINISTIC
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calcula si existe alguna base imponible positiva
|
||||||
|
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
||||||
|
*
|
||||||
|
* returns BOOLEAN
|
||||||
|
*/
|
||||||
|
|
||||||
|
DECLARE hasAnyPositiveBase BOOLEAN;
|
||||||
|
|
||||||
|
CALL getTaxBases();
|
||||||
|
|
||||||
|
SELECT positive INTO hasAnyPositiveBase
|
||||||
|
FROM tmp.taxBases
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE
|
||||||
|
tmp.ticketTax,
|
||||||
|
tmp.ticket,
|
||||||
|
tmp.taxBases;
|
||||||
|
|
||||||
|
RETURN hasAnyPositiveBase;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -9,6 +9,7 @@ BEGIN
|
||||||
DECLARE v26Month DATE;
|
DECLARE v26Month DATE;
|
||||||
DECLARE v3Month DATE;
|
DECLARE v3Month DATE;
|
||||||
DECLARE vTrashId VARCHAR(15);
|
DECLARE vTrashId VARCHAR(15);
|
||||||
|
DECLARE v2Years DATE;
|
||||||
DECLARE v5Years DATE;
|
DECLARE v5Years DATE;
|
||||||
|
|
||||||
SET vDateShort = util.VN_CURDATE() - INTERVAL 2 MONTH;
|
SET vDateShort = util.VN_CURDATE() - INTERVAL 2 MONTH;
|
||||||
|
@ -18,6 +19,7 @@ BEGIN
|
||||||
SET v18Month = util.VN_CURDATE() - INTERVAL 18 MONTH;
|
SET v18Month = util.VN_CURDATE() - INTERVAL 18 MONTH;
|
||||||
SET v26Month = util.VN_CURDATE() - INTERVAL 26 MONTH;
|
SET v26Month = util.VN_CURDATE() - INTERVAL 26 MONTH;
|
||||||
SET v3Month = util.VN_CURDATE() - INTERVAL 3 MONTH;
|
SET v3Month = util.VN_CURDATE() - INTERVAL 3 MONTH;
|
||||||
|
SET v2Years = util.VN_CURDATE() - INTERVAL 2 YEAR;
|
||||||
SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR;
|
SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR;
|
||||||
|
|
||||||
DELETE FROM ticketParking WHERE created < vDateShort;
|
DELETE FROM ticketParking WHERE created < vDateShort;
|
||||||
|
@ -163,7 +165,11 @@ BEGIN
|
||||||
FROM tmp.duaToDelete tmp
|
FROM tmp.duaToDelete tmp
|
||||||
JOIN vn.dua d ON d.id = tmp.id;
|
JOIN vn.dua d ON d.id = tmp.id;
|
||||||
|
|
||||||
DELETE FROM vn.awb WHERE created < TIMESTAMPADD(YEAR,-2,util.VN_CURDATE());
|
DELETE a
|
||||||
|
FROM vn.awb a
|
||||||
|
LEFT JOIN vn.travel t ON t.awbFk = a.id
|
||||||
|
WHERE a.created < v2Years
|
||||||
|
AND t.id IS NULL;
|
||||||
|
|
||||||
-- Borra los registros de collection y ticketcollection
|
-- Borra los registros de collection y ticketcollection
|
||||||
DELETE FROM vn.collection WHERE created < vDateShort;
|
DELETE FROM vn.collection WHERE created < vDateShort;
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`(vDuaFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`(vDuaFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Genera el asiento de un DUA y marca las entradas como confirmadas
|
||||||
|
*
|
||||||
|
* @param vDuaFk Id del dua a recalcular
|
||||||
|
*/
|
||||||
DECLARE done BOOL DEFAULT FALSE;
|
DECLARE done BOOL DEFAULT FALSE;
|
||||||
DECLARE vInvoiceFk INT;
|
DECLARE vInvoiceFk INT;
|
||||||
DECLARE vASIEN BIGINT DEFAULT 0;
|
DECLARE vASIEN BIGINT DEFAULT 0;
|
||||||
DECLARE vCounter INT DEFAULT 0;
|
DECLARE vCounter INT DEFAULT 0;
|
||||||
|
|
||||||
DECLARE rs CURSOR FOR
|
DECLARE rs CURSOR FOR
|
||||||
SELECT e.invoiceInFk
|
SELECT DISTINCT e.invoiceInFk
|
||||||
FROM entry e
|
FROM entry e
|
||||||
JOIN duaEntry de ON de.entryFk = e.id
|
JOIN duaEntry de ON de.entryFk = e.id
|
||||||
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
|
JOIN invoiceIn ii ON ii.id = e.invoiceInFk
|
||||||
|
@ -44,13 +48,13 @@ BEGIN
|
||||||
|
|
||||||
IF vCounter > 0 OR vASIEN > 0 THEN
|
IF vCounter > 0 OR vASIEN > 0 THEN
|
||||||
|
|
||||||
UPDATE vn.XDiario x
|
UPDATE vn2008.XDiario x
|
||||||
JOIN vn.ledgerConfig lc ON lc.lastBookEntry = x.ASIEN
|
JOIN ledgerConfig lc ON lc.lastBookEntry = x.ASIEN
|
||||||
SET x.ASIEN = vASIEN;
|
SET x.ASIEN = vASIEN;
|
||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
|
|
||||||
SELECT lastBookEntry INTO vASIEN FROM vn.ledgerConfig;
|
SELECT lastBookEntry INTO vASIEN FROM ledgerConfig;
|
||||||
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`getTaxBases`()
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Calcula y devuelve en número de bases imponibles postivas y negativas
|
||||||
|
* Requiere la tabla temporal tmp.ticketToInvoice(id)
|
||||||
|
*
|
||||||
|
* returns tmp.taxBases
|
||||||
|
*/
|
||||||
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
|
(KEY (ticketFk))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT id ticketFk
|
||||||
|
FROM tmp.ticketToInvoice;
|
||||||
|
|
||||||
|
CALL ticket_getTax(NULL);
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.taxBases;
|
||||||
|
CREATE TEMPORARY TABLE tmp.taxBases
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT
|
||||||
|
SUM(taxableBase > 0) as positive,
|
||||||
|
SUM(taxableBase < 0) as negative
|
||||||
|
FROM(
|
||||||
|
SELECT SUM(taxableBase) taxableBase
|
||||||
|
FROM tmp.ticketTax
|
||||||
|
GROUP BY pgcFk
|
||||||
|
) t;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,120 +1,115 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMake`(vDate DATE, vWh INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMake`(vInventoryDate DATE)
|
||||||
proc: BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Recalcula los inventarios de todos los almacenes, si vWh = 0
|
* Recalculate the inventories
|
||||||
*
|
*
|
||||||
* @param vDate Fecha de los nuevos inventarios
|
* @param vInventoryDate date for the new inventory
|
||||||
* @param vWh almacen al cual hacer el inventario
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vEntryFk INT;
|
DECLARE vEntryFk INT;
|
||||||
DECLARE vTravelFk INT;
|
DECLARE vTravelFk INT;
|
||||||
DECLARE vDateLastInventory DATE;
|
DECLARE vDateLastInventory DATE;
|
||||||
DECLARE vDateYesterday DATETIME DEFAULT vDate - INTERVAL 1 SECOND;
|
DECLARE vDateYesterday DATETIME DEFAULT vInventoryDate - INTERVAL 1 SECOND;
|
||||||
DECLARE vWarehouseOutFkInventory INT;
|
DECLARE vWarehouseOutFkInventory INT;
|
||||||
DECLARE vInventorySupplierFk INT;
|
DECLARE vInventorySupplierFk INT;
|
||||||
DECLARE vAgencyModeFkInventory INT;
|
DECLARE vAgencyModeFkInventory INT;
|
||||||
|
DECLARE vMaxRecentInventories INT;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
|
||||||
DECLARE cWarehouses CURSOR FOR
|
DECLARE cWarehouses CURSOR FOR
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM warehouse
|
FROM warehouse
|
||||||
WHERE isInventory
|
WHERE isInventory;
|
||||||
AND vWh IN (0,id);
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SELECT inventorySupplierFk INTO vInventorySupplierFk FROM entryConfig LIMIT 1;
|
||||||
|
SELECT inventoried INTO vDateLastInventory FROM config LIMIT 1;
|
||||||
|
SELECT maxRecentInventories,
|
||||||
|
warehouseOutFk,
|
||||||
|
agencyModeFk
|
||||||
|
INTO vMaxRecentInventories,
|
||||||
|
vWarehouseOutFkInventory,
|
||||||
|
vAgencyModeFkInventory
|
||||||
|
FROM inventoryConfig
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF vDateLastInventory IS NULL
|
||||||
|
OR vInventorySupplierFk IS NULL
|
||||||
|
OR vMaxRecentInventories IS NULL
|
||||||
|
OR vInventoryDate IS NULL
|
||||||
|
OR vWarehouseOutFkInventory IS NULL
|
||||||
|
OR vAgencyModeFkInventory IS NULL THEN
|
||||||
|
CALL util.throw('Some config parameters are not set');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
OPEN cWarehouses;
|
OPEN cWarehouses;
|
||||||
|
-- Environment variable to disable the triggers of the affected tables
|
||||||
SET @isModeInventory := TRUE;
|
SET @isModeInventory := TRUE;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
|
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH cWarehouses INTO vWh;
|
SET vEntryFk = NULL;
|
||||||
|
SET vTravelFk = NULL;
|
||||||
|
|
||||||
|
FETCH cWarehouses INTO vWarehouseFk;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT w.id INTO vWarehouseOutFkInventory
|
-- Generate travel, if it does not exist
|
||||||
FROM warehouse w
|
|
||||||
WHERE w.code = 'inv';
|
|
||||||
|
|
||||||
SELECT inventorySupplierFk INTO vInventorySupplierFk
|
|
||||||
FROM entryConfig;
|
|
||||||
|
|
||||||
SELECT am.id INTO vAgencyModeFkInventory
|
|
||||||
FROM agencyMode am
|
|
||||||
where code = 'inv';
|
|
||||||
|
|
||||||
SELECT MAX(landed) INTO vDateLastInventory
|
|
||||||
FROM travel tr
|
|
||||||
JOIN entry e ON e.travelFk = tr.id
|
|
||||||
JOIN buy b ON b.entryFk = e.id
|
|
||||||
WHERE warehouseOutFk = vWarehouseOutFkInventory
|
|
||||||
AND landed < vDate
|
|
||||||
AND e.supplierFk = vInventorySupplierFk
|
|
||||||
AND warehouseInFk = vWh
|
|
||||||
AND NOT isRaid;
|
|
||||||
|
|
||||||
IF vDateLastInventory IS NULL THEN
|
|
||||||
SELECT inventoried INTO vDateLastInventory FROM config;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Generamos travel, si no existe.
|
|
||||||
SET vTravelFK = 0;
|
|
||||||
|
|
||||||
SELECT id INTO vTravelFk
|
SELECT id INTO vTravelFk
|
||||||
FROM travel
|
FROM travel
|
||||||
WHERE warehouseOutFk = vWarehouseOutFkInventory
|
WHERE warehouseOutFk = vWarehouseOutFkInventory
|
||||||
AND warehouseInFk = vWh
|
AND warehouseInFk = vWarehouseFk
|
||||||
AND landed = vDate
|
AND landed = vInventoryDate
|
||||||
AND agencyModeFk = vAgencyModeFkInventory
|
AND agencyModeFk = vAgencyModeFkInventory
|
||||||
AND ref = 'inventario'
|
AND ref = 'inventario'
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
IF NOT vTravelFK THEN
|
IF vTravelFk IS NULL THEN
|
||||||
|
INSERT INTO travel
|
||||||
INSERT INTO travel SET
|
SET warehouseOutFk = vWarehouseOutFkInventory,
|
||||||
warehouseOutFk = vWarehouseOutFkInventory,
|
warehouseInFk = vWarehouseFk,
|
||||||
warehouseInFk = vWh,
|
shipped = vInventoryDate,
|
||||||
shipped = vDate,
|
landed = vInventoryDate,
|
||||||
landed = vDate,
|
|
||||||
agencyModeFk = vAgencyModeFkInventory,
|
agencyModeFk = vAgencyModeFkInventory,
|
||||||
ref = 'inventario',
|
ref = 'inventario',
|
||||||
isDelivered = TRUE,
|
isDelivered = TRUE,
|
||||||
isReceived = TRUE;
|
isReceived = TRUE;
|
||||||
|
|
||||||
SELECT LAST_INSERT_ID() INTO vTravelFk;
|
SELECT LAST_INSERT_ID() INTO vTravelFk;
|
||||||
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Generamos entrada si no existe, o la vaciamos.
|
-- Generate an entry if it does not exist, or we empty it
|
||||||
SET vEntryFk = 0;
|
|
||||||
|
|
||||||
SELECT id INTO vEntryFk
|
SELECT id INTO vEntryFk
|
||||||
FROM entry
|
FROM entry
|
||||||
WHERE supplierFk = vInventorySupplierFk
|
WHERE supplierFk = vInventorySupplierFk
|
||||||
AND travelFk = vTravelFk;
|
AND travelFk = vTravelFk;
|
||||||
|
|
||||||
IF NOT vEntryFk THEN
|
IF vEntryFk IS NULL THEN
|
||||||
|
INSERT INTO entry
|
||||||
INSERT INTO entry SET
|
SET supplierFk = vInventorySupplierFk,
|
||||||
supplierFk = vInventorySupplierFk,
|
|
||||||
isConfirmed = TRUE,
|
isConfirmed = TRUE,
|
||||||
isOrdered = TRUE,
|
isOrdered = TRUE,
|
||||||
travelFk = vTravelFk;
|
travelFk = vTravelFk;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Preparamos tabla auxilar
|
-- Prepare the auxiliary table
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.inventory (
|
CREATE OR REPLACE TEMPORARY TABLE tInventory (
|
||||||
itemFk INT(11) NOT NULL PRIMARY KEY,
|
itemFk INT(11) NOT NULL PRIMARY KEY,
|
||||||
quantity int(11) DEFAULT '0',
|
quantity int(11) DEFAULT '0',
|
||||||
buyingValue decimal(10,4) DEFAULT '0.0000',
|
buyingValue decimal(10,4) DEFAULT '0.0000',
|
||||||
|
@ -130,53 +125,51 @@ proc: BEGIN
|
||||||
price3 decimal(10,2) DEFAULT '0.00',
|
price3 decimal(10,2) DEFAULT '0.00',
|
||||||
minPrice decimal(10,2) DEFAULT '0.00',
|
minPrice decimal(10,2) DEFAULT '0.00',
|
||||||
producer varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
|
producer varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
|
||||||
INDEX (itemFK)) ENGINE = MEMORY;
|
INDEX (itemFK)
|
||||||
|
) ENGINE = MEMORY;
|
||||||
|
|
||||||
-- Compras
|
-- Buys
|
||||||
INSERT INTO tmp.inventory(itemFk,quantity)
|
INSERT INTO tInventory(itemFk, quantity)
|
||||||
SELECT b.itemFk, SUM(b.quantity)
|
SELECT b.itemFk, SUM(b.quantity)
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.warehouseInFk = vWh
|
WHERE tr.warehouseInFk = vWarehouseFk
|
||||||
AND tr.landed BETWEEN vDateLastInventory
|
AND tr.landed BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
AND vDateYesterday
|
|
||||||
AND NOT isRaid
|
AND NOT isRaid
|
||||||
GROUP BY b.itemFk;
|
GROUP BY b.itemFk;
|
||||||
SELECT vDateLastInventory , vDateYesterday;
|
|
||||||
|
|
||||||
-- Traslados
|
-- Transfers
|
||||||
INSERT INTO tmp.inventory(itemFk, quantity)
|
INSERT INTO tInventory(itemFk, quantity)
|
||||||
SELECT itemFk, quantityOut
|
SELECT itemFk, quantityOut
|
||||||
FROM (
|
FROM (
|
||||||
SELECT b.itemFk,- SUM(b.quantity) quantityOut
|
SELECT b.itemFk,- SUM(b.quantity) quantityOut
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
JOIN travel tr ON tr.id = e.travelFk
|
||||||
WHERE tr.warehouseOutFk = vWh
|
WHERE tr.warehouseOutFk = vWarehouseFk
|
||||||
AND tr.shipped BETWEEN vDateLastInventory
|
AND tr.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
AND vDateYesterday
|
|
||||||
AND NOT isRaid
|
AND NOT isRaid
|
||||||
GROUP BY b.itemFk
|
GROUP BY b.itemFk
|
||||||
) sub
|
) sub
|
||||||
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity, 0) + sub.quantityOut;
|
||||||
|
|
||||||
-- Ventas
|
-- Sales
|
||||||
INSERT INTO tmp.inventory(itemFk,quantity)
|
INSERT INTO tInventory(itemFk, quantity)
|
||||||
SELECT itemFk, saleOut
|
SELECT itemFk, saleOut
|
||||||
FROM (
|
FROM (
|
||||||
SELECT s.itemFk, - SUM(s.quantity) saleOut
|
SELECT s.itemFk, - SUM(s.quantity) saleOut
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
WHERE t.warehouseFk = vWh
|
WHERE t.warehouseFk = vWarehouseFk
|
||||||
AND t.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
AND t.shipped BETWEEN vDateLastInventory AND vDateYesterday
|
||||||
GROUP BY s.itemFk
|
GROUP BY s.itemFk
|
||||||
) sub
|
) sub
|
||||||
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.saleOut;
|
ON DUPLICATE KEY UPDATE quantity = IFNULL(quantity,0) + sub.saleOut;
|
||||||
|
|
||||||
-- Actualiza valores de la ultima compra
|
-- Update values of the last purchase
|
||||||
UPDATE tmp.inventory inv
|
UPDATE tInventory inv
|
||||||
JOIN cache.last_buy lb ON lb.item_id = inv.itemFk AND lb.warehouse_id = vWh
|
JOIN cache.last_buy lb ON lb.item_id = inv.itemFk AND lb.warehouse_id = vWarehouseFk
|
||||||
JOIN buy b ON b.id = lb.buy_id
|
JOIN buy b ON b.id = lb.buy_id
|
||||||
JOIN item i ON i.id = b.itemFk
|
JOIN item i ON i.id = b.itemFk
|
||||||
LEFT JOIN producer p ON p.id = i.producerFk
|
LEFT JOIN producer p ON p.id = i.producerFk
|
||||||
|
@ -224,42 +217,53 @@ proc: BEGIN
|
||||||
price3,
|
price3,
|
||||||
minPrice,
|
minPrice,
|
||||||
vEntryFk
|
vEntryFk
|
||||||
FROM tmp.inventory;
|
FROM tInventory;
|
||||||
|
|
||||||
SELECT vWh, COUNT(*), util.VN_NOW() FROM tmp.inventory;
|
-- Update the 'lastUsed' field of the item
|
||||||
|
|
||||||
-- Actualizamos el campo lastUsed de item
|
|
||||||
UPDATE item i
|
UPDATE item i
|
||||||
JOIN tmp.inventory 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 tmp.inventory;
|
DROP TEMPORARY TABLE tInventory;
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE cWarehouses;
|
CLOSE cWarehouses;
|
||||||
|
|
||||||
UPDATE config SET inventoried = vDate;
|
UPDATE config SET inventoried = vInventoryDate;
|
||||||
|
|
||||||
SET @isModeInventory := FALSE;
|
SET @isModeInventory := FALSE;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.entryToDelete;
|
CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
|
||||||
CREATE TEMPORARY TABLE tmp.entryToDelete
|
(INDEX(entryId)) ENGINE = MEMORY
|
||||||
(INDEX(entryId) USING BTREE) ENGINE = MEMORY
|
SELECT e.id entryId,
|
||||||
SELECT e.id as entryId,
|
t.id travelId
|
||||||
t.id as travelId
|
FROM travel t
|
||||||
|
JOIN `entry` e ON e.travelFk = t.id
|
||||||
|
JOIN (
|
||||||
|
SELECT t.shipped
|
||||||
FROM travel t
|
FROM travel t
|
||||||
JOIN `entry` e ON e.travelFk = t.id
|
JOIN `entry` e ON e.travelFk = t.id
|
||||||
WHERE e.supplierFk = vInventorySupplierFk
|
WHERE e.supplierFk = vInventorySupplierFk
|
||||||
AND t.shipped <= util.VN_CURDATE() - INTERVAL 12 DAY
|
AND t.shipped <= vInventoryDate
|
||||||
AND (DAY(t.shipped) <> 1 OR shipped < util.VN_CURDATE() - INTERVAL 12 DAY);
|
GROUP BY t.shipped
|
||||||
|
ORDER BY t.shipped DESC
|
||||||
|
OFFSET vMaxRecentInventories ROWS
|
||||||
|
) sub
|
||||||
|
WHERE e.supplierFk = vInventorySupplierFk
|
||||||
|
AND t.shipped IN (sub.shipped);
|
||||||
|
|
||||||
DELETE e
|
DELETE e
|
||||||
FROM `entry` e
|
FROM `entry` e
|
||||||
JOIN tmp.entryToDelete tmp ON tmp.entryId = e.id;
|
JOIN tEntryToDelete tmp ON tmp.entryId = e.id;
|
||||||
|
|
||||||
DELETE IGNORE t
|
DELETE IGNORE t
|
||||||
FROM travel t
|
FROM travel t
|
||||||
JOIN tmp.entryToDelete tmp ON tmp.travelId = t.id;
|
JOIN tEntryToDelete tmp ON tmp.travelId = t.id;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tEntryToDelete;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -2,10 +2,11 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMakeLauncher`()
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`inventoryMakeLauncher`()
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Recalcula los inventarios de todos los almacenes.
|
* Recalculate the inventories of all warehouses
|
||||||
*/
|
*/
|
||||||
|
CALL inventoryMake(
|
||||||
call vn.inventoryMake(TIMESTAMPADD(DAY, -10, util.VN_CURDATE()), 0);
|
util.VN_CURDATE() -
|
||||||
|
INTERVAL (SELECT daysInPastForInventory FROM inventoryConfig LIMIT 1) DAY
|
||||||
|
);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,32 +1,35 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(vDuaFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTaxMakeByDua`(vDuaFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
DECLARE done BOOL DEFAULT FALSE;
|
* Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry
|
||||||
|
*
|
||||||
|
* @param vDuaFk Id del dua a recalcular
|
||||||
|
*/
|
||||||
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vInvoiceInFk INT;
|
DECLARE vInvoiceInFk INT;
|
||||||
|
|
||||||
DECLARE rs CURSOR FOR
|
DECLARE vInvoices CURSOR FOR
|
||||||
SELECT invoiceInFk
|
SELECT DISTINCT invoiceInFk
|
||||||
FROM entry e
|
FROM entry e
|
||||||
JOIN duaEntry de ON de.entryFk = e.id
|
JOIN duaEntry de ON de.entryFk = e.id
|
||||||
WHERE de.duaFk = vDuaFk;
|
WHERE de.duaFk = vDuaFk;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
OPEN rs;
|
OPEN vInvoices;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vInvoices INTO vInvoiceInFk;
|
||||||
|
|
||||||
FETCH rs INTO vInvoiceInFk;
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
WHILE NOT done DO
|
END IF;
|
||||||
|
|
||||||
CALL vn2008.recibidaIvaInsert(vInvoiceInFk);
|
CALL vn2008.recibidaIvaInsert(vInvoiceInFk);
|
||||||
CALL invoiceInDueDay_recalc(vInvoiceInFk);
|
CALL invoiceInDueDay_recalc(vInvoiceInFk);
|
||||||
|
|
||||||
FETCH rs INTO vInvoiceInFk;
|
END LOOP;
|
||||||
|
CLOSE vInvoices;
|
||||||
END WHILE;
|
|
||||||
|
|
||||||
CLOSE rs;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,32 +1,35 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromDua`(vDuaFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromDua`(vDuaFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
DECLARE done BOOL DEFAULT FALSE;
|
* Borra los valores de duaTax y sus vctos. y los vuelve a crear en base a la tabla duaEntry
|
||||||
|
*
|
||||||
|
* @param vDuaFk Id del dua a recalcular
|
||||||
|
*/
|
||||||
|
DECLARE vDone BOOL DEFAULT FALSE;
|
||||||
DECLARE vInvoiceInFk INT;
|
DECLARE vInvoiceInFk INT;
|
||||||
|
|
||||||
DECLARE rs CURSOR FOR
|
DECLARE vInvoices CURSOR FOR
|
||||||
SELECT invoiceInFk
|
SELECT DISTINCT invoiceInFk
|
||||||
FROM entry e
|
FROM entry e
|
||||||
JOIN duaEntry de ON de.entryFk = e.id
|
JOIN duaEntry de ON de.entryFk = e.id
|
||||||
WHERE de.duaFk = vDuaFk;
|
WHERE de.duaFk = vDuaFk;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
OPEN rs;
|
OPEN vInvoices;
|
||||||
|
l: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
FETCH vInvoices INTO vInvoiceInFk;
|
||||||
|
|
||||||
FETCH rs INTO vInvoiceInFk;
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
WHILE NOT done DO
|
END IF;
|
||||||
|
|
||||||
CALL invoiceInTax_getFromEntries(vInvoiceInFk);
|
CALL invoiceInTax_getFromEntries(vInvoiceInFk);
|
||||||
CALL invoiceInDueDay_calculate(vInvoiceInFk);
|
CALL invoiceInDueDay_calculate(vInvoiceInFk);
|
||||||
|
|
||||||
FETCH rs INTO vInvoiceInFk;
|
END LOOP;
|
||||||
|
CLOSE vInvoices;
|
||||||
END WHILE;
|
|
||||||
|
|
||||||
CLOSE rs;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(IN vId INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_getFromEntries`(IN vInvoiceInFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vRate DOUBLE DEFAULT 1;
|
DECLARE vRate DOUBLE DEFAULT 1;
|
||||||
DECLARE vDated DATE;
|
DECLARE vDated DATE;
|
||||||
DECLARE vExpenseFk VARCHAR(10);
|
DECLARE vExpenseFk VARCHAR(10);
|
||||||
|
DECLARE vIsBooked BOOLEAN DEFAULT FALSE;
|
||||||
|
|
||||||
|
SELECT isBooked INTO vIsBooked
|
||||||
|
FROM invoiceIn ii
|
||||||
|
WHERE id = vInvoiceInFk;
|
||||||
|
|
||||||
|
IF vIsBooked THEN
|
||||||
|
CALL util.throw('A booked invoice cannot be modified');
|
||||||
|
END IF;
|
||||||
|
|
||||||
SELECT MAX(rr.dated) INTO vDated
|
SELECT MAX(rr.dated) INTO vDated
|
||||||
FROM referenceRate rr
|
FROM referenceRate rr
|
||||||
JOIN invoiceIn ii ON ii.id = vId
|
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
|
||||||
WHERE rr.dated <= ii.issued
|
WHERE rr.dated <= ii.issued
|
||||||
AND rr.currencyFk = ii.currencyFk ;
|
AND rr.currencyFk = ii.currencyFk ;
|
||||||
|
|
||||||
|
@ -24,7 +33,7 @@ BEGIN
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
DELETE FROM invoiceInTax
|
DELETE FROM invoiceInTax
|
||||||
WHERE invoiceInFk = vId;
|
WHERE invoiceInFk = vInvoiceInFk;
|
||||||
|
|
||||||
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk)
|
INSERT INTO invoiceInTax(invoiceInFk, taxableBase, expenseFk, foreignValue, taxTypeSageFk, transactionTypeSageFk)
|
||||||
SELECT ii.id,
|
SELECT ii.id,
|
||||||
|
@ -39,7 +48,7 @@ BEGIN
|
||||||
JOIN buy b ON b.entryFk = e.id
|
JOIN buy b ON b.entryFk = e.id
|
||||||
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
|
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
|
||||||
AND rr.dated = ii.issued
|
AND rr.dated = ii.issued
|
||||||
WHERE ii.id = vId
|
WHERE ii.id = vInvoiceInFk
|
||||||
HAVING taxableBase IS NOT NULL;
|
HAVING taxableBase IS NOT NULL;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -20,20 +20,23 @@ BEGIN
|
||||||
DECLARE vCompanyFk INT;
|
DECLARE vCompanyFk INT;
|
||||||
DECLARE vAgencyModeFk INT;
|
DECLARE vAgencyModeFk INT;
|
||||||
DECLARE vItemShelvingFk INT;
|
DECLARE vItemShelvingFk INT;
|
||||||
|
DECLARE vAddressFk INT;
|
||||||
|
|
||||||
SELECT c.id,
|
SELECT c.id,
|
||||||
pc.clientSelfConsumptionFk,
|
pc.clientSelfConsumptionFk,
|
||||||
s.warehouseFk
|
s.warehouseFk,
|
||||||
|
pc.addressSelfConsumptionFk
|
||||||
INTO vCompanyFk,
|
INTO vCompanyFk,
|
||||||
vClientFk,
|
vClientFk,
|
||||||
vWarehouseFk
|
vWarehouseFk,
|
||||||
|
vAddressFk
|
||||||
FROM company c
|
FROM company c
|
||||||
JOIN address a ON a.clientFk = c.clientFk
|
JOIN address a ON a.clientFk = c.clientFk
|
||||||
JOIN warehouse w ON w.addressFk = a.id
|
JOIN warehouse w ON w.addressFk = a.id
|
||||||
JOIN sector s ON s.warehouseFk = w.id
|
JOIN sector s ON s.warehouseFk = w.id
|
||||||
JOIN parking p ON p.sectorFk = s.id
|
JOIN parking p ON p.sectorFk = s.id
|
||||||
JOIN shelving s2 ON s2.parkingFk = p.id
|
JOIN shelving s2 ON s2.parkingFk = p.id
|
||||||
JOIN productionConfig pc ON TRUE
|
JOIN productionConfig pc
|
||||||
WHERE s2.code = vShelvingFk;
|
WHERE s2.code = vShelvingFk;
|
||||||
|
|
||||||
IF vClientFk IS NULL THEN
|
IF vClientFk IS NULL THEN
|
||||||
|
@ -65,7 +68,7 @@ BEGIN
|
||||||
vClientFk,
|
vClientFk,
|
||||||
vWarehouseFk,
|
vWarehouseFk,
|
||||||
CURDATE(),
|
CURDATE(),
|
||||||
NULL,
|
vAddressFk,
|
||||||
vCompanyFk,
|
vCompanyFk,
|
||||||
NULL,
|
NULL,
|
||||||
vTicketFk
|
vTicketFk
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`test`()
|
|
||||||
BEGIN
|
|
||||||
select 'procedimiento ejecutado con éxito';
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,24 +1,33 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getMovable`(vTicketFk INT, vDatedNew DATETIME, vWarehouseFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getMovable`(
|
||||||
|
vTicketFk INT,
|
||||||
|
vNewShipped DATETIME,
|
||||||
|
vWarehouseFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Cálcula el stock movible para los artículos de un ticket
|
* Cálcula el stock movible para los artículos de un ticket
|
||||||
* vDatedNew debe ser menor que vDatedOld, en los otros casos se
|
* vNewShipped debe ser menor que vOldShipped, en los otros casos se
|
||||||
* asume que siempre es posible
|
* asume que siempre es posible
|
||||||
*
|
*
|
||||||
* @param vTicketFk -> Ticket
|
* @param vTicketFk -> Ticket
|
||||||
* @param vDatedNew -> Nueva fecha
|
* @param vNewShipped -> Nueva fecha
|
||||||
* @return Sales con Movible
|
* @return Sales con Movible
|
||||||
*/
|
*/
|
||||||
DECLARE vDatedOld DATETIME;
|
DECLARE vOldShipped DATETIME;
|
||||||
SET vDatedNew = DATE_ADD(vDatedNew, INTERVAL 1 DAY);
|
|
||||||
|
|
||||||
SELECT t.shipped INTO vDatedOld
|
SELECT t.shipped INTO vOldShipped
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
WHERE t.id = vTicketFk;
|
WHERE t.id = vTicketFk;
|
||||||
|
|
||||||
CALL item_getStock(vWarehouseFk, vDatedNew, NULL);
|
-- Añadimos un dia más para calcular el stock hasta vNewShipped inclusive
|
||||||
CALL item_getMinacum(vWarehouseFk, vDatedNew, DATEDIFF(DATE_SUB(vDatedOld, INTERVAL 1 DAY), vDatedNew), NULL);
|
CALL item_getStock(vWarehouseFk, DATE_ADD(vNewShipped, INTERVAL 1 DAY), NULL);
|
||||||
|
CALL item_getMinacum(
|
||||||
|
vWarehouseFk,
|
||||||
|
vNewShipped,
|
||||||
|
DATEDIFF(DATE_SUB(vOldShipped, INTERVAL 1 DAY), vNewShipped),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.itemFk,
|
s.itemFk,
|
||||||
|
@ -33,12 +42,14 @@ BEGIN
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
LEFT JOIN tmp.itemMinacum im ON im.itemFk = s.itemFk AND im.warehouseFk = vWarehouseFk
|
LEFT JOIN tmp.itemMinacum im ON im.itemFk = s.itemFk
|
||||||
|
AND im.warehouseFk = vWarehouseFk
|
||||||
LEFT JOIN tmp.itemList il ON il.itemFk = s.itemFk
|
LEFT JOIN tmp.itemList il ON il.itemFk = s.itemFk
|
||||||
WHERE t.id = vTicketFk;
|
WHERE t.id = vTicketFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemList;
|
DROP TEMPORARY TABLE IF EXISTS
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum;
|
tmp.itemList,
|
||||||
|
tmp.itemMinacum;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -11,11 +11,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_cloneWithEnt
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Clona un travel junto con sus entradas y compras
|
* Clona un travel junto con sus entradas y compras
|
||||||
*
|
|
||||||
* @param vTravelFk travel plantilla a clonar
|
* @param vTravelFk travel plantilla a clonar
|
||||||
* @param vDateStart fecha del shipment del nuevo travel
|
* @param vDateStart fecha del shipment del nuevo travel
|
||||||
* @param vDateEnd fecha del landing del nuevo travel
|
* @param vDateEnd fecha del landing del nuevo travel
|
||||||
* @param vWarehouseOutFk fecha del salida del nuevo travel
|
* @param vWarehouseOutFk warehouse del salida del nuevo travel
|
||||||
* @param vWarehouseInFk warehouse de landing del nuevo travel
|
* @param vWarehouseInFk warehouse de landing del nuevo travel
|
||||||
* @param vRef referencia del nuevo travel
|
* @param vRef referencia del nuevo travel
|
||||||
* @param vAgencyModeFk del nuevo travel
|
* @param vAgencyModeFk del nuevo travel
|
||||||
|
@ -25,6 +24,7 @@ BEGIN
|
||||||
DECLARE vEvaNotes VARCHAR(255);
|
DECLARE vEvaNotes VARCHAR(255);
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vAuxEntryFk INT;
|
DECLARE vAuxEntryFk INT;
|
||||||
|
DECLARE vTx BOOLEAN DEFAULT @@in_transaction;
|
||||||
DECLARE vRsEntry CURSOR FOR
|
DECLARE vRsEntry CURSOR FOR
|
||||||
SELECT e.id
|
SELECT e.id
|
||||||
FROM entry e
|
FROM entry e
|
||||||
|
@ -35,11 +35,11 @@ BEGIN
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
CALL util.tx_rollback(vTx);
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
START TRANSACTION;
|
CALL util.tx_start(vTx);
|
||||||
|
|
||||||
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
|
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
|
||||||
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
|
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
|
||||||
|
@ -76,6 +76,6 @@ BEGIN
|
||||||
SET @isModeInventory = FALSE;
|
SET @isModeInventory = FALSE;
|
||||||
CLOSE vRsEntry;
|
CLOSE vRsEntry;
|
||||||
|
|
||||||
COMMIT;
|
CALL util.tx_commit(vTx);
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -28,4 +28,4 @@ FROM (
|
||||||
JOIN `vn`.`volumeConfig` `vc`
|
JOIN `vn`.`volumeConfig` `vc`
|
||||||
)
|
)
|
||||||
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1)
|
WHERE `t`.`shipped` > makedate(year(`util`.`VN_CURDATE`()) - 1, 1)
|
||||||
AND t.awbFk
|
AND `t`.`awbFk` <> 0
|
||||||
|
|
|
@ -9,7 +9,7 @@ AS SELECT `et2`.`description` AS `truck`,
|
||||||
`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,
|
`et`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,
|
||||||
`t`.`warehouseFk` AS `warehouseFk`,
|
`t`.`warehouseFk` AS `warehouseFk`,
|
||||||
IF(
|
IF(
|
||||||
`r`.`created` > util.VN_CURDATE() + INTERVAL 1 DAY,
|
`r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY,
|
||||||
ucase(dayname(`r`.`created`)),
|
ucase(dayname(`r`.`created`)),
|
||||||
NULL
|
NULL
|
||||||
) AS `nombreDia`
|
) AS `nombreDia`
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn`.`itemShelvingAvailable`
|
VIEW `vn`.`itemShelvingAvailable`
|
||||||
AS SELECT `s`.`id` `saleFk`,
|
AS SELECT `s`.`id` AS `saleFk`,
|
||||||
`tst`.`updated` AS `Modificado`,
|
`tst`.`updated` AS `Modificado`,
|
||||||
`s`.`ticketFk` AS `ticketFk`,
|
`s`.`ticketFk` AS `ticketFk`,
|
||||||
0 AS `isPicked`,
|
0 AS `isPicked`,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn`.`ticketStateToday`
|
VIEW `vn`.`ticketStateToday`
|
||||||
AS SELECT
|
AS SELECT `ts`.`ticketFk` AS `ticketFk`,
|
||||||
`ts`.`ticketFk` AS `ticketFk`,
|
|
||||||
`ts`.`state` AS `state`,
|
`ts`.`state` AS `state`,
|
||||||
`ts`.`productionOrder` AS `productionOrder`,
|
`ts`.`productionOrder` AS `productionOrder`,
|
||||||
`ts`.`alertLevel` AS `alertLevel`,
|
`ts`.`alertLevel` AS `alertLevel`,
|
||||||
|
@ -10,6 +9,8 @@ AS SELECT
|
||||||
`ts`.`code` AS `code`,
|
`ts`.`code` AS `code`,
|
||||||
`ts`.`updated` AS `updated`,
|
`ts`.`updated` AS `updated`,
|
||||||
`ts`.`isPicked` AS `isPicked`
|
`ts`.`isPicked` AS `isPicked`
|
||||||
FROM `ticketState` `ts`
|
FROM (
|
||||||
JOIN `ticket` `t` ON `t`.`id` = `ts`.`ticketFk`
|
`vn`.`ticketState` `ts`
|
||||||
WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`());
|
JOIN `vn`.`ticket` `t` ON(`t`.`id` = `ts`.`ticketFk`)
|
||||||
|
)
|
||||||
|
WHERE `t`.`shipped` BETWEEN `util`.`VN_CURDATE`() AND `MIDNIGHT`(`util`.`VN_CURDATE`())
|
||||||
|
|
|
@ -1,24 +1,48 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn`.`zoneEstimatedDelivery`
|
VIEW `vn`.`zoneEstimatedDelivery`
|
||||||
AS SELECT t.zoneFk,
|
AS SELECT `t`.`zoneFk` AS `zoneFk`,
|
||||||
zc.`hour` zoneClosureHour,
|
`zc`.`hour` AS `zoneClosureHour`,
|
||||||
z.`hour` zoneHour,
|
`z`.`hour` AS `zoneHour`,
|
||||||
sv.volume volume,
|
`sv`.`volume` AS `volume`,
|
||||||
al.hasToRecalcPrice,
|
`al`.`hasToRecalcPrice` AS `hasToRecalcPrice`,
|
||||||
lhp.m3,
|
`lhp`.`m3` AS `m3`,
|
||||||
dl.minSpeed
|
`dl`.`minSpeed` AS `minSpeed`
|
||||||
FROM ticket t
|
FROM (
|
||||||
JOIN ticketStateToday tst ON tst.ticketFk = t.id
|
(
|
||||||
JOIN state s ON s.id = tst.state
|
(
|
||||||
JOIN saleVolume sv ON sv.ticketFk = t.id
|
(
|
||||||
LEFT JOIN lastHourProduction lhp ON lhp.warehouseFk = t.warehouseFk
|
(
|
||||||
JOIN warehouse w ON w.id = t.warehouseFk
|
(
|
||||||
STRAIGHT_JOIN `zone` z ON z.id = t.zoneFk
|
(
|
||||||
LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
|
(
|
||||||
AND zc.dated = util.VN_CURDATE()
|
(
|
||||||
LEFT JOIN cache.departure_limit dl ON dl.warehouse_id = t.warehouseFk
|
(
|
||||||
AND dl.fecha = util.VN_CURDATE()
|
`vn`.`ticket` `t`
|
||||||
JOIN alertLevel al ON al.id = s.alertLevel
|
JOIN `vn`.`ticketStateToday` `tst` ON(`tst`.`ticketFk` = `t`.`id`)
|
||||||
WHERE w.hasProduction
|
)
|
||||||
AND DATE(t.shipped) = util.VN_CURDATE()
|
JOIN `vn`.`state` `s` ON(`s`.`id` = `tst`.`state`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`saleVolume` `sv` ON(`sv`.`ticketFk` = `t`.`id`)
|
||||||
|
)
|
||||||
|
LEFT JOIN `vn`.`lastHourProduction` `lhp` ON(`lhp`.`warehouseFk` = `t`.`warehouseFk`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`warehouse` `w` ON(`w`.`id` = `t`.`warehouseFk`)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`warehouseAlias` `wa` ON(`wa`.`id` = `w`.`aliasFk`)
|
||||||
|
) STRAIGHT_JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
|
||||||
|
)
|
||||||
|
LEFT JOIN `vn`.`zoneClosure` `zc` ON(
|
||||||
|
`zc`.`zoneFk` = `t`.`zoneFk`
|
||||||
|
AND `zc`.`dated` = `util`.`VN_CURDATE`()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
LEFT JOIN `cache`.`departure_limit` `dl` ON(
|
||||||
|
`dl`.`warehouse_id` = `t`.`warehouseFk`
|
||||||
|
AND `dl`.`fecha` = `util`.`VN_CURDATE`()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
JOIN `vn`.`alertLevel` `al` ON(`al`.`id` = `s`.`alertLevel`)
|
||||||
|
)
|
||||||
|
WHERE `w`.`hasProduction` <> 0
|
||||||
|
AND cast(`t`.`shipped` AS date) = `util`.`VN_CURDATE`()
|
||||||
|
|
|
@ -27,7 +27,7 @@ BEGIN
|
||||||
DECLARE vEvaNotes VARCHAR(255);
|
DECLARE vEvaNotes VARCHAR(255);
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vAuxEntryFk INT;
|
DECLARE vAuxEntryFk INT;
|
||||||
DECLARE vTx BOOLEAN DEFAULT !@@in_transaction;
|
DECLARE vTx BOOLEAN DEFAULT @@in_transaction;
|
||||||
DECLARE vRsEntry CURSOR FOR
|
DECLARE vRsEntry CURSOR FOR
|
||||||
SELECT e.id
|
SELECT e.id
|
||||||
FROM entry e
|
FROM entry e
|
||||||
|
|
|
@ -256,7 +256,7 @@ async function dockerStart() {
|
||||||
await myt.run(Start);
|
await myt.run(Start);
|
||||||
await myt.deinit();
|
await myt.deinit();
|
||||||
}
|
}
|
||||||
dockerStart.description = `Starts the salix-db container`;
|
dockerStart.description = `Starts the DB container`;
|
||||||
|
|
||||||
async function docker() {
|
async function docker() {
|
||||||
const myt = new Myt();
|
const myt = new Myt();
|
||||||
|
@ -264,7 +264,7 @@ async function docker() {
|
||||||
await myt.run(Run);
|
await myt.run(Run);
|
||||||
await myt.deinit();
|
await myt.deinit();
|
||||||
}
|
}
|
||||||
docker.description = `Runs the salix-db container`;
|
docker.description = `Builds and starts the DB container`;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
default: defaultTask,
|
default: defaultTask,
|
||||||
|
|
|
@ -207,5 +207,7 @@
|
||||||
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
|
"The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified",
|
||||||
"Name should be uppercase": "Name should be uppercase",
|
"Name should be uppercase": "Name should be uppercase",
|
||||||
"You cannot update these fields": "You cannot update these fields",
|
"You cannot update these fields": "You cannot update these fields",
|
||||||
"CountryFK cannot be empty": "Country cannot be empty"
|
"CountryFK cannot be empty": "Country cannot be empty",
|
||||||
|
"You are not allowed to modify the alias": "You are not allowed to modify the alias",
|
||||||
|
"You already have the mailAlias": "You already have the mailAlias"
|
||||||
}
|
}
|
|
@ -139,7 +139,7 @@
|
||||||
"Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
|
"Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*",
|
||||||
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
|
||||||
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto",
|
||||||
"Distance must be lesser than 1000": "La distancia debe ser inferior a 1000",
|
"Distance must be lesser than 4000": "La distancia debe ser inferior a 4000",
|
||||||
"This ticket is deleted": "Este ticket está eliminado",
|
"This ticket is deleted": "Este ticket está eliminado",
|
||||||
"Unable to clone this travel": "No ha sido posible clonar este travel",
|
"Unable to clone this travel": "No ha sido posible clonar este travel",
|
||||||
"This thermograph id already exists": "La id del termógrafo ya existe",
|
"This thermograph id already exists": "La id del termógrafo ya existe",
|
||||||
|
@ -336,12 +336,13 @@
|
||||||
"Incorrect pin": "Pin incorrecto",
|
"Incorrect pin": "Pin incorrecto",
|
||||||
"You already have the mailAlias": "Ya tienes este alias de correo",
|
"You already have the mailAlias": "Ya tienes este alias de correo",
|
||||||
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
"The alias cant be modified": "Este alias de correo no puede ser modificado",
|
||||||
"No tickets to invoice": "No hay tickets para facturar",
|
|
||||||
"This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado",
|
"This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado",
|
||||||
"Name should be uppercase": "El nombre debe ir en mayúscula",
|
"Name should be uppercase": "El nombre debe ir en mayúscula",
|
||||||
"Bank entity must be specified": "La entidad bancaria es obligatoria",
|
"Bank entity must be specified": "La entidad bancaria es obligatoria",
|
||||||
"An email is necessary": "Es necesario un email",
|
"An email is necessary": "Es necesario un email",
|
||||||
"You cannot update these fields": "No puedes actualizar estos campos",
|
"You cannot update these fields": "No puedes actualizar estos campos",
|
||||||
"CountryFK cannot be empty": "El país no puede estar vacío",
|
"CountryFK cannot be empty": "El país no puede estar vacío",
|
||||||
"Cmr file does not exist": "El archivo del cmr no existe"
|
"Cmr file does not exist": "El archivo del cmr no existe",
|
||||||
|
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
|
||||||
|
"No tickets to invoice": "No hay tickets para facturar"
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.rewriteDbError(function(err) {
|
Self.rewriteDbError(function(err) {
|
||||||
|
@ -8,38 +8,38 @@ module.exports = Self => {
|
||||||
return err;
|
return err;
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.observe('before save', async ctx => {
|
Self.beforeRemote('create', async function(ctx) {
|
||||||
const changes = ctx.currentInstance || ctx.instance;
|
const mailAlias = ctx.args.data?.mailAlias;
|
||||||
|
if (!mailAlias) return;
|
||||||
await checkModifyPermission(ctx, changes.mailAlias);
|
await checkModifyPermission(ctx, mailAlias);
|
||||||
});
|
});
|
||||||
|
Self.beforeRemote('deleteById', async function(ctx) {
|
||||||
Self.observe('before delete', async ctx => {
|
const instance = await Self.findById(ctx.args.id,
|
||||||
const mailAliasAccount = await Self.findById(ctx.where.id);
|
{fields: ['mailAlias']}
|
||||||
|
);
|
||||||
await checkModifyPermission(ctx, mailAliasAccount.mailAlias);
|
await checkModifyPermission(ctx, instance.mailAlias);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function checkModifyPermission(ctx, mailAliasFk) {
|
async function checkModifyPermission(ctx, mailAliasFk) {
|
||||||
const userId = ctx.options.accessToken.userId;
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
|
const userId = ctx.req.accessToken.userId;
|
||||||
|
|
||||||
const roles = await models.RoleMapping.find({
|
const canEditAlias = await models.ACL.checkAccessAcl(ctx,
|
||||||
fields: ['roleId'],
|
'MailAliasAccount', 'canEditAlias', 'WRITE');
|
||||||
where: {principalId: userId}
|
if (canEditAlias) return;
|
||||||
|
|
||||||
|
const allowedRoles = await models.MailAliasAcl.find({
|
||||||
|
fields: ['roleFk'],
|
||||||
|
where: {mailAliasFk}
|
||||||
|
});
|
||||||
|
const nRoles = allowedRoles.length &&
|
||||||
|
await models.RoleMapping.count({
|
||||||
|
principalId: userId,
|
||||||
|
principalType: 'USER',
|
||||||
|
roleId: {inq: allowedRoles.map(x => x.roleFk)}
|
||||||
});
|
});
|
||||||
|
|
||||||
const availableMailAlias = await models.MailAliasAcl.findOne({
|
if (!nRoles)
|
||||||
fields: ['mailAliasFk'],
|
throw new ForbiddenError('You are not allowed to modify the alias');
|
||||||
include: {relation: 'mailAlias'},
|
|
||||||
where: {
|
|
||||||
roleFk: {
|
|
||||||
inq: roles.map(role => role.roleId),
|
|
||||||
},
|
|
||||||
mailAliasFk
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!availableMailAlias) throw new UserError('The alias cant be modified');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,7 +71,7 @@ class Controller extends Descriptor {
|
||||||
const params = {newPassword: this.newPassword};
|
const params = {newPassword: this.newPassword};
|
||||||
|
|
||||||
if (this.askOldPass) {
|
if (this.askOldPass) {
|
||||||
method = 'changePassword';
|
method = 'change-password';
|
||||||
params.oldPassword = this.oldPassword;
|
params.oldPassword = this.oldPassword;
|
||||||
} else
|
} else
|
||||||
method = 'setPassword';
|
method = 'setPassword';
|
||||||
|
|
|
@ -22,16 +22,16 @@ module.exports = Self => {
|
||||||
require('../methods/route/getByWorker')(Self);
|
require('../methods/route/getByWorker')(Self);
|
||||||
|
|
||||||
Self.validate('kmStart', validateDistance, {
|
Self.validate('kmStart', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 4000'
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.validate('kmEnd', validateDistance, {
|
Self.validate('kmEnd', validateDistance, {
|
||||||
message: 'Distance must be lesser than 1000'
|
message: 'Distance must be lesser than 4000'
|
||||||
});
|
});
|
||||||
|
|
||||||
function validateDistance(err) {
|
function validateDistance(err) {
|
||||||
const routeTotalKm = this.kmEnd - this.kmStart;
|
const routeTotalKm = this.kmEnd - this.kmStart;
|
||||||
const routeMaxKm = 1000;
|
const routeMaxKm = 4000;
|
||||||
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
|
if (routeTotalKm > routeMaxKm || this.kmStart > this.kmEnd)
|
||||||
err();
|
err();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ describe('Travel cloneWithEntries()', () => {
|
||||||
expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
|
expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
|
||||||
expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
|
expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
|
||||||
expect(travelEntries.length).toBeGreaterThan(0);
|
expect(travelEntries.length).toBeGreaterThan(0);
|
||||||
|
await models.Entry.destroyAll({
|
||||||
|
travelFk: newTravelId
|
||||||
|
}, options);
|
||||||
|
await models.Travel.destroyById(newTravelId, options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
const travelRemoved = await models.Travel.findById(newTravelId, options);
|
const travelRemoved = await models.Travel.findById(newTravelId, options);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
"mysql": "2.18.1",
|
"mysql": "2.18.1",
|
||||||
"node-ssh": "^11.0.0",
|
"node-ssh": "^11.0.0",
|
||||||
"object.pick": "^1.3.0",
|
"object.pick": "^1.3.0",
|
||||||
"puppeteer": "^21.10.0",
|
"puppeteer": "^21.11.0",
|
||||||
|
"read-chunk": "^3.2.0",
|
||||||
"require-yaml": "0.0.1",
|
"require-yaml": "0.0.1",
|
||||||
"smbhash": "0.0.1",
|
"smbhash": "0.0.1",
|
||||||
"strong-error-handler": "^2.3.2",
|
"strong-error-handler": "^2.3.2",
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
init() {
|
init() {
|
||||||
if (this.pool) return;
|
if (this.pool) return;
|
||||||
Cluster.launch({
|
Cluster.launch({
|
||||||
concurrency: Cluster.CONCURRENCY_CONTEXT,
|
concurrency: Cluster.CONCURRENCY_PAGE,
|
||||||
maxConcurrency: cpus().length,
|
maxConcurrency: cpus().length,
|
||||||
puppeteerOptions: {
|
puppeteerOptions: {
|
||||||
headless: 'new',
|
headless: 'new',
|
||||||
|
|
|
@ -46,6 +46,9 @@ section.text-area {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
background-color: #e5e5e5;
|
background-color: #e5e5e5;
|
||||||
|
& > p {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.route-block {
|
.route-block {
|
||||||
|
|
|
@ -5,7 +5,6 @@ module.exports = {
|
||||||
mixins: [vnReport],
|
mixins: [vnReport],
|
||||||
async serverPrefetch() {
|
async serverPrefetch() {
|
||||||
let ids = this.id;
|
let ids = this.id;
|
||||||
|
|
||||||
const hasMultipleRoutes = String(this.id).includes(',');
|
const hasMultipleRoutes = String(this.id).includes(',');
|
||||||
if (hasMultipleRoutes)
|
if (hasMultipleRoutes)
|
||||||
ids = this.id.split(',');
|
ids = this.id.split(',');
|
||||||
|
@ -30,7 +29,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
id: {
|
id: {
|
||||||
type: Number,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The route id'
|
description: 'The route id'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue