Merge branch 'dev' into 7323-fineTunningWorker
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
commit
0311069f00
|
@ -15,9 +15,6 @@
|
||||||
"nickname": {
|
"nickname": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
|
||||||
"display": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
|
|
@ -179,12 +179,12 @@ INSERT INTO `vn`.`country`(`id`, `name`, `isUeeMember`, `code`, `currencyFk`, `i
|
||||||
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
|
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
|
||||||
|
|
||||||
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`)
|
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`)
|
||||||
VALUES (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
VALUES
|
||||||
|
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||||
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0),
|
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0),
|
||||||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
|
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
|
||||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
|
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
|
||||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
|
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
|
||||||
(6, 'Warehouse six', 'VNH', 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
|
|
||||||
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
|
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
|
||||||
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);
|
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
@ -1544,7 +1544,7 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12', '56.20', '56.20', '56.20'),
|
||||||
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
|
('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20', '56.20', '56.20', '56.20');
|
||||||
|
|
||||||
INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created)
|
INSERT INTO vn.buy(id,entryFk,itemFk,buyingValue,quantity,packagingFk,stickers,freightValue,packageValue,comissionValue,packing,grouping,groupingMode,location,price1,price2,price3,printedStickers,isChecked,isIgnored,weight,created)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
(1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH),
|
||||||
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
|
(2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH),
|
||||||
|
@ -2442,7 +2442,8 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, `
|
||||||
(1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1),
|
(1107, CONCAT(util.VN_CURDATE(), ' 10:20'), TRUE, 'middle', 1),
|
||||||
(1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1);
|
(1107, CONCAT(util.VN_CURDATE(), ' 14:50'), TRUE, 'out', 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
INSERT INTO `vn`.`dmsType`
|
||||||
|
(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'),
|
(1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'),
|
||||||
(2, 'Doc oficial', NULL, NULL, 'officialDoc'),
|
(2, 'Doc oficial', NULL, NULL, 'officialDoc'),
|
||||||
|
@ -2465,7 +2466,8 @@ INSERT INTO `vn`.`dmsType`(`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`)
|
||||||
(19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
|
(19, 'inmovilizado', NULL, NULL, 'fixedAssets'),
|
||||||
(20, 'Reclamación', 1, 1, 'claim'),
|
(20, 'Reclamación', 1, 1, 'claim'),
|
||||||
(21, 'Entrada', 1, 1, 'entry'),
|
(21, 'Entrada', 1, 1, 'entry'),
|
||||||
(22, 'Proveedor', 1, 1, 'supplier');
|
(22, 'Proveedor', 1, 1, 'supplier'),
|
||||||
|
(23, 'Termografos', 35, 35, 'thermograph');
|
||||||
|
|
||||||
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `warehouseFk`, `companyFk`, `hardCopyNumber`, `hasFile`, `reference`, `description`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -2473,7 +2475,7 @@ INSERT INTO `vn`.`dms`(`id`, `dmsTypeFk`, `file`, `contentType`, `workerFk`, `wa
|
||||||
(2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()),
|
(2, 5, '2.txt', 'text/plain', 5, 1, 442, 1, TRUE, 'Client:104', 'Client:104 dms for the client', util.VN_CURDATE()),
|
||||||
(3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()),
|
(3, 5, '3.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Client: 104', 'Client:104 readme', util.VN_CURDATE()),
|
||||||
(4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()),
|
(4, 3, '4.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'Worker: 106', 'Worker:106 readme', util.VN_CURDATE()),
|
||||||
(5, 5, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()),
|
(5, 23, '5.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'travel: 1', 'dmsForThermograph', util.VN_CURDATE()),
|
||||||
(6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
|
(6, 5, '6.txt', 'text/plain', 5, 1, 442, NULL, TRUE, 'NotExists', 'DoesNotExists', util.VN_CURDATE()),
|
||||||
(7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
(7, 20, '7.jpg', 'image/jpeg', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
||||||
(8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
(8, 20, '8.mp4', 'video/mp4', 9, 1, 442, NULL, FALSE, '1', 'TICKET ID DEL CLIENTE BRUCE WAYNE ID 1101', util.VN_CURDATE()),
|
||||||
|
@ -3188,7 +3190,7 @@ UPDATE vn.department
|
||||||
SET workerFk = null;
|
SET workerFk = null;
|
||||||
|
|
||||||
INSERT INTO vn.packaging
|
INSERT INTO vn.packaging
|
||||||
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0);
|
VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1);
|
||||||
|
|
||||||
|
|
||||||
INSERT IGNORE INTO vn.intrastat
|
INSERT IGNORE INTO vn.intrastat
|
||||||
|
@ -3939,32 +3941,38 @@ INSERT INTO vn.medicalReview
|
||||||
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
|
(id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark)
|
||||||
VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL);
|
VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL);
|
||||||
|
|
||||||
INSERT INTO vn.stockBought (workerFk, bought, reserve, dated)
|
INSERT INTO vn.payrollComponent
|
||||||
VALUES(35, 1.00, 1.00, '2001-01-01');
|
(id, name, isSalaryAgreed, isVariable, isException)
|
||||||
|
VALUES
|
||||||
INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk)
|
(1, 'Salario1', 1, 0, 0),
|
||||||
VALUES (1,0.6,6);
|
|
||||||
|
|
||||||
INSERT INTO vn.payrollComponent (id, name, isSalaryAgreed, isVariable, isException)
|
|
||||||
VALUES (1, 'Salario1', 1, 0, 0),
|
|
||||||
(2, 'Salario2', 1, 1, 0),
|
(2, 'Salario2', 1, 1, 0),
|
||||||
(3, 'Salario3', 1, 0, 1);
|
(3, 'Salario3', 1, 0, 1);
|
||||||
|
|
||||||
INSERT INTO vn.workerIncome (debit, credit, incomeTypeFk, paymentDate, workerFk, concept)
|
|
||||||
VALUES (1000.00, 900.00, 2, '2000-01-01', 1106, NULL),
|
INSERT INTO vn.workerIncome
|
||||||
|
(debit, credit, incomeTypeFk, paymentDate, workerFk, concept)
|
||||||
|
VALUES
|
||||||
|
(1000.00, 900.00, 2, '2000-01-01', 1106, NULL),
|
||||||
(1001.00, 800.00, 2, '2000-01-01', 1106, NULL);
|
(1001.00, 800.00, 2, '2000-01-01', 1106, NULL);
|
||||||
|
|
||||||
INSERT INTO dipole.printer (id, description) VALUES(1, '');
|
|
||||||
|
|
||||||
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
INSERT INTO dipole.printer (id, description)
|
||||||
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
VALUES(1, '');
|
||||||
|
|
||||||
INSERT INTO vn.accountDetail (id, value, accountDetailTypeFk, supplierAccountFk)
|
INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode,
|
||||||
VALUES (21, 'ES12345B12345678', 3, 241),
|
truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments)
|
||||||
|
VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL);
|
||||||
|
|
||||||
|
INSERT INTO vn.accountDetail
|
||||||
|
(id, value, accountDetailTypeFk, supplierAccountFk)
|
||||||
|
VALUES
|
||||||
|
(21, 'ES12345B12345678', 3, 241),
|
||||||
(35, 'ES12346B12345679', 3, 241);
|
(35, 'ES12346B12345679', 3, 241);
|
||||||
|
|
||||||
INSERT INTO vn.accountDetailType (id, description, code)
|
INSERT INTO vn.accountDetailType
|
||||||
VALUES (1, 'IBAN', 'iban'),
|
(id, description, code)
|
||||||
|
VALUES
|
||||||
|
(1, 'IBAN', 'iban'),
|
||||||
(2, 'SWIFT', 'swift'),
|
(2, 'SWIFT', 'swift'),
|
||||||
(3, 'Referencia Remesas', 'remRef'),
|
(3, 'Referencia Remesas', 'remRef'),
|
||||||
(4, 'Referencia Transferencias', 'trnRef'),
|
(4, 'Referencia Transferencias', 'trnRef'),
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
||||||
|
PROCEDURE `hedera`.`orderRow_updateOverstocking`(vOrderFk INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Set amount = 0 to avoid overbooking sales
|
||||||
|
*
|
||||||
|
* @param vOrderFk hedera.order.id
|
||||||
|
*/
|
||||||
|
DECLARE vCalcFk INT;
|
||||||
|
DECLARE vDone BOOL;
|
||||||
|
DECLARE vWarehouseFk INT;
|
||||||
|
|
||||||
|
DECLARE cWarehouses CURSOR FOR
|
||||||
|
SELECT DISTINCT warehouseFk
|
||||||
|
FROM orderRow
|
||||||
|
WHERE orderFk = vOrderFk
|
||||||
|
AND shipped = util.VN_CURDATE();
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
|
BEGIN
|
||||||
|
ROLLBACK;
|
||||||
|
RESIGNAL;
|
||||||
|
END;
|
||||||
|
|
||||||
|
OPEN cWarehouses;
|
||||||
|
checking: LOOP
|
||||||
|
SET vDone = FALSE;
|
||||||
|
|
||||||
|
FETCH cWarehouses INTO vWarehouseFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE checking;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
|
UPDATE orderRow r
|
||||||
|
JOIN `order` o ON o.id = r.orderFk
|
||||||
|
JOIN orderConfig oc
|
||||||
|
JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
|
||||||
|
SET r.amount = 0
|
||||||
|
WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW()
|
||||||
|
AND a.available <= 0
|
||||||
|
AND r.warehouseFk = vWarehouseFk
|
||||||
|
AND r.orderFk = vOrderFk;
|
||||||
|
END LOOP;
|
||||||
|
CLOSE cWarehouses;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -12,6 +12,7 @@ BEGIN
|
||||||
* @param vUser The user identifier
|
* @param vUser The user identifier
|
||||||
*/
|
*/
|
||||||
DECLARE vHasRows BOOL;
|
DECLARE vHasRows BOOL;
|
||||||
|
DECLARE vHas0Amount BOOL;
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vShipment DATE;
|
DECLARE vShipment DATE;
|
||||||
|
@ -101,6 +102,8 @@ BEGIN
|
||||||
|
|
||||||
CALL order_checkEditable(vSelf);
|
CALL order_checkEditable(vSelf);
|
||||||
|
|
||||||
|
CALL orderRow_updateOverstocking(vSelf);
|
||||||
|
|
||||||
-- Check order is not empty
|
-- Check order is not empty
|
||||||
SELECT COUNT(*) > 0 INTO vHasRows
|
SELECT COUNT(*) > 0 INTO vHasRows
|
||||||
FROM orderRow
|
FROM orderRow
|
||||||
|
@ -111,6 +114,18 @@ BEGIN
|
||||||
CALL util.throw('ORDER_EMPTY');
|
CALL util.throw('ORDER_EMPTY');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
-- Check if any product has a quantity of 0
|
||||||
|
SELECT EXISTS (
|
||||||
|
SELECT id
|
||||||
|
FROM orderRow
|
||||||
|
WHERE orderFk = vSelf
|
||||||
|
AND amount = 0
|
||||||
|
) INTO vHas0Amount;
|
||||||
|
|
||||||
|
IF vHas0Amount THEN
|
||||||
|
CALL util.throw('Remove lines with quantity = 0 before confirming');
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Crea los tickets del pedido
|
-- Crea los tickets del pedido
|
||||||
OPEN vDates;
|
OPEN vDates;
|
||||||
lDates: LOOP
|
lDates: LOOP
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert`
|
||||||
|
AFTER INSERT ON `orderRow`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE `order`
|
||||||
|
SET rowUpdated = NOW()
|
||||||
|
WHERE id = NEW.orderFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_setDelivered`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` EVENT `vn`.`travel_setDelivered`
|
||||||
ON SCHEDULE EVERY 1 DAY
|
ON SCHEDULE EVERY 1 DAY
|
||||||
STARTS '2024-07-12 00:10:00.000'
|
STARTS '2024-07-12 00:10:00.000'
|
||||||
ON COMPLETION PRESERVE
|
ON COMPLETION PRESERVE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimate`(
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vWarehouseFk SMALLINT,
|
vWarehouseFk SMALLINT,
|
||||||
vDated DATE
|
vDated DATE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`(
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vWarehouseFk SMALLINT,
|
vWarehouseFk SMALLINT,
|
||||||
vStarted DATE,
|
vStarted DATE,
|
||||||
|
|
|
@ -41,9 +41,12 @@ BEGIN
|
||||||
AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
|
AND (pd.originFk IS NULL OR pd.originFk = i.originFk)
|
||||||
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
|
AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk)
|
||||||
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
|
AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk)
|
||||||
|
LEFT JOIN zoneGeo zg ON zg.id = pd.zoneGeoFk
|
||||||
|
LEFT JOIN zoneGeo zg2 ON zg2.id = address_getGeo(vAddressFk)
|
||||||
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
|
WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped)
|
||||||
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
|
AND (pd.toDated IS NULL OR pd.toDated >= vShipped)
|
||||||
GROUP BY i.id;
|
AND (pd.zoneGeoFk IS NULL OR zg2.lft BETWEEN zg.lft AND zg.rgt)
|
||||||
|
GROUP BY itemFk;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
|
CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice
|
||||||
(INDEX (itemFk))
|
(INDEX (itemFk))
|
||||||
|
|
|
@ -59,7 +59,7 @@ BEGIN
|
||||||
DELETE b FROM buy b
|
DELETE b FROM buy b
|
||||||
JOIN entryConfig e ON e.defaultEntry = b.entryFk
|
JOIN entryConfig e ON e.defaultEntry = b.entryFk
|
||||||
WHERE b.created < v2Months;
|
WHERE b.created < v2Months;
|
||||||
DELETE FROM stockBuyed WHERE creationDate < v2Months;
|
DELETE FROM stockBought WHERE dated < v2Months;
|
||||||
DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months;
|
DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months;
|
||||||
-- Equipos duplicados
|
-- Equipos duplicados
|
||||||
DELETE w.*
|
DELETE w.*
|
||||||
|
|
|
@ -55,24 +55,20 @@ BEGIN
|
||||||
SELECT ts.saleFk,
|
SELECT ts.saleFk,
|
||||||
ts.itemFk,
|
ts.itemFk,
|
||||||
CAST(0 AS DECIMAL(10,0)) saleOrder,
|
CAST(0 AS DECIMAL(10,0)) saleOrder,
|
||||||
IF(ish.visible > 0 OR iss.id, 1, 100000) *
|
(IF(ish.visible > 0 OR iss.id, 1, 100000) *
|
||||||
IFNULL(p2.pickingOrder, p.pickingOrder) `order`,
|
COALESCE(p2.pickingOrder, p.pickingOrder)) `order`,
|
||||||
TO_SECONDS(IF(iss.id,
|
TO_SECONDS(COALESCE(iss.created, ish.created)) - TO_SECONDS(MAKEDATE(IFNULL(YEAR(iss.created), YEAR(ish.created)), 1)) priority,
|
||||||
iss.created - INTERVAL vCurrentYear YEAR,
|
|
||||||
ish.created - INTERVAL YEAR(ish.created) YEAR)) priority,
|
|
||||||
CONCAT(
|
CONCAT(
|
||||||
IF(iss.id,
|
IF(iss.id, CONCAT('< ', COALESCE(wk.`code`, '---'),' > '), ''),
|
||||||
CONCAT('< ', IFNULL(wk.`code`, '---'),' > '),
|
p.`code`
|
||||||
''),
|
) COLLATE utf8_general_ci placement,
|
||||||
p.`code`) COLLATE utf8_general_ci placement,
|
|
||||||
sh.priority shelvingPriority,
|
sh.priority shelvingPriority,
|
||||||
sh.code COLLATE utf8_general_ci shelving,
|
sh.code COLLATE utf8_general_ci shelving,
|
||||||
ish.created,
|
ish.created,
|
||||||
ish.visible,
|
ish.visible,
|
||||||
IFNULL(
|
COALESCE(
|
||||||
IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),
|
IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),1) `grouping`,
|
||||||
1) `grouping`,
|
(st.code = 'previousPrepared') isPreviousPrepared,
|
||||||
st.code = 'previousPrepared' isPreviousPrepared,
|
|
||||||
iss.id itemShelvingSaleFk,
|
iss.id itemShelvingSaleFk,
|
||||||
ts.ticketFk,
|
ts.ticketFk,
|
||||||
iss.id,
|
iss.id,
|
||||||
|
@ -80,11 +76,12 @@ BEGIN
|
||||||
iss.userFk,
|
iss.userFk,
|
||||||
ts.quantity
|
ts.quantity
|
||||||
FROM tSale ts
|
FROM tSale ts
|
||||||
LEFT JOIN (SELECT DISTINCT saleFk
|
LEFT JOIN (SELECT st.saleFk
|
||||||
FROM saleTracking st
|
FROM saleTracking st
|
||||||
JOIN state s ON s.id = st.stateFk
|
JOIN state s ON s.id = st.stateFk
|
||||||
WHERE st.isChecked
|
WHERE st.isChecked
|
||||||
AND s.semaphore = 1) st ON st.saleFk = ts.saleFk
|
AND s.semaphore = 1
|
||||||
|
GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk
|
||||||
JOIN itemShelving ish ON ish.itemFk = ts.itemFk
|
JOIN itemShelving ish ON ish.itemFk = ts.itemFk
|
||||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
JOIN shelving sh ON sh.code = ish.shelvingFk
|
||||||
JOIN parking p ON p.id = sh.parkingFk
|
JOIN parking p ON p.id = sh.parkingFk
|
||||||
|
@ -100,7 +97,7 @@ BEGIN
|
||||||
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
||||||
WHERE w.id = vWarehouseFk
|
WHERE w.id = vWarehouseFk
|
||||||
AND NOT sc.isHideForPickers
|
AND NOT sc.isHideForPickers
|
||||||
HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL;
|
AND ((iss.id AND st.saleFk) OR st.saleFk IS NULL);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2
|
CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2
|
||||||
(INDEX(saleFk), INDEX(olderPriority))
|
(INDEX(saleFk), INDEX(olderPriority))
|
||||||
|
|
|
@ -23,7 +23,7 @@ BEGIN
|
||||||
JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
|
JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk
|
||||||
LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
|
LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
|
||||||
WHERE ot.`code` = 'itemPicker'
|
WHERE ot.`code` = 'itemPicker'
|
||||||
AND tc.collectionFk = vParamFk
|
AND tc.collectionFk = vParamFk OR tc.ticketFk = vParamFk
|
||||||
)
|
)
|
||||||
SELECT t.id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_mergeSales`(vCollectionFk INT)
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_mergeSales`(vCollectionFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vTicketFk INT;
|
DECLARE vTicketFk INT;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(vUserFk INT, OUT vCollectionFk INT)
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_new`(
|
||||||
|
vUserFk INT,
|
||||||
|
OUT vCollectionFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Genera colecciones de tickets sin asignar trabajador.
|
* Genera colecciones de tickets sin asignar trabajador.
|
||||||
|
@ -12,30 +15,29 @@ BEGIN
|
||||||
DECLARE vLinesLimit INT;
|
DECLARE vLinesLimit INT;
|
||||||
DECLARE vTicketLines INT;
|
DECLARE vTicketLines INT;
|
||||||
DECLARE vVolumeLimit DECIMAL;
|
DECLARE vVolumeLimit DECIMAL;
|
||||||
DECLARE vTicketVolume DECIMAL;
|
|
||||||
DECLARE vSizeLimit INT;
|
DECLARE vSizeLimit INT;
|
||||||
|
DECLARE vTicketVolume DECIMAL;
|
||||||
DECLARE vMaxTickets INT;
|
DECLARE vMaxTickets INT;
|
||||||
DECLARE vStateFk VARCHAR(45);
|
DECLARE vStateCode VARCHAR(45);
|
||||||
DECLARE vFirstTicketFk INT;
|
DECLARE vFirstTicketFk INT;
|
||||||
DECLARE vHour INT;
|
|
||||||
DECLARE vMinute INT;
|
|
||||||
DECLARE vWorkerCode VARCHAR(3);
|
DECLARE vWorkerCode VARCHAR(3);
|
||||||
DECLARE vWagonCounter INT DEFAULT 0;
|
DECLARE vWagonCounter INT DEFAULT 1;
|
||||||
DECLARE vTicketFk INT;
|
DECLARE vTicketFk INT;
|
||||||
DECLARE vItemPackingTypeFk VARCHAR(1);
|
DECLARE vItemPackingTypeFk VARCHAR(1);
|
||||||
DECLARE vHasAssignedTickets BOOLEAN;
|
DECLARE vHasAssignedTickets BOOL;
|
||||||
DECLARE vHasUniqueCollectionTime BOOL;
|
DECLARE vHasUniqueCollectionTime BOOL;
|
||||||
DECLARE vDone INT DEFAULT FALSE;
|
DECLARE vHeight INT;
|
||||||
DECLARE vLockName VARCHAR(215);
|
DECLARE vVolume INT;
|
||||||
DECLARE vLockTime INT DEFAULT 30;
|
DECLARE vLiters INT;
|
||||||
|
DECLARE vLines INT;
|
||||||
|
DECLARE vTotalLines INT DEFAULT 0;
|
||||||
|
DECLARE vTotalVolume INT DEFAULT 0;
|
||||||
DECLARE vFreeWagonFk INT;
|
DECLARE vFreeWagonFk INT;
|
||||||
DECLARE vErrorNumber INT;
|
DECLARE vDone INT DEFAULT FALSE;
|
||||||
DECLARE vErrorMsg TEXT;
|
|
||||||
|
|
||||||
DECLARE c1 CURSOR FOR
|
DECLARE vTickets CURSOR FOR
|
||||||
SELECT ticketFk, `lines`, m3
|
SELECT ticketFk, `lines`, m3
|
||||||
FROM tmp.productionBuffer
|
FROM tmp.productionBuffer
|
||||||
WHERE ticketFk <> vFirstTicketFk
|
|
||||||
ORDER BY HH,
|
ORDER BY HH,
|
||||||
mm,
|
mm,
|
||||||
productionOrder DESC,
|
productionOrder DESC,
|
||||||
|
@ -48,26 +50,6 @@ BEGIN
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
GET DIAGNOSTICS CONDITION 1
|
|
||||||
vErrorNumber = MYSQL_ERRNO,
|
|
||||||
vErrorMsg = MESSAGE_TEXT;
|
|
||||||
|
|
||||||
CALL util.debugAdd('collection_new', JSON_OBJECT(
|
|
||||||
'errorNumber', vErrorNumber,
|
|
||||||
'errorMsg', vErrorMsg,
|
|
||||||
'lockName', vLockName,
|
|
||||||
'userFk', vUserFk,
|
|
||||||
'ticketFk', vTicketFk
|
|
||||||
)); -- Tmp
|
|
||||||
|
|
||||||
IF vLockName IS NOT NULL THEN
|
|
||||||
DO RELEASE_LOCK(vLockName);
|
|
||||||
END IF;
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
|
SELECT pc.ticketTrolleyMax * o.numberOfWagons,
|
||||||
pc.hasUniqueCollectionTime,
|
pc.hasUniqueCollectionTime,
|
||||||
w.code,
|
w.code,
|
||||||
|
@ -78,36 +60,26 @@ BEGIN
|
||||||
o.trainFk,
|
o.trainFk,
|
||||||
o.linesLimit,
|
o.linesLimit,
|
||||||
o.volumeLimit,
|
o.volumeLimit,
|
||||||
o.sizeLimit,
|
o.sizeLimit
|
||||||
pc.collection_new_lockname
|
|
||||||
INTO vMaxTickets,
|
INTO vMaxTickets,
|
||||||
vHasUniqueCollectionTime,
|
vHasUniqueCollectionTime,
|
||||||
vWorkerCode,
|
vWorkerCode,
|
||||||
vWarehouseFk,
|
vWarehouseFk,
|
||||||
vItemPackingTypeFk,
|
vItemPackingTypeFk,
|
||||||
vStateFk,
|
vStateCode,
|
||||||
vWagons,
|
vWagons,
|
||||||
vTrainFk,
|
vTrainFk,
|
||||||
vLinesLimit,
|
vLinesLimit,
|
||||||
vVolumeLimit,
|
vVolumeLimit,
|
||||||
vSizeLimit,
|
vSizeLimit
|
||||||
vLockName
|
FROM worker w
|
||||||
FROM productionConfig pc
|
JOIN operator o ON o.workerFk = w.id
|
||||||
JOIN worker w ON w.id = vUserFk
|
|
||||||
JOIN state st ON st.`code` = 'ON_PREPARATION'
|
JOIN state st ON st.`code` = 'ON_PREPARATION'
|
||||||
JOIN operator o ON o.workerFk = vUserFk;
|
JOIN productionConfig pc
|
||||||
|
WHERE w.id = vUserFk;
|
||||||
SET vLockName = CONCAT_WS('/',
|
|
||||||
vLockName,
|
|
||||||
vWarehouseFk,
|
|
||||||
vItemPackingTypeFk
|
|
||||||
);
|
|
||||||
|
|
||||||
IF NOT GET_LOCK(vLockName, vLockTime) THEN
|
|
||||||
CALL util.throw(CONCAT('Cannot get lock: ', vLockName));
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- Se prepara el tren, con tantos vagones como sea necesario.
|
-- Se prepara el tren, con tantos vagones como sea necesario.
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tTrain
|
CREATE OR REPLACE TEMPORARY TABLE tTrain
|
||||||
(wagon INT,
|
(wagon INT,
|
||||||
shelve INT,
|
shelve INT,
|
||||||
|
@ -118,59 +90,60 @@ BEGIN
|
||||||
PRIMARY KEY(wagon, shelve))
|
PRIMARY KEY(wagon, shelve))
|
||||||
ENGINE = MEMORY;
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
WHILE vWagons > vWagonCounter DO
|
INSERT INTO tTrain (wagon, shelve, liters, `lines`, height)
|
||||||
SET vWagonCounter = vWagonCounter + 1;
|
WITH RECURSIVE wagonSequence AS (
|
||||||
|
SELECT vWagonCounter wagon
|
||||||
INSERT INTO tTrain(wagon, shelve, liters, `lines`, height)
|
UNION ALL
|
||||||
SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height
|
SELECT wagon + 1 wagon
|
||||||
FROM collectionVolumetry cv
|
FROM wagonSequence
|
||||||
WHERE cv.trainFk = vTrainFk
|
WHERE wagon < vWagonCounter + vWagons -1
|
||||||
|
)
|
||||||
|
SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height
|
||||||
|
FROM wagonSequence ws
|
||||||
|
JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk
|
||||||
AND cv.itemPackingTypeFk = vItemPackingTypeFk;
|
AND cv.itemPackingTypeFk = vItemPackingTypeFk;
|
||||||
END WHILE;
|
|
||||||
|
|
||||||
-- Esto desaparecerá cuando tengamos la table cache.ticket
|
-- Esto desaparecerá cuando tengamos la table cache.ticket
|
||||||
|
|
||||||
CALL productionControl(vWarehouseFk, 0);
|
CALL productionControl(vWarehouseFk, 0);
|
||||||
|
|
||||||
ALTER TABLE tmp.productionBuffer
|
ALTER TABLE tmp.productionBuffer
|
||||||
ADD COLUMN liters INT,
|
ADD COLUMN liters INT,
|
||||||
ADD COLUMN height INT;
|
ADD COLUMN height INT;
|
||||||
|
|
||||||
-- Se obtiene nº de colección.
|
|
||||||
INSERT INTO collection
|
|
||||||
SET itemPackingTypeFk = vItemPackingTypeFk,
|
|
||||||
trainFk = vTrainFk,
|
|
||||||
wagons = vWagons,
|
|
||||||
warehouseFk = vWarehouseFk;
|
|
||||||
|
|
||||||
SELECT LAST_INSERT_ID() INTO vCollectionFk;
|
|
||||||
|
|
||||||
-- Los tickets de recogida en Algemesí sólo se sacan si están asignados.
|
-- Los tickets de recogida en Algemesí sólo se sacan si están asignados.
|
||||||
-- Los pedidos con riesgo no se sacan aunque se asignen.
|
-- Los pedidos con riesgo no se sacan aunque se asignen.
|
||||||
DELETE pb.*
|
|
||||||
|
DELETE pb
|
||||||
FROM tmp.productionBuffer pb
|
FROM tmp.productionBuffer pb
|
||||||
JOIN state s ON s.id = pb.state
|
JOIN state s ON s.id = pb.state
|
||||||
WHERE (pb.agency = 'REC_ALGEMESI'
|
WHERE (pb.agency = 'REC_ALGEMESI'
|
||||||
AND s.code <> 'PICKER_DESIGNED')
|
AND s.code <> 'PICKER_DESIGNED')
|
||||||
OR pb.problem LIKE '%RIESGO%';
|
OR pb.problem LIKE '%RIESGO%';
|
||||||
|
|
||||||
-- Comprobamos si hay tickets asignados. En ese caso, nos centramos
|
-- Si hay tickets asignados, nos centramos exclusivamente en esos tickets
|
||||||
-- exclusivamente en esos tickets y los sacamos independientemente
|
-- y los sacamos independientemente de problemas o tamaños
|
||||||
-- de problemas o tamaños
|
|
||||||
SELECT COUNT(*) INTO vHasAssignedTickets
|
SELECT EXISTS (
|
||||||
|
SELECT TRUE
|
||||||
FROM tmp.productionBuffer pb
|
FROM tmp.productionBuffer pb
|
||||||
JOIN state s ON s.id = pb.state
|
JOIN state s ON s.id = pb.state
|
||||||
WHERE s.code = 'PICKER_DESIGNED'
|
WHERE (s.code = 'PICKER_DESIGNED'
|
||||||
AND pb.workerCode = vWorkerCode;
|
AND pb.workerCode = vWorkerCode)
|
||||||
|
OR s.code = 'LAST_CALL'
|
||||||
|
) INTO vHasAssignedTickets;
|
||||||
|
|
||||||
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
|
-- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados
|
||||||
|
|
||||||
IF vHasAssignedTickets THEN
|
IF vHasAssignedTickets THEN
|
||||||
DELETE pb.*
|
DELETE pb
|
||||||
FROM tmp.productionBuffer pb
|
FROM tmp.productionBuffer pb
|
||||||
JOIN state s ON s.id = pb.state
|
JOIN state s ON s.id = pb.state
|
||||||
WHERE s.code <> 'PICKER_DESIGNED'
|
WHERE (s.code <> 'PICKER_DESIGNED'
|
||||||
OR pb.workerCode <> vWorkerCode;
|
OR pb.workerCode <> vWorkerCode)
|
||||||
|
AND s.code <> 'LAST_CALL';
|
||||||
ELSE
|
ELSE
|
||||||
DELETE pb.*
|
DELETE pb
|
||||||
FROM tmp.productionBuffer pb
|
FROM tmp.productionBuffer pb
|
||||||
JOIN state s ON s.id = pb.state
|
JOIN state s ON s.id = pb.state
|
||||||
JOIN agencyMode am ON am.id = pb.agencyModeFk
|
JOIN agencyMode am ON am.id = pb.agencyModeFk
|
||||||
|
@ -193,24 +166,23 @@ BEGIN
|
||||||
OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H')
|
OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H')
|
||||||
OR (NOT pb.V AND vItemPackingTypeFk = 'V')
|
OR (NOT pb.V AND vItemPackingTypeFk = 'V')
|
||||||
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
|
OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking)
|
||||||
OR LENGTH(pb.problem) > 0
|
OR LENGTH(pb.problem)
|
||||||
OR pb.lines > vLinesLimit
|
OR pb.lines > vLinesLimit
|
||||||
OR pb.m3 > vVolumeLimit
|
OR pb.m3 > vVolumeLimit
|
||||||
OR sub.maxSize > vSizeLimit
|
OR sub.maxSize > vSizeLimit
|
||||||
OR pb.hasPlantTray;
|
OR pb.hasPlantTray;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Es importante que el primer ticket se coja en todos los casos
|
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
|
||||||
SELECT ticketFk,
|
|
||||||
HH,
|
IF vHasUniqueCollectionTime THEN
|
||||||
mm,
|
DELETE pb
|
||||||
`lines`,
|
FROM tmp.productionBuffer pb
|
||||||
m3
|
JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk
|
||||||
INTO vFirstTicketFk,
|
AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm);
|
||||||
vHour,
|
END IF;
|
||||||
vMinute,
|
|
||||||
vTicketLines,
|
SELECT ticketFk INTO vFirstTicketFk
|
||||||
vTicketVolume
|
|
||||||
FROM tmp.productionBuffer
|
FROM tmp.productionBuffer
|
||||||
ORDER BY HH,
|
ORDER BY HH,
|
||||||
mm,
|
mm,
|
||||||
|
@ -222,44 +194,37 @@ BEGIN
|
||||||
ticketFk
|
ticketFk
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
-- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede
|
OPEN vTickets;
|
||||||
IF vHasUniqueCollectionTime THEN
|
l: LOOP
|
||||||
DELETE FROM tmp.productionBuffer
|
SET vDone = FALSE;
|
||||||
WHERE HH <> vHour
|
FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume;
|
||||||
OR mm <> vMinute;
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SET vTicketFk = vFirstTicketFk;
|
|
||||||
SET @lines = 0;
|
|
||||||
SET @volume = 0;
|
|
||||||
|
|
||||||
OPEN c1;
|
|
||||||
read_loop: LOOP
|
|
||||||
SET vDone = FALSE;
|
|
||||||
|
|
||||||
-- Buscamos un ticket que cumpla con los requisitos en el listado
|
-- Buscamos un ticket que cumpla con los requisitos en el listado
|
||||||
IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL)
|
|
||||||
AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN
|
IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit)
|
||||||
|
AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN
|
||||||
|
|
||||||
CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
|
CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk);
|
||||||
DROP TEMPORARY TABLE tmp.ticketIPT;
|
DROP TEMPORARY TABLE tmp.ticketIPT;
|
||||||
|
|
||||||
UPDATE tmp.productionBuffer pb
|
SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume)
|
||||||
JOIN (
|
INTO vLines, vLiters, vHeight, vVolume
|
||||||
SELECT SUM(litros) liters,
|
|
||||||
@lines:= COUNT(*) + @lines,
|
|
||||||
COUNT(*) `lines`,
|
|
||||||
MAX(i.`size`) height,
|
|
||||||
@volume := SUM(sv.volume) + @volume,
|
|
||||||
SUM(sv.volume) volume
|
|
||||||
FROM saleVolume sv
|
FROM saleVolume sv
|
||||||
JOIN sale s ON s.id = sv.saleFk
|
JOIN sale s ON s.id = sv.saleFk
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
WHERE sv.ticketFk = vTicketFk
|
WHERE sv.ticketFk = vTicketFk;
|
||||||
) sub
|
|
||||||
SET pb.liters = sub.liters,
|
SET vTotalVolume = vTotalVolume + vVolume,
|
||||||
pb.`lines` = sub.`lines`,
|
vTotalLines = vTotalLines + vLines;
|
||||||
pb.height = sub.height
|
|
||||||
|
UPDATE tmp.productionBuffer pb
|
||||||
|
SET pb.liters = vLiters,
|
||||||
|
pb.`lines` = vLines,
|
||||||
|
pb.height = vHeight
|
||||||
WHERE pb.ticketFk = vTicketFk;
|
WHERE pb.ticketFk = vTicketFk;
|
||||||
|
|
||||||
UPDATE tTrain tt
|
UPDATE tTrain tt
|
||||||
|
@ -276,17 +241,13 @@ BEGIN
|
||||||
tt.height
|
tt.height
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
-- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre
|
-- Si no le encuentra una balda, intentamos darle un carro entero libre
|
||||||
|
|
||||||
IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
|
IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
|
||||||
SELECT tt.wagon
|
SELECT wagon INTO vFreeWagonFk
|
||||||
INTO vFreeWagonFk
|
|
||||||
FROM tTrain tt
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT DISTINCT wagon
|
|
||||||
FROM tTrain
|
FROM tTrain
|
||||||
WHERE ticketFk IS NOT NULL
|
GROUP BY wagon
|
||||||
) nn ON nn.wagon = tt.wagon
|
HAVING COUNT(ticketFk) = 0
|
||||||
WHERE nn.wagon IS NULL
|
|
||||||
ORDER BY wagon
|
ORDER BY wagon
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
|
@ -295,38 +256,35 @@ BEGIN
|
||||||
SET ticketFk = vFirstTicketFk
|
SET ticketFk = vFirstTicketFk
|
||||||
WHERE wagon = vFreeWagonFk;
|
WHERE wagon = vFreeWagonFk;
|
||||||
|
|
||||||
-- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo
|
-- Se anulan el resto de carros libres,
|
||||||
DELETE tt.*
|
-- máximo un carro con pedido excesivo
|
||||||
FROM tTrain tt
|
|
||||||
LEFT JOIN (
|
|
||||||
SELECT DISTINCT wagon
|
|
||||||
FROM tTrain
|
|
||||||
WHERE ticketFk IS NOT NULL
|
|
||||||
) nn ON nn.wagon = tt.wagon
|
|
||||||
WHERE nn.wagon IS NULL;
|
|
||||||
END IF;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
|
DELETE tt
|
||||||
IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN
|
FROM tTrain tt
|
||||||
LEAVE read_loop;
|
JOIN (SELECT wagon
|
||||||
|
FROM tTrain
|
||||||
|
GROUP BY wagon
|
||||||
|
HAVING COUNT(ticketFk) = 0
|
||||||
|
) sub ON sub.wagon = tt.wagon;
|
||||||
END IF;
|
END IF;
|
||||||
ELSE
|
|
||||||
FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume;
|
|
||||||
IF vDone THEN
|
|
||||||
LEAVE read_loop;
|
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE c1;
|
CLOSE vTickets;
|
||||||
|
|
||||||
IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
|
IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN
|
||||||
UPDATE collection c
|
-- Se obtiene nº de colección
|
||||||
JOIN state st ON st.code = 'ON_PREPARATION'
|
|
||||||
SET c.stateFk = st.id
|
INSERT INTO collection
|
||||||
WHERE c.id = vCollectionFk;
|
SET itemPackingTypeFk = vItemPackingTypeFk,
|
||||||
|
trainFk = vTrainFk,
|
||||||
|
wagons = vWagons,
|
||||||
|
warehouseFk = vWarehouseFk;
|
||||||
|
|
||||||
|
SELECT LAST_INSERT_ID() INTO vCollectionFk;
|
||||||
|
|
||||||
-- Asigna las bandejas
|
-- Asigna las bandejas
|
||||||
|
|
||||||
INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters)
|
INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters)
|
||||||
SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters
|
SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters
|
||||||
FROM tTrain tt
|
FROM tTrain tt
|
||||||
|
@ -334,37 +292,34 @@ BEGIN
|
||||||
ORDER BY tt.wagon, tt.shelve;
|
ORDER BY tt.wagon, tt.shelve;
|
||||||
|
|
||||||
-- Actualiza el estado de los tickets
|
-- Actualiza el estado de los tickets
|
||||||
CALL collection_setState(vCollectionFk, vStateFk);
|
|
||||||
|
CALL collection_setState(vCollectionFk, vStateCode);
|
||||||
|
|
||||||
-- Aviso para la preparacion previa
|
-- Aviso para la preparacion previa
|
||||||
|
|
||||||
INSERT INTO ticketDown(ticketFk, collectionFk)
|
INSERT INTO ticketDown(ticketFk, collectionFk)
|
||||||
SELECT tc.ticketFk, tc.collectionFk
|
SELECT tc.ticketFk, tc.collectionFk
|
||||||
FROM ticketCollection tc
|
FROM ticketCollection tc
|
||||||
WHERE tc.collectionFk = vCollectionFk;
|
WHERE tc.collectionFk = vCollectionFk;
|
||||||
|
|
||||||
CALL sales_mergeByCollection(vCollectionFk);
|
CALL collection_mergeSales(vCollectionFk);
|
||||||
|
|
||||||
UPDATE `collection` c
|
UPDATE `collection` c
|
||||||
JOIN (
|
JOIN(
|
||||||
SELECT COUNT(*) saleTotalCount,
|
SELECT COUNT(*) saleTotalCount,
|
||||||
SUM(s.isPicked <> 0) salePickedCount
|
SUM(s.isPicked <> 0) salePickedCount
|
||||||
FROM ticketCollection tc
|
FROM ticketCollection tc
|
||||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||||
WHERE tc.collectionFk = vCollectionFk
|
WHERE tc.collectionFk = vCollectionFk
|
||||||
AND s.quantity > 0
|
AND s.quantity > 0
|
||||||
) sub
|
)sub
|
||||||
SET c.saleTotalCount = sub.saleTotalCount,
|
SET c.saleTotalCount = sub.saleTotalCount,
|
||||||
c.salePickedCount = sub.salePickedCount
|
c.salePickedCount = sub.salePickedCount
|
||||||
WHERE c.id = vCollectionFk;
|
WHERE c.id = vCollectionFk;
|
||||||
|
|
||||||
ELSE
|
ELSE
|
||||||
DELETE FROM `collection`
|
|
||||||
WHERE id = vCollectionFk;
|
|
||||||
SET vCollectionFk = NULL;
|
SET vCollectionFk = NULL;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
DO RELEASE_LOCK(vLockName);
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tTrain,
|
tTrain,
|
||||||
tmp.productionBuffer;
|
tmp.productionBuffer;
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`invoiceOut_newFromAddress`(
|
||||||
|
IN vAddressFk INT,
|
||||||
|
IN vSerial CHAR(2),
|
||||||
|
IN vMaxShipped DATE,
|
||||||
|
IN vCompanyFk INT,
|
||||||
|
IN vTaxArea VARCHAR(25),
|
||||||
|
IN vRef VARCHAR(25),
|
||||||
|
OUT vInvoiceId INT)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Factura los tickets de un consignatario hasta una fecha dada
|
||||||
|
* @param vAddressFk Id del consignatario a facturar
|
||||||
|
* @param vSerial Serie de factura
|
||||||
|
* @param vMaxShipped Fecha hasta la cual cogerá tickets para facturar
|
||||||
|
* @param vCompanyFk Id de la empresa desde la que se factura
|
||||||
|
* @param vTaxArea Tipo de iva en relacion a la empresa y al cliente, NULL por defecto
|
||||||
|
* @param vRef Referencia de la factura en caso que se quiera forzar, NULL por defecto
|
||||||
|
* @return vInvoiceId factura
|
||||||
|
*/
|
||||||
|
DECLARE vIsRefEditable BOOLEAN;
|
||||||
|
|
||||||
|
IF vRef IS NOT NULL AND vSerial IS NOT NULL THEN
|
||||||
|
SELECT isRefEditable INTO vIsRefEditable
|
||||||
|
FROM invoiceOutSerial
|
||||||
|
WHERE code = vSerial;
|
||||||
|
|
||||||
|
IF NOT vIsRefEditable THEN
|
||||||
|
CALL util.throw('serial non editable');
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`;
|
||||||
|
CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice`
|
||||||
|
(PRIMARY KEY (`id`))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT id FROM ticket t
|
||||||
|
WHERE t.addressFk = vAddressFk
|
||||||
|
AND t.refFk IS NULL
|
||||||
|
AND t.companyFk = vCompanyFk
|
||||||
|
AND t.shipped BETWEEN
|
||||||
|
util.firstDayOfYear(vMaxShipped - INTERVAL 1 YEAR)
|
||||||
|
AND util.dayend(vMaxShipped);
|
||||||
|
|
||||||
|
CALL invoiceOut_new(vSerial, util.VN_CURDATE(), vTaxArea, vInvoiceId);
|
||||||
|
|
||||||
|
UPDATE invoiceOut
|
||||||
|
SET `ref` = vRef
|
||||||
|
WHERE id = vInvoiceId
|
||||||
|
AND vRef IS NOT NULL;
|
||||||
|
|
||||||
|
IF vSerial <> 'R' AND NOT ISNULL(vInvoiceId) AND vInvoiceId <> 0 THEN
|
||||||
|
CALL invoiceOutBooking(vInvoiceId);
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemMinimumQuantity_check`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemMinimumQuantity_check`(
|
||||||
vSelf INT,
|
vSelf INT,
|
||||||
vItemFk INT,
|
vItemFk INT,
|
||||||
vStarted DATE,
|
vStarted DATE,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`(
|
||||||
vSaleGroupFk INT(11)
|
vSaleGroupFk INT(11)
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(vShelvingFk VARCHAR(3), vList TEXT, vIsChecking BOOL, vWarehouseFk INT)
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(
|
||||||
|
vShelvingFk VARCHAR(3),
|
||||||
|
vList TEXT,
|
||||||
|
vIsChecking BOOL,
|
||||||
|
vWarehouseFk INT
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/* Recorre cada elemento en la colección vList.
|
/**
|
||||||
|
* Recorre cada elemento en la colección vList.
|
||||||
* Si el parámetro isChecking = FALSE, llama a itemShelving_add.
|
* Si el parámetro isChecking = FALSE, llama a itemShelving_add.
|
||||||
*
|
*
|
||||||
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
|
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
|
||||||
* ese shelving, actualizando los valores del campo vn.itemShelving.isChecked
|
* ese shelving, actualizando los valores del campo itemShelving.isChecked
|
||||||
*
|
*
|
||||||
* param vShelvingFk Identificador de vn.shelving
|
* @param vShelvingFk Identificador de shelving
|
||||||
* param vList JSON array con esta estructura: '[value1, value2, ...]'
|
* @param vList JSON array con esta estructura: '[value1, value2, ...]'
|
||||||
* param vIsChecking Define si hay que añadir o comprobar los items
|
* @param vIsChecking Define si hay que añadir o comprobar los items
|
||||||
* param vWarehouseFk Identificador de vn.warehouse
|
* @param vWarehouseFk Identificador de warehouse
|
||||||
*/
|
*/
|
||||||
DECLARE vListLength INT DEFAULT JSON_LENGTH(vList);
|
DECLARE vListLength INT DEFAULT JSON_LENGTH(vList);
|
||||||
DECLARE vCounter INT DEFAULT 0;
|
DECLARE vCounter INT DEFAULT 0;
|
||||||
|
@ -20,26 +26,27 @@ BEGIN
|
||||||
DECLARE vIsChecked BOOL;
|
DECLARE vIsChecked BOOL;
|
||||||
|
|
||||||
WHILE vCounter < vListLength DO
|
WHILE vCounter < vListLength DO
|
||||||
SET vPath = CONCAT('$[',vCounter,']');
|
SET vPath = CONCAT('$[', vCounter, ']');
|
||||||
SET vBarcode = JSON_EXTRACT(vList,vPath);
|
SET vBarcode = JSON_EXTRACT(vList, vPath);
|
||||||
SET vIsChecked = NULL;
|
SET vIsChecked = NULL;
|
||||||
IF vIsChecking THEN
|
IF vIsChecking THEN
|
||||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vIsChecked
|
SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
|
||||||
FROM vn.itemShelving
|
FROM itemShelving
|
||||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||||
AND itemFk = vItemFk;
|
AND itemFk = vItemFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF NOT (vIsChecking AND vIsChecked) THEN
|
IF NOT vIsChecking OR NOT vIsChecked THEN
|
||||||
CALL vn.itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
|
CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
UPDATE vn.itemShelving
|
UPDATE itemShelving
|
||||||
SET isChecked = vIsChecked
|
SET isChecked = vIsChecked
|
||||||
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk
|
||||||
AND itemFk = vItemFk AND isChecked IS NULL;
|
AND itemFk = vItemFk
|
||||||
|
AND isChecked IS NULL;
|
||||||
|
|
||||||
SET vCounter = vCounter + 1;
|
SET vCounter = vCounter + 1;
|
||||||
END WHILE;
|
END WHILE;
|
||||||
|
|
|
@ -52,13 +52,13 @@ BEGIN
|
||||||
FROM vn.sale s
|
FROM vn.sale s
|
||||||
JOIN vn.ticket t ON t.id = s.ticketFk
|
JOIN vn.ticket t ON t.id = s.ticketFk
|
||||||
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
||||||
WHERE t.shipped BETWEEN CURDATE() AND CURDATE() + INTERVAL vDaysInForward DAY
|
WHERE t.shipped >= CURDATE() + INTERVAL vDaysInForward DAY
|
||||||
AND iss.saleFk IS NULL
|
AND iss.saleFk IS NULL
|
||||||
AND t.warehouseFk = vWarehouseFk
|
AND t.warehouseFk = vWarehouseFk
|
||||||
GROUP BY s.itemFk
|
GROUP BY s.itemFk
|
||||||
)
|
)
|
||||||
SELECT i.id itemFk,
|
SELECT i.id itemFk,
|
||||||
CAST(sd.quantity AS INT) advanceable,
|
LEAST(CAST(sd.quantity AS INT), sk.stock) advanceable,
|
||||||
i.longName,
|
i.longName,
|
||||||
i.subName,
|
i.subName,
|
||||||
i.tag5,
|
i.tag5,
|
||||||
|
|
|
@ -15,13 +15,11 @@ proc: BEGIN
|
||||||
DECLARE vEndingDate DATETIME;
|
DECLARE vEndingDate DATETIME;
|
||||||
DECLARE vIsTodayRelative BOOLEAN;
|
DECLARE vIsTodayRelative BOOLEAN;
|
||||||
|
|
||||||
SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY
|
SELECT w.isTodayRelative, util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, pc.maxProductionScopeDays) DAY
|
||||||
INTO vEndingDate
|
INTO vIsTodayRelative,vEndingDate
|
||||||
FROM productionConfig;
|
FROM worker w
|
||||||
|
JOIN productionConfig pc
|
||||||
SELECT isTodayRelative INTO vIsTodayRelative
|
WHERE w.id = account.myUser_getId();
|
||||||
FROM worker
|
|
||||||
WHERE id = getUser(); -- Cambiar por account.myUser_getId(), falta dar permisos
|
|
||||||
|
|
||||||
CALL prepareTicketList(util.yesterday(), vEndingDate);
|
CALL prepareTicketList(util.yesterday(), vEndingDate);
|
||||||
|
|
||||||
|
@ -272,7 +270,6 @@ proc: BEGIN
|
||||||
AND lb.item_id = s.itemFk
|
AND lb.item_id = s.itemFk
|
||||||
JOIN buy b ON b.id = lb.buy_id
|
JOIN buy b ON b.id = lb.buy_id
|
||||||
JOIN packaging p ON p.id = b.packagingFk
|
JOIN packaging p ON p.id = b.packagingFk
|
||||||
JOIN productionConfig pc
|
|
||||||
SET pb.hasPlantTray = TRUE
|
SET pb.hasPlantTray = TRUE
|
||||||
WHERE p.isPlantTray
|
WHERE p.isPlantTray
|
||||||
AND s.quantity >= b.packing
|
AND s.quantity >= b.packing
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBought_calculate`(
|
||||||
vDated DATE
|
vDated DATE
|
||||||
)
|
)
|
||||||
proc: BEGIN
|
proc: BEGIN
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyedByWorker`(
|
|
||||||
vDated DATE,
|
|
||||||
vWorker INT
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Inserta el volumen de compra de un comprador
|
|
||||||
* en stockBuyed de acuerdo con la fecha.
|
|
||||||
*
|
|
||||||
* @param vDated Fecha de compra
|
|
||||||
* @param vWorker Id de trabajador
|
|
||||||
*/
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
|
|
||||||
(INDEX (userFk))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT requested, reserved, userFk
|
|
||||||
FROM stockBuyed
|
|
||||||
WHERE dated = vDated
|
|
||||||
AND userFk = vWorker;
|
|
||||||
|
|
||||||
DELETE FROM stockBuyed
|
|
||||||
WHERE dated = vDated
|
|
||||||
AND userFk = vWorker;
|
|
||||||
|
|
||||||
CALL item_calculateStock(vDated);
|
|
||||||
|
|
||||||
INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description)
|
|
||||||
SELECT it.workerFk,
|
|
||||||
SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000,
|
|
||||||
vDated,
|
|
||||||
sb.reserved,
|
|
||||||
sb.requested,
|
|
||||||
u.name
|
|
||||||
FROM itemType it
|
|
||||||
JOIN item i ON i.typeFk = it.id
|
|
||||||
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
|
|
||||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
|
||||||
JOIN warehouse wh ON wh.code = 'VNH'
|
|
||||||
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
|
|
||||||
AND bu.warehouseFk = wh.id
|
|
||||||
JOIN buy b ON b.id = bu.buyFk
|
|
||||||
JOIN volumeConfig vc
|
|
||||||
JOIN account.`user` u ON u.id = it.workerFk
|
|
||||||
LEFT JOIN tStockBuyed sb ON sb.userFk = it.workerFk
|
|
||||||
WHERE ic.display
|
|
||||||
AND it.workerFk = vWorker;
|
|
||||||
|
|
||||||
SELECT b.entryFk Id_Entrada,
|
|
||||||
i.id Id_Article,
|
|
||||||
i.name Article,
|
|
||||||
ti.quantity Cantidad,
|
|
||||||
(ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id))
|
|
||||||
/ (vc.trolleyM3 * 1000000) buyed,
|
|
||||||
b.packagingFk id_cubo,
|
|
||||||
b.packing
|
|
||||||
FROM tmp.item ti
|
|
||||||
JOIN item i ON i.id = ti.itemFk
|
|
||||||
JOIN itemType it ON i.typeFk = it.id
|
|
||||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
|
||||||
JOIN worker w ON w.id = it.workerFk
|
|
||||||
JOIN auctionConfig ac
|
|
||||||
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id
|
|
||||||
AND bu.warehouseFk = ac.warehouseFk
|
|
||||||
JOIN buy b ON b.id = bu.buyFk
|
|
||||||
JOIN volumeConfig vc
|
|
||||||
WHERE ic.display
|
|
||||||
AND w.id = vWorker;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.buyUltimate,
|
|
||||||
tmp.item,
|
|
||||||
tStockBuyed;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,70 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockBuyed_add`(
|
|
||||||
vDated DATE
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Inserta el volumen de compra por comprador
|
|
||||||
* en stockBuyed de acuerdo con la fecha.
|
|
||||||
*
|
|
||||||
* @param vDated Fecha de compra
|
|
||||||
*/
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tStockBuyed
|
|
||||||
(INDEX (userFk))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT requested, reserved, userFk
|
|
||||||
FROM stockBuyed
|
|
||||||
WHERE dated = vDated;
|
|
||||||
|
|
||||||
DELETE FROM stockBuyed WHERE dated = vDated;
|
|
||||||
|
|
||||||
CALL item_calculateStock(vDated);
|
|
||||||
|
|
||||||
INSERT INTO stockBuyed(userFk, buyed, `dated`, description)
|
|
||||||
SELECT it.workerFk,
|
|
||||||
SUM((ti.quantity / b.packing) * buy_getVolume(b.id)) / vc.palletM3 / 1000000,
|
|
||||||
vDated,
|
|
||||||
u.name
|
|
||||||
FROM itemType it
|
|
||||||
JOIN item i ON i.typeFk = it.id
|
|
||||||
LEFT JOIN tmp.item ti ON ti.itemFk = i.id
|
|
||||||
JOIN itemCategory ic ON ic.id = it.categoryFk
|
|
||||||
JOIN warehouse wh ON wh.code = 'VNH'
|
|
||||||
JOIN tmp.buyUltimate bu ON bu.itemFk = i.id AND bu.warehouseFk = wh.id
|
|
||||||
JOIN buy b ON b.id = bu.buyFk
|
|
||||||
JOIN volumeConfig vc
|
|
||||||
JOIN account.`user` u ON u.id = it.workerFk
|
|
||||||
JOIN workerDepartment wd ON wd.workerFk = u.id
|
|
||||||
JOIN department d ON d.id = wd.departmentFk
|
|
||||||
WHERE ic.display
|
|
||||||
AND d.code IN ('shopping', 'logistic', 'franceTeam')
|
|
||||||
GROUP BY it.workerFk;
|
|
||||||
|
|
||||||
INSERT INTO stockBuyed(buyed, dated, description)
|
|
||||||
SELECT SUM(ic.cm3 * ito.quantity / vc.palletM3 / 1000000),
|
|
||||||
vDated,
|
|
||||||
IF(c.code = 'ES', p.name, c.name) destiny
|
|
||||||
FROM itemTicketOut ito
|
|
||||||
JOIN ticket t ON t.id = ito.ticketFk
|
|
||||||
JOIN `address` a ON a.id = t.addressFk
|
|
||||||
JOIN province p ON p.id = a.provinceFk
|
|
||||||
JOIN country c ON c.id = p.countryFk
|
|
||||||
JOIN warehouse wh ON wh.id = t.warehouseFk
|
|
||||||
JOIN itemCost ic ON ic.itemFk = ito.itemFk
|
|
||||||
AND ic.warehouseFk = t.warehouseFk
|
|
||||||
JOIN volumeConfig vc
|
|
||||||
WHERE ito.shipped BETWEEN vDated AND util.dayend(vDated)
|
|
||||||
AND wh.code = 'VNH'
|
|
||||||
GROUP BY destiny;
|
|
||||||
|
|
||||||
UPDATE stockBuyed s
|
|
||||||
JOIN tStockBuyed ts ON ts.userFk = s.userFk
|
|
||||||
SET s.requested = ts.requested,
|
|
||||||
s.reserved = ts.reserved
|
|
||||||
WHERE s.dated = vDated;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.buyUltimate,
|
|
||||||
tmp.item,
|
|
||||||
tStockBuyed;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE vn.supplier_statementWithEntries(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE vn.supplier_statementWithEntries(
|
||||||
vSupplierFk INT,
|
vSupplierFk INT,
|
||||||
vCurrencyFk INT,
|
vCurrencyFk INT,
|
||||||
vCompanyFk INT,
|
vCompanyFk INT,
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketRefund_upsert`(
|
||||||
|
vRefundTicketFk INT,
|
||||||
|
vOriginalTicketFk INT
|
||||||
|
)
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Common code for ticketRefund triggers
|
||||||
|
*
|
||||||
|
* @param vRefundTicketFk
|
||||||
|
* @param vOriginalTicketFk
|
||||||
|
*/
|
||||||
|
DECLARE vIsDeleted BOOL;
|
||||||
|
|
||||||
|
SELECT COUNT(*) INTO vIsDeleted
|
||||||
|
FROM ticket
|
||||||
|
WHERE id IN (vRefundTicketFk, vOriginalTicketFk)
|
||||||
|
AND isDeleted;
|
||||||
|
|
||||||
|
IF vIsDeleted THEN
|
||||||
|
CALL util.throw('The refund ticket cannot be deleted tickets');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,14 +1,27 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`(
|
||||||
vSelf INT
|
vSelf INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Para un ticket se agrupa las diferentes líneas de venta de un mismo artículo en una sola
|
||||||
|
* siempre y cuando tengan el mismo precio y dto.
|
||||||
|
*
|
||||||
|
* @param vSelf Id de ticket
|
||||||
|
*/
|
||||||
|
DECLARE vHasSalesToMerge BOOL;
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||||
BEGIN
|
BEGIN
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
RESIGNAL;
|
RESIGNAL;
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SELECT id INTO vSelf
|
||||||
|
FROM ticket
|
||||||
|
WHERE id = vSelf FOR UPDATE;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
|
CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
|
||||||
(PRIMARY KEY (id))
|
(PRIMARY KEY (id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -18,26 +31,24 @@ BEGIN
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
JOIN itemType it ON it.id = i.typeFk
|
||||||
WHERE s.ticketFk = vSelf
|
WHERE s.ticketFk = vSelf
|
||||||
AND it.isMergeable
|
AND it.isMergeable
|
||||||
GROUP BY s.itemFk, s.price, s.discount;
|
GROUP BY s.itemFk, s.price, s.discount
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
START TRANSACTION;
|
SELECT COUNT(*) INTO vHasSalesToMerge FROM tSalesToPreserve;
|
||||||
|
|
||||||
|
IF vHasSalesToMerge THEN
|
||||||
UPDATE sale s
|
UPDATE sale s
|
||||||
JOIN tSalesToPreserve stp ON stp.id = s.id
|
JOIN tSalesToPreserve stp ON stp.id = s.id
|
||||||
SET s.quantity = newQuantity
|
SET s.quantity = newQuantity;
|
||||||
WHERE s.ticketFk = vSelf;
|
|
||||||
|
|
||||||
DELETE s.*
|
DELETE s
|
||||||
FROM sale s
|
FROM sale s
|
||||||
LEFT JOIN tSalesToPreserve stp ON stp.id = s.id
|
JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk
|
||||||
JOIN item i ON i.id = s.itemFk
|
|
||||||
JOIN itemType it ON it.id = i.typeFk
|
|
||||||
WHERE s.ticketFk = vSelf
|
WHERE s.ticketFk = vSelf
|
||||||
AND stp.id IS NULL
|
AND s.id <> stp.id;
|
||||||
AND it.isMergeable;
|
END IF;
|
||||||
|
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tSalesToPreserve;
|
DROP TEMPORARY TABLE tSalesToPreserve;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`(
|
||||||
vClientFk INT
|
vClientFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolume`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setVolume`(
|
||||||
vSelf INT
|
vSelf INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolumeItemCost`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setVolumeItemCost`(
|
||||||
vItemFk INT
|
vItemFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -3,83 +3,62 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
|
||||||
vSelf INT,
|
vSelf INT,
|
||||||
vOriginalItemPackingTypeFk VARCHAR(1)
|
vOriginalItemPackingTypeFk VARCHAR(1)
|
||||||
)
|
)
|
||||||
BEGIN
|
proc:BEGIN
|
||||||
/**
|
/**
|
||||||
* Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
|
* Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado.
|
||||||
* Respeta el id inicial para el tipo propuesto.
|
* Respeta el id de ticket original para el tipo de empaquetado propuesto.
|
||||||
*
|
*
|
||||||
* @param vSelf Id ticket
|
* @param vSelf Id ticket
|
||||||
* @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
|
* @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original
|
||||||
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
||||||
*/
|
*/
|
||||||
DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
|
|
||||||
DECLARE vNewTicketFk INT;
|
|
||||||
DECLARE vPackingTypesToSplit INT;
|
|
||||||
DECLARE vDone INT DEFAULT FALSE;
|
DECLARE vDone INT DEFAULT FALSE;
|
||||||
|
DECLARE vHasItemPackingType BOOL;
|
||||||
|
DECLARE vItemPackingTypeFk INT;
|
||||||
|
DECLARE vNewTicketFk INT;
|
||||||
|
|
||||||
DECLARE vSaleGroup CURSOR FOR
|
DECLARE vItemPackingTypes CURSOR FOR
|
||||||
SELECT itemPackingTypeFk
|
SELECT DISTINCT itemPackingTypeFk
|
||||||
FROM tSaleGroup
|
FROM tSalesToMove;
|
||||||
WHERE itemPackingTypeFk IS NOT NULL
|
|
||||||
ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
|
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
START TRANSACTION;
|
SELECT COUNT(*) INTO vHasItemPackingType
|
||||||
|
FROM ticket t
|
||||||
SELECT id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
FROM sale
|
|
||||||
WHERE ticketFk = vSelf
|
|
||||||
AND NOT quantity
|
|
||||||
FOR UPDATE;
|
|
||||||
|
|
||||||
DELETE FROM sale
|
|
||||||
WHERE NOT quantity
|
|
||||||
AND ticketFk = vSelf;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSale
|
|
||||||
(PRIMARY KEY (id))
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros
|
|
||||||
FROM sale s
|
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
LEFT JOIN saleVolume sv ON sv.saleFk = s.id
|
WHERE t.id = vSelf
|
||||||
WHERE s.ticketFk = vSelf;
|
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
|
|
||||||
ENGINE = MEMORY
|
|
||||||
SELECT itemPackingTypeFk, SUM(litros) totalLitros
|
|
||||||
FROM tSale
|
|
||||||
GROUP BY itemPackingTypeFk;
|
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vPackingTypesToSplit
|
|
||||||
FROM tSaleGroup
|
|
||||||
WHERE itemPackingTypeFk IS NOT NULL;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
|
||||||
ticketFk INT,
|
ticketFk INT,
|
||||||
itemPackingTypeFk VARCHAR(1)
|
itemPackingTypeFk VARCHAR(1)
|
||||||
) ENGINE = MEMORY;
|
) ENGINE=MEMORY
|
||||||
|
SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk;
|
||||||
|
|
||||||
CASE vPackingTypesToSplit
|
IF NOT vHasItemPackingType THEN
|
||||||
WHEN 0 THEN
|
LEAVE proc;
|
||||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
END IF;
|
||||||
VALUES(vSelf, vItemPackingTypeFk);
|
|
||||||
WHEN 1 THEN
|
|
||||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
|
||||||
SELECT vSelf, itemPackingTypeFk
|
|
||||||
FROM tSaleGroup
|
|
||||||
WHERE itemPackingTypeFk IS NOT NULL;
|
|
||||||
ELSE
|
|
||||||
OPEN vSaleGroup;
|
|
||||||
FETCH vSaleGroup INTO vItemPackingTypeFk;
|
|
||||||
|
|
||||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove (
|
||||||
VALUES(vSelf, vItemPackingTypeFk);
|
ticketFk INT,
|
||||||
|
saleFk INT,
|
||||||
|
itemPackingTypeFk INT
|
||||||
|
) ENGINE=MEMORY;
|
||||||
|
|
||||||
|
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
|
||||||
|
SELECT s.id, i.itemPackingTypeFk
|
||||||
|
FROM ticket t
|
||||||
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
WHERE t.id = vSelf
|
||||||
|
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
|
||||||
|
|
||||||
|
OPEN vItemPackingTypes;
|
||||||
|
|
||||||
l: LOOP
|
l: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vSaleGroup INTO vItemPackingTypeFk;
|
FETCH vItemPackingTypes INTO vItemPackingTypeFk;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
|
@ -87,40 +66,24 @@ BEGIN
|
||||||
|
|
||||||
CALL ticket_Clone(vSelf, vNewTicketFk);
|
CALL ticket_Clone(vSelf, vNewTicketFk);
|
||||||
|
|
||||||
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
|
UPDATE tSalesToMove
|
||||||
VALUES(vNewTicketFk, vItemPackingTypeFk);
|
SET ticketFk = vNewTicketFk
|
||||||
|
WHERE itemPackingTypeFk = vItemPackingTypeFk;
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE vSaleGroup;
|
CLOSE vItemPackingTypes;
|
||||||
|
|
||||||
SELECT s.id
|
|
||||||
FROM sale s
|
|
||||||
JOIN tSale ts ON ts.id = s.id
|
|
||||||
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
|
|
||||||
FOR UPDATE;
|
|
||||||
|
|
||||||
UPDATE sale s
|
UPDATE sale s
|
||||||
JOIN tSale ts ON ts.id = s.id
|
JOIN tSalesToMove stm ON stm.saleFk = s.id
|
||||||
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
|
SET s.ticketFk = stm.ticketFk
|
||||||
SET s.ticketFk = t.ticketFk;
|
WHERE stm.ticketFk;
|
||||||
|
|
||||||
SELECT itemPackingTypeFk INTO vItemPackingTypeFk
|
INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk)
|
||||||
FROM tSaleGroup sg
|
SELECT ticketFk, itemPackingTypeFk
|
||||||
WHERE sg.itemPackingTypeFk IS NOT NULL
|
FROM tSalesToMove
|
||||||
ORDER BY sg.itemPackingTypeFk
|
GROUP BY ticketFk;
|
||||||
LIMIT 1;
|
|
||||||
|
|
||||||
UPDATE sale s
|
DROP TEMPORARY TABLE tSalesToMove;
|
||||||
JOIN tSale ts ON ts.id = s.id
|
|
||||||
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk
|
|
||||||
SET s.ticketFk = t.ticketFk
|
|
||||||
WHERE ts.itemPackingTypeFk IS NULL;
|
|
||||||
END CASE;
|
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
|
||||||
tSale,
|
|
||||||
tSaleGroup;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`host_beforeInsert`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`host_beforeInsert`
|
||||||
BEFORE INSERT ON `host`
|
BEFORE INSERT ON `host`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert`
|
||||||
|
AFTER INSERT ON `itemShelving`
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO itemShelvingLog
|
||||||
|
SET itemShelvingFk = NEW.id,
|
||||||
|
workerFk = account.myUser_getId(),
|
||||||
|
accion = 'CREA REGISTRO',
|
||||||
|
itemFk = NEW.itemFk,
|
||||||
|
shelvingFk = NEW.shelvingFk,
|
||||||
|
visible = NEW.visible,
|
||||||
|
`grouping` = NEW.`grouping`,
|
||||||
|
packing = NEW.packing,
|
||||||
|
available = NEW.available;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert`
|
||||||
BEFORE INSERT ON `roadmap`
|
BEFORE INSERT ON `roadmap`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate`
|
||||||
BEFORE UPDATE ON `roadmap`
|
BEFORE UPDATE ON `roadmap`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeInsert`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeInsert`
|
||||||
BEFORE INSERT ON `saleGroupDetail`
|
BEFORE INSERT ON `saleGroupDetail`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroupDetail_afterDelete`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroupDetail_afterDelete`
|
||||||
AFTER DELETE ON `saleGroupDetail`
|
AFTER DELETE ON `saleGroupDetail`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeUpdate`
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`saleGroupDetail_beforeUpdate`
|
||||||
BEFORE UPDATE ON `saleGroupDetail`
|
BEFORE UPDATE ON `saleGroupDetail`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeInse
|
||||||
BEFORE INSERT ON `ticketRefund`
|
BEFORE INSERT ON `ticketRefund`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`ticketRefund_beforeUpda
|
||||||
BEFORE UPDATE ON `ticketRefund`
|
BEFORE UPDATE ON `ticketRefund`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL ticketRefund_upsert(NEW.refundTicketFk, NEW.originalTicketFk);
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -4,5 +4,14 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_befor
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
|
IF NEW.travelFk IS NULL AND
|
||||||
|
(SELECT COUNT(*) FROM travelThermograph
|
||||||
|
WHERE thermographFk = NEW.thermographFk
|
||||||
|
AND travelFk IS NULL
|
||||||
|
AND id <> NEW.id) > 0
|
||||||
|
THEN
|
||||||
|
CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -4,5 +4,14 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`travelThermograph_befor
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
|
IF NEW.travelFk IS NULL AND
|
||||||
|
(SELECT COUNT(*) FROM travelThermograph
|
||||||
|
WHERE thermographFk = NEW.thermographFk
|
||||||
|
AND travelFk IS NULL
|
||||||
|
AND id <> NEW.id) > 0
|
||||||
|
THEN
|
||||||
|
CALL util.throw('Duplicate thermographFk without travelFk not allowed.');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -2,12 +2,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
||||||
SQL SECURITY DEFINER
|
SQL SECURITY DEFINER
|
||||||
VIEW `vn`.`buyer`
|
VIEW `vn`.`buyer`
|
||||||
AS SELECT DISTINCT `u`.`id` AS `userFk`,
|
AS SELECT DISTINCT `u`.`id` AS `userFk`,
|
||||||
`u`.`nickname` AS `nickname`,
|
`u`.`nickname` AS `nickname`
|
||||||
`ic`.`display` AS `display`
|
|
||||||
FROM (
|
FROM (
|
||||||
`account`.`user` `u`
|
`account`.`user` `u`
|
||||||
JOIN `vn`.`itemType` `it` ON(`it`.`workerFk` = `u`.`id`)
|
JOIN `vn`.`itemType` `it` ON(`it`.`workerFk` = `u`.`id`)
|
||||||
JOIN `vn`.`itemCategory` `ic` ON(`ic`.`id` = `it`.`categoryFk`)
|
|
||||||
)
|
)
|
||||||
WHERE `u`.`active` <> 0
|
WHERE `u`.`active` <> 0
|
||||||
ORDER BY `u`.`nickname`
|
ORDER BY `u`.`nickname`
|
||||||
|
|
|
@ -13,6 +13,5 @@ AS SELECT `am`.`id` AS `Id_Agencia`,
|
||||||
`am`.`reportMail` AS `send_mail`,
|
`am`.`reportMail` AS `send_mail`,
|
||||||
`am`.`isActive` AS `tpv`,
|
`am`.`isActive` AS `tpv`,
|
||||||
`am`.`code` AS `code`,
|
`am`.`code` AS `code`,
|
||||||
`am`.`showAgencyName` AS `show_AgencyName`,
|
|
||||||
`am`.`isRiskFree` AS `isRiskFree`
|
`am`.`isRiskFree` AS `isRiskFree`
|
||||||
FROM `vn`.`agencyMode` `am`
|
FROM `vn`.`agencyMode` `am`
|
||||||
|
|
|
@ -17,5 +17,6 @@ AS SELECT `p`.`id` AS `Id_Cubo`,
|
||||||
`p`.`upload` AS `Suben`,
|
`p`.`upload` AS `Suben`,
|
||||||
`p`.`base` AS `Base`,
|
`p`.`base` AS `Base`,
|
||||||
`p`.`isBox` AS `box`,
|
`p`.`isBox` AS `box`,
|
||||||
`p`.`returnCost` AS `costeRetorno`
|
`p`.`returnCost` AS `costeRetorno`,
|
||||||
|
`p`.`isActive` AS `isActive`
|
||||||
FROM `vn`.`packaging` `p`
|
FROM `vn`.`packaging` `p`
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
UPDATE vn.itemShelving
|
||||||
|
SET isChecked = TRUE
|
||||||
|
WHERE isChecked;
|
||||||
|
|
||||||
|
UPDATE vn.itemShelving
|
||||||
|
SET isChecked = FALSE
|
||||||
|
WHERE NOT isChecked;
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE vn.agencyMode
|
||||||
|
CHANGE IF EXISTS showAgencyName showAgencyName__ tinyint(1) DEFAULT 1 COMMENT '@deprecated 2024-09-24';
|
|
@ -0,0 +1,31 @@
|
||||||
|
-- vn.priceDelta definition
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE vn.priceDelta (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`itemTypeFk` smallint(5) unsigned NOT NULL,
|
||||||
|
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
|
||||||
|
`maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size',
|
||||||
|
`inkFk` varchar(3) DEFAULT NULL,
|
||||||
|
`originFk` tinyint(2) unsigned DEFAULT NULL,
|
||||||
|
`producerFk` mediumint(3) unsigned DEFAULT NULL,
|
||||||
|
`fromDated` date DEFAULT NULL,
|
||||||
|
`toDated` date DEFAULT NULL,
|
||||||
|
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
|
||||||
|
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
|
||||||
|
`warehouseFk` smallint(6) unsigned NOT NULL,
|
||||||
|
`created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
|
||||||
|
KEY `priceDelta_ink_FK` (`inkFk`),
|
||||||
|
KEY `priceDelta_producer_FK` (`producerFk`),
|
||||||
|
KEY `priceDelta_warehouse_FK` (`warehouseFk`),
|
||||||
|
KEY `priceDelta_worker_FK` (`editorFk`),
|
||||||
|
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
|
||||||
|
|
||||||
|
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer;
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
-- vn.priceDelta definition
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE vn.priceDelta (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`itemTypeFk` smallint(5) unsigned NOT NULL,
|
||||||
|
`minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size',
|
||||||
|
`maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size',
|
||||||
|
`inkFk` varchar(3) DEFAULT NULL,
|
||||||
|
`originFk` tinyint(2) unsigned DEFAULT NULL,
|
||||||
|
`producerFk` mediumint(3) unsigned DEFAULT NULL,
|
||||||
|
`fromDated` date DEFAULT NULL,
|
||||||
|
`toDated` date DEFAULT NULL,
|
||||||
|
`absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price',
|
||||||
|
`ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price',
|
||||||
|
`warehouseFk` smallint(6) unsigned NOT NULL,
|
||||||
|
`created` timestamp NOT NULL DEFAULT current_timestamp(),
|
||||||
|
`editorFk` int(10) unsigned DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `priceDelta_itemType_FK` (`itemTypeFk`),
|
||||||
|
KEY `priceDelta_ink_FK` (`inkFk`),
|
||||||
|
KEY `priceDelta_producer_FK` (`producerFk`),
|
||||||
|
KEY `priceDelta_warehouse_FK` (`warehouseFk`),
|
||||||
|
KEY `priceDelta_worker_FK` (`editorFk`),
|
||||||
|
CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items';
|
||||||
|
|
||||||
|
GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer;
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL COMMENT 'Application area for the bonus component';
|
||||||
|
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk) REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,4 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
RENAME TABLE vn.stockBuyed TO vn.stockBuyed__;
|
||||||
|
ALTER TABLE vn.stockBuyed__
|
||||||
|
COMMENT='@deprecated 2024-10-01 rename and refactor to stockBought';
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.address MODIFY COLUMN isEqualizated tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.chat MODIFY COLUMN checkUserStatus tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE vn.warehouse
|
||||||
|
MODIFY COLUMN isOrigin tinyint(1) DEFAULT FALSE NOT NULL,
|
||||||
|
MODIFY COLUMN isDestiny tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.zoneIncluded MODIFY COLUMN isIncluded tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE bs.defaulter MODIFY COLUMN hasChanged tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE account.user MODIFY COLUMN emailVerified tinyint(1) DEFAULT FALSE NOT NULL;
|
|
@ -0,0 +1,3 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE hedera.`order` ADD IF NOT EXISTS rowUpdated DATETIME NULL
|
||||||
|
COMMENT 'Timestamp for last updated record in orderRow table';
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk)
|
||||||
|
REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
|
||||||
|
ALTER TABLE vn.priceDelta ADD IF NOT EXISTS zoneGeoFk int(11) NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.priceDelta ADD CONSTRAINT priceDelta_zoneGeo_FK FOREIGN KEY IF NOT EXISTS (zoneGeoFk)
|
||||||
|
REFERENCES vn.zoneGeo (`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,24 @@
|
||||||
|
ALTER TABLE `vn`.`packaging`
|
||||||
|
ADD COLUMN IF NOT EXISTS `isActive` TINYINT(1) DEFAULT 1;
|
||||||
|
|
||||||
|
UPDATE vn.packaging
|
||||||
|
SET isActive = FALSE
|
||||||
|
WHERE id IN('06x04x06','07x04x03','1000','100SM','1031','104','105','1060','10x04x06','10x04x07','1100','118','119','1200','129','1300',
|
||||||
|
'134','146','147','148','158','159','17x01x02','17X01X03','17x01x04','17x01x05','18X01X04','198','199',
|
||||||
|
'20P','20x01x03','246','273','278','279','280','290','359','37247','382','40P','453','463','464','465','466',
|
||||||
|
'467','469','471','473','494','508','509','511','512','514','515','516','518','519-50B','575','598-3x6','604','605','606',
|
||||||
|
'607','609','647','67515','676','680','682','685','687','688','691','692','693','694','695','730','751','7808','790','7910',
|
||||||
|
'7920','79450','7950','7952','7960','7976','7982','7986','7988',
|
||||||
|
'7993','8000','8046','8049','8053','8057','8058','8065','8076','8085','8086','8088',
|
||||||
|
'8091','8095','8096','8097','8101','8106','8108','8110','8112','8124','8134','8140','8141','8143','8145','8149','8150',
|
||||||
|
'8170','8174','8192','8200','8210','8249','8270','8275','8288','8300','8350','8375','8399','8400','8420','845','847','8480','8500',
|
||||||
|
'855','858','8600','862','869','871','872','8720','878','879','880','8800','882','885','910','911','912','914','916','917','918','919',
|
||||||
|
'920','921','922','923','924','925','926','927','930','9300','932','934','935','936','938','942','948','9600','980','984','9920',
|
||||||
|
'B20x16','B43x13','Bande Rota','bb3','Bcesta','BcestaOVAL','BcestaRED','Bcirios','BciriosG','BjarronBLN','BjarronNGR',
|
||||||
|
'Btazon','Bvelas','cactus200','Caja040','CajaTGLF','CC Alza Pl','CC_falso',
|
||||||
|
'EB-RSMINA','EMB 1_4','EMB 2_5','espuma','FB-BENCH','granel','Grenex','guzma1200','guzma1400','guzma330','guzma400','guzma650','guzma900','HB-ALEX',
|
||||||
|
'HB-APOSENT','HB-MAGIC','HB-NATUF','HB-RSMINA','HB-TES-RSR','HB068','HB117','HB2-CIRCA','JB-AROMA','jumboX3','kalan330','kalan400',
|
||||||
|
'kalan577','kalan900','L12','L120','L14','L2-120','L200','L3-120','L4-120','L44','L6','L6-180','L8','L8-200','MB-BENCH','MBOLA','mc_11',
|
||||||
|
'mc_13','Msp','NO VALIDO','NO-002','PANIC','PBLG','PISOCC/3','PISOCC/4','PISOCC/5','PISOCC/6',
|
||||||
|
'procona','QB-CARDENA','QB-PANDERO','QB-TES-RSR','QB7-TOSCA','QB9-TOSCA','RB-BENCH','SemiEuroPa','spolette','t_flori11','T26x23',
|
||||||
|
'T26x25','T27x24','T27x30','T28x26','T30x24','T33x30','THA50','ti_13','Tumbado','UB-BENCH')
|
|
@ -1,68 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('SmartTable SearchBar integration', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('salesPerson', 'item');
|
|
||||||
await page.waitToClick(selectors.globalItems.searchButton);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search by type in searchBar, reload page and have same results', async() => {
|
|
||||||
await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton);
|
|
||||||
await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium');
|
|
||||||
await page.waitToClick(selectors.itemsIndex.advancedSearchButton);
|
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
|
|
||||||
|
|
||||||
await page.reload({
|
|
||||||
waitUntil: 'networkidle2'
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 4);
|
|
||||||
|
|
||||||
await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2);
|
|
||||||
|
|
||||||
await page.reload({
|
|
||||||
waitUntil: 'networkidle2'
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should filter in section without smart-table and search in searchBar go to zone section', async() => {
|
|
||||||
await page.loginAndModule('salesPerson', 'zone');
|
|
||||||
await page.waitToClick(selectors.globalItems.searchButton);
|
|
||||||
|
|
||||||
await page.doSearch('A');
|
|
||||||
const firstCount = await page.countElement(selectors.zoneIndex.searchResult);
|
|
||||||
|
|
||||||
await page.doSearch('A');
|
|
||||||
const secondCount = await page.countElement(selectors.zoneIndex.searchResult);
|
|
||||||
|
|
||||||
expect(firstCount).toEqual(7);
|
|
||||||
expect(secondCount).toEqual(7);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should order orders by first id and order by last id, reload page and have same order', async() => {
|
|
||||||
await page.loginAndModule('developer', 'item');
|
|
||||||
await page.accessToSection('item.fixedPrice');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
|
|
||||||
await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '1');
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.itemFixedPrice.orderColumnId);
|
|
||||||
await page.reload({
|
|
||||||
waitUntil: 'networkidle2'
|
|
||||||
});
|
|
||||||
await page.waitForTextInField(selectors.itemFixedPrice.firstItemID, '3');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,42 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Travel create path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create a new travel and check it was created with the correct data', async() => {
|
|
||||||
const date = Date.vnNew();
|
|
||||||
date.setDate(15);
|
|
||||||
date.setUTCHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.travelIndex.newTravelButton);
|
|
||||||
await page.waitForState('travel.create');
|
|
||||||
|
|
||||||
const values = {
|
|
||||||
reference: 'Testing reference',
|
|
||||||
agencyMode: 'inhouse pickup',
|
|
||||||
shipped: date,
|
|
||||||
landed: date,
|
|
||||||
warehouseOut: 'Warehouse One',
|
|
||||||
warehouseIn: 'Warehouse Five'
|
|
||||||
};
|
|
||||||
|
|
||||||
const message = await page.sendForm('vn-travel-create form', values);
|
|
||||||
await page.waitForState('travel.card.basicData');
|
|
||||||
const formValues = await page.fetchForm('vn-travel-basic-data form', Object.keys(values));
|
|
||||||
|
|
||||||
expect(message.isSuccess).toBeTrue();
|
|
||||||
expect(formValues).toEqual(values);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,97 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Travel basic data path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.accessToSection('travel.card.basicData');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reach the thermograph section', async() => {
|
|
||||||
await page.waitForState('travel.card.basicData');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should set a wrong delivery date then receive an error on submit', async() => {
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
await page.write(selectors.travelIndex.generalSearchFilter, '4');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.accessToSection('travel.card.basicData');
|
|
||||||
await page.waitForState('travel.card.basicData');
|
|
||||||
|
|
||||||
const lastMonth = Date.vnNew();
|
|
||||||
lastMonth.setMonth(lastMonth.getMonth() - 2);
|
|
||||||
|
|
||||||
await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth);
|
|
||||||
await page.waitToClick(selectors.travelBasicData.save);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Landing cannot be lesser than shipment');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should undo the changes', async() => {
|
|
||||||
await page.clearInput(selectors.travelBasicData.reference);
|
|
||||||
await page.write(selectors.travelBasicData.reference, 'totally pointless ref');
|
|
||||||
await page.waitToClick(selectors.travelBasicData.undoChanges);
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('fourth travel');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should now edit the whole form then save', async() => {
|
|
||||||
await page.clearInput(selectors.travelBasicData.reference);
|
|
||||||
await page.write(selectors.travelBasicData.reference, 'new reference!');
|
|
||||||
await page.autocompleteSearch(selectors.travelBasicData.agency, 'Entanglement');
|
|
||||||
await page.autocompleteSearch(selectors.travelBasicData.outputWarehouse, 'Warehouse Three');
|
|
||||||
await page.autocompleteSearch(selectors.travelBasicData.inputWarehouse, 'Warehouse Four');
|
|
||||||
await page.waitToClick(selectors.travelBasicData.delivered);
|
|
||||||
await page.waitToClick(selectors.travelBasicData.received);
|
|
||||||
await page.waitToClick(selectors.travelBasicData.save);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the section and check the reference was saved', async() => {
|
|
||||||
await page.reloadSection('travel.card.basicData');
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('new reference!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the agency was saved', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelBasicData.agency, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('Entanglement');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the output warehouse date was saved', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelBasicData.outputWarehouse, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('Warehouse Three');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check the input warehouse date was saved', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelBasicData.inputWarehouse, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('Warehouse Four');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => {
|
|
||||||
await page.waitForClassPresent(selectors.travelBasicData.delivered, 'checked');
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
|
||||||
await page.waitForClassPresent(selectors.travelBasicData.received, 'checked');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,36 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Travel descriptor path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.waitForState('travel.card.summary');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should click the descriptor button to navigate to the travel index showing all travels with current agency', async() => {
|
|
||||||
await page.waitToClick(selectors.travelDescriptor.filterByAgencyButton);
|
|
||||||
await page.waitForState('travel.index');
|
|
||||||
const result = await page.countElement(selectors.travelIndex.anySearchResult);
|
|
||||||
|
|
||||||
expect(result).toBeGreaterThanOrEqual(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should navigate to the first search result', async() => {
|
|
||||||
await page.waitToClick(selectors.travelIndex.firstSearchResult);
|
|
||||||
await page.waitForState('travel.card.summary');
|
|
||||||
const state = await page.getState();
|
|
||||||
|
|
||||||
expect(state).toBe('travel.card.summary');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,42 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Travel extra community path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
await page.accessToSection('travel.extraCommunity');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit the travel reference and the locked kilograms', async() => {
|
|
||||||
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
|
||||||
await page.waitForSpinnerLoad();
|
|
||||||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
|
||||||
await page.waitForSpinnerLoad();
|
|
||||||
await page.writeOnEditableTD(selectors.travelExtraCommunity.firstTravelLockedKg, '1500');
|
|
||||||
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reload the index and confirm the reference and locked kg were edited', async() => {
|
|
||||||
await page.accessToSection('travel.index');
|
|
||||||
await page.accessToSection('travel.extraCommunity');
|
|
||||||
await page.waitToClick(selectors.travelExtraCommunity.removeContinentFilter);
|
|
||||||
await page.waitForTextInElement(selectors.travelExtraCommunity.firstTravelReference, 'edited reference');
|
|
||||||
const reference = await page.getProperty(selectors.travelExtraCommunity.firstTravelReference, 'innerText');
|
|
||||||
const lockedKg = await page.getProperty(selectors.travelExtraCommunity.firstTravelLockedKg, 'innerText');
|
|
||||||
|
|
||||||
expect(reference).toContain('edited reference');
|
|
||||||
expect(lockedKg).toContain(1500);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,64 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Travel thermograph path', () => {
|
|
||||||
const thermographName = '7H3-37H3RN4L-FL4M3';
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
await page.accessToSection('travel.card.thermograph.index');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reach the thermograph section', async() => {
|
|
||||||
await page.waitForState('travel.card.thermograph.index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should click the add thermograph floating button', async() => {
|
|
||||||
await page.waitToClick(selectors.travelThermograph.add);
|
|
||||||
await page.waitForState('travel.card.thermograph.create');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should click on the add thermograph icon of the thermograph autocomplete', async() => {
|
|
||||||
await page.waitToClick(selectors.travelThermograph.addThermographIcon);
|
|
||||||
await page.write(selectors.travelThermograph.newThermographId, thermographName);
|
|
||||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographModel, 'TEMPMATE');
|
|
||||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographWarehouse, 'Warehouse Two');
|
|
||||||
await page.autocompleteSearch(selectors.travelThermograph.newThermographTemperature, 'Warm');
|
|
||||||
await page.waitToClick(selectors.travelThermograph.createThermographButton);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should select the file to upload', async() => {
|
|
||||||
let currentDir = process.cwd();
|
|
||||||
let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`;
|
|
||||||
|
|
||||||
const [fileChooser] = await Promise.all([
|
|
||||||
page.waitForFileChooser(),
|
|
||||||
page.waitToClick(selectors.travelThermograph.uploadIcon)
|
|
||||||
]);
|
|
||||||
await fileChooser.accept([filePath]);
|
|
||||||
|
|
||||||
await page.waitToClick(selectors.travelThermograph.upload);
|
|
||||||
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
const state = await page.getState();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
expect(state).toBe('travel.card.thermograph.index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should check everything was saved correctly', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.travelThermograph.createdThermograph, 'innerText');
|
|
||||||
|
|
||||||
expect(result).toContain(thermographName);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,62 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Travel search panel path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
let httpRequest;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('buyer', 'travel');
|
|
||||||
page.on('request', req => {
|
|
||||||
if (req.url().includes(`Travels/filter`))
|
|
||||||
httpRequest = req.url();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should filter using all the fields', async() => {
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.write(selectors.travelIndex.generalSearchFilter, 'travel');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('search=travel');
|
|
||||||
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.autocompleteSearch(selectors.travelIndex.agencyFilter, 'Entanglement');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('agencyModeFk');
|
|
||||||
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.autocompleteSearch(selectors.travelIndex.warehouseOutFilter, 'Warehouse One');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('warehouseOutFk');
|
|
||||||
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.autocompleteSearch(selectors.travelIndex.warehouseInFilter, 'Warehouse Two');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('warehouseInFk');
|
|
||||||
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.overwrite(selectors.travelIndex.scopeDaysFilter, '15');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('scopeDays=15');
|
|
||||||
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.autocompleteSearch(selectors.travelIndex.continentFilter, 'Asia');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('continent');
|
|
||||||
|
|
||||||
await page.click(selectors.travelIndex.chip);
|
|
||||||
await page.write(selectors.travelIndex.totalEntriesFilter, '1');
|
|
||||||
await page.keyboard.press('Enter');
|
|
||||||
|
|
||||||
expect(httpRequest).toContain('totalEntries=1');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,104 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Zone basic data path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
|
|
||||||
await page.loginAndModule('deliveryAssistant',
|
|
||||||
'zone'); // turns up the zone module name and route aint the same lol
|
|
||||||
await page.accessToSearchResult('10');
|
|
||||||
await page.accessToSection('zone.card.basicData');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should reach the basic data section', async() => {
|
|
||||||
await page.waitForState('zone.card.basicData');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should edit de form and then save', async() => {
|
|
||||||
await page.clearInput(selectors.zoneBasicData.name);
|
|
||||||
await page.write(selectors.zoneBasicData.name, 'Brimstone teleportation');
|
|
||||||
await page.autocompleteSearch(selectors.zoneBasicData.agency, 'Quantum break device');
|
|
||||||
await page.clearInput(selectors.zoneBasicData.maxVolume);
|
|
||||||
await page.write(selectors.zoneBasicData.maxVolume, '10');
|
|
||||||
await page.clearInput(selectors.zoneBasicData.travelingDays);
|
|
||||||
await page.write(selectors.zoneBasicData.travelingDays, '1');
|
|
||||||
await page.clearInput(selectors.zoneBasicData.closing);
|
|
||||||
await page.pickTime(selectors.zoneBasicData.closing, '21:00');
|
|
||||||
await page.clearInput(selectors.zoneBasicData.price);
|
|
||||||
await page.write(selectors.zoneBasicData.price, '999');
|
|
||||||
await page.clearInput(selectors.zoneBasicData.bonus);
|
|
||||||
await page.write(selectors.zoneBasicData.bonus, '100');
|
|
||||||
await page.clearInput(selectors.zoneBasicData.inflation);
|
|
||||||
await page.write(selectors.zoneBasicData.inflation, '200');
|
|
||||||
await page.waitToClick(selectors.zoneBasicData.volumetric);
|
|
||||||
await page.waitToClick(selectors.zoneBasicData.saveButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Data saved!');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should now reload the section', async() => {
|
|
||||||
await page.reloadSection('zone.card.basicData');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the name was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.name, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('Brimstone teleportation');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the agency was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.agency, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('Quantum break device');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the max volume was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.maxVolume, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('10');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the traveling days were updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.travelingDays, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('1');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the closing hour was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.closing, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('21:00');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the price was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.price, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('999');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the bonus was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.bonus, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('100');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the inflation was updated', async() => {
|
|
||||||
const result = await page.waitToGetProperty(selectors.zoneBasicData.inflation, 'value');
|
|
||||||
|
|
||||||
expect(result).toEqual('200');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should confirm the volumetric checkbox was checked', async() => {
|
|
||||||
await page.waitForClassPresent(selectors.zoneBasicData.volumetric, 'checked');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,32 +0,0 @@
|
||||||
import selectors from '../../helpers/selectors.js';
|
|
||||||
import getBrowser from '../../helpers/puppeteer';
|
|
||||||
|
|
||||||
describe('Zone descriptor path', () => {
|
|
||||||
let browser;
|
|
||||||
let page;
|
|
||||||
|
|
||||||
beforeAll(async() => {
|
|
||||||
browser = await getBrowser();
|
|
||||||
page = browser.page;
|
|
||||||
await page.loginAndModule('deliveryAssistant', 'zone');
|
|
||||||
await page.accessToSearchResult('13');
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(async() => {
|
|
||||||
await browser.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should eliminate the zone using the descriptor option', async() => {
|
|
||||||
await page.waitToClick(selectors.zoneDescriptor.menu);
|
|
||||||
await page.waitToClick(selectors.zoneDescriptor.deleteZone);
|
|
||||||
await page.respondToDialog('accept');
|
|
||||||
await page.waitForState('zone.index');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should search for the deleted zone to find no results', async() => {
|
|
||||||
await page.doSearch('13');
|
|
||||||
const count = await page.countElement(selectors.zoneIndex.searchResult);
|
|
||||||
|
|
||||||
expect(count).toEqual(0);
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -57,7 +57,7 @@ export default class App {
|
||||||
|
|
||||||
getUrl(route, appName = 'lilium') {
|
getUrl(route, appName = 'lilium') {
|
||||||
const index = window.location.hash.indexOf(route.toLowerCase());
|
const index = window.location.hash.indexOf(route.toLowerCase());
|
||||||
const newRoute = index < 0 ? route : window.location.hash.substring(index);
|
let newRoute = index < 0 ? route : window.location.hash.substring(index);
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {and: [
|
where: {and: [
|
||||||
|
@ -66,6 +66,11 @@ export default class App {
|
||||||
]}
|
]}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (this.logger.$params.q)
|
||||||
|
newRoute = newRoute.concat(`?table=${this.logger.$params.q}`);
|
||||||
|
|
||||||
|
|
||||||
return this.logger.$http.get('Urls/findOne', {filter})
|
return this.logger.$http.get('Urls/findOne', {filter})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res && res.data)
|
if (res && res.data)
|
||||||
|
|
|
@ -235,10 +235,10 @@
|
||||||
"Cannot add holidays on this day": "Cannot add holidays on this day",
|
"Cannot add holidays on this day": "Cannot add holidays on this day",
|
||||||
"Cannot send mail": "Cannot send mail",
|
"Cannot send mail": "Cannot send mail",
|
||||||
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
|
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
|
||||||
|
"This postcode already exists": "This postcode already exists",
|
||||||
"Original invoice not found": "Original invoice not found",
|
"Original invoice not found": "Original invoice not found",
|
||||||
"There is already a tray with the same height": "There is already a tray with the same height",
|
"There is already a tray with the same height": "There is already a tray with the same height",
|
||||||
"The height must be greater than 50cm": "The height must be greater than 50cm",
|
"The height must be greater than 50cm": "The height must be greater than 50cm",
|
||||||
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
|
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm",
|
||||||
"This postcode already exists": "This postcode already exists",
|
"The quantity claimed cannot be greater than the quantity of the line": "The quantity claimed cannot be greater than the quantity of the line"
|
||||||
"This buyer has already made a reservation for this date": "This buyer has already made a reservation for this date"
|
|
||||||
}
|
}
|
|
@ -366,9 +366,11 @@
|
||||||
"The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
|
"The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
|
||||||
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono",
|
||||||
"Payment method is required": "El método de pago es obligatorio",
|
"Payment method is required": "El método de pago es obligatorio",
|
||||||
"Cannot send mail": "No se ha podido enviar el correo",
|
"Cannot send mail": "Não é possível enviar o email",
|
||||||
"CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos",
|
"CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos",
|
||||||
"The sale not exists in the item shelving": "La venta no existe en la estantería del artículo",
|
"The sale not exists in the item shelving": "La venta no existe en la estantería del artículo",
|
||||||
|
"The entry not have stickers": "La entrada no tiene etiquetas",
|
||||||
|
"Too many records": "Demasiados registros",
|
||||||
"Original invoice not found": "Factura original no encontrada",
|
"Original invoice not found": "Factura original no encontrada",
|
||||||
"The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
|
"The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
|
||||||
"Weight already set": "El peso ya está establecido",
|
"Weight already set": "El peso ya está establecido",
|
||||||
|
@ -377,7 +379,7 @@
|
||||||
"The height must be greater than 50cm": "La altura debe ser superior a 50cm",
|
"The height must be greater than 50cm": "La altura debe ser superior a 50cm",
|
||||||
"The maximum height of the wagon is 200cm": "La altura máxima es 200cm",
|
"The maximum height of the wagon is 200cm": "La altura máxima es 200cm",
|
||||||
"The entry does not have stickers": "La entrada no tiene etiquetas",
|
"The entry does not have stickers": "La entrada no tiene etiquetas",
|
||||||
"Too many records": "Demasiados registros",
|
|
||||||
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
|
"This buyer has already made a reservation for this date": "Este comprador ya ha hecho una reserva para esta fecha",
|
||||||
"No valid travel thermograph found": "No se encontró un termógrafo válido"
|
"No valid travel thermograph found": "No se encontró un termógrafo válido",
|
||||||
|
"The quantity claimed cannot be greater than the quantity of the line": "La cantidad reclamada no puede ser mayor que la cantidad de la línea"
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,6 +361,6 @@
|
||||||
"The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
|
"The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
|
||||||
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
|
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré",
|
||||||
"Cannot send mail": "Impossible d'envoyer le mail",
|
"Cannot send mail": "Impossible d'envoyer le mail",
|
||||||
"Original invoice not found": "Facture originale introuvable"
|
"Original invoice not found": "Facture originale introuvable",
|
||||||
|
"The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne"
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,5 +361,6 @@
|
||||||
"The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado",
|
"The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado",
|
||||||
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso",
|
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso",
|
||||||
"Original invoice not found": "Fatura original não encontrada",
|
"Original invoice not found": "Fatura original não encontrada",
|
||||||
"Cannot send mail": "Não é possível enviar o email"
|
"Cannot send mail": "Não é possível enviar o email",
|
||||||
|
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
|
|
||||||
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.rewriteDbError(function(err) {
|
Self.rewriteDbError(function(err) {
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
|
describe('ClaimBeginning model()', () => {
|
||||||
|
const claimFk = 1;
|
||||||
|
const activeCtx = {
|
||||||
|
accessToken: {userId: 18},
|
||||||
|
headers: {origin: 'localhost:5000'},
|
||||||
|
__: () => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change quantity claimed', async() => {
|
||||||
|
const tx = await models.ClaimBeginning.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const claim = await models.ClaimBeginning.findOne({where: {claimFk}}, options);
|
||||||
|
const sale = await models.Sale.findById(claim.saleFk, {}, options);
|
||||||
|
await claim.updateAttribute('quantity', sale.quantity - 1, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw error when quantity claimed is greater than quantity of the sale', async() => {
|
||||||
|
const tx = await models.ClaimBeginning.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
const claim = await models.ClaimBeginning.findOne({where: {claimFk}}, options);
|
||||||
|
const sale = await models.Sale.findById(claim.saleFk, {}, options);
|
||||||
|
await claim.updateAttribute('quantity', sale.quantity + 1, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
error = e;
|
||||||
|
await tx.rollback();
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.toString()).toContain('The quantity claimed cannot be greater than the quantity of the line');
|
||||||
|
});
|
||||||
|
});
|
|
@ -10,16 +10,21 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.observe('before save', async ctx => {
|
Self.observe('before save', async ctx => {
|
||||||
if (ctx.isNewInstance) {
|
|
||||||
const models = Self.app.models;
|
|
||||||
const options = ctx.options;
|
const options = ctx.options;
|
||||||
const instance = ctx.instance;
|
const models = Self.app.models;
|
||||||
const ticket = await models.Sale.findById(instance.saleFk, {fields: ['ticketFk']}, options);
|
const saleFk = ctx?.currentInstance?.saleFk || ctx?.instance?.saleFk;
|
||||||
const claim = await models.Claim.findById(instance.claimFk, {fields: ['ticketFk']}, options);
|
const sale = await models.Sale.findById(saleFk, {fields: ['ticketFk', 'quantity']}, options);
|
||||||
if (ticket.ticketFk != claim.ticketFk)
|
|
||||||
|
if (ctx.isNewInstance) {
|
||||||
|
const claim = await models.Claim.findById(ctx.instance.claimFk, {fields: ['ticketFk']}, options);
|
||||||
|
if (sale.ticketFk != claim.ticketFk)
|
||||||
throw new UserError(`Cannot create a new claimBeginning from a different ticket`);
|
throw new UserError(`Cannot create a new claimBeginning from a different ticket`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await claimIsEditable(ctx);
|
await claimIsEditable(ctx);
|
||||||
|
|
||||||
|
if (sale?.quantity && ctx.data?.quantity && ctx.data.quantity > sale?.quantity)
|
||||||
|
throw new UserError('The quantity claimed cannot be greater than the quantity of the line');
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.observe('before delete', async ctx => {
|
Self.observe('before delete', async ctx => {
|
||||||
|
|
|
@ -106,10 +106,15 @@ module.exports = Self => {
|
||||||
description: `The to shipped date filter`
|
description: `The to shipped date filter`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'days',
|
arg: 'daysOnward',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
description: `N days interval`
|
description: `N days interval`
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'daysAgo',
|
||||||
|
type: 'number',
|
||||||
|
description: `N days ago interval`
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'invoiceAmount',
|
arg: 'invoiceAmount',
|
||||||
type: 'number',
|
type: 'number',
|
||||||
|
@ -216,16 +221,29 @@ module.exports = Self => {
|
||||||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ctx.args.days) {
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
stmt.merge({
|
|
||||||
sql: `
|
const {daysAgo, daysOnward} = ctx.args;
|
||||||
AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY
|
if (daysOnward || daysAgo) {
|
||||||
AND t.shipped >= util.VN_CURDATE()
|
const params = [];
|
||||||
`,
|
let today = 'util.VN_CURDATE()';
|
||||||
params: [ctx.args.days]
|
let from = today;
|
||||||
});
|
let to = today;
|
||||||
|
|
||||||
|
if (daysAgo) {
|
||||||
|
from += ' - INTERVAL ? DAY';
|
||||||
|
params.push(daysAgo);
|
||||||
}
|
}
|
||||||
stmt.merge(conn.makeSuffix(filter));
|
if (daysOnward) {
|
||||||
|
to += ' + INTERVAL ? DAY';
|
||||||
|
params.push(daysOnward);
|
||||||
|
}
|
||||||
|
|
||||||
|
const whereDays = (filter.where ? 'AND' : 'WHERE') + ` t.shipped BETWEEN ${from} AND ${to}`;
|
||||||
|
stmt.merge({sql: whereDays, params});
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt.merge(conn.makePagination(filter));
|
||||||
const itemsIndex = stmts.push(stmt) - 1;
|
const itemsIndex = stmts.push(stmt) - 1;
|
||||||
|
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
|
|
|
@ -52,7 +52,7 @@ module.exports = Self => {
|
||||||
await merger.add(new Uint8Array(pdfBuffer[0]));
|
await merger.add(new Uint8Array(pdfBuffer[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!merger._doc) throw new UserError('The entry does not have stickers');
|
if (!merger._doc) throw new UserError('The entry not have stickers');
|
||||||
|
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE buy
|
UPDATE buy
|
||||||
|
|
|
@ -39,7 +39,7 @@ describe('Entry filter()', () => {
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(12);
|
expect(result.length).toEqual(11);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -49,13 +49,13 @@ describe('Entry filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('should return the entry matching the supplier', () => {
|
describe('should return the entry matching the supplier', () => {
|
||||||
it('when userId is supplier ', async() => {
|
it('when userId is supplier and searching days onward', async() => {
|
||||||
const tx = await models.Entry.beginTransaction({});
|
const tx = await models.Entry.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {days: 6},
|
args: {daysOnward: 6},
|
||||||
req: {accessToken: {userId: 1102}}
|
req: {accessToken: {userId: 1102}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,6 +70,27 @@ describe('Entry filter()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('when userId is supplier and searching days ago', async() => {
|
||||||
|
const tx = await models.Entry.beginTransaction({});
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const ctx = {
|
||||||
|
args: {daysAgo: 31},
|
||||||
|
req: {accessToken: {userId: 1102}}
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
||||||
|
expect(result.length).toEqual(6);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('when userId is supplier fetching other supplier', async() => {
|
it('when userId is supplier fetching other supplier', async() => {
|
||||||
const tx = await models.Entry.beginTransaction({});
|
const tx = await models.Entry.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
@ -131,7 +152,7 @@ describe('Entry filter()', () => {
|
||||||
|
|
||||||
const result = await models.Entry.filter(ctx, options);
|
const result = await models.Entry.filter(ctx, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(11);
|
expect(result.length).toEqual(10);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -10,6 +10,11 @@ module.exports = Self => {
|
||||||
type: 'any',
|
type: 'any',
|
||||||
description: 'The invoiceable client id'
|
description: 'The invoiceable client id'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'addressFk',
|
||||||
|
type: 'any',
|
||||||
|
description: 'The address id'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
arg: 'ticketFk',
|
arg: 'ticketFk',
|
||||||
type: 'any',
|
type: 'any',
|
||||||
|
@ -23,7 +28,8 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
arg: 'serial',
|
arg: 'serial',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'The invoice serial'
|
description: 'The invoice serial',
|
||||||
|
required: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'taxArea',
|
arg: 'taxArea',
|
||||||
|
@ -46,7 +52,8 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.createManualInvoice = async(ctx, clientFk, ticketFk, maxShipped, serial, taxArea, reference, options) => {
|
Self.createManualInvoice =
|
||||||
|
async(ctx, clientFk, addressFk, ticketFk, maxShipped, serial, taxArea, reference, options) => {
|
||||||
if (!clientFk && !ticketFk) throw new UserError(`Select ticket or client`);
|
if (!clientFk && !ticketFk) throw new UserError(`Select ticket or client`);
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
@ -60,34 +67,43 @@ module.exports = Self => {
|
||||||
myOptions.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
let companyId;
|
let companyFk;
|
||||||
let newInvoice;
|
let newInvoice;
|
||||||
let query;
|
let query;
|
||||||
try {
|
try {
|
||||||
if (ticketFk) {
|
if (ticketFk) {
|
||||||
const ticket = await models.Ticket.findById(ticketFk, null, myOptions);
|
const ticket = await models.Ticket.findById(ticketFk, {
|
||||||
const company = await models.Company.findById(ticket.companyFk, null, myOptions);
|
fields: ['clientFk', 'companyFk', 'shipped', 'refFk', 'totalWithVat']
|
||||||
|
}, myOptions);
|
||||||
|
const company = await models.Company.findById(ticket.companyFk, {
|
||||||
|
fields: ['code']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
clientFk = ticket.clientFk;
|
clientFk = ticket.clientFk;
|
||||||
maxShipped = ticket.shipped;
|
maxShipped = ticket.shipped;
|
||||||
companyId = ticket.companyFk;
|
companyFk = ticket.companyFk;
|
||||||
|
|
||||||
// Validates invoiced ticket
|
|
||||||
if (ticket.refFk)
|
if (ticket.refFk)
|
||||||
throw new UserError('This ticket is already invoiced');
|
throw new UserError('This ticket is already invoiced');
|
||||||
|
|
||||||
// Validates ticket amount
|
|
||||||
if (ticket.totalWithVat == 0)
|
if (ticket.totalWithVat == 0)
|
||||||
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
throw new UserError(`A ticket with an amount of zero can't be invoiced`);
|
||||||
|
|
||||||
// Validates ticket nagative base
|
const hasNegativeBase = await getNegativeBase(maxShipped, clientFk, companyFk, myOptions);
|
||||||
const hasNegativeBase = await getNegativeBase(maxShipped, clientFk, companyId, myOptions);
|
|
||||||
if (hasNegativeBase && company.code == 'VNL')
|
if (hasNegativeBase && company.code == 'VNL')
|
||||||
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
throw new UserError(`A ticket with a negative base can't be invoiced`);
|
||||||
} else {
|
} else {
|
||||||
if (!maxShipped)
|
if (!maxShipped)
|
||||||
throw new UserError(`Max shipped required`);
|
throw new UserError(`Max shipped required`);
|
||||||
|
|
||||||
|
if (addressFk) {
|
||||||
|
const address = await models.Address.findById(addressFk, {
|
||||||
|
fields: ['clientFk']
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
|
if (clientFk && clientFk !== address.clientFk)
|
||||||
|
throw new UserError('The provided clientFk does not match');
|
||||||
|
}
|
||||||
const company = await models.Ticket.findOne({
|
const company = await models.Ticket.findOne({
|
||||||
fields: ['companyFk'],
|
fields: ['companyFk'],
|
||||||
where: {
|
where: {
|
||||||
|
@ -95,22 +111,20 @@ module.exports = Self => {
|
||||||
shipped: {lte: maxShipped}
|
shipped: {lte: maxShipped}
|
||||||
}
|
}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
companyId = company.companyFk;
|
companyFk = company.companyFk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate invoiceable client
|
|
||||||
const isClientInvoiceable = await isInvoiceable(clientFk, myOptions);
|
const isClientInvoiceable = await isInvoiceable(clientFk, myOptions);
|
||||||
if (!isClientInvoiceable)
|
if (!isClientInvoiceable)
|
||||||
throw new UserError(`This client is not invoiceable`);
|
throw new UserError(`This client is not invoiceable`);
|
||||||
|
|
||||||
// Can't invoice tickets into future
|
|
||||||
const tomorrow = Date.vnNew();
|
const tomorrow = Date.vnNew();
|
||||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
|
|
||||||
if (maxShipped >= tomorrow)
|
if (maxShipped >= tomorrow)
|
||||||
throw new UserError(`Can't invoice to future`);
|
throw new UserError(`Can't invoice to future`);
|
||||||
|
|
||||||
const maxInvoiceDate = await getMaxIssued(serial, companyId, myOptions);
|
const maxInvoiceDate = await getMaxIssued(serial, companyFk, myOptions);
|
||||||
if (Date.vnNew() < maxInvoiceDate)
|
if (Date.vnNew() < maxInvoiceDate)
|
||||||
throw new UserError(`Can't invoice to past`);
|
throw new UserError(`Can't invoice to past`);
|
||||||
|
|
||||||
|
@ -122,13 +136,23 @@ module.exports = Self => {
|
||||||
taxArea,
|
taxArea,
|
||||||
reference
|
reference
|
||||||
], myOptions);
|
], myOptions);
|
||||||
|
} else if (addressFk) {
|
||||||
|
query = `CALL invoiceOut_newFromAddress(?, ?, ?, ?, ?, ?, @newInvoiceId)`;
|
||||||
|
await Self.rawSql(query, [
|
||||||
|
addressFk,
|
||||||
|
serial,
|
||||||
|
maxShipped,
|
||||||
|
companyFk,
|
||||||
|
taxArea,
|
||||||
|
reference
|
||||||
|
], myOptions);
|
||||||
} else {
|
} else {
|
||||||
query = `CALL invoiceOut_newFromClient(?, ?, ?, ?, ?, ?, @newInvoiceId)`;
|
query = `CALL invoiceOut_newFromClient(?, ?, ?, ?, ?, ?, @newInvoiceId)`;
|
||||||
await Self.rawSql(query, [
|
await Self.rawSql(query, [
|
||||||
clientFk,
|
clientFk,
|
||||||
serial,
|
serial,
|
||||||
maxShipped,
|
maxShipped,
|
||||||
companyId,
|
companyFk,
|
||||||
taxArea,
|
taxArea,
|
||||||
reference
|
reference
|
||||||
], myOptions);
|
], myOptions);
|
||||||
|
@ -159,10 +183,10 @@ module.exports = Self => {
|
||||||
return result.invoiceable;
|
return result.invoiceable;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNegativeBase(maxShipped, clientFk, companyId, options) {
|
async function getNegativeBase(maxShipped, clientFk, companyFk, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)',
|
await models.InvoiceOut.rawSql('CALL invoiceOut_exportationFromClient(?,?,?)',
|
||||||
[maxShipped, clientFk, companyId], options
|
[maxShipped, clientFk, companyFk], options
|
||||||
);
|
);
|
||||||
const query = 'SELECT vn.hasAnyNegativeBase() AS base';
|
const query = 'SELECT vn.hasAnyNegativeBase() AS base';
|
||||||
const [result] = await models.InvoiceOut.rawSql(query, [], options);
|
const [result] = await models.InvoiceOut.rawSql(query, [], options);
|
||||||
|
@ -170,14 +194,14 @@ module.exports = Self => {
|
||||||
return result.base;
|
return result.base;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMaxIssued(serial, companyId, options) {
|
async function getMaxIssued(serial, companyFk, options) {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const query = `SELECT MAX(issued) AS issued
|
const query = `SELECT MAX(issued) AS issued
|
||||||
FROM invoiceOut
|
FROM invoiceOut
|
||||||
WHERE serial = ? AND companyFk = ?`;
|
WHERE serial = ? AND companyFk = ?`;
|
||||||
const [maxIssued] = await models.InvoiceOut.rawSql(query,
|
const [maxIssued] = await models.InvoiceOut.rawSql(query,
|
||||||
[serial, companyId], options);
|
[serial, companyFk], options);
|
||||||
const maxInvoiceDate = maxIssued && maxIssued.issued || Date.vnNew();
|
const maxInvoiceDate = maxIssued?.issued || Date.vnNew();
|
||||||
|
|
||||||
return maxInvoiceDate;
|
return maxInvoiceDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
const client = await models.Client.findById(args.clientId, {
|
const client = await models.Client.findById(args.clientId, {
|
||||||
fields: ['id', 'hasToInvoiceByAddress']
|
fields: ['id', 'hasToInvoiceByAddress']
|
||||||
}, options);
|
}, myOptions);
|
||||||
|
|
||||||
if (client.hasToInvoiceByAddress) {
|
if (client.hasToInvoiceByAddress) {
|
||||||
await Self.rawSql('CALL ticketToInvoiceByAddress(?, ?, ?, ?)', [
|
await Self.rawSql('CALL ticketToInvoiceByAddress(?, ?, ?, ?)', [
|
||||||
|
@ -72,13 +72,13 @@ module.exports = Self => {
|
||||||
args.maxShipped,
|
args.maxShipped,
|
||||||
args.addressId,
|
args.addressId,
|
||||||
args.companyFk
|
args.companyFk
|
||||||
], options);
|
], myOptions);
|
||||||
} else {
|
} else {
|
||||||
await Self.rawSql('CALL invoiceFromClient(?, ?, ?)', [
|
await Self.rawSql('CALL invoiceFromClient(?, ?, ?)', [
|
||||||
args.maxShipped,
|
args.maxShipped,
|
||||||
client.id,
|
client.id,
|
||||||
args.companyFk
|
args.companyFk
|
||||||
], options);
|
], myOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const invoiceId = await models.Ticket.makeInvoice(
|
const invoiceId = await models.Ticket.makeInvoice(
|
||||||
|
@ -87,7 +87,7 @@ module.exports = Self => {
|
||||||
args.companyFk,
|
args.companyFk,
|
||||||
args.invoiceDate,
|
args.invoiceDate,
|
||||||
null,
|
null,
|
||||||
options
|
myOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -6,110 +6,90 @@ describe('InvoiceOut createManualInvoice()', () => {
|
||||||
const clientId = 1106;
|
const clientId = 1106;
|
||||||
const activeCtx = {accessToken: {userId: 1}};
|
const activeCtx = {accessToken: {userId: 1}};
|
||||||
const ctx = {req: activeCtx};
|
const ctx = {req: activeCtx};
|
||||||
|
let tx; let options;
|
||||||
|
|
||||||
|
beforeEach(async() => {
|
||||||
|
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(Promise.resolve(true));
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
|
||||||
|
tx = await models.InvoiceOut.beginTransaction({});
|
||||||
|
options = {transaction: tx};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async() => {
|
||||||
|
await tx.rollback();
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw an error trying to invoice again', async() => {
|
it('should throw an error trying to invoice again', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
await createInvoice(ctx, options, undefined, ticketId);
|
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||||
await createInvoice(ctx, options, undefined, ticketId);
|
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
await tx.rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toContain('This ticket is already invoiced');
|
expect(error.message).toContain('This ticket is already invoiced');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error for a ticket with an amount of zero', async() => {
|
it('should throw an error for a ticket with an amount of zero', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const ticket = await models.Ticket.findById(ticketId, null, options);
|
const ticket = await models.Ticket.findById(ticketId, null, options);
|
||||||
await ticket.updateAttributes({totalWithVat: 0}, options);
|
await ticket.updateAttributes({totalWithVat: 0}, options);
|
||||||
|
|
||||||
await createInvoice(ctx, options, undefined, ticketId);
|
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
await tx.rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toContain(`A ticket with an amount of zero can't be invoiced`);
|
expect(error.message).toContain(`A ticket with an amount of zero can't be invoiced`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error when the clientFk property is set without the max shipped date', async() => {
|
it('should throw an error when the clientFk property is set without the max shipped date', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
await createInvoice(ctx, options, clientId);
|
await createInvoice(ctx, options, clientId);
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
await tx.rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toContain(`Max shipped required`);
|
expect(error.message).toContain(`Max shipped required`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error for a non-invoiceable client', async() => {
|
it('should throw an error for a non-invoiceable client', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const client = await models.Client.findById(clientId, null, options);
|
const client = await models.Client.findById(clientId, null, options);
|
||||||
await client.updateAttributes({isTaxDataChecked: false}, options);
|
await client.updateAttributes({isTaxDataChecked: false}, options);
|
||||||
|
|
||||||
await createInvoice(ctx, options, undefined, ticketId);
|
await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
await tx.rollback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toContain(`This client is not invoiceable`);
|
expect(error.message).toContain(`This client is not invoiceable`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a manual invoice', async() => {
|
it('should create a manual invoice with ticket', async() => {
|
||||||
spyOn(models.InvoiceOut, 'createPdf').and.returnValue(new Promise(resolve => resolve(true)));
|
const result = await createInvoice(ctx, options, undefined, undefined, ticketId);
|
||||||
|
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await createInvoice(ctx, options, undefined, ticketId);
|
|
||||||
|
|
||||||
expect(result.id).toEqual(jasmine.any(Number));
|
expect(result.id).toEqual(jasmine.any(Number));
|
||||||
|
});
|
||||||
|
|
||||||
await tx.rollback();
|
it('should create a manual invoice with client', async() => {
|
||||||
} catch (e) {
|
const result = await createInvoice(ctx, options, clientId, undefined, undefined, Date.vnNew());
|
||||||
await tx.rollback();
|
|
||||||
throw e;
|
expect(result.id).toEqual(jasmine.any(Number));
|
||||||
}
|
});
|
||||||
|
|
||||||
|
it('should create a manual invoice with address', async() => {
|
||||||
|
const addressFk = 126;
|
||||||
|
const result = await createInvoice(ctx, options, clientId, addressFk, undefined, Date.vnNew());
|
||||||
|
|
||||||
|
expect(result.id).toEqual(jasmine.any(Number));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -117,6 +97,7 @@ function createInvoice(
|
||||||
ctx,
|
ctx,
|
||||||
options,
|
options,
|
||||||
clientFk = undefined,
|
clientFk = undefined,
|
||||||
|
addressFk = undefined,
|
||||||
ticketFk = undefined,
|
ticketFk = undefined,
|
||||||
maxShipped = undefined,
|
maxShipped = undefined,
|
||||||
serial = 'T',
|
serial = 'T',
|
||||||
|
@ -124,6 +105,6 @@ function createInvoice(
|
||||||
reference = undefined
|
reference = undefined
|
||||||
) {
|
) {
|
||||||
return models.InvoiceOut.createManualInvoice(
|
return models.InvoiceOut.createManualInvoice(
|
||||||
ctx, clientFk, ticketFk, maxShipped, serial, taxArea, reference, options
|
ctx, clientFk, addressFk, ticketFk, maxShipped, serial, taxArea, reference, options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,13 @@ module.exports = Self => {
|
||||||
|
|
||||||
const itemShelving = itemShelvingSale.itemShelving();
|
const itemShelving = itemShelvingSale.itemShelving();
|
||||||
const quantity = itemShelving.visible + itemShelvingSale.quantity;
|
const quantity = itemShelving.visible + itemShelvingSale.quantity;
|
||||||
|
const available = itemShelving.available + itemShelvingSale.quantity;
|
||||||
|
|
||||||
await itemShelving.updateAttributes(
|
await itemShelving.updateAttributes(
|
||||||
{visible: quantity},
|
{
|
||||||
|
visible: quantity,
|
||||||
|
available: available
|
||||||
|
},
|
||||||
myOptions
|
myOptions
|
||||||
);
|
);
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
describe('item lastEntriesFilter()', () => {
|
describe('item lastEntriesFilter()', () => {
|
||||||
it('should return two entry for the given item', async() => {
|
it('should return one entry for the given item', async() => {
|
||||||
const minDate = Date.vnNew();
|
const minDate = Date.vnNew();
|
||||||
minDate.setHours(0, 0, 0, 0);
|
minDate.setHours(0, 0, 0, 0);
|
||||||
const maxDate = Date.vnNew();
|
const maxDate = Date.vnNew();
|
||||||
|
@ -13,7 +13,7 @@ describe('item lastEntriesFilter()', () => {
|
||||||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(1);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -22,7 +22,7 @@ describe('item lastEntriesFilter()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return six entries for the given item', async() => {
|
it('should return five entries for the given item', async() => {
|
||||||
const minDate = Date.vnNew();
|
const minDate = Date.vnNew();
|
||||||
minDate.setHours(0, 0, 0, 0);
|
minDate.setHours(0, 0, 0, 0);
|
||||||
minDate.setMonth(minDate.getMonth() - 2, 1);
|
minDate.setMonth(minDate.getMonth() - 2, 1);
|
||||||
|
@ -37,7 +37,7 @@ describe('item lastEntriesFilter()', () => {
|
||||||
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}};
|
||||||
const result = await models.Item.lastEntriesFilter(filter, options);
|
const result = await models.Item.lastEntriesFilter(filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(6);
|
expect(result.length).toEqual(5);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -75,7 +75,11 @@ module.exports = Self => {
|
||||||
|
|
||||||
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, null, myOptions);
|
const itemShelving = await models.ItemShelving.findById(itemShelvingFk, null, myOptions);
|
||||||
|
|
||||||
await itemShelving.updateAttributes({visible: itemShelving.visible - quantity}, myOptions);
|
await itemShelving.updateAttributes(
|
||||||
|
{
|
||||||
|
visible: itemShelving.visible - quantity,
|
||||||
|
available: itemShelving.available - quantity
|
||||||
|
}, myOptions);
|
||||||
|
|
||||||
await Self.updateAll(
|
await Self.updateAll(
|
||||||
{saleFk},
|
{saleFk},
|
||||||
|
|
|
@ -142,12 +142,19 @@ module.exports = Self => {
|
||||||
ctx.args.addressId = ticket.addressFk;
|
ctx.args.addressId = ticket.addressFk;
|
||||||
|
|
||||||
const newTicket = await models.Ticket.new(ctx, myOptions);
|
const newTicket = await models.Ticket.new(ctx, myOptions);
|
||||||
|
const existingRefund = await models.TicketRefund.findOne({
|
||||||
|
where: {
|
||||||
|
originalTicketFk: ticketId,
|
||||||
|
refundTicketFk: newTicket.id
|
||||||
|
},
|
||||||
|
myOptions
|
||||||
|
});
|
||||||
|
if (!existingRefund) {
|
||||||
await models.TicketRefund.create({
|
await models.TicketRefund.create({
|
||||||
originalTicketFk: ticketId,
|
originalTicketFk: ticketId,
|
||||||
refundTicketFk: newTicket.id
|
refundTicketFk: newTicket.id
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
}
|
||||||
return newTicket;
|
return newTicket;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,7 +117,8 @@ module.exports = Self => {
|
||||||
result: state,
|
result: state,
|
||||||
maxTemperature,
|
maxTemperature,
|
||||||
minTemperature,
|
minTemperature,
|
||||||
temperatureFk
|
temperatureFk,
|
||||||
|
warehouseFk: warehouseId,
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
if (tx) await tx.commit();
|
if (tx) await tx.commit();
|
||||||
|
|
|
@ -4,7 +4,7 @@ describe('Thermograph saveThermograph()', () => {
|
||||||
const ctx = beforeAll.getCtx();
|
const ctx = beforeAll.getCtx();
|
||||||
const travelFk = 1;
|
const travelFk = 1;
|
||||||
const thermographId = '138350-0';
|
const thermographId = '138350-0';
|
||||||
const warehouseFk = '1';
|
const warehouseFk = 1;
|
||||||
const state = 'COMPLETED';
|
const state = 'COMPLETED';
|
||||||
const maxTemperature = 30;
|
const maxTemperature = 30;
|
||||||
const minTemperature = 10;
|
const minTemperature = 10;
|
||||||
|
@ -41,7 +41,7 @@ describe('Thermograph saveThermograph()', () => {
|
||||||
maxTemperature,
|
maxTemperature,
|
||||||
minTemperature,
|
minTemperature,
|
||||||
temperatureFk,
|
temperatureFk,
|
||||||
null,
|
warehouseFk,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
<mg-ajax path="Travels/{{patch.params.id}}" options="vnPatch"></mg-ajax>
|
|
||||||
<vn-watcher
|
|
||||||
vn-id="watcher"
|
|
||||||
data="$ctrl.travel"
|
|
||||||
form="form"
|
|
||||||
save="patch">
|
|
||||||
</vn-watcher>
|
|
||||||
<vn-crud-model
|
|
||||||
auto-load="true"
|
|
||||||
url="Warehouses"
|
|
||||||
data="warehouses"
|
|
||||||
order="name">
|
|
||||||
</vn-crud-model>
|
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
|
||||||
<vn-card class="vn-pa-lg">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield
|
|
||||||
vn-one
|
|
||||||
label="Reference"
|
|
||||||
ng-model="$ctrl.travel.ref"
|
|
||||||
vn-name="reference">
|
|
||||||
</vn-textfield>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
ng-model="$ctrl.travel.agencyModeFk"
|
|
||||||
url="AgencyModes"
|
|
||||||
show-field="name"
|
|
||||||
value-field="id"
|
|
||||||
label="Agency"
|
|
||||||
vn-name="agencyMode">
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-date-picker
|
|
||||||
vn-one
|
|
||||||
label="Shipped"
|
|
||||||
ng-model="$ctrl.travel.shipped"
|
|
||||||
vn-name="shipped">
|
|
||||||
</vn-date-picker>
|
|
||||||
<vn-date-picker
|
|
||||||
vn-one
|
|
||||||
label="Landed"
|
|
||||||
ng-model="$ctrl.travel.landed"
|
|
||||||
vn-name="landed">
|
|
||||||
</vn-date-picker>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
ng-model="$ctrl.travel.warehouseOutFk"
|
|
||||||
vn-name="warehouseOut"
|
|
||||||
data="warehouses"
|
|
||||||
show-field="name"
|
|
||||||
value-field="id"
|
|
||||||
label="Warehouse Out">
|
|
||||||
</vn-autocomplete>
|
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
ng-model="$ctrl.travel.warehouseInFk"
|
|
||||||
vn-name="warehouseIn"
|
|
||||||
data="warehouses"
|
|
||||||
show-field="name"
|
|
||||||
value-field="id"
|
|
||||||
label="Warehouse In">
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-check
|
|
||||||
vn-one
|
|
||||||
label="Delivered"
|
|
||||||
ng-model="$ctrl.travel.isDelivered">
|
|
||||||
</vn-check>
|
|
||||||
<vn-check
|
|
||||||
vn-one
|
|
||||||
label="Received"
|
|
||||||
ng-model="$ctrl.travel.isReceived">
|
|
||||||
</vn-check>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
<vn-button-bar>
|
|
||||||
<vn-submit
|
|
||||||
disabled="!watcher.dataChanged()"
|
|
||||||
label="Save">
|
|
||||||
</vn-submit>
|
|
||||||
<vn-button
|
|
||||||
class="cancel"
|
|
||||||
label="Undo changes"
|
|
||||||
disabled="!watcher.dataChanged()"
|
|
||||||
ng-click="watcher.loadOriginalData()">
|
|
||||||
</vn-button>
|
|
||||||
</vn-button-bar>
|
|
||||||
</form>
|
|
|
@ -1,21 +0,0 @@
|
||||||
import ngModule from '../module';
|
|
||||||
import Section from 'salix/components/section';
|
|
||||||
|
|
||||||
class Controller extends Section {
|
|
||||||
onSubmit() {
|
|
||||||
return this.$.watcher.submit().then(() =>
|
|
||||||
this.card.reload()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnTravelBasicData', {
|
|
||||||
template: require('./index.html'),
|
|
||||||
controller: Controller,
|
|
||||||
bindings: {
|
|
||||||
travel: '<'
|
|
||||||
},
|
|
||||||
require: {
|
|
||||||
card: '^vnTravelCard'
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,28 +0,0 @@
|
||||||
import './index.js';
|
|
||||||
|
|
||||||
describe('Travel Component vnTravelBasicData', () => {
|
|
||||||
let controller;
|
|
||||||
|
|
||||||
beforeEach(angular.mock.module('travel', $translateProvider => {
|
|
||||||
$translateProvider.translations('en', {});
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(inject($componentController => {
|
|
||||||
const $element = angular.element('<vn-travel-basic-data></vn-travel-basic-data>');
|
|
||||||
controller = $componentController('vnTravelBasicData', {$element});
|
|
||||||
controller.card = {reload: () => {}};
|
|
||||||
controller.$.watcher = {submit: () => {}};
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
|
||||||
it('should call the card reload method after the watcher submits', done => {
|
|
||||||
jest.spyOn(controller.card, 'reload');
|
|
||||||
jest.spyOn(controller.$.watcher, 'submit').mockReturnValue(Promise.resolve());
|
|
||||||
|
|
||||||
controller.onSubmit().then(() => {
|
|
||||||
expect(controller.card.reload).toHaveBeenCalledWith();
|
|
||||||
done();
|
|
||||||
}).catch(done.fail);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1 +0,0 @@
|
||||||
Undo changes: Deshacer cambios
|
|
|
@ -1,5 +0,0 @@
|
||||||
<vn-portal slot="menu">
|
|
||||||
<vn-travel-descriptor travel="$ctrl.travel"></vn-travel-descriptor>
|
|
||||||
<vn-left-menu source="card"></vn-left-menu>
|
|
||||||
</vn-portal>
|
|
||||||
<ui-view></ui-view>
|
|
|
@ -1,31 +0,0 @@
|
||||||
import ngModule from '../module';
|
|
||||||
import ModuleCard from 'salix/components/module-card';
|
|
||||||
|
|
||||||
class Controller extends ModuleCard {
|
|
||||||
reload() {
|
|
||||||
let filter = {
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
relation: 'warehouseIn',
|
|
||||||
scope: {
|
|
||||||
fields: ['id', 'name']
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
relation: 'warehouseOut',
|
|
||||||
scope: {
|
|
||||||
fields: ['id', 'name']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
this.$http.get(`Travels/${this.$params.id}`, {filter})
|
|
||||||
.then(response => this.travel = response.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnTravelCard', {
|
|
||||||
template: require('./index.html'),
|
|
||||||
controller: Controller
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
<vn-watcher
|
|
||||||
vn-id="watcher"
|
|
||||||
url="Travels"
|
|
||||||
data="$ctrl.travel"
|
|
||||||
insert-mode="true"
|
|
||||||
form="form">
|
|
||||||
</vn-watcher>
|
|
||||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
|
||||||
<vn-card class="vn-pa-lg">
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield
|
|
||||||
label="Reference"
|
|
||||||
ng-model="$ctrl.travel.ref"
|
|
||||||
vn-name="reference">
|
|
||||||
</vn-textfield>
|
|
||||||
<vn-autocomplete
|
|
||||||
label="Agency"
|
|
||||||
ng-model="$ctrl.travel.agencyModeFk"
|
|
||||||
vn-name="agencyMode"
|
|
||||||
url="AgencyModes">
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-date-picker
|
|
||||||
on-change="$ctrl.onShippedChange(value)"
|
|
||||||
label="Shipped"
|
|
||||||
ng-model="$ctrl.travel.shipped"
|
|
||||||
vn-name="shipped">
|
|
||||||
</vn-date-picker>
|
|
||||||
<vn-date-picker
|
|
||||||
label="Landed"
|
|
||||||
ng-model="$ctrl.travel.landed"
|
|
||||||
vn-name="landed">
|
|
||||||
</vn-date-picker>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete
|
|
||||||
label="Warehouse Out"
|
|
||||||
ng-model="$ctrl.travel.warehouseOutFk"
|
|
||||||
vn-name="warehouseOut"
|
|
||||||
url="Warehouses">
|
|
||||||
</vn-autocomplete>
|
|
||||||
<vn-autocomplete
|
|
||||||
label="Warehouse In"
|
|
||||||
ng-model="$ctrl.travel.warehouseInFk"
|
|
||||||
vn-name="warehouseIn"
|
|
||||||
url="Warehouses">
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
</vn-card>
|
|
||||||
<vn-button-bar>
|
|
||||||
<vn-submit
|
|
||||||
label="Save">
|
|
||||||
</vn-submit>
|
|
||||||
<vn-button
|
|
||||||
class="cancel"
|
|
||||||
label="Cancel"
|
|
||||||
ui-sref="travel.index">
|
|
||||||
</vn-button>
|
|
||||||
</vn-button-bar>
|
|
||||||
</form>
|
|
|
@ -1,48 +0,0 @@
|
||||||
import ngModule from '../module';
|
|
||||||
import Section from 'salix/components/section';
|
|
||||||
|
|
||||||
class Controller extends Section {
|
|
||||||
$onChanges() {
|
|
||||||
if (this.$params && this.$params.q)
|
|
||||||
this.travel = JSON.parse(this.$params.q);
|
|
||||||
}
|
|
||||||
|
|
||||||
onShippedChange(value) {
|
|
||||||
let hasFilledProperties;
|
|
||||||
let hasAgencyMode;
|
|
||||||
if (this.travel) {
|
|
||||||
hasAgencyMode = Boolean(this.travel.agencyModeFk);
|
|
||||||
hasFilledProperties = this.travel.landed || this.travel.warehouseInFk || this.travel.warehouseOutFk;
|
|
||||||
}
|
|
||||||
if (!hasAgencyMode || hasFilledProperties)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const query = `travels/getAverageDays`;
|
|
||||||
const params = {
|
|
||||||
agencyModeFk: this.travel.agencyModeFk
|
|
||||||
};
|
|
||||||
this.$http.get(query, {params}).then(res => {
|
|
||||||
if (!res.data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const landed = new Date(value);
|
|
||||||
const futureDate = landed.getDate() + res.data.dayDuration;
|
|
||||||
landed.setDate(futureDate);
|
|
||||||
|
|
||||||
this.travel.landed = landed;
|
|
||||||
this.travel.warehouseInFk = res.data.warehouseInFk;
|
|
||||||
this.travel.warehouseOutFk = res.data.warehouseOutFk;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit() {
|
|
||||||
return this.$.watcher.submit().then(
|
|
||||||
res => this.$state.go('travel.card.basicData', {id: res.data.id})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngModule.vnComponent('vnTravelCreate', {
|
|
||||||
template: require('./index.html'),
|
|
||||||
controller: Controller
|
|
||||||
});
|
|
|
@ -1,88 +0,0 @@
|
||||||
import './index';
|
|
||||||
import watcher from 'core/mocks/watcher';
|
|
||||||
|
|
||||||
describe('Travel Component vnTravelCreate', () => {
|
|
||||||
let $scope;
|
|
||||||
let $state;
|
|
||||||
let controller;
|
|
||||||
let $httpBackend;
|
|
||||||
|
|
||||||
beforeEach(ngModule('travel'));
|
|
||||||
|
|
||||||
beforeEach(inject(($componentController, $rootScope, _$state_, _$httpBackend_) => {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
$scope = $rootScope.$new();
|
|
||||||
$state = _$state_;
|
|
||||||
$scope.watcher = watcher;
|
|
||||||
const $element = angular.element('<vn-travel-create></vn-travel-create>');
|
|
||||||
controller = $componentController('vnTravelCreate', {$element, $scope});
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
|
||||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
|
||||||
jest.spyOn($state, 'go');
|
|
||||||
|
|
||||||
controller.onSubmit();
|
|
||||||
|
|
||||||
expect(controller.$state.go).toHaveBeenCalledWith('travel.card.basicData', {id: 1234});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('$onChanges()', () => {
|
|
||||||
it('should update the travel data when $params.q is defined', () => {
|
|
||||||
controller.$params = {q: '{"ref": 1,"agencyModeFk": 1}'};
|
|
||||||
|
|
||||||
const params = {q: '{"ref": 1, "agencyModeFk": 1}'};
|
|
||||||
const json = JSON.parse(params.q);
|
|
||||||
|
|
||||||
controller.$onChanges();
|
|
||||||
|
|
||||||
expect(controller.travel).toEqual(json);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onShippedChange()', () => {
|
|
||||||
it(`should do nothing if there's no agencyModeFk in the travel.`, () => {
|
|
||||||
controller.travel = {};
|
|
||||||
controller.onShippedChange();
|
|
||||||
|
|
||||||
expect(controller.travel.landed).toBeUndefined();
|
|
||||||
expect(controller.travel.warehouseInFk).toBeUndefined();
|
|
||||||
expect(controller.travel.warehouseOutFk).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should do nothing if there's no response data.`, () => {
|
|
||||||
controller.travel = {agencyModeFk: 4};
|
|
||||||
const tomorrow = Date.vnNew();
|
|
||||||
|
|
||||||
const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`;
|
|
||||||
$httpBackend.expectGET(query).respond(undefined);
|
|
||||||
controller.onShippedChange(tomorrow);
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.travel.warehouseInFk).toBeUndefined();
|
|
||||||
expect(controller.travel.warehouseOutFk).toBeUndefined();
|
|
||||||
expect(controller.travel.dayDuration).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should fill the fields when it's selected a date and agency.`, () => {
|
|
||||||
controller.travel = {agencyModeFk: 1};
|
|
||||||
const tomorrow = Date.vnNew();
|
|
||||||
tomorrow.setDate(tomorrow.getDate() + 9);
|
|
||||||
const expectedResponse = {
|
|
||||||
id: 8,
|
|
||||||
dayDuration: 9,
|
|
||||||
warehouseInFk: 5,
|
|
||||||
warehouseOutFk: 1
|
|
||||||
};
|
|
||||||
|
|
||||||
const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`;
|
|
||||||
$httpBackend.expectGET(query).respond(expectedResponse);
|
|
||||||
controller.onShippedChange(tomorrow);
|
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.travel.warehouseInFk).toEqual(expectedResponse.warehouseInFk);
|
|
||||||
expect(controller.travel.warehouseOutFk).toEqual(expectedResponse.warehouseOutFk);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,59 +0,0 @@
|
||||||
<vn-icon-button
|
|
||||||
icon="more_vert"
|
|
||||||
vn-popover="menu">
|
|
||||||
</vn-icon-button>
|
|
||||||
<vn-menu vn-id="menu">
|
|
||||||
<vn-list>
|
|
||||||
<vn-item
|
|
||||||
id="clone"
|
|
||||||
ng-click="clone.show()"
|
|
||||||
ng-show="::$ctrl.isBuyer"
|
|
||||||
translate>
|
|
||||||
Clone travel
|
|
||||||
</vn-item>
|
|
||||||
<vn-item
|
|
||||||
id="cloneWithEntries"
|
|
||||||
ng-click="cloneWithEntries.show()"
|
|
||||||
ng-show="::$ctrl.isBuyer"
|
|
||||||
translate>
|
|
||||||
Clone travel and his entries
|
|
||||||
</vn-item>
|
|
||||||
<vn-item
|
|
||||||
id="delete"
|
|
||||||
ng-click="delete.show()"
|
|
||||||
ng-show="$ctrl.isBuyer && !$ctrl.entries.length"
|
|
||||||
translate>
|
|
||||||
Delete travel
|
|
||||||
</vn-item>
|
|
||||||
<a class="vn-item"
|
|
||||||
name="addEntry"
|
|
||||||
ng-click="$ctrl.redirectToCreateEntry()"
|
|
||||||
translate>
|
|
||||||
Add entry
|
|
||||||
</a>
|
|
||||||
</vn-list>
|
|
||||||
</vn-menu>
|
|
||||||
|
|
||||||
<!-- Clone travel popup -->
|
|
||||||
<vn-confirm
|
|
||||||
vn-id="clone"
|
|
||||||
on-accept="$ctrl.onCloneAccept()"
|
|
||||||
question="Do you want to clone this travel?"
|
|
||||||
message="All it's properties will be copied">
|
|
||||||
</vn-confirm>
|
|
||||||
|
|
||||||
<!-- Delete travel popup -->
|
|
||||||
<vn-confirm
|
|
||||||
vn-id="delete"
|
|
||||||
on-accept="$ctrl.onDeleteAccept()"
|
|
||||||
question="Do you want to delete this travel?"
|
|
||||||
message="The travel will be deleted">
|
|
||||||
</vn-confirm>
|
|
||||||
|
|
||||||
<!-- Clone travel popup -->
|
|
||||||
<vn-confirm
|
|
||||||
vn-id="cloneWithEntries"
|
|
||||||
on-accept="$ctrl.onCloneWithEntriesAccept()"
|
|
||||||
question="Do you want to clone this travel and all containing entries?"
|
|
||||||
message="All it's properties will be copied">
|
|
||||||
</vn-confirm>
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue