feat: refs #7984 add currency option

This commit is contained in:
Carlos Andrés 2024-11-27 18:19:57 +01:00
parent c3aeba16c1
commit d111599c59
55 changed files with 764 additions and 599 deletions

View File

@ -613,13 +613,13 @@ INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
VALUES
(241, 442, 'ES111122333344111122221111', 128);
INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`)
INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`, `currencyFk`)
VALUES
(69 , 'CCs', NULL, 30, 0, NULL, 1, NULL , NULL),
(442 , 'VNL', 241, 30, 1, NULL, 2, 'VNL Company - Plant passport' , 1101),
(567 , 'VNH', NULL, 30, 4, NULL, 1, 'VNH Company - Plant passport' , NULL),
(791 , 'FTH', NULL, 30, 3, '2015-11-30', 1, NULL , NULL),
(1381, 'ORN', NULL, 30, 7, NULL, 1, 'ORN Company - Plant passport' , NULL);
(69 , 'CCs', NULL, 30, 0, NULL, 1, NULL , NULL, 1),
(442 , 'VNL', 241, 30, 1, NULL, 2, 'VNL Company - Plant passport' , 1101, 1),
(567 , 'VNH', NULL, 30, 4, NULL, 1, 'VNH Company - Plant passport' , NULL, 1),
(791 , 'FTH', NULL, 30, 3, '2015-11-30', 1, NULL , NULL, 1),
(1381, 'ORN', NULL, 30, 7, NULL, 1, 'ORN Company - Plant passport' , NULL, 1);
INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`)
VALUES
@ -755,45 +755,45 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen
(6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3),
(7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5);
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`)
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `currencyFk`, `created`, `weight`, `cmrFk`, `problem`, `risk`)
VALUES
(1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'hasHighRisk', 901.4),
(2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'hasHighRisk', 901.4),
(3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3, NULL, NULL),
(4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL, NULL, NULL),
(5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL, NULL, NULL),
(6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL, 'hasHighRisk', 901.4),
(7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL),
(11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest', NULL),
(12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isFreezed', NULL),
(16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7),
(17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7),
(18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL),
(19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL),
(20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL),
(21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL),
(22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL),
(23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest, hasHighRisk', 901.4),
(24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 901.4),
(28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL);
(1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'hasHighRisk', 901.4),
(2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'hasHighRisk', 901.4),
(3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3, NULL, NULL),
(4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL, NULL, NULL),
(5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL, NULL, NULL),
(6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL, 'hasHighRisk', 901.4),
(7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL),
(11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest', NULL),
(12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'isFreezed', NULL),
(16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7),
(17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7),
(18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL),
(19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL),
(20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL),
(21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL),
(22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL),
(23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest, hasHighRisk', 901.4),
(24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4),
(27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, 901.4),
(28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL),
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL);
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
VALUES

View File

@ -1,39 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`catalog_calcFromMyAddress`(vDelivery DATE, vAddress INT)
BEGIN
/**
* Gets the available items list.
*
* @param vDelivery Delivery date
* @param vAddress Address id
* @return tmp.ticketCalculateItem
* @return tmp.ticketComponentPrice
* @return tmp.ticketComponent
* @return tmp.ticketLot
* @return tmp.zoneGetShipped
*/
DECLARE vAgencyMode INT;
SELECT a.agencyModeFk
INTO vAgencyMode
FROM myClient c
JOIN vn.address a ON a.clientFk = c.id
WHERE a.id = vAddress;
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT c.item_id itemFk
FROM `cache`.available c
JOIN tmp.availableCalc a ON a.calcFk = c.calc_id
WHERE c.available > 0
GROUP BY c.item_id;
CALL vn.catalog_calculate(vDelivery, vAddress, vAgencyMode, FALSE);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -1,31 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_calcCatalog`(
vSelf INT,
vLanded DATE,
vAddressFk INT,
vAgencyModeFk INT)
BEGIN
/**
* Calculates available and price for a single item.
*
* @param vItemFk The item id
* @return List of available lots
*/
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
ENGINE = MEMORY
SELECT vSelf itemFk;
CALL vn.catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
SELECT l.warehouseFk, w.name warehouse,
p.`grouping`, p.price, p.rate, l.available
FROM tmp.ticketLot l
JOIN tmp.ticketComponentPrice p ON p.warehouseFk = l.warehouseFk
JOIN vn.warehouse w ON w.id = p.warehouseFk
ORDER BY warehouseFk, `grouping`;
CALL vn.ticketCalculatePurge();
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -16,14 +16,18 @@ proc: BEGIN
* @param vAddress Address id, @NULL for pickup
*/
DECLARE vCompany INT;
DECLARE vCurrencyFk INT;
SELECT defaultCompanyFk INTO vCompany
FROM orderConfig;
SELECT oc.defaultCompanyFk, c.currencyFk INTO vCompany, vCurrencyFk
FROM orderConfig oc
LEFT JOIN vn.company c ON c.id = oc.defaultCompanyFk
LIMIT 1;
INSERT INTO `order`
SET customer_id = account.myUser_getId(),
source_app = 'WEB',
company_id = vCompany;
company_id = vCompany,
currencyFk = vCurrencyFk;
SET vSelf = LAST_INSERT_ID();
CALL myOrder_configure(

View File

@ -1,10 +1,10 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myTicket_getRows`(vSelf INT)
BEGIN
SELECT r.itemFk, r.quantity, r.concept, r.price, r.discount,
SELECT r.itemFk, r.quantity, r.concept, r.price, r.foreignPrice, r.discount,
i.category, i.size, i.stems, i.inkFk,
i.tag5, i.value5, i.tag6, i.value6, i.tag7, i.value7,
i.image, im.updated
i.image, im.updated
FROM myTicketRow r
JOIN vn.item i ON i.id = r.itemFk
LEFT JOIN image im

View File

@ -7,7 +7,7 @@ BEGIN
* @param vSelf The ticket identifier
* @select The ticket services
*/
SELECT id, description, quantity, price
SELECT id, description, quantity, price, foreignPrice
FROM myTicketService
WHERE ticketFk = vSelf;
END$$

View File

@ -22,8 +22,9 @@ BEGIN
DECLARE vRate INT;
DECLARE vShipment DATE;
DECLARE vPrice DECIMAL(10,2);
DECLARE vForeignPrice DECIMAL(10,2);
DECLARE cur CURSOR FOR
SELECT `grouping`, price, rate
SELECT `grouping`, price, rate, foreignPrice
FROM tmp.ticketComponentPrice
WHERE warehouseFk = vWarehouse
AND itemFk = vItem
@ -84,7 +85,7 @@ BEGIN
l: LOOP
SET vDone = FALSE;
FETCH cur INTO vGrouping, vPrice, vRate;
FETCH cur INTO vGrouping, vPrice, vRate, vForeignPrice;
IF vDone THEN
LEAVE l;
@ -104,7 +105,8 @@ BEGIN
shipment = vShipment,
rate = vRate,
amount = vAdd,
price = vPrice;
price = vPrice,
foreignPrice = vForeignPrice;
CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd);

View File

@ -13,9 +13,10 @@ BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
DECLARE vCurrencyFk INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
SELECT date_send, address_id, agency_id, currencyFk
INTO vDate, vAddress, vAgencyMode, vCurrencyFk
FROM `order`
WHERE id = vSelf;
@ -23,11 +24,11 @@ BEGIN
CREATE TEMPORARY TABLE tmp.item
(PRIMARY KEY (itemFk))
ENGINE = MEMORY
SELECT itemFk FROM orderRow
SELECT itemFk FROM orderRow
WHERE orderFk = vSelf
GROUP BY itemFk;
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, vCurrencyFk, FALSE);
DROP TEMPORARY TABLE tmp.item;
END$$

View File

@ -16,12 +16,13 @@ BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
DECLARE vCurrencyFk INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
SELECT date_send, address_id, agency_id, currencyFk
INTO vDate, vAddress, vAgencyMode, vCurrencyFk
FROM `order`
WHERE id = vSelf;
CALL vn.catalog_calcFromItem(vDate, vAddress, vAgencyMode, vItem);
CALL vn.catalog_calcFromItem(vDate, vAddress, vAgencyMode, vCurrencyFk, vItem);
END$$
DELIMITER ;

View File

@ -16,13 +16,14 @@ BEGIN
DECLARE vDate DATE;
DECLARE vAddress INT;
DECLARE vAgencyMode INT;
DECLARE vCurrencyFk INT;
SELECT date_send, address_id, agency_id
INTO vDate, vAddress, vAgencyMode
SELECT date_send, address_id, agency_id, currencyFk
INTO vDate, vAddress, vAgencyMode, vCurrencyFk
FROM `order`
WHERE id = vSelf;
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, FALSE);
CALL vn.catalog_calculate(vDate, vAddress, vAgencyMode, vCurrencyFk, FALSE);
IF account.myUser_getName() = 'visitor' THEN
UPDATE tmp.ticketCalculateItem

View File

@ -23,6 +23,7 @@ BEGIN
DECLARE vConcept VARCHAR(30);
DECLARE vAmount INT;
DECLARE vPrice DECIMAL(10,2);
DECLARE vForeignPrice DECIMAL(10,2);
DECLARE vSaleFk INT;
DECLARE vRowFk INT;
DECLARE vPriceFixed DECIMAL(10,2);
@ -32,6 +33,7 @@ BEGIN
DECLARE vCompanyFk INT;
DECLARE vAgencyModeFk INT;
DECLARE vIsTaxDataChecked BOOL;
DECLARE vCurrencyFk INT;
DECLARE vDates CURSOR FOR
SELECT zgs.shipped, r.warehouseFk
@ -47,7 +49,8 @@ BEGIN
r.itemFk,
i.name,
r.amount,
r.price
r.price,
r.foreignPrice
FROM orderRow r
JOIN vn.item i ON i.id = r.itemFk
WHERE r.amount
@ -70,14 +73,16 @@ BEGIN
a.clientFk,
o.company_id,
o.agency_id,
c.isTaxDataChecked
c.isTaxDataChecked,
o.currencyFk
INTO vLanded,
vAddressFk,
vNotes,
vClientFk,
vCompanyFk,
vAgencyModeFk,
vIsTaxDataChecked
vIsTaxDataChecked,
vCurrencyFk
FROM `order` o
JOIN vn.address a ON a.id = o.address_id
JOIN vn.client c ON c.id = a.clientFk
@ -144,6 +149,7 @@ BEGIN
JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk
WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd
AND t.currencyFk = vCurrencyFk
)
SELECT t.id INTO vTicketFk
FROM vn.ticket t
@ -154,6 +160,7 @@ BEGIN
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
AND t.warehouseFk = vWarehouseFk
AND o.date_send = t.landed
AND t.currencyFk = o.currencyFk
WHERE o.id = vSelf
AND t.refFk IS NULL
AND tp.ticketFk IS NULL
@ -171,6 +178,7 @@ BEGIN
JOIN hedera.orderRow oro ON oro.itemFk = i.id
JOIN hedera.`order` o ON o.id = oro.orderFk
WHERE oro.orderFk = vSelf
AND o.currencyFk = vCurrencyFk
),
tItemPackingTypeTicket AS (
SELECT t.id,
@ -188,6 +196,7 @@ BEGIN
AND t.warehouseFk = vWarehouseFk
AND t.addressFk = ipto.address_id
AND al.code = 'ON_PREVIOUS'
AND t.currencyFk = vCurrencyFk
GROUP BY t.id
)
SELECT iptt.id INTO vTicketFk
@ -211,6 +220,7 @@ BEGIN
vLanded,
vUserFk,
TRUE,
vCurrencyFk,
vTicketFk
);
ELSE
@ -239,7 +249,7 @@ BEGIN
lRows: LOOP
SET vSaleFk = NULL;
SET vDone = FALSE;
FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice;
FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice, vForeignPrice;
IF vDone THEN
LEAVE lRows;
@ -249,6 +259,7 @@ BEGIN
FROM vn.sale s
WHERE ticketFk = vTicketFk
AND price = vPrice
AND foreignPrice = vForeignPrice
AND itemFk = vItemFk
AND discount = 0
LIMIT 1;
@ -274,7 +285,8 @@ BEGIN
quantity = vAmount,
price = vPrice,
priceFixed = vPriceFixed,
isPriceFixed = TRUE;
isPriceFixed = TRUE,
foreignPrice = vForeignPrice;
SET vSaleFk = LAST_INSERT_ID();

View File

@ -13,7 +13,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk))
ENGINE = MEMORY
ENGINE = MEMORY
SELECT DISTINCT o.address_id addressFk, o.company_id companyFk
FROM tmp.`order` tmpOrder
JOIN `order` o ON o.id = tmpOrder.orderFk;
@ -45,7 +45,10 @@ BEGIN
SELECT o.orderFk,
tc.code,
SUM(o.total) taxableBase,
pgc.rate
pgc.rate,
currency_getRate(o.currencyFk, NULL) *
SUM(o.total) foreignTaxableBase,
o.currencyFk
FROM orders o
JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk
AND bp.taxAreaFk = o.areaFk
@ -55,17 +58,23 @@ BEGIN
GROUP BY o.orderFk, pgc.code, pgc.rate
HAVING taxableBase
ORDER BY bp.priority;
-- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount;
CREATE TEMPORARY TABLE tmp.orderAmount
(INDEX (orderFk))
ENGINE = MEMORY
SELECT orderFk, taxableBase, `code`,
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax
SELECT orderFk,
taxableBase,
`code`,
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,
currencyFk,
foreignTaxableBase,
currency_getRate(o.currencyFk, NULL) *
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) foreignTax
FROM tmp.orderTax
GROUP BY orderFk, `code`;
DROP TEMPORARY TABLE tmp.addressTaxArea;
END$$
DELIMITER ;

View File

@ -13,7 +13,9 @@ BEGIN
CREATE TEMPORARY TABLE tmp.orderTotal
(INDEX (orderFk))
ENGINE = MEMORY
SELECT o.orderFk, IFNULL(SUM(ot.taxableBase + ot.tax), 0.0) AS total
SELECT o.orderFk,
IFNULL(SUM(ot.taxableBase + ot.tax), 0.0) total,
IFNULL(SUM(ot.taxableBase + ot.tax) * ot.currencyFk, 0.0) foreignTotal
FROM tmp.`order` o
LEFT JOIN tmp.orderAmount ot ON o.orderFk = ot.orderFk
GROUP BY orderFk;

View File

@ -8,6 +8,8 @@ BEGIN
*/
DECLARE vTaxableBase DECIMAL(10,2);
DECLARE vTax DECIMAL(10,2);
DECLARE vForeignTaxableBase DECIMAL(10,2);
DECLARE vForeignTax DECIMAL(10,2);
DROP TEMPORARY TABLE IF EXISTS tmp.`order`;
CREATE TEMPORARY TABLE tmp.`order`
@ -16,14 +18,23 @@ BEGIN
CALL order_getTax;
SELECT IFNULL(SUM(taxableBase), 0.0), IFNULL(SUM(tax), 0.0)
INTO vTaxableBase, vTax
SELECT IFNULL(SUM(taxableBase), 0.0),
IFNULL(SUM(tax), 0.0),
IFNULL(SUM(foreignTaxableBase), 0.0),
IFNULL(SUM(foreignTax), 0.0)
INTO vTaxableBase,
vTax,
vForeignTaxableBase,
vForeignTax
FROM tmp.orderAmount;
UPDATE `order`
SET taxableBase = vTaxableBase,
tax = vTax,
total = vTaxableBase + vTax
total = vTaxableBase + vTax,
foreignTaxableBase = vForeignTaxableBase,
foreignTax = vForeignTax,
foreignTotal = vForeignTaxableBase + vForeignTax
WHERE id = vSelf;
DROP TEMPORARY TABLE

View File

@ -22,28 +22,27 @@ proc: BEGIN
SELECT COUNT(*) INTO vNRows
FROM orderRow WHERE orderFk = vSelf;
IF vNRows > 0
THEN
IF vNRows > 0 THEN
CALL order_calcCatalog(vSelf);
DELETE c
FROM orderRow r
JOIN orderRowComponent c ON c.rowFk = r.id
WHERE r.orderFk = vSelf;
UPDATE orderRow r
LEFT JOIN tmp.ticketComponentPrice p
ON p.warehouseFk = r.warehouseFk
WHERE r.orderFk = vSelf;
UPDATE orderRow r
JOIN `order` o ON o.id = r.orderFk
LEFT JOIN tmp.ticketComponentPrice p ON p.warehouseFk = r.warehouseFk
AND p.itemFk = r.itemFk
AND p.rate = r.rate
LEFT JOIN tmp.zoneGetShipped t
ON t.warehouseFk = r.warehouseFk
SET
r.price = p.price,
LEFT JOIN tmp.zoneGetShipped t ON t.warehouseFk = r.warehouseFk
SET r.price = p.price,
r.foreignPrice = currency_getRate(o.currencyFk, NULL) * p.price,
r.amount = IF(p.itemFk IS NOT NULL,
r.amount + IF(@m := MOD(r.amount, p.`grouping`), p.`grouping` - @m, 0), 0),
r.amount + IF(@m := MOD(r.amount, p.`grouping`), p.`grouping` - @m, 0)
, 0),
r.shipment = t.shipped
WHERE r.orderFk = vSelf;
WHERE o.id = vSelf;
INSERT INTO orderRowComponent(rowFk, componentFk, price)
SELECT r.id, c.componentFk, c.cost
@ -59,8 +58,7 @@ proc: BEGIN
CALL vn.ticketCalculatePurge;
END IF;
UPDATE `order` SET date_make = util.VN_NOW()
WHERE id = vSelf;
UPDATE `order` SET date_make = util.VN_NOW() WHERE id = vSelf;
COMMIT;
END$$

View File

@ -8,6 +8,7 @@ AS SELECT `orw`.`id` AS `id`,
`orw`.`shipment` AS `shipped`,
`orw`.`amount` AS `amount`,
`orw`.`price` AS `price`,
`orw`.`foreignPrice` AS `foreignPrice`,
`orw`.`rate` AS `rate`,
`orw`.`created` AS `created`,
`orw`.`Id_Movimiento` AS `saleFk`

View File

@ -7,6 +7,7 @@ AS SELECT `s`.`id` AS `id`,
`s`.`concept` AS `concept`,
`s`.`quantity` AS `quantity`,
`s`.`price` AS `price`,
`s`.`foreignPrice` AS `foreignPrice`,
`s`.`discount` AS `discount`,
`s`.`reserved` AS `reserved`,
`s`.`isPicked` AS `isPicked`

View File

@ -5,6 +5,7 @@ AS SELECT `s`.`id` AS `id`,
`s`.`description` AS `description`,
`s`.`quantity` AS `quantity`,
`s`.`price` AS `price`,
`s`.`foreignPrice` AS `foreignPrice`,
`s`.`taxClassFk` AS `taxClassFk`,
`s`.`ticketFk` AS `ticketFk`,
`s`.`ticketServiceTypeFk` AS `ticketServiceTypeFk`

View File

@ -8,6 +8,7 @@ AS SELECT `t`.`id` AS `id`,
`t`.`shipment` AS `shipment`,
`t`.`amount` AS `amount`,
`t`.`price` AS `price`,
`t`.`foreignPrice` AS `foreignPrice`,
`t`.`rate` AS `rate`,
`t`.`created` AS `created`,
`t`.`saleFk` AS `Id_Movimiento`

View File

@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_calcFromItem`
vLanded DATE,
vAddressFk INT,
vAgencyModeFk INT,
vCurrencyFk INT,
vItemFk INT)
BEGIN
/**
@ -17,10 +18,10 @@ BEGIN
*/
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
ENGINE = MEMORY
ENGINE = MEMORY
SELECT vItemFk itemFk;
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, TRUE);
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, vCurrencyFk, TRUE);
DROP TEMPORARY TABLE tmp.item;
END$$
DELIMITER ;

View File

@ -3,17 +3,21 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_calculate`(
vLanded DATE,
vAddressFk INT,
vAgencyModeFk INT,
vShowExpiredZones BOOLEAN)
BEGIN
vCurrencyFk INT,
vShowExpiredZones BOOLEAN
)
BEGIN
/**
* Calcula los articulos disponibles y sus precios
* Calcula los articulos disponibles y sus precios.
*
* @table tmp.item(itemFk) Listado de artículos a calcular
* @param vLanded Fecha de recepcion de mercancia
* @param vAddressFk Id del consignatario
* @param vAgencyModeFk Id de la agencia
* @return tmp.ticketCalculateItem(itemFk, available, producer,
* item, size, stems, category, inkFk, image, origin, price)
* @param vCurrencyFk Id de la moneda
* @return tmp.ticketCalculateItem(itemFk, available, producer, item, size, stems,
* category, inkFk,image, origin, price, priceKg, foreignPrice,
* foreignPriceKg, grouping, minQuantity)
* @return tmp.ticketLot(warehouseFk, itemFk, available, buyFk)
* @return tmp.ticketComponent
* @return tmp.ticketComponentPrice
@ -46,23 +50,25 @@ BEGIN
CALL catalog_componentPrepare();
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem(
itemFk INT(11) NOT NULL,
itemFk INT(11) NOT NULL,
available INT(11),
producer VARCHAR(50),
item VARCHAR(50),
size INT(10) UNSIGNED,
stems INT(11),
category VARCHAR(3),
inkFk VARCHAR(3),
producer VARCHAR(50),
item VARCHAR(50),
size INT(10) UNSIGNED,
stems INT(11),
category VARCHAR(3),
inkFk VARCHAR(3),
image VARCHAR(50),
origin VARCHAR(3),
origin VARCHAR(3),
price DECIMAL(10,2),
priceKg DECIMAL(10,2),
foreignPrice DECIMAL(10,2),
foreignPriceKg DECIMAL(10,2),
`grouping` INT(10) UNSIGNED,
minQuantity INT(10) UNSIGNED,
PRIMARY KEY `itemFk` (`itemFk`)
) ENGINE = MEMORY DEFAULT CHARSET=utf8;
OPEN cTravelTree;
l: LOOP
SET vDone = FALSE;
@ -83,20 +89,20 @@ BEGIN
bu.buyFk,
vZoneFk
FROM `cache`.available a
LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id
LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id
AND anr.calc_id = vAvailableNoRaidsCalc
JOIN tmp.item i ON i.itemFk = a.item_id
JOIN item it ON it.id = i.itemFk
JOIN `zone` z ON z.id = vZoneFk
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk
LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id
LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk
LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID
LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID
LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed
FROM addressFilter af
JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
FROM address ad
JOIN province p ON p.id = ad.provinceFk
JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed
FROM address ad
JOIN province p ON p.id = ad.provinceFk
WHERE ad.id = vAddressFk
) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk)
AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk)
@ -113,13 +119,13 @@ BEGIN
JOIN itemType itt ON itt.id = it.typeFk
JOIN itemCategory itc on itc.id = itt.categoryFk
JOIN address ad ON ad.id = vAddressFk
LEFT JOIN clientItemType cit
LEFT JOIN clientItemType cit
ON cit.clientFk = ad.clientFk
AND cit.itemTypeFk = itt.id
LEFT JOIN zoneItemType zit
LEFT JOIN zoneItemType zit
ON zit.zoneFk = vZoneFk
AND zit.itemTypeFk = itt.id
LEFT JOIN agencyModeItemType ait
LEFT JOIN agencyModeItemType ait
ON ait.agencyModeFk = vAgencyModeFk
AND ait.itemTypeFk = itt.id
WHERE a.calc_id = vAvailableCalc
@ -136,7 +142,7 @@ BEGIN
DROP TEMPORARY TABLE tmp.buyUltimate;
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk, vCurrencyFk);
INSERT INTO tmp.ticketCalculateItem(
itemFk,
@ -151,6 +157,8 @@ BEGIN
origin,
price,
priceKg,
foreignPrice,
foreignPriceKg,
`grouping`,
minQuantity)
SELECT tl.itemFk,
@ -165,6 +173,8 @@ BEGIN
o.code origin,
bl.price,
bl.priceKg,
currency_getRate(vCurrencyFk, NULL) * bl.price,
currency_getRate(vCurrencyFk, NULL) * bl.priceKg,
bl.`grouping`,
mq.quantity
FROM tmp.ticketLot tl

View File

@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_componentCalc
vZoneFk INT,
vAddressFk INT,
vShipped DATE,
vWarehouseFk INT
vWarehouseFk INT,
vCurrencyFk INT
)
BEGIN
/**
@ -16,7 +17,7 @@ BEGIN
* @table tmp.ticketLot (warehouseFk, available, itemFk, buyFk, zoneFk)
* @table tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost)
*
* @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
* @return tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, foreignPrice)
*/
DECLARE vClientFk INT;
DECLARE vVNHWarehouseFk INT DEFAULT 7;
@ -245,7 +246,8 @@ BEGIN
DROP TEMPORARY TABLE tmp.zoneOption;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCopy ENGINE = MEMORY
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCopy
ENGINE = MEMORY
SELECT * FROM tmp.ticketComponent;
-- Precio especial
@ -284,54 +286,66 @@ BEGIN
JOIN component c ON c.id = tc.componentFk
GROUP BY tc.itemFk, tc.warehouseFk, c.classRate;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentRate ENGINE = MEMORY
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentRate
ENGINE = MEMORY
SELECT tcc.warehouseFk,
tcc.itemFk,
1 rate,
IF(tcc.groupingMode = 'grouping', tcc.`grouping`, 1) `grouping`,
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price,
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg
CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg,
currency_getRate(vCurrencyFk, NULL) * SUM(tcs.sumCost) foreignPrice
FROM tmp.ticketComponentCalculate tcc
JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
AND tcs.warehouseFk = tcc.warehouseFk
WHERE IFNULL(tcs.classRate, 1) = 1
AND (tcc.groupingMode = 'grouping' OR tcc.groupingMode IS NULL)
AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL)
GROUP BY tcs.warehouseFk, tcs.itemFk;
INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
GROUP BY tcs.warehouseFk, tcs.itemFk
UNION ALL
SELECT tcc.warehouseFk,
tcc.itemFk,
2 rate,
tcc.packing `grouping`,
SUM(tcs.sumCost) price,
SUM(tcs.sumCost) / weightGrouping priceKg
SUM(tcs.sumCost) / weightGrouping priceKg,
currency_getRate(vCurrencyFk, NULL) * SUM(tcs.sumCost) foreignPrice
FROM tmp.ticketComponentCalculate tcc
JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
AND tcs.warehouseFk = tcc.warehouseFk
WHERE tcc.available IS NULL
OR (IFNULL(tcs.classRate, 2) = 2
AND tcc.packing > 0 AND tcc.available >= tcc.packing)
GROUP BY tcs.warehouseFk, tcs.itemFk;
INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
GROUP BY tcs.warehouseFk, tcs.itemFk
UNION ALL
SELECT tcc.warehouseFk,
tcc.itemFk,
3 rate,
tcc.available `grouping`,
SUM(tcs.sumCost) price,
SUM(tcs.sumCost) / weightGrouping priceKg
SUM(tcs.sumCost) / weightGrouping priceKg,
currency_getRate(vCurrencyFk, NULL) * SUM(tcs.sumCost) foreignPrice
FROM tmp.ticketComponentCalculate tcc
JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk
AND tcs.warehouseFk = tcc.warehouseFk
WHERE IFNULL(tcs.classRate, 3) = 3
GROUP BY tcs.warehouseFk, tcs.itemFk;
INSERT INTO tmp.ticketComponentPrice (warehouseFk, itemFk, rate, `grouping`, price, priceKg)
SELECT * FROM (
SELECT * FROM tmp.ticketComponentRate ORDER BY price LIMIT 10000000000000000000
) t
GROUP BY itemFk, warehouseFk, `grouping`;
INSERT INTO tmp.ticketComponentPrice(
warehouseFk,
itemFk,
rate,
`grouping`,
price,
priceKg,
foreignPrice
)SELECT * FROM (
SELECT *
FROM tmp.ticketComponentRate
ORDER BY price
LIMIT 10000000000000000000
) t
GROUP BY itemFk, warehouseFk, `grouping`;
DROP TEMPORARY TABLE
tmp.ticketComponentCalculate,

View File

@ -19,7 +19,9 @@ BEGIN
`rate` INT NOT NULL,
`grouping` INT UNSIGNED NOT NULL,
`price` DECIMAL(10,4) NOT NULL,
`priceKg` DECIMAL(10,4),
`priceKg` DECIMAL(10,4),
`foreignPrice` DECIMAL(10,4),
`foreignPriceKg` DECIMAL(10,4),
INDEX `itemWarehouse` USING BTREE (`itemFk` ASC, `warehouseFk` ASC),
UNIQUE `fkItemWarehouseRate` (`itemFk` ASC, `warehouseFk` ASC, `rate` ASC)
)ENGINE=MEMORY DEFAULT CHARSET=utf8;

View File

@ -21,6 +21,7 @@ BEGIN
,CURDATE()
,account.myUser_getId()
,TRUE
,1
,vNewTicket);
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price)

View File

@ -8,23 +8,28 @@ BEGIN
DELETE FROM invoiceOutExpense
WHERE invoiceOutFk = vInvoice;
INSERT INTO invoiceOutExpense(invoiceOutFk, expenseFk, amount)
INSERT INTO invoiceOutExpense(invoiceOutFk, expenseFk, amount, foreignAmount)
SELECT vInvoice,
expenseFk,
SUM(ROUND(quantity * price * (100 - discount)/100,2)) amount
FROM tmp.ticketToInvoice t
expenseFk,
SUM(ROUND(quantity * price * (100 - discount) / 100, 2)) amount,
currency_getRate(t.currencyFk, NULL) *
SUM(ROUND(quantity * price * (100 - discount) / 100, 2)) foreignAmount
FROM tmp.ticketToInvoice tti
JOIN ticket t ON t.id = tti.id
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
GROUP BY i.expenseFk
HAVING amount != 0;
INSERT INTO invoiceOutExpense(invoiceOutFk, expenseFk, amount)
HAVING amount <> 0
UNION ALL
SELECT vInvoice,
tst.expenseFk,
SUM(ROUND(ts.quantity * ts.price ,2)) amount
FROM tmp.ticketToInvoice t
SUM(ROUND(ts.quantity * ts.price ,2)) amount,
currency_getRate(t.currencyFk, NULL),
SUM(ROUND(ts.quantity * ts.price, 2)) foreignAmount
FROM tmp.ticketToInvoice tti
JOIN ticket t ON t.id = tti.id
JOIN ticketService ts ON ts.ticketFk = t.id
JOIN ticketServiceType tst ON tst.id = ts.ticketServiceTypeFk
HAVING amount != 0;
HAVING amount <> 0;
END$$
DELIMITER ;

View File

@ -1,14 +1,14 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`(
vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
vItemFk INT,
vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
vItemFk INT,
vQuantity INT
)
BEGIN
BEGIN
/**
* Leave the indicated amount on the shelve
* and create a ticket with the difference.
*
*
* @param vShelvingCode Code of the shelve where the item is located
* @param vItemFk Item of which the self-consumption ticket is to be created
* @param vQuantity Amount that will stay on the shelve
@ -18,6 +18,7 @@ BEGIN
DECLARE vTicketFk INT;
DECLARE vWarehouseFk INT;
DECLARE vCompanyFk INT;
DECLARE vCurrencyFk INT;
DECLARE vAgencyModeFk INT;
DECLARE vItemShelvingFk INT;
DECLARE vAddressFk INT;
@ -28,10 +29,12 @@ BEGIN
WHERE code = vShelvingCode;
SELECT c.id,
c.currencyFk,
pc.clientSelfConsumptionFk,
s.warehouseFk,
pc.addressSelfConsumptionFk
INTO vCompanyFk,
vCurrencyFk,
vClientFk,
vWarehouseFk,
vAddressFk
@ -61,10 +64,10 @@ BEGIN
END IF;
SELECT SUM(visible), id INTO vVisible, vItemShelvingFk
FROM itemShelving
FROM itemShelving
WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk;
IF vVisible IS NULL THEN
CALL util.throw('The item is not on the shelf.');
END IF;
@ -75,6 +78,7 @@ BEGIN
CURDATE(),
vAddressFk,
vCompanyFk,
vCurrencyFk,
NULL,
vTicketFk
);

View File

@ -18,14 +18,12 @@ BEGIN
DECLARE vTicketFk INT;
DECLARE vClientFk INT;
DECLARE vDefaultCompanyFk INT;
DECLARE vDefaultCurrencyFk INT;
DECLARE vCalc INT;
DECLARE vAddressShortage INT;
SELECT barcodeToItem(vItemFk) INTO vItemFk;
SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk
FROM vn.ticket LIMIT 1;
IF vAddressFk IS NULL THEN
SELECT pc.shortageAddressFk INTO vAddressShortage
FROM productionConfig pc ;
@ -50,6 +48,11 @@ BEGIN
CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk);
IF vTicketFk IS NULL THEN
SELECT DEFAULT(companyFk), DEFAULT(currencyFk)
INTO vDefaultCompanyFk, vDefaultCurrencyFk
FROM vn.ticket
LIMIT 1;
CALL ticket_add(
vClientFk,
util.VN_CURDATE(),
@ -61,6 +64,7 @@ BEGIN
util.VN_CURDATE(),
account.myUser_getId(),
FALSE,
vDefaultCurrencyFk,
vTicketFk);
END IF;

View File

@ -1,5 +1,9 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`recipe_Plaster`(vItemFk INT, vTicketFk INT, vQuantity INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`recipe_Plaster`(
vItemFk INT,
vTicketFk INT,
vQuantity INT
)
BEGIN
DECLARE vLastCost DECIMAL(10,2);
@ -7,12 +11,13 @@ BEGIN
DECLARE vShipped DATE;
DECLARE vEntryFk INT;
DECLARE vTravelFk INT;
DECLARE vCurrencyFk INT;
CALL cache.last_buy_refresh(FALSE);
SELECT warehouseFk, shipped
INTO vWarehouseFk, vShipped
FROM vn.ticket
SELECT warehouseFk, shipped, currencyFk
INTO vWarehouseFk, vShipped, vCurrencyFk
FROM vn.ticket
WHERE id = vTicketFk;
UPDATE vn.ticket t
@ -27,8 +32,19 @@ BEGIN
ORDER BY (lb.warehouse_id = vWarehouseFk) DESC
LIMIT 1;
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price)
SELECT vTicketFk, 98, - vQuantity, i.longName, vLastCost
INSERT INTO vn.sale(
ticketFk,
itemFk,
quantity,
concept,
price,
foreignPrice
)SELECT vTicketFk,
98,
- vQuantity,
i.longName,
vLastCost,
currency_getRate(vCurrencyFk, NULL) * vLastCost
FROM vn.item i
WHERE i.id = vItemFk;
END$$

View File

@ -1,43 +1,42 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleSplit`(vSaleFk INT, vQuantity INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleSplit`(
vSaleFk INT,
vQuantity INT
)
BEGIN
DECLARE vNewSaleFk INT;
DECLARE vNewSaleFk INT;
INSERT INTO vn.sale(itemFk,
concept,
price,
discount,
quantity,
ticketFk,
isPriceFixed)
SELECT s.itemFk,
i.longName,
s.price,
s.discount,
vQuantity,
s.ticketFk,
s.isPriceFixed
INSERT INTO vn.sale(
itemFk,
concept,
price,
foreignPrice,
discount,
quantity,
ticketFk,
isPriceFixed
)SELECT s.itemFk,
i.longName,
s.price,
s.foreignPrice,
s.discount,
vQuantity,
s.ticketFk,
s.isPriceFixed
FROM vn.sale s
JOIN vn.item i ON i.id = s.itemFk
WHERE s.id = vSaleFk;
UPDATE vn.sale s
JOIN vn.item i ON i.id = s.itemFk
SET s.quantity = s.quantity - vQuantity, s.concept = i.longName
WHERE s.id = vSaleFk;
SELECT LAST_INSERT_ID() INTO vNewSaleFk;
INSERT INTO vn.saleComponent( saleFk,
componentFk,
value)
SELECT vNewSaleFk,
componentFk,
value
FROM vn.saleComponent
WHERE saleFk = vSaleFk;
UPDATE vn.sale s
JOIN vn.item i ON i.id = s.itemFk
SET s.quantity = s.quantity - vQuantity, s.concept = i.longName
WHERE s.id = vSaleFk;
SELECT LAST_INSERT_ID() INTO vNewSaleFk;
INSERT INTO vn.saleComponent(saleFk, componentFk, value)
SELECT vNewSaleFk, componentFk, value
FROM vn.saleComponent
WHERE saleFk = vSaleFk;
END$$
DELIMITER ;

View File

@ -1,22 +1,24 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_PriceFix`(vTicketFk INT)
BEGIN
DELETE sc.*
FROM vn.saleComponent sc
JOIN vn.sale s ON s.id = sc.saleFk
JOIN vn.component c ON c.id = sc.componentFk
JOIN vn.componentType ct ON ct.id = c.typeFk
DELETE sc
FROM saleComponent sc
JOIN sale s ON s.id = sc.saleFk
JOIN component c ON c.id = sc.componentFk
JOIN componentType ct ON ct.id = c.typeFk
WHERE s.ticketFk = vTicketFk
AND ct.code = 'other';
UPDATE vn.sale s
JOIN (
SELECT sc.saleFk, sum(sc.value ) price
FROM vn.saleComponent sc
JOIN vn.sale s ON s.id = sc.saleFk
WHERE s.ticketFk = vTicketFk
GROUP BY sc.saleFk) sub ON sub.saleFk = s.id
SET s.price = sub.price;
UPDATE sale s
JOIN (
SELECT sc.saleFk, SUM(sc.value) price, t.currencyFk
FROM ticket
JOIN sale s ON s.ticketFk = t.id
JOIN saleComponent sc ON sc.saleFk = s.id
WHERE t.id = vTicketFk
GROUP BY sc.saleFk) sub ON sub.saleFk = s.id
SET s.price = sub.price,
s.foreignPrice = currency_getRate(sub.currencyFk, NULL) * sub.price;
END$$
DELIMITER ;

View File

@ -1,15 +1,24 @@
DELIMITER $$
$$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE vn.sale_boxPickingPrint(
IN vPrinterFk INT,
IN vSaleFk INT,
IN vPacking INT,
IN vSectorFk INT,
IN vUserFk INT,
IN vPackagingFk VARCHAR(10),
IN vPackingSiteFk INT)
vPrinterFk INT,
vSaleFk INT,
vPacking INT,
vSectorFk INT,
vUserFk INT,
vPackagingFk VARCHAR(10),
vPackingSiteFk INT
)
BEGIN
/** Splits a line of sale to a different ticket and prints the transport sticker
/**
* Splits a line of sale to a different ticket and prints the transport sticker
*
* @param vPrinterFk Id printer
* @param vSaleFk Id sale
* @param vPacking Id packing
* @param vSectorFk Id sector
* @param vUserFk Id user
* @param vPackagingFk Id packaging
* @param vPackingSiteFk Id PackingSite
*/
DECLARE vAgencyModeFk INT;
DECLARE vConcept VARCHAR(30);
@ -30,25 +39,38 @@ BEGIN
DECLARE vShelvingFk VARCHAR(10);
DECLARE vTicketFk INT;
SELECT s.quantity,
s.quantity MOD vPacking,
s.ticketFk,
s.itemFk,
s.concept
SELECT quantity,
quantity MOD vPacking,
ticketFk,
itemFk,
concept
INTO vQuantity,
vRemainder,
vTicketFk,
vItemFk,
vConcept
FROM sale s
WHERE s.id = vSaleFk;
WHERE id = vSaleFk;
IF vRemainder THEN
UPDATE sale SET quantity = quantity - vRemainder WHERE id = vSaleFk;
INSERT INTO sale(ticketFk, itemFk, quantity, price, discount, concept)
SELECT ticketFk, itemFk, vRemainder, price, discount, concept
FROM sale
INSERT INTO sale(
ticketFk,
itemFk,
quantity,
price,
foreignPrice,
discount,
concept
)SELECT ticketFk,
itemFk,
vRemainder,
price,
foreignPrice,
discount,
concept
FROM sale
WHERE id = vSaleFk;
SET vRemainderSaleFk = LAST_INSERT_ID();
@ -62,7 +84,6 @@ BEGIN
w1: WHILE vQuantity >= vPacking DO
SET vQuantity = vQuantity - vPacking;
SET vItemShelvingFk = NULL;
SELECT sub.id
@ -114,25 +135,25 @@ w1: WHILE vQuantity >= vPacking DO
AND tt.clientFk = t.clientFk
AND t.shipped BETWEEN tt.shipped AND util.dayend(tt.shipped)
AND t.warehouseFk = tt.warehouseFk
WHERE tls.name = 'Encajado' ;
WHERE tls.name = 'Encajado';
IF ISNULL(vNewTicketFk) THEN
INSERT INTO ticket( clientFk,
shipped,
addressFk,
agencyModeFk,
nickname,
warehouseFk,
companyFk,
landed,
zoneFk,
zonePrice,
zoneBonus,
routeFk,
priority,
hasPriority,
clonedFrom)
SELECT clientFk,
shipped,
addressFk,
agencyModeFk,
nickname,
warehouseFk,
companyFk,
landed,
zoneFk,
zonePrice,
zoneBonus,
routeFk,
priority,
hasPriority,
clonedFrom
)SELECT clientFk,
shipped,
addressFk,
agencyModeFk,
@ -161,9 +182,9 @@ w1: WHILE vQuantity >= vPacking DO
UPDATE sale SET quantity = quantity - vPacking WHERE id = vSaleFk;
UPDATE itemShelving
SET visible = visible - vPacking,
available = available - vPacking
WHERE id = vItemShelvingFk;
SET visible = visible - vPacking,
available = available - vPacking
WHERE id = vItemShelvingFk;
SET vNewSaleFk = NULL;
@ -199,8 +220,21 @@ w1: WHILE vQuantity >= vPacking DO
WHERE id = vItemShelvingSaleFk;
END IF;
ELSE
INSERT INTO sale(ticketFk, itemFk, concept, quantity, discount, price)
SELECT vNewTicketFk, itemFk, concept, vPacking, discount, price
INSERT INTO sale(
ticketFk,
itemFk,
concept,
quantity,
discount,
price,
foreignPrice
)SELECT vNewTicketFk,
itemFk,
concept,
vPacking,
discount,
price,
foreignPrice
FROM sale
WHERE id = vSaleFk;
@ -227,19 +261,18 @@ w1: WHILE vQuantity >= vPacking DO
WHERE id = vNewTicketFk;
INSERT INTO expedition(
agencyModeFk,
ticketFk,
freightItemFk,
workerFk,
packagingFk,
itemPackingTypeFk,
hostFk,
packingSiteFk,
monitorId,
started,
ended
)
SELECT vAgencyModeFk,
agencyModeFk,
ticketFk,
freightItemFk,
workerFk,
packagingFk,
itemPackingTypeFk,
hostFk,
packingSiteFk,
monitorId,
started,
ended
)SELECT vAgencyModeFk,
vNewTicketFk,
pc.defaultFreightItemFk,
vUserFk,
@ -256,7 +289,6 @@ w1: WHILE vQuantity >= vPacking DO
WHERE ps.id = vPackingSiteFk;
SET vExpeditionFk = LAST_INSERT_ID();
SET vLastExpeditionTimeStamp = NOW();
CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
@ -282,8 +314,6 @@ w1: WHILE vQuantity >= vPacking DO
DELETE FROM sale
WHERE quantity = 0
AND id = vSaleFk;
END WHILE;
END$$
DELIMITER ;

View File

@ -2,11 +2,11 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_replaceItem`(vSaleFk INT, vNewItemFk INT, vQuantity INT)
BEGIN
/**
* Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones.
* Añade un nuevo artículo para sustituir a otro, y actualiza la memoria de sustituciones.
*
* @param vSaleFk id de la tabla sale
* @param vNewItemFk articulo sustituto
* @param vQuantity cantidad que se va a sustituir
* @param vSaleFk Id de la tabla sale
* @param vNewItemFk Artículo sustituto
* @param vQuantity Cantidad que se va a sustituir
*/
DECLARE vTicketFk INT;
DECLARE vItemFk INT;
@ -21,9 +21,13 @@ BEGIN
DECLARE vAgencyModeFk INT;
DECLARE vNewPrice DECIMAL(10,2);
DECLARE vOldPrice DECIMAL(10,2);
DECLARE vNewForeignPrice DECIMAL(10,2);
DECLARE vOldForeignPrice DECIMAL(10,2);
DECLARE vOption VARCHAR(255);
DECLARE vNewSaleFk INT;
DECLARE vFinalPrice DECIMAL(10,2);
DECLARE vFinalForeignPrice DECIMAL(10,2);
DECLARE vCurrencyFk INT;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@ -39,7 +43,9 @@ BEGIN
t.landed,
t.addressFk,
t.agencyModeFk,
s.price
s.price,
s.foreignPrice,
t.currencyFk
INTO vTicketFk,
vQuantity,
vItemFk,
@ -48,7 +54,9 @@ BEGIN
vLanded,
vAddressFk,
vAgencyModeFk,
vOldPrice
vOldPrice,
vOldForeignPrice,
vCurrencyFk
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
WHERE s.id = vSaleFk;
@ -62,7 +70,7 @@ BEGIN
WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk;
DROP TEMPORARY TABLE tmp.buyUltimate;
IF vGroupingMode = 'packing' AND vPacking > 0 THEN
SET vRoundQuantity = vPacking;
END IF;
@ -74,9 +82,10 @@ BEGIN
vLanded,
vAddressFk,
vAgencyModeFk,
vCurrencyFk,
vNewItemFk);
SELECT price INTO vNewPrice
SELECT price, foreignPrice INTO vNewPrice, vNewForeignPrice
FROM tmp.ticketComponentPrice
ORDER BY (vQuantity % `grouping`) ASC
LIMIT 1;
@ -86,11 +95,13 @@ BEGIN
END IF;
IF vNewPrice > vOldPrice THEN
SET vFinalPrice = vOldPrice;
SET vOption = 'substitution';
SET vFinalPrice = vOldPrice,
vFinalForeignPrice = vOldForeignPrice,
vOption = 'substitution';
ELSE
SET vFinalPrice = vNewPrice;
SET vOption = 'renewPrices';
SET vFinalPrice = vNewPrice,
vFinalForeignPrice = vNewForeignPrice,
vOption = 'renewPrices';
END IF;
START TRANSACTION;
@ -104,12 +115,14 @@ BEGIN
itemFk,
quantity,
concept,
price)
price,
foreignPrice)
SELECT vTicketFk,
vNewItemFk,
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity,
CONCAT('+ ', i.name),
vFinalPrice
vFinalPrice,
vFinalForeignPrice
FROM vn.item i
WHERE id = vNewItemFk;

View File

@ -1,18 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketCalculateFromType`( vLanded DATE,
vAddressFk INT,
vAgencyModeFk INT,
vTypeFk INT)
BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.item;
CREATE TEMPORARY TABLE tmp.item
(INDEX (itemFk))
ENGINE = MEMORY
SELECT id itemFk FROM vn.item
WHERE typeFk = vTypeFk;
CALL catalog_calculate(vLanded, vAddressFk, vAgencyModeFk, FALSE);
DROP TEMPORARY TABLE tmp.item;
DROP TEMPORARY TABLE tmp.ticketLot;
END$$
DELIMITER ;

View File

@ -1,28 +1,30 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(vCode VARCHAR(25))
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketComponentUpdateSale`(
vCode VARCHAR(25)
)
BEGIN
/**
* A partir de la tabla tmp.sale, crea los Movimientos_componentes
* y modifica el campo Preu de la tabla Movimientos
* y modifica el campo vn.sale.price
*
* @param i_option integer tipo de actualizacion
* @param vCode integer tipo de actualizacion
* @param table tmp.sale tabla memory con el campo saleFk, warehouseFk
**/
DECLARE vComponentFk INT;
IF vCode <> 'renewPrices' THEN
IF vCode <> 'renewPrices' THEN
SELECT id INTO vComponentFk FROM component WHERE `code` = vCode;
END IF;
DELETE sc.*
FROM tmp.sale tmps
DELETE sc
FROM tmp.sale tmps
JOIN saleComponent sc ON sc.saleFk = tmps.saleFk
JOIN `component` c ON c.id = sc.componentFk
WHERE c.isRenewable;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, tc.componentFk, tc.cost
FROM sale s
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
@ -40,7 +42,7 @@ BEGIN
JOIN cache.last_buy lb ON lb.item_id = s.itemFk AND tmps.warehouseFk = lb.warehouse_id
JOIN vn.buy b ON b.id = buy_id
JOIN tmp.ticketComponent tc ON tc.itemFk = s.itemFk AND tc.warehouseFk = tmps.warehouseFk
JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage'
JOIN `component` c ON c.id = tc.componentFk AND c.code = 'salePerPackage'
LEFT JOIN (
SELECT s.id
FROM vn.sale s
@ -63,43 +65,46 @@ BEGIN
HAVING dif <> 0;
ELSE
UPDATE sale s
JOIN ticket t ON t.id = s.ticketFk
JOIN item i on i.id = s.itemFk
JOIN itemType it on it.id = i.typeFk
JOIN (SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.price = sumValue / ((100 - s.discount) / 100)
WHERE it.code != 'PRT' ;
SET s.price = sumValue / ((100 - s.discount) / 100),
s.foreignPrice = currency_getRate(t.currencyFk, NULL) * (sumValue / ((100 - s.discount) / 100))
WHERE it.code <> 'PRT' ;
REPLACE INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 21, ROUND((s.price * (100 - s.discount) / 100) - SUM(value), 3) saleValue
FROM sale s
JOIN tmp.sale tmps ON tmps.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE sc.componentFk != 21
WHERE sc.componentFk <> 21
GROUP BY s.id
HAVING ROUND(saleValue, 4) <> 0;
END IF;
UPDATE sale s
JOIN (
SELECT SUM(sc.value) sumValue, sc.saleFk
SELECT SUM(sc.value) sumValue, sc.saleFk
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN `component` c ON c.id = sc.componentFk
JOIN componentType ct on ct.id = c.typeFk AND ct.isBase
GROUP BY sc.saleFk) sc ON sc.saleFk = s.id
SET s.priceFixed = sumValue, s.isPriceFixed = 1;
SET s.priceFixed = sumValue,
s.isPriceFixed = TRUE;
DELETE sc.*
DELETE sc
FROM saleComponent sc
JOIN tmp.sale tmps ON tmps.saleFk = sc.saleFk
JOIN sale s on s.id = sc.saleFk
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE it.code = 'PRT';
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT s.id, 15, s.price
FROM sale s

View File

@ -2,35 +2,33 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketGetVisibleAvailable`(
vTicket INT)
BEGIN
DECLARE vVisibleCalc INT;
DECLARE vAvailableCalc INT;
DECLARE vShipped DATE;
DECLARE vWarehouse TINYINT;
DECLARE vAlertLevel INT;
DECLARE vVisibleCalc INT;
DECLARE vAvailableCalc INT;
DECLARE vShipped DATE;
DECLARE vWarehouse TINYINT;
DECLARE vAlertLevel INT;
DECLARE vAlertLevelFree INT;
SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id
SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id
INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree
FROM ticket t
FROM ticket t
JOIN alertLevel al ON al.code = 'FREE'
LEFT JOIN ticketState ts ON ts.ticketFk = vTicket
WHERE t.id = vTicket;
LEFT JOIN ticketState ts ON ts.ticketFk = vTicket
WHERE t.id = vTicket;
IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN
IF vShipped >= util.VN_CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
END IF;
IF vShipped = util.VN_CURDATE() THEN
CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse);
END IF;
END IF;
IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN
IF vShipped >= util.VN_CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
END IF;
IF vShipped = util.VN_CURDATE() THEN
CALL cache.visible_refresh(vVisibleCalc, FALSE, vWarehouse);
END IF;
END IF;
SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.reserved, s.discount, v.visible, av.available, it.image, it.subName
FROM sale s
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCalc
LEFT JOIN cache.available av ON av.item_id = s.itemFk AND av.calc_id = vAvailableCalc
LEFT JOIN item it ON it.id = s.itemFk
WHERE s.ticketFk = vTicket
ORDER BY s.concept;
SELECT s.itemFk, v.visible, av.available
FROM sale s
LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCalc
LEFT JOIN cache.available av ON av.item_id = s.itemFk AND av.calc_id = vAvailableCalc
WHERE s.ticketFk = vTicket;
END$$
DELIMITER ;

View File

@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketPackaging_add`(
vClientFk INT,
vDated DATE,
vCompanyFk INT,
vCurrencyFk INT,
vWithoutPeriodGrace BOOLEAN)
BEGIN
/**
@ -12,6 +13,7 @@ BEGIN
* @param vClientFk Cliente en caso de NULL todos los clientes
* @param vDated Fecha hasta la cual se revisan los embalajes
* @param vCompanyFk Empresa de la cual se comprobaran sus clientes
* @param vCurrencyFk Id de la moneda
* @param vWithoutPeriodGrace si no se aplica el periodo de gracia de un mes
*/
DECLARE vNewTicket INT;
@ -22,7 +24,7 @@ BEGIN
DECLARE vComponentCost INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vClientId INT;
DECLARE vCursor CURSOR FOR
SELECT DISTINCT clientFk
FROM (
@ -42,31 +44,31 @@ BEGIN
RESIGNAL;
END;
SELECT id INTO vWarehouseInventory
FROM warehouse
SELECT id INTO vWarehouseInventory
FROM warehouse
WHERE `code`= 'inv';
SELECT id INTO vComponentCost
FROM component
SELECT id INTO vComponentCost
FROM component
WHERE `code`= 'purchaseValue';
SELECT packagingInvoicingDated INTO vDateStart
FROM ticketConfig;
SELECT packagingInvoicingDated INTO vDateStart
FROM ticketConfig;
IF vWarehouseInventory IS NULL THEN
CALL util.throw('Warehouse inventory not set');
END IF;
IF vComponentCost IS NULL THEN
CALL util.throw('Component cost not set');
END IF;
END IF;
SET vDateEnd = vDated + INTERVAL 1 DAY;
IF NOT vWithoutPeriodGrace THEN
SET vGraceDate = vGraceDate -INTERVAL 1 MONTH;
END IF;
DROP TEMPORARY TABLE IF EXISTS tmp.packagingToInvoice;
CREATE TEMPORARY TABLE tmp.packagingToInvoice
(INDEX (clientFk))
@ -79,7 +81,7 @@ BEGIN
t.clientFk
FROM ticketPackaging tp
JOIN packaging p ON p.id = tp.packagingFk
JOIN ticket t ON t.id = tp.ticketFk
JOIN ticket t ON t.id = tp.ticketFk
JOIN client c ON c.id = t.clientFk
WHERE c.isActive
AND (vClientFk IS NULL OR t.clientFk = vClientFk)
@ -87,7 +89,7 @@ BEGIN
AND (tp.quantity < 0 OR (tp.quantity > 0 AND t.shipped < vGraceDate))
AND tp.quantity
AND p.itemFk;
OPEN vCursor;
l: LOOP
@ -100,25 +102,26 @@ BEGIN
START TRANSACTION;
CALL ticket_add(
vClientId,
vClientId,
vDateEnd,
vWarehouseInventory,
vCompanyFk,
NULL,
NULL,
NULL,
vDateEnd,
account.myUser_getId(),
vWarehouseInventory,
vCompanyFk,
NULL,
NULL,
NULL,
vDateEnd,
account.myUser_getId(),
TRUE,
vCurrencyFk,
vNewTicket);
INSERT INTO ticketPackaging(ticketFk, packagingFk, quantity, pvp)
SELECT vNewTicket, packagingFk, - SUM(quantity) totalQuantity, price
FROM tmp.packagingToInvoice
FROM tmp.packagingToInvoice
WHERE clientFk = vClientId
GROUP BY packagingFk
HAVING IF(vWithoutPeriodGrace, totalQuantity <> 0, totalQuantity < 0);
INSERT INTO sale(ticketFk, itemFk, concept, quantity, price)
SELECT vNewTicket, pti.itemFk, i.name, SUM(pti.quantity) totalQuantity, pti.price
FROM tmp.packagingToInvoice pti
@ -126,12 +129,12 @@ BEGIN
WHERE pti.clientFk = vClientId
GROUP BY pti.itemFk
HAVING IF(vWithoutPeriodGrace, totalQuantity <> 0, totalQuantity > 0);
INSERT INTO saleComponent(saleFk, componentFk, value)
SELECT id, vComponentCost, price
FROM sale
WHERE ticketFk = vNewTicket;
COMMIT;
END LOOP;
CLOSE vCursor;

View File

@ -1,5 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_Clone`(vOriginalTicket INT, OUT vNewTicket INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_Clone`(
vOriginalTicket INT,
OUT vNewTicket INT
)
BEGIN
/**
* Clona el contenido de un ticket en otro
@ -29,10 +32,9 @@ BEGIN
routeFk,
priority,
hasPriority,
clonedFrom
)
SELECT
clientFk,
clonedFrom,
currencyFk
)SELECT clientFk,
shipped,
addressFk,
agencyModeFk,
@ -46,7 +48,8 @@ BEGIN
routeFk,
priority,
hasPriority,
vOriginalTicket
vOriginalTicket,
currencyFk
FROM ticket
WHERE id = vOriginalTicket;

View File

@ -1,16 +1,18 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_add`(
vClientId INT
,vShipped DATE
,vWarehouseFk INT
,vCompanyFk INT
,vAddressFk INT
,vAgencyModeFk INT
,vRouteFk INT
,vlanded DATE
,vUserId INT
,vIsRequiredZone INT
,OUT vNewTicket INT)
vClientId INT,
vShipped DATE,
vWarehouseFk INT,
vCompanyFk INT,
vAddressFk INT,
vAgencyModeFk INT,
vRouteFk INT,
vlanded DATE,
vUserId INT,
vIsRequiredZone INT,
vCurrencyFk INT,
OUT vNewTicket INT
)
BEGIN
/**
* Crea un ticket,
@ -30,8 +32,11 @@ BEGIN
*/
DECLARE vZoneFk INT;
DECLARE vPrice DECIMAL(10,2);
DECLARE vForeignPrice DECIMAL(10,2);
DECLARE vBonus DECIMAL(10,2);
DECLARE vIsActive BOOL;
DECLARE vDefaultCompanyFk INT;
DECLARE vDefaultCurrencyFk INT;
IF vClientId IS NULL THEN
CALL util.throw ('CLIENT_NOT_ESPECIFIED');
@ -52,6 +57,13 @@ BEGIN
AND isDefaultAddress;
END IF;
IF vCompanyFk IS NULL OR vCurrencyFk IS NULL THEN
SELECT DEFAULT(companyFk), DEFAULT(currencyFk)
INTO vDefaultCompanyFk, vDefaultCurrencyFk
FROM ticket
LIMIT 1;
END IF;
IF vAgencyModeFk IS NOT NULL THEN
CALL vn.zone_getShipped (vlanded, vAddressFk, vAgencyModeFk, TRUE);
@ -65,7 +77,7 @@ BEGIN
IF (vZoneFk IS NULL OR vZoneFk = 0) AND vIsRequiredZone THEN
CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS');
END IF;
DROP TEMPORARY TABLE tmp.zoneGetShipped;
END IF;
@ -81,7 +93,8 @@ BEGIN
landed,
zoneFk,
zonePrice,
zoneBonus
zoneBonus,
currencyFk
)
SELECT vClientId,
vShipped,
@ -90,11 +103,12 @@ BEGIN
a.nickname,
vWarehouseFk,
IF(vRouteFk,vRouteFk,NULL),
vCompanyFk,
IFNULL(vCompanyFk, vDefaultCompanyFk),
vlanded,
vZoneFk,
vPrice,
vBonus
vBonus,
IFNULL(vCurrencyFk, vDefaultCurrencyFk)
FROM address a
JOIN agencyMode am ON am.id = a.agencyModeFk
WHERE a.id = vAddressFk;

View File

@ -1,19 +1,20 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_administrativeCopy`(vOriginalTicket INT, OUT vNewTicket INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_administrativeCopy`(
vOriginalTicket INT,
OUT vNewTicket INT
)
BEGIN
INSERT INTO vn.ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed)
SELECT t.clientFk , t.addressFk , t.shipped ,w.id, t.companyFk , t.landed
FROM vn.ticket t
INSERT INTO ticket(clientFk, addressFk, shipped, warehouseFk, companyFk, landed, currencyFk)
SELECT t.clientFk, t.addressFk, t.shipped, w.id, t.companyFk, t.landed, t.currencyFk
FROM ticket t
JOIN vn.warehouse w ON w.name = 'INVENTARIO'
WHERE t.id = vOriginalTicket;
SELECT LAST_INSERT_ID() INTO vNewTicket;
INSERT INTO vn.sale(ticketFk, itemFk, concept, quantity, price, discount)
SELECT vNewTicket, s.itemFk , s.concept , s.quantity , s.price , s.discount
FROM vn.sale s
WHERE s.ticketFk = vOriginalTicket;
INSERT INTO sale(ticketFk, itemFk, concept, quantity, price, discount, foreignPrice)
SELECT vNewTicket, itemFk , concept, quantity, price, discount, foreignPrice
FROM sale
WHERE ticketFk = vOriginalTicket;
END$$
DELIMITER ;

View File

@ -1,55 +1,76 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(
vTicketFk INT,
vNewShipped DATE,
vWithWarehouse BOOLEAN,
OUT vNewTicketFk INT
)
BEGIN
DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE vOldSaleFk INT;
DECLARE vNewSaleFk INT;
DECLARE cur1 CURSOR FOR
SELECT id
FROM sale
WHERE ticketFk = vTicketFk;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
CALL ticket_Clone(vTicketFk, vNewTicketFk);
UPDATE ticket
UPDATE ticket
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
shipped = vNewShipped,
warehouseFk = IF(vWithWarehouse, warehouseFk, NULL)
WHERE id = vNewTicketFk;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO vOldSaleFk;
IF vDone THEN
LEAVE read_loop;
END IF;
INSERT INTO sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
INSERT INTO sale(
ticketFk,
itemFk,
quantity,
concept,
price,
foreignPrice,
discount,
priceFixed,
isPriceFixed
)SELECT vNewTicketFk,
itemFk,
quantity,
concept,
price,
foreignPrice,
discount,
priceFixed,
isPriceFixed
FROM sale
WHERE id = vOldSaleFk;
SELECT max(id) INTO vNewSaleFk
SELECT MAX(id) INTO vNewSaleFk
FROM sale
WHERE ticketFk = vNewTicketFk;
INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
SELECT vNewSaleFk, componentFk, value, isGreuge
FROM saleComponent
WHERE saleFk = vOldSaleFk;
END LOOP;
CLOSE cur1;
END$$
DELIMITER ;

View File

@ -12,6 +12,7 @@ BEGIN
DECLARE vCompanyFk INT;
DECLARE vAddressFk INT;
DECLARE vAgencyModeFk INT;
DECLARE vCurrencyFk INT;
DECLARE vNewTicket INT;
DECLARE vYear INT;
DECLARE vObservationSalesPersonFk INT
@ -29,6 +30,7 @@ BEGIN
t.clientFk,
t.warehouseFk,
t.companyFk,
t.currencyFk,
t.addressFk,
tt.agencyModeFk,
ti.dated
@ -49,6 +51,7 @@ BEGIN
vClientFk,
vWarehouseFk,
vCompanyFk,
vCurrencyFk,
vAddressFk,
vAgencyModeFk,
vShipment;
@ -92,6 +95,7 @@ BEGIN
vLanding,
account.myUser_getId(),
FALSE,
vCurrencyFk,
vNewTicket);
UPDATE ticket
@ -103,6 +107,7 @@ BEGIN
concept,
quantity,
price,
foreignPrice,
discount,
priceFixed,
isPriceFixed)
@ -111,6 +116,7 @@ BEGIN
concept,
quantity,
price,
foreignPrice,
discount,
priceFixed,
isPriceFixed

View File

@ -18,6 +18,7 @@ BEGIN
DECLARE vWithPackage BOOL;
DECLARE vHasToInvoice BOOL;
DECLARE vSerial VARCHAR(2);
DECLARE vCurrencyFk INT;
DECLARE cur CURSOR FOR
SELECT ticketFk FROM tmp.ticket_close;
@ -45,14 +46,16 @@ BEGIN
t.shipped,
c.hasDailyInvoice,
w.isManaged,
c.hasToInvoice
c.hasToInvoice,
t.currencyFk
INTO vClientFk,
vIsTaxDataChecked,
vCompanyFk,
vShipped,
vHasDailyInvoice,
vWithPackage,
vHasToInvoice
vHasToInvoice,
vCurrencyFk
FROM ticket t
JOIN `client` c ON c.id = t.clientFk
JOIN warehouse w ON w.id = t.warehouseFk
@ -71,14 +74,29 @@ BEGIN
GROUP BY p.itemFk);
-- No retornables o no catalogados
INSERT INTO sale (itemFk, ticketFk, concept, quantity, price, isPriceFixed)
(SELECT e.freightItemFk, vCurTicketFk, i.name, COUNT(*) AS amount, getSpecialPrice(e.freightItemFk, vClientFk), 1
INSERT INTO sale (
itemFk,
ticketFk,
concept,
quantity,
price,
foreignPrice,
isPriceFixed
)SELECT e.freightItemFk,
vCurTicketFk,
i.name,
COUNT(*),
getSpecialPrice(e.freightItemFk, vClientFk),
getSpecialPrice(e.freightItemFk, vClientFk) *
currency_getRate(vCurrencyFk, vShipped - INTERVAL 1 DAY),
TRUE
FROM expedition e
JOIN item i ON i.id = e.freightItemFk
LEFT JOIN packaging p ON p.itemFk = i.id
WHERE e.ticketFk = vCurTicketFk AND IFNULL(p.isPackageReturnable, 0) = 0
AND getSpecialPrice(e.freightItemFk, vClientFk) > 0
GROUP BY e.freightItemFk);
GROUP BY e.freightItemFk;
IF(vHasDailyInvoice) AND vHasToInvoice THEN
SELECT invoiceSerial(vClientFk, vCompanyFk, 'quick') INTO vSerial;

View File

@ -2,6 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_componentMakeUpdate`(
vTicketFk INT,
vClientFk INT,
vCurrencyFk INT,
vNickname VARCHAR(50),
vAgencyModeFk INT,
vAddressFk INT,
@ -12,75 +13,74 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_componentMakeU
vLanded DATE,
vIsDeleted BOOLEAN,
vHasToBeUnrouted BOOLEAN,
vOption VARCHAR(25))
vOption VARCHAR(25)
)
BEGIN
/**
* Modifica en el ticket los campos que se le pasan por parámetro
* y cambia sus componentes
*
* @param vTicketFk Id del ticket a modificar
* @param vClientFk nuevo cliente
* @param vNickname nuevo alias
* @param vAgencyModeFk nueva agencia
* @param vAddressFk nuevo consignatario
* @param vZoneFk nueva zona
* @param vWarehouseFk nuevo almacen
* @param vCompanyFk nueva empresa
* @param vShipped nueva fecha del envio de mercancia
* @param vLanded nueva fecha de recepcion de mercancia
* @param vIsDeleted si se borra el ticket
* @param vHasToBeUnrouted si se le elimina la ruta al ticket
* @param vOption opcion para el case del proc ticketComponentUpdateSale
*/
/**
* Modifica en el ticket los campos que se le pasan por parámetro
* y cambia sus componentes
*
* @param vTicketFk Id del ticket a modificar
* @param vClientFk nuevo cliente
* @param vCurrencyFk moneda
* @param vNickname nuevo alias
* @param vAgencyModeFk nueva agencia
* @param vAddressFk nuevo consignatario
* @param vZoneFk nueva zona
* @param vWarehouseFk nuevo almacen
* @param vCompanyFk nueva empresa
* @param vShipped nueva fecha del envio de mercancia
* @param vLanded nueva fecha de recepcion de mercancia
* @param vIsDeleted si se borra el ticket
* @param vHasToBeUnrouted si se le elimina la ruta al ticket
* @param vOption opcion para el case del proc ticketComponentUpdateSale
*/
DECLARE vPrice DECIMAL(10,2);
DECLARE vBonus DECIMAL(10,2);
CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
UPDATE ticket t
UPDATE ticket t
JOIN address a ON a.id = vAddressFk
SET t.nickname = a.nickname
WHERE t.id = vTicketFk;
END IF;
CALL zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, TRUE);
SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
SELECT zoneFk, price, bonus INTO vZoneFk, vPrice, vBonus
FROM tmp.zoneGetShipped
WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped) AND warehouseFk = vWarehouseFk LIMIT 1;
WHERE shipped BETWEEN DATE(vShipped) AND util.dayEnd(vShipped)
AND warehouseFk = vWarehouseFk
LIMIT 1;
UPDATE ticket t
SET
t.clientFk = vClientFk,
t.nickname = vNickname,
t.agencyModeFk = vAgencyModeFk,
t.addressFk = vAddressFk,
t.zoneFk = vZoneFk,
t.zonePrice = vPrice,
t.zoneBonus = vBonus,
t.warehouseFk = vWarehouseFk,
t.companyFk = vCompanyFk,
t.landed = vLanded,
t.shipped = vShipped,
t.isDeleted = vIsDeleted
WHERE
t.id = vTicketFk;
UPDATE ticket
SET clientFk = vClientFk,
nickname = vNickname,
agencyModeFk = vAgencyModeFk,
addressFk = vAddressFk,
zoneFk = vZoneFk,
zonePrice = vPrice,
zoneBonus = vBonus,
warehouseFk = vWarehouseFk,
companyFk = vCompanyFk,
landed = vLanded,
shipped = vShipped,
isDeleted = vIsDeleted,
currencyFk = vCurrencyFk
WHERE id = vTicketFk;
IF vHasToBeUnrouted THEN
UPDATE ticket t SET t.routeFk = NULL
WHERE t.id = vTicketFk;
UPDATE ticket SET routeFk = NULL
WHERE id = vTicketFk;
END IF;
DROP TEMPORARY TABLE IF EXISTS tmp.sale;
CREATE TEMPORARY TABLE tmp.sale
(PRIMARY KEY (saleFk))
ENGINE = MEMORY
SELECT id AS saleFk, vWarehouseFk warehouseFk
SELECT id saleFk, vWarehouseFk warehouseFk
FROM sale s WHERE s.ticketFk = vTicketFk;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
@ -89,9 +89,7 @@ BEGIN
CALL ticketComponentUpdateSale (vOption);
DROP TEMPORARY TABLE tmp.sale;
DROP TEMPORARY TABLE IF EXISTS tmp.ticketComponent;
DROP TEMPORARY TABLE tmp.zoneGetShipped, tmp.ticketComponentPreview;
DROP TEMPORARY TABLE tmp.sale, tmp.zoneGetShipped, tmp.ticketComponentPreview;
END$$
DELIMITER ;

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_componentPreview`(
vTicketFk INT,
vLanded DATE,
vLanded DATE,
vAddressFk INT,
vZoneFk INT,
vWarehouseFk SMALLINT)
@ -17,26 +17,28 @@ BEGIN
*
* @return tmp.ticketComponentPreview (warehouseFk, itemFk, componentFk, cost)
*/
DECLARE vHasDataChanged BOOL DEFAULT FALSE;
DECLARE vHasDataChanged BOOL DEFAULT FALSE;
DECLARE vHasAddressChanged BOOL;
DECLARE vHasZoneChanged BOOL DEFAULT FALSE;
DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE;
DECLARE vCurrencyFk INT;
DECLARE vShipped DATE;
DECLARE vAddressTypeRateFk INT DEFAULT NULL;
DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL;
DECLARE vHasChangeAll BOOL DEFAULT FALSE;
SELECT DATE(landed) <> vLanded,
addressFk <> vAddressFk,
SELECT DATE(landed) <> vLanded,
addressFk <> vAddressFk,
zoneFk <> vZoneFk,
warehouseFk <> vWarehouseFk
warehouseFk <> vWarehouseFk,
currencyFk
INTO
vHasDataChanged,
vHasAddressChanged,
vHasZoneChanged,
vHasWarehouseChanged
vHasWarehouseChanged,
vCurrencyFk
FROM vn.ticket t
WHERE t.id = vTicketFk;
@ -52,14 +54,14 @@ BEGIN
SET vAgencyModeTypeRateFk = 6;
END IF;
SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped
SELECT TIMESTAMPADD(DAY, -travelingDays, vLanded) INTO vShipped
FROM zone
WHERE id = vZoneFk;
CALL buy_getUltimate(NULL, vWarehouseFk, vShipped);
DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot;
CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY (
SELECT vWarehouseFk warehouseFk,
NULL available,
s.itemFk,
@ -71,7 +73,7 @@ BEGIN
GROUP BY bu.warehouseFk, bu.itemFk);
CALL catalog_componentPrepare();
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk, vCurrencyFk);
REPLACE INTO tmp.ticketComponent (warehouseFk, itemFk, componentFk, cost)
SELECT t.warehouseFk, s.itemFk, sc.componentFk, sc.value
@ -79,9 +81,9 @@ BEGIN
JOIN sale s ON s.id = sc.saleFk
JOIN ticket t ON t.id = s.ticketFk
JOIN `component` c ON c.id = sc.componentFk
WHERE s.ticketFk = vTicketFk
AND (c.isRenewable = FALSE
OR
WHERE s.ticketFk = vTicketFk
AND (c.isRenewable = FALSE
OR
(NOT vHasChangeAll
AND (NOT (c.typeFk <=> vAddressTypeRateFk
OR c.typeFk <=> vAgencyModeTypeRateFk))));

View File

@ -34,6 +34,7 @@ BEGIN
s.quantity,
s.concept,
s.price,
s.foreignPrice,
s.reserved,
s.discount,
i.image,

View File

@ -1,10 +1,11 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getWithParameters`(
vClientFk INT,
vClientFk INT,
vWarehouseFk INT,
vShipped DATE,
vAddressFk INT,
vCompanyFk INT,
vShipped DATE,
vAddressFk INT,
vCompanyFk INT,
vCurrencyFk INT,
vAgencyModeFk INT,
OUT vTicketFk INT
)
@ -17,9 +18,10 @@ BEGIN
* @param vShipped Fecha de preparacion
* @param vAddressFk Consignatario
* @param vCompanyFk Empresa
* @param vCurrencyFk Id de moneda
* @param vAgencyModeFk agencia
*/
*/
SELECT t.id INTO vTicketFk
FROM vn.ticket t
WHERE t.clientFk <=> vClientFk
@ -29,9 +31,9 @@ BEGIN
AND (t.companyFk <=> vCompanyFk OR vCompanyFk IS NULL)
AND (t.agencyModeFk <=> vAgencyModeFk OR vAgencyModeFk IS NULL)
LIMIT 1;
IF vTicketFk IS NULL THEN
CALL vn.ticket_add(
CALL vn.pticket_add(
vClientFk,
IFNULL(vShipped, util.VN_CURDATE()),
vWarehouseFk,
@ -42,6 +44,7 @@ BEGIN
vShipped,
`account`.`myUser_getId`(),
TRUE,
vCurrencyFk,
vTicketFk
);
END IF;

View File

@ -1,14 +1,15 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_priceDifference`(
vTicketFk INT,
vLanded DATE,
vLanded DATE,
vAddressFk INT,
vZoneFk INT,
vWarehouseFk INT)
vWarehouseFk INT
)
BEGIN
/**
* Devuelve las diferencias de precio de los movimientos de un ticket.
*
*
* @param vTicketFk Id del ticket
* @param vLanded Fecha de recepcion
* @param vAddressFk Id del consignatario
@ -17,26 +18,26 @@ BEGIN
*/
CALL vn.ticket_componentPreview(vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
SELECT s.itemFk,
i.name,
i.size,
i.category,
IFNULL(s.quantity, 0) AS quantity,
IFNULL(s.price, 0) AS price,
ROUND(SUM(tc.cost), 2) AS newPrice,
SELECT s.itemFk,
i.name,
i.size,
i.category,
IFNULL(s.quantity, 0) quantity,
IFNULL(s.price, 0) price,
ROUND(SUM(tc.cost), 2) newPrice,
s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference,
s.id AS saleFk
s.id saleFk
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk
JOIN item i ON i.id = s.itemFk
JOIN ticket t ON t.id = s.ticketFk
LEFT JOIN tmp.ticketComponentPreview tc ON tc.itemFk = s.itemFk
AND tc.warehouseFk = vWarehouseFk
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
AND sc.componentFk = tc.componentFk
LEFT JOIN `component` c ON c.id = tc.componentFk
WHERE t.id = vTicketFk
AND IF(sc.componentFk IS NULL
AND c.classRate IS NOT NULL, FALSE, TRUE)
LEFT JOIN `component` c ON c.id = tc.componentFk
WHERE t.id = vTicketFk
AND IF(sc.componentFk IS NULL
AND c.classRate IS NOT NULL, FALSE, TRUE)
GROUP BY s.id ORDER BY s.id;
DROP TEMPORARY TABLE tmp.ticketComponentPreview;

View File

@ -22,6 +22,11 @@ module.exports = Self => {
type: 'number',
description: 'The company id to invoice',
required: true
}, {
arg: 'currencyFk',
type: 'number',
description: 'The currency id',
required: true
},
],
returns: {
@ -34,7 +39,7 @@ module.exports = Self => {
}
});
Self.clientsToInvoice = async(ctx, clientId, invoiceDate, maxShipped, companyFk, options) => {
Self.clientsToInvoice = async(ctx, clientId, invoiceDate, maxShipped, companyFk, currencyFk, options) => {
let tx;
const myOptions = {userId: ctx.req.accessToken.userId};
@ -49,10 +54,11 @@ module.exports = Self => {
try {
// Packaging liquidation
const vIsAllInvoiceable = false;
await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [
await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?, ?)', [
clientId,
invoiceDate,
companyFk,
currencyFk,
vIsAllInvoiceable
], myOptions);
@ -71,6 +77,7 @@ module.exports = Self => {
AND t.shipped BETWEEN ? AND util.dayEnd(?)
AND (t.clientFk = ? OR ? IS NULL )
AND t.companyFk = ?
AND t.currencyFk = ?
AND c.hasToInvoice
AND c.isTaxDataChecked
AND c.isActive
@ -83,7 +90,8 @@ module.exports = Self => {
maxShipped,
clientId,
clientId,
companyFk
companyFk,
currencyFk
], myOptions);
if (tx) await tx.commit();

View File

@ -4,6 +4,7 @@ describe('InvoiceOut clientsToInvoice()', () => {
const userId = 1;
const clientId = 1101;
const companyFk = 442;
const currencyFk = 1;
const maxShipped = new Date();
maxShipped.setMonth(11);
maxShipped.setDate(31);
@ -42,7 +43,7 @@ describe('InvoiceOut clientsToInvoice()', () => {
try {
const addresses = await models.InvoiceOut.clientsToInvoice(
ctx, clientId, invoiceDate, maxShipped, companyFk, options);
ctx, clientId, invoiceDate, maxShipped, companyFk, currencyFk, options);
expect(addresses.length).toBeGreaterThan(0);
expect(addresses[0].clientId).toBe(clientId);
@ -66,7 +67,8 @@ describe('InvoiceOut clientsToInvoice()', () => {
const options = {transaction: tx};
try {
await models.InvoiceOut.clientsToInvoice(ctx, clientId, invoiceDate, maxShipped, companyFk, options);
await models.InvoiceOut.clientsToInvoice(
ctx, clientId, invoiceDate, maxShipped, companyFk, currencyFk, options);
} catch (e) {
expect(e.message).toBe('Test Error');
await tx.rollback();

View File

@ -84,9 +84,10 @@ module.exports = Self => {
required: true
},
{
arg: 'withWarningAccept',
type: 'boolean',
description: 'Has pressed in confirm message',
arg: 'currencyFk',
type: 'integer',
description: 'The currency id',
required: true
},
{
arg: 'newTicket',
@ -97,6 +98,11 @@ module.exports = Self => {
arg: 'keepPrice',
type: 'boolean',
description: 'If prices should be maintained',
},
{
arg: 'withWarningAccept',
type: 'boolean',
description: 'Has pressed in confirm message',
}
],
returns: {
@ -176,7 +182,8 @@ module.exports = Self => {
'landed',
'isDeleted',
'routeFk',
'nickname'
'nickname',
'currencyFk'
],
include: [
{
@ -206,7 +213,8 @@ module.exports = Self => {
companyFk: args.companyFk,
shipped: args.shipped,
landed: args.landed,
isDeleted: args.isDeleted
isDeleted: args.isDeleted,
currencyFk: args.currencyFk
};
let response;
@ -216,7 +224,7 @@ module.exports = Self => {
} else {
const hasToBeUnrouted = true;
response = await Self.rawSql(
'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
'CALL vn.ticket_componentMakeUpdate(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[args.id].concat(Object.values(ticketChanges), [hasToBeUnrouted, args.option]),
myOptions
);

View File

@ -46,6 +46,11 @@ module.exports = Self => {
arg: 'routeId',
type: 'number',
description: `The route id filter`
},
{
arg: 'currencyId',
type: 'number',
description: `The currency id filter`
}],
returns: {
type: 'object',
@ -106,19 +111,20 @@ module.exports = Self => {
args.landed = landedResult && landedResult.landed;
}
query = `CALL vn.ticket_add(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @result);
query = `CALL vn.ticket_add(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, @result);
SELECT @result newTicketId;`;
const result = await Self.rawSql(query, [
args.clientId,
args.shipped,
args.warehouseId,
args.companyId || 442,
args.companyId || null,
args.addressId,
args.agencyModeId || null,
args.routeId || null,
args.landed,
userId,
true,
userId
args.currencyId || null
], myOptions);
const ticket = await models.Ticket.findById(result[1][0].newTicketId, null, myOptions);

View File

@ -19,6 +19,7 @@ describe('ticket new()', () => {
landed: null,
warehouseId: 1,
companyId: 442,
currencyFk: 1,
addressId: 6
};
@ -47,6 +48,7 @@ describe('ticket new()', () => {
landed: null,
warehouseId: 1,
companyId: 442,
currencyFk: 1,
addressId: 'invalid address'
};
@ -73,6 +75,7 @@ describe('ticket new()', () => {
landed: today,
warehouseId: 2,
companyId: 442,
currencyFk: 1,
addressId: 4,
agencyModeId: 1
};
@ -102,6 +105,7 @@ describe('ticket new()', () => {
shipped: null,
warehouseId: 2,
companyId: 442,
currencyFk: 1,
addressId: 4,
agencyModeId: null
};

View File

@ -72,10 +72,11 @@ module.exports = Self => {
if (await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*')) return;
await models.Sale.rawSql(`CALL catalog_calcFromItem(?,?,?,?)`, [
await models.Sale.rawSql(`CALL catalog_calcFromItem(?,?,?,?,?)`, [
ticket.landed,
ticket.addressFk,
ticket.agencyModeFk,
ticket.currencyFk,
itemId
],
ctx.options);

View File

@ -70,6 +70,9 @@
"cmrFk": {
"type": "number"
},
"currencyFk": {
"type": "number"
},
"problem": {
"type": "string"
}

View File

@ -1,9 +1,10 @@
{
"name": "Currency",
"description": "Currencies",
"base": "VnModel",
"options": {
"mysql": {
"table": "currency"
"table": "currency"
}
},
"properties": {