7984-addCurrency #3316
|
@ -275,6 +275,7 @@ UPDATE `vn`.`agencyMode` SET `description` = `name`;
|
|||
INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount, employeeFk, `url`, testMode, testUrl, testKey, merchantUrl)
|
||||
VALUES (978, 1, 0, 2000, 9, 'https://sis.redsys.es/sis/realizarPago', 0, 'https://sis-t.redsys.es:25443/sis/realizarPago', 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', NULL);
|
||||
*/
|
||||
|
||||
INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk)
|
||||
VALUES (1, 442);
|
||||
|
||||
|
@ -312,3 +313,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`)
|
|||
FROM mysql.roles_mapping
|
||||
WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost;
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
|
|
|
@ -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, util.VN_CURDATE()),
|
||||
(7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5, util.VN_CURDATE());
|
||||
|
||||
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, 2, 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
|
||||
|
@ -2691,6 +2691,18 @@ UPDATE `vn`.`invoiceIn`
|
|||
SET isBooked = TRUE
|
||||
WHERE id IN (5, 7, 8, 9, 10);
|
||||
|
||||
INSERT INTO vn.referenceRate (currencyFk, dated, value)
|
||||
VALUES (2, '2000-12-01', 1.0495),
|
||||
(2, '2001-01-01', 1.0531),
|
||||
(2, '2001-02-01', 7.6347),
|
||||
(2, '2000-12-31', 7.6347);
|
||||
|
||||
UPDATE vn.ticket t
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.referenceRate rr ON rr.currencyFk = t.currencyFk
|
||||
AND rr.dated = util.VN_CURDATE()
|
||||
SET s.foreignPrice = s.price * vn.currency_getRate(t.currencyFk, NULL);
|
||||
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE `tmp`.`ticket_recalc`()
|
||||
BEGIN
|
||||
|
@ -4045,14 +4057,15 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
|
|||
INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate)
|
||||
VALUES (1106,'26493101E','2019-09-20');
|
||||
|
||||
INSERT INTO vn.referenceRate (currencyFk, dated, value)
|
||||
VALUES (2, '2000-12-01', 1.0495),
|
||||
(2, '2001-01-01', 1.0531),
|
||||
(2, '2001-02-01', 7.6347);
|
||||
|
||||
INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance)
|
||||
VALUES (1,'https://router.project-osrm.org', 0.002);
|
||||
|
||||
INSERT IGNORE INTO vn.inventoryConfig
|
||||
SET id = 1,
|
||||
supplierFk = 4;
|
||||
|
||||
UPDATE vn.ticket t
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.referenceRate rr ON rr.currencyFk = t.currencyFk
|
||||
AND rr.dated = util.VN_CURDATE()
|
||||
SET s.foreignPrice = s.price * vn.currency_getRate(t.currencyFk, NULL);
|
||||
|
|
|
@ -20,7 +20,7 @@ BEGIN
|
|||
|
||||
CALL order_getTotal;
|
||||
|
||||
SELECT total INTO vTotal FROM tmp.orderTotal;
|
||||
SELECT IFNULL(foreignTotal, total) INTO vTotal FROM tmp.orderTotal;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.`order`,
|
||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -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(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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
|
||||
|
|
|
@ -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$$
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -27,7 +28,7 @@ BEGIN
|
|||
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$$
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ BEGIN
|
|||
oro.amount * oro.price total,
|
||||
s.countryFk,
|
||||
ata.areaFk,
|
||||
itc.taxClassFk
|
||||
itc.taxClassFk,
|
||||
o.currencyFk
|
||||
FROM hedera.orderRow oro
|
||||
JOIN tmp.order tor ON tor.orderFk = oro.orderFk
|
||||
JOIN hedera.`order` o ON o.id = tor.orderFk
|
||||
|
@ -45,7 +46,10 @@ BEGIN
|
|||
SELECT o.orderFk,
|
||||
tc.code,
|
||||
SUM(o.total) taxableBase,
|
||||
pgc.rate
|
||||
pgc.rate,
|
||||
vn.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
|
||||
|
@ -61,8 +65,14 @@ BEGIN
|
|||
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,
|
||||
vn.currency_getRate(currencyFk, NULL) *
|
||||
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) foreignTax
|
||||
FROM tmp.orderTax
|
||||
GROUP BY orderFk, `code`;
|
||||
|
||||
|
|
|
@ -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.foreignTaxableBase + ot.foreignTax), 0.0) foreignTotal
|
||||
FROM tmp.`order` o
|
||||
LEFT JOIN tmp.orderAmount ot ON o.orderFk = ot.orderFk
|
||||
GROUP BY orderFk;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -22,8 +22,7 @@ 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
|
||||
|
@ -32,18 +31,18 @@ proc: BEGIN
|
|||
WHERE r.orderFk = vSelf;
|
||||
|
||||
UPDATE orderRow r
|
||||
LEFT JOIN tmp.ticketComponentPrice p
|
||||
ON p.warehouseFk = r.warehouseFk
|
||||
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 = vn.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$$
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
-- DELIMITER $$
|
||||
-- CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION vn.client_getCompany(vSelf INT)
|
||||
-- RETURNS INT(3)
|
||||
-- DETERMINISTIC
|
||||
-- BEGIN
|
||||
-- /**
|
||||
-- * Devuelve la moneda por defecto del cliente dado
|
||||
-- *
|
||||
-- * @param vSelf id del cliente
|
||||
-- * @return devuelve id de la compañia por defecto
|
||||
-- */
|
||||
-- DECLARE vCompanyFk INT;
|
||||
|
||||
-- SELECT co.currencyFk INTO vCompanyFk
|
||||
-- FROM client c
|
||||
-- JOIN vn.province p ON p.id = c.provinceFk
|
||||
-- JOIN vn.country co ON co.id = p.countryFk
|
||||
-- WHERE c.id = vSelf
|
||||
-- LIMIT 1;
|
||||
|
||||
-- RETURN vCompanyFk;
|
||||
-- END$$
|
||||
-- DELIMITER ;
|
|
@ -0,0 +1,23 @@
|
|||
-- DELIMITER $$
|
||||
-- CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION vn.client_getCurrency(vSelf INT)
|
||||
-- RETURNS INT(3)
|
||||
-- DETERMINISTIC
|
||||
-- BEGIN
|
||||
-- /**
|
||||
-- * Devuelve la moneda por defecto del cliente dado
|
||||
-- *
|
||||
-- * @param vSelf id del cliente
|
||||
-- * @return devuelve id del tipo de moneda
|
||||
-- */
|
||||
-- DECLARE vCurrencyFk INT;
|
||||
|
||||
-- SELECT co.currencyFk INTO vCurrencyFk
|
||||
-- FROM client c
|
||||
-- JOIN vn.province p ON p.id = c.provinceFk
|
||||
-- JOIN vn.country co ON co.id = p.countryFk
|
||||
-- WHERE c.id = vSelf
|
||||
-- LIMIT 1;
|
||||
|
||||
-- RETURN vCurrencyFk;
|
||||
-- END$$
|
||||
-- DELIMITER ;
|
|
@ -0,0 +1,29 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`currency_getRate`(
|
||||
vSelf VARCHAR(3),
|
||||
vDated DATE
|
||||
)
|
||||
RETURNS DECIMAL(10,2)
|
||||
NOT DETERMINISTIC
|
||||
READS SQL DATA
|
||||
BEGIN
|
||||
/**
|
||||
* Returns the rate exchange based on the specified currency
|
||||
* and yesterday's exchange rate.
|
||||
*
|
||||
* @param vSelf The currency code
|
||||
* @param vDated The date of exchangue
|
||||
* @return vForeignRate The rate e of currency exchange
|
||||
*/
|
||||
DECLARE vForeignRate DECIMAL(10,2);
|
||||
|
||||
SELECT value INTO vForeignRate
|
||||
FROM referenceRate
|
||||
WHERE dated = IFNULL(vDated, util.yesterday())
|
||||
AND currencyFk = vSelf
|
||||
ORDER BY dated DESC
|
||||
LIMIT 1;
|
||||
|
||||
RETURN vForeignRate;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -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
|
||||
/**
|
||||
|
@ -20,7 +21,7 @@ BEGIN
|
|||
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 ;
|
||||
|
|
|
@ -3,17 +3,21 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_calculate`(
|
|||
vLanded DATE,
|
||||
vAddressFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vShowExpiredZones BOOLEAN)
|
||||
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
|
||||
|
@ -58,6 +62,8 @@ BEGIN
|
|||
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`)
|
||||
|
@ -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
|
||||
|
|
|
@ -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,52 +286,64 @@ 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
|
||||
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`;
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ BEGIN
|
|||
`grouping` INT UNSIGNED NOT NULL,
|
||||
`price` DECIMAL(10,4) NOT NULL,
|
||||
`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;
|
||||
|
|
|
@ -21,6 +21,7 @@ BEGIN
|
|||
,CURDATE()
|
||||
,account.myUser_getId()
|
||||
,TRUE
|
||||
,1
|
||||
,vNewTicket);
|
||||
|
||||
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price)
|
||||
|
|
|
@ -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
|
||||
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 ;
|
||||
|
|
|
@ -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
|
||||
|
@ -75,6 +78,7 @@ BEGIN
|
|||
CURDATE(),
|
||||
vAddressFk,
|
||||
vCompanyFk,
|
||||
vCurrencyFk,
|
||||
NULL,
|
||||
vTicketFk
|
||||
);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`orderCreate`(
|
|||
vLanded DATE,
|
||||
vAgencyMode INT,
|
||||
vAddress INT,
|
||||
vCompany INT,
|
||||
vCurrency INT,
|
||||
vSourceApp VARCHAR(10),
|
||||
OUT vOrderId INT)
|
||||
BEGIN
|
||||
|
@ -18,8 +20,8 @@ BEGIN
|
|||
FROM vn.address
|
||||
WHERE id = vAddress;
|
||||
|
||||
INSERT INTO hedera.order(date_send,customer_id,delivery_method_id,agency_id,address_id,source_app)
|
||||
VALUES( vLanded,vClient ,vDeliveryMethod,vAgencyMode ,vAddress ,vSourceApp);
|
||||
INSERT INTO hedera.order(date_send,customer_id,delivery_method_id,agency_id,address_id,company_id,currencyFk,source_app)
|
||||
VALUES( vLanded,vClient ,vDeliveryMethod,vAgencyMode,vAddress,vCompany,vCurrency,vSourceApp);
|
||||
|
||||
SET vOrderId = LAST_INSERT_ID();
|
||||
|
||||
|
|
|
@ -3,11 +3,13 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`orderListCreate`(
|
|||
vLanded DATE,
|
||||
vAgencyMode INT,
|
||||
vAddress INT,
|
||||
vCompany INT,
|
||||
vCurrency INT,
|
||||
vSourceApp VARCHAR(10))
|
||||
BEGIN
|
||||
|
||||
DECLARE vOrderId INT;
|
||||
CALL vn.orderCreate(vLanded,vAgencyMode,vAddress,vSourceApp,vOrderId);
|
||||
CALL vn.orderCreate(vLanded,vAgencyMode,vAddress,vCompany,vCurrency,vSourceApp,vOrderId);
|
||||
SELECT vOrderId;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -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,11 +11,12 @@ 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
|
||||
SELECT warehouseFk, shipped, currencyFk
|
||||
INTO vWarehouseFk, vShipped, vCurrencyFk
|
||||
FROM vn.ticket
|
||||
WHERE id = vTicketFk;
|
||||
|
||||
|
@ -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$$
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
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;
|
||||
|
||||
INSERT INTO vn.sale(itemFk,
|
||||
INSERT INTO vn.sale(
|
||||
itemFk,
|
||||
concept,
|
||||
price,
|
||||
foreignPrice,
|
||||
discount,
|
||||
quantity,
|
||||
ticketFk,
|
||||
isPriceFixed)
|
||||
SELECT s.itemFk,
|
||||
isPriceFixed
|
||||
)SELECT s.itemFk,
|
||||
i.longName,
|
||||
s.price,
|
||||
s.foreignPrice,
|
||||
s.discount,
|
||||
vQuantity,
|
||||
s.ticketFk,
|
||||
|
@ -30,14 +34,9 @@ BEGIN
|
|||
|
||||
SELECT LAST_INSERT_ID() INTO vNewSaleFk;
|
||||
|
||||
INSERT INTO vn.saleComponent( saleFk,
|
||||
componentFk,
|
||||
value)
|
||||
SELECT vNewSaleFk,
|
||||
componentFk,
|
||||
value
|
||||
INSERT INTO vn.saleComponent(saleFk, componentFk, value)
|
||||
SELECT vNewSaleFk, componentFk, value
|
||||
FROM vn.saleComponent
|
||||
WHERE saleFk = vSaleFk;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -2,21 +2,23 @@ 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
|
||||
UPDATE 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
|
||||
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;
|
||||
SET s.price = sub.price,
|
||||
s.foreignPrice = currency_getRate(sub.currencyFk, NULL) * sub.price;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -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,24 +39,37 @@ 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
|
||||
INSERT INTO sale(
|
||||
ticketFk,
|
||||
itemFk,
|
||||
quantity,
|
||||
price,
|
||||
foreignPrice,
|
||||
discount,
|
||||
concept
|
||||
)SELECT ticketFk,
|
||||
itemFk,
|
||||
vRemainder,
|
||||
price,
|
||||
foreignPrice,
|
||||
discount,
|
||||
concept
|
||||
FROM sale
|
||||
WHERE id = vSaleFk;
|
||||
|
||||
|
@ -62,7 +84,6 @@ BEGIN
|
|||
w1: WHILE vQuantity >= vPacking DO
|
||||
|
||||
SET vQuantity = vQuantity - vPacking;
|
||||
|
||||
SET vItemShelvingFk = NULL;
|
||||
|
||||
SELECT sub.id
|
||||
|
@ -131,8 +152,8 @@ w1: WHILE vQuantity >= vPacking DO
|
|||
routeFk,
|
||||
priority,
|
||||
hasPriority,
|
||||
clonedFrom)
|
||||
SELECT clientFk,
|
||||
clonedFrom
|
||||
)SELECT clientFk,
|
||||
shipped,
|
||||
addressFk,
|
||||
agencyModeFk,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -238,8 +272,7 @@ w1: WHILE vQuantity >= vPacking DO
|
|||
monitorId,
|
||||
started,
|
||||
ended
|
||||
)
|
||||
SELECT vAgencyModeFk,
|
||||
)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 ;
|
|
@ -16,6 +16,7 @@ proc: BEGIN
|
|||
DECLARE vLanded DATE;
|
||||
DECLARE vIsEditable BOOLEAN;
|
||||
DECLARE vZoneFk INTEGER;
|
||||
DECLARE vCurrencyFk SMALLINT;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
|
||||
DECLARE vCur CURSOR FOR
|
||||
|
@ -41,14 +42,16 @@ proc: BEGIN
|
|||
t.shipped,
|
||||
t.addressFk,
|
||||
t.agencyModeFk,
|
||||
t.landed
|
||||
t.landed,
|
||||
t.currencyFk
|
||||
INTO vIsEditable,
|
||||
vZoneFk,
|
||||
vWarehouseFk,
|
||||
vShipped,
|
||||
vAddressFk,
|
||||
vAgencyModeFk,
|
||||
vLanded
|
||||
vLanded,
|
||||
vCurrencyFk
|
||||
FROM ticket t
|
||||
LEFT JOIN ticketState ts ON t.id = ts.ticketFk
|
||||
LEFT JOIN alertLevel al ON al.id = ts.alertLevel
|
||||
|
@ -96,7 +99,7 @@ proc: BEGIN
|
|||
GROUP BY s.itemFk;
|
||||
|
||||
CALL catalog_componentPrepare();
|
||||
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk);
|
||||
CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk, vCurrencyFk);
|
||||
|
||||
IF vOption IS NULL THEN
|
||||
SET vOption = IF(vIsEditable, 'renewPrices', 'imbalance');
|
||||
|
|
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 ;
|
|
@ -1,11 +1,13 @@
|
|||
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;
|
||||
|
@ -14,7 +16,7 @@ BEGIN
|
|||
SELECT id INTO vComponentFk FROM component WHERE `code` = vCode;
|
||||
END IF;
|
||||
|
||||
DELETE sc.*
|
||||
DELETE sc
|
||||
FROM tmp.sale tmps
|
||||
JOIN saleComponent sc ON sc.saleFk = tmps.saleFk
|
||||
JOIN `component` c ON c.id = sc.componentFk
|
||||
|
@ -63,21 +65,23 @@ 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;
|
||||
|
@ -90,9 +94,10 @@ BEGIN
|
|||
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
|
||||
|
|
|
@ -15,8 +15,10 @@ BEGIN
|
|||
(INDEX (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.ticketFk,
|
||||
IFNULL(SUM(ta.taxableBase + ta.tax), 0.0) AS total,
|
||||
SUM(ta.taxableBase) totalWithoutVat
|
||||
SUM(ta.taxableBase) totalWithoutVat,
|
||||
SUM(ta.foreignTaxableBase) foreignTotalWithoutVat,
|
||||
IFNULL(SUM(ta.taxableBase + ta.tax), 0.0) total,
|
||||
IFNULL(SUM(ta.foreignTaxableBase + ta.foreignTax), 0.0) foreignTotal
|
||||
FROM tmp.ticket t
|
||||
LEFT JOIN tmp.ticketAmount ta ON t.ticketFk = ta.ticketFk
|
||||
GROUP BY ticketFk;
|
||||
|
|
|
@ -25,12 +25,10 @@ BEGIN
|
|||
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
|
||||
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
|
||||
LEFT JOIN item it ON it.id = s.itemFk
|
||||
WHERE s.ticketFk = vTicket
|
||||
ORDER BY s.concept;
|
||||
WHERE s.ticketFk = vTicket;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -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;
|
||||
|
@ -110,6 +112,7 @@ BEGIN
|
|||
vDateEnd,
|
||||
account.myUser_getId(),
|
||||
TRUE,
|
||||
vCurrencyFk,
|
||||
vNewTicket);
|
||||
|
||||
INSERT INTO ticketPackaging(ticketFk, packagingFk, quantity, pvp)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 ;
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
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;
|
||||
|
@ -33,12 +37,29 @@ BEGIN
|
|||
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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,15 +13,16 @@ 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 vCurrencyFk moneda
|
||||
* @param vNickname nuevo alias
|
||||
* @param vAgencyModeFk nueva agencia
|
||||
* @param vAddressFk nuevo consignatario
|
||||
|
@ -33,54 +35,52 @@ BEGIN
|
|||
* @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);
|
||||
CALL ticket_componentPreview (vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk, NULL);
|
||||
|
||||
IF (SELECT addressFk FROM ticket WHERE id = vTicketFk) <> vAddressFk THEN
|
||||
|
||||
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
|
||||
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 ;
|
||||
|
|
|
@ -4,7 +4,9 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_componentPrevi
|
|||
vLanded DATE,
|
||||
vAddressFk INT,
|
||||
vZoneFk INT,
|
||||
vWarehouseFk SMALLINT)
|
||||
vWarehouseFk SMALLINT,
|
||||
vCurrencyFk SMALLINT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula los componentes de los articulos de un ticket
|
||||
|
@ -21,7 +23,6 @@ BEGIN
|
|||
DECLARE vHasAddressChanged BOOL;
|
||||
DECLARE vHasZoneChanged BOOL DEFAULT FALSE;
|
||||
DECLARE vHasWarehouseChanged BOOL DEFAULT FALSE;
|
||||
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vAddressTypeRateFk INT DEFAULT NULL;
|
||||
DECLARE vAgencyModeTypeRateFk INT DEFAULT NULL;
|
||||
|
@ -31,12 +32,14 @@ BEGIN
|
|||
SELECT DATE(landed) <> vLanded,
|
||||
addressFk <> vAddressFk,
|
||||
zoneFk <> vZoneFk,
|
||||
warehouseFk <> vWarehouseFk
|
||||
warehouseFk <> vWarehouseFk,
|
||||
IFNULL(vCurrencyFk, currencyFk)
|
||||
INTO
|
||||
vHasDataChanged,
|
||||
vHasAddressChanged,
|
||||
vHasZoneChanged,
|
||||
vHasWarehouseChanged
|
||||
vHasWarehouseChanged,
|
||||
vCurrencyFk
|
||||
FROM vn.ticket t
|
||||
WHERE t.id = vTicketFk;
|
||||
|
||||
|
@ -71,7 +74,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
|
||||
|
|
|
@ -34,6 +34,7 @@ BEGIN
|
|||
s.quantity,
|
||||
s.concept,
|
||||
s.price,
|
||||
s.foreignPrice,
|
||||
s.reserved,
|
||||
s.discount,
|
||||
i.image,
|
||||
|
|
|
@ -39,6 +39,7 @@ BEGIN
|
|||
SELECT s.ticketFk,
|
||||
s.itemFk,
|
||||
s.quantity * s.price * (100 - s.discount) / 100 total,
|
||||
s.quantity * s.foreignPrice * (100 - s.discount) / 100 foreignTotal,
|
||||
t.companyFk,
|
||||
t.addressFk,
|
||||
su.countryFk,
|
||||
|
@ -57,6 +58,7 @@ BEGIN
|
|||
SELECT s.ticketFk,
|
||||
bp.pgcFk,
|
||||
SUM(s.total) taxableBase,
|
||||
SUM(s.foreignTotal) foreignTaxableBase,
|
||||
pgc.rate,
|
||||
tc.code,
|
||||
bp.priority
|
||||
|
@ -76,6 +78,7 @@ BEGIN
|
|||
SELECT tt.ticketFk,
|
||||
pgc.code pgcFk,
|
||||
SUM(ts.quantity * ts.price) taxableBase,
|
||||
SUM(ts.quantity * ts.foreignPrice) foreignTaxableBase,
|
||||
pgc.rate,
|
||||
tc.code
|
||||
FROM tmp.ticket tt
|
||||
|
@ -92,17 +95,21 @@ BEGIN
|
|||
GROUP BY tt.ticketFk, pgc.code
|
||||
HAVING taxableBase;
|
||||
|
||||
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code)
|
||||
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code
|
||||
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, foreignTaxableBase, rate, code)
|
||||
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.foreignTaxableBase, ts.rate, ts.code
|
||||
FROM tmp.ticketServiceTax ts
|
||||
ON DUPLICATE KEY UPDATE ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase ;
|
||||
ON DUPLICATE KEY UPDATE
|
||||
ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase,
|
||||
ticketTax.foreignTaxableBase = VALUES (foreignTaxableBase) + ticketTax.foreignTaxableBase;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketAmount
|
||||
(INDEX (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT ticketFk,
|
||||
taxableBase,
|
||||
foreignTaxableBase,
|
||||
SUM(CAST(taxableBase * rate / 100 AS DECIMAL(10, 2))) tax,
|
||||
SUM(CAST(foreignTaxableBase * rate / 100 AS DECIMAL(10, 2))) foreignTax,
|
||||
code
|
||||
FROM tmp.ticketTax
|
||||
GROUP BY ticketFk, code;
|
||||
|
|
|
@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_getWithParamet
|
|||
vShipped DATE,
|
||||
vAddressFk INT,
|
||||
vCompanyFk INT,
|
||||
vCurrencyFk INT,
|
||||
vAgencyModeFk INT,
|
||||
OUT vTicketFk INT
|
||||
)
|
||||
|
@ -17,6 +18,7 @@ BEGIN
|
|||
* @param vShipped Fecha de preparacion
|
||||
* @param vAddressFk Consignatario
|
||||
* @param vCompanyFk Empresa
|
||||
* @param vCurrencyFk Id de moneda
|
||||
* @param vAgencyModeFk agencia
|
||||
*/
|
||||
|
||||
|
@ -31,7 +33,7 @@ BEGIN
|
|||
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;
|
||||
|
|
|
@ -4,7 +4,9 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_priceDifferenc
|
|||
vLanded DATE,
|
||||
vAddressFk INT,
|
||||
vZoneFk INT,
|
||||
vWarehouseFk INT)
|
||||
vWarehouseFk INT,
|
||||
vCurrencyFk SMALLINT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve las diferencias de precio de los movimientos de un ticket.
|
||||
|
@ -15,29 +17,36 @@ BEGIN
|
|||
* @param vZoneFk Id de la zona
|
||||
* @param vWarehouseFk Id del almacén
|
||||
*/
|
||||
CALL vn.ticket_componentPreview(vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk);
|
||||
CALL vn.ticket_componentPreview(vTicketFk, vLanded, vAddressFk, vZoneFk, vWarehouseFk, vCurrencyFk);
|
||||
|
||||
WITH ticketPriceDifference AS (
|
||||
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,
|
||||
s.quantity * (s.price - ROUND(SUM(tc.cost), 2)) difference,
|
||||
s.id AS saleFk
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
IFNULL(s.quantity, 0) quantity,
|
||||
IFNULL(s.price, 0) price,
|
||||
ROUND(SUM(tc.cost), 2) newPrice,
|
||||
s.id saleFk
|
||||
FROM vn.sale s
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.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 vn.saleComponent sc ON sc.saleFk = s.id
|
||||
AND sc.componentFk = tc.componentFk
|
||||
LEFT JOIN `component` c ON c.id = tc.componentFk
|
||||
LEFT JOIN vn.`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;
|
||||
GROUP BY s.id ORDER BY s.id
|
||||
) SELECT
|
||||
*,
|
||||
currency_getRate(vCurrencyFk, NULL) * price foreignPrice,
|
||||
currency_getRate(vCurrencyFk, NULL) * newPrice newForeignPrice,
|
||||
quantity * (price - newPrice) difference,
|
||||
currency_getRate(vCurrencyFk, NULL) * quantity * (price - newPrice) foreignDifference
|
||||
FROM ticketPriceDifference;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticketComponentPreview;
|
||||
END$$
|
||||
|
|
|
@ -27,8 +27,10 @@ proc:BEGIN
|
|||
|
||||
UPDATE ticket t
|
||||
JOIN tmp.ticketTotal tt ON tt.ticketFk = t.id
|
||||
SET t.totalWithVat = tt.total,
|
||||
t.totalWithoutVat = tt.totalWithoutVat;
|
||||
SET t.totalWithoutVat = tt.totalWithoutVat,
|
||||
t.foreignTotalWithoutVat = tt.foreignTotalWithoutVat,
|
||||
t.totalWithVat = tt.total,
|
||||
t.foreignTotalWithVat = tt.foreignTotal;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.ticket,
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
ALTER TABLE hedera.order ADD `currencyFk` tinyint(3) UNSIGNED DEFAULT 1 NOT NULL AFTER total;
|
||||
ALTER TABLE hedera.order ADD `foreignTaxableBase` decimal(10,2) NULL AFTER currencyFk;
|
||||
ALTER TABLE hedera.order ADD `foreignTax` decimal(10,2) NULL AFTER foreignTaxableBase;
|
||||
ALTER TABLE hedera.order ADD `foreignTotal` decimal(10,2) NULL AFTER foreignTax;
|
||||
|
||||
|
||||
ALTER TABLE hedera.order DROP FOREIGN KEY IF EXISTS order_currency_FK;
|
||||
ALTER TABLE hedera.order ADD CONSTRAINT order_currency_FK FOREIGN KEY (currencyFk)
|
||||
REFERENCES vn.currency(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE hedera.orderRow ADD `foreignPrice` decimal(10,2) NULL AFTER price;
|
||||
|
||||
ALTER TABLE vn.company ADD `currencyFk` tinyint(3) UNSIGNED DEFAULT 1 NOT NULL;
|
||||
ALTER TABLE vn.company DROP FOREIGN KEY IF EXISTS company_currency_FK;
|
||||
ALTER TABLE vn.company ADD CONSTRAINT company_currency_FK FOREIGN KEY (currencyFk)
|
||||
REFERENCES vn.currency(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.ticket ADD `currencyFk` tinyint(3) UNSIGNED DEFAULT 1 NOT NULL AFTER totalWithoutVat;
|
||||
ALTER TABLE vn.ticket ADD `foreignTotalWithVat` decimal(10,2) NULL AFTER currencyFk;
|
||||
ALTER TABLE vn.ticket ADD `foreignTotalWithoutVat` decimal(10,2) NULL AFTER foreignTotalWithVat;
|
||||
|
||||
ALTER TABLE vn.ticket DROP FOREIGN KEY IF EXISTS ticket_currency_FK;
|
||||
ALTER TABLE vn.ticket ADD CONSTRAINT ticket_currency_FK FOREIGN KEY (currencyFk)
|
||||
REFERENCES vn.currency(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.sale ADD `foreignPrice` decimal(10,2) NULL AFTER price;
|
||||
ALTER TABLE vn.sale ADD `foreignTotal` decimal(10,2) NULL AFTER total;
|
||||
|
||||
ALTER TABLE vn.ticketService ADD `foreignPrice` decimal(10,2) NULL AFTER price;
|
||||
|
||||
ALTER TABLE vn.invoiceOut ADD `foreignAmount` decimal(10,2) NULL AFTER amount;
|
||||
ALTER TABLE vn.invoiceOutExpense ADD `foreignAmount` DECIMAL(10,2) DEFAULT NULL AFTER amount;
|
||||
ALTER TABLE vn.invoiceOutTax ADD `foreignTaxableBase` DECIMAL(10,2) DEFAULT NULL AFTER vat;
|
||||
ALTER TABLE vn.invoiceOutTax ADD `foreignVat` DECIMAL(10,2) DEFAULT NULL AFTER foreignTaxableBase;
|
||||
|
||||
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `hedera`.`order_row`
|
||||
AS SELECT `t`.`id` AS `id`,
|
||||
`t`.`orderFk` AS `order_id`,
|
||||
`t`.`itemFk` AS `item_id`,
|
||||
`t`.`warehouseFk` AS `warehouse_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`
|
||||
FROM `hedera`.`orderRow` `t`;
|
||||
|
||||
|
||||
|
||||
ALTER TABLE vn.country ADD IF NOT EXISTS `companyFk` int(10) UNSIGNED DEFAULT 442 NOT NULL;
|
||||
ALTER TABLE vn.country DROP FOREIGN KEY IF EXISTS country_defaultCompany_FK;
|
||||
ALTER TABLE vn.country ADD CONSTRAINT country_defaultCompany_FK FOREIGN KEY (companyFk)
|
||||
REFERENCES vn.company(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.client ADD IF NOT EXISTS `defaultCompanyFk` int(10) UNSIGNED DEFAULT 442 NOT NULL;
|
||||
ALTER TABLE vn.client ADD IF NOT EXISTS `defaultCurrencyFk` tinyint(3) UNSIGNED DEFAULT 1 NOT NULL;
|
||||
|
||||
|
||||
ALTER TABLE vn.client DROP FOREIGN KEY IF EXISTS client_defaultCompany_FK;
|
||||
ALTER TABLE vn.client DROP FOREIGN KEY IF EXISTS client_defaultCurrency_FK;
|
||||
|
||||
ALTER TABLE vn.client ADD CONSTRAINT client_defaultCompany_FK FOREIGN KEY (defaultCompanyFk)
|
||||
REFERENCES vn.company(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE vn.client ADD CONSTRAINT client_defaultCurrency_FK FOREIGN KEY (defaultCurrencyFk)
|
||||
REFERENCES vn.currency(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
UPDATE vn.client c
|
||||
JOIN vn.province p ON p.id = c.provinceFk
|
||||
JOIN vn.country co ON co.id = p.countryFk
|
||||
SET c.defaultCompanyFk = co.companyFk,
|
||||
c.defaultCurrencyFk = co.currencyFk;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -250,6 +250,5 @@
|
|||
"Sales already moved": "Sales already moved",
|
||||
"Holidays to past days not available": "Holidays to past days not available",
|
||||
"Price cannot be blank": "Price cannot be blank",
|
||||
"There are tickets to be invoiced": "There are tickets to be invoiced",
|
||||
"The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent"
|
||||
"There are tickets to be invoiced": "There are tickets to be invoiced"
|
||||
}
|
||||
|
|
|
@ -147,8 +147,13 @@
|
|||
},
|
||||
"hasDailyInvoice": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultCompanyFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultCurrencyFk": {
|
||||
"type": "number"
|
||||
}
|
||||
|
||||
},
|
||||
"relations": {
|
||||
"account": {
|
||||
|
@ -256,6 +261,16 @@
|
|||
"model": "Supplier",
|
||||
"foreignKey": "fi",
|
||||
"primaryKey": "nif"
|
||||
},
|
||||
"currency": {
|
||||
"type": "belongsTo",
|
||||
"model": "Currency",
|
||||
"foreignKey": "defaultCurrencyFk"
|
||||
},
|
||||
"company": {
|
||||
"type": "belongsTo",
|
||||
"model": "Comapny",
|
||||
"foreignKey": "defaultCompanyFk"
|
||||
}
|
||||
},
|
||||
"scopes": {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('clientsToInvoice', {
|
||||
description: 'Get the clients to make global invoicing',
|
||||
|
@ -24,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: {
|
||||
|
@ -36,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};
|
||||
|
||||
|
@ -50,10 +53,11 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
const vIsAllInvoiceable = false;
|
||||
await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [
|
||||
await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?, ?)', [
|
||||
clientId,
|
||||
invoiceDate,
|
||||
companyFk,
|
||||
currencyFk,
|
||||
vIsAllInvoiceable
|
||||
], myOptions);
|
||||
|
||||
|
@ -72,6 +76,7 @@ module.exports = Self => {
|
|||
AND t.shipped BETWEEN ? AND util.dayEnd(?)
|
||||
AND (t.clientFk = ? OR ? IS NULL )
|
||||
AND t.companyFk = ?
|
||||
AND t.currencyFk = ?
|
||||
AND NOT t.isDeleted
|
||||
GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id)
|
||||
HAVING SUM(t.totalWithVat) > 0;`;
|
||||
|
@ -81,7 +86,8 @@ module.exports = Self => {
|
|||
maxShipped,
|
||||
clientId,
|
||||
clientId,
|
||||
companyFk
|
||||
companyFk,
|
||||
currencyFk
|
||||
], myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -5,6 +5,7 @@ describe('InvoiceOut clientsToInvoice()', () => {
|
|||
const userId = 1;
|
||||
const clientId = 1101;
|
||||
const companyFk = 442;
|
||||
const currencyFk = 1;
|
||||
const maxShipped = Date.vnNew();
|
||||
maxShipped.setMonth(11);
|
||||
maxShipped.setDate(31);
|
||||
|
@ -54,7 +55,7 @@ describe('InvoiceOut clientsToInvoice()', () => {
|
|||
});
|
||||
|
||||
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);
|
||||
|
@ -69,7 +70,8 @@ describe('InvoiceOut clientsToInvoice()', () => {
|
|||
});
|
||||
|
||||
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');
|
||||
}
|
||||
|
|
|
@ -92,11 +92,12 @@ module.exports = Self => {
|
|||
// Calculate items
|
||||
const order = await Self.findById(orderFk, null, myOptions);
|
||||
stmts.push(new ParameterizedSQL(
|
||||
'CALL vn.catalog_calculate(?, ?, ?, ?)', [
|
||||
'CALL vn.catalog_calculate(?, ?, ?, ?, ?)', [
|
||||
order.landed,
|
||||
order.address_id,
|
||||
order.agency_id,
|
||||
false
|
||||
order.currencyFk,
|
||||
false,
|
||||
]
|
||||
));
|
||||
|
||||
|
@ -119,7 +120,9 @@ module.exports = Self => {
|
|||
w.firstName,
|
||||
tci.priceKg,
|
||||
ink.hex,
|
||||
tci.minQuantity
|
||||
tci.minQuantity,
|
||||
tci.foreignPrice,
|
||||
tci.foreignPriceKg
|
||||
FROM tmp.ticketCalculateItem tci
|
||||
JOIN vn.item i ON i.id = tci.itemFk
|
||||
JOIN vn.itemType it ON it.id = i.typeFk
|
||||
|
@ -161,9 +164,11 @@ module.exports = Self => {
|
|||
`SELECT tcp.itemFk,
|
||||
tcp.grouping,
|
||||
tcp.price,
|
||||
tcp.foreignPrice,
|
||||
tcp.rate,
|
||||
tcp.warehouseFk,
|
||||
tcp.priceKg,
|
||||
tcp.foreignPriceKg,
|
||||
w.name warehouse
|
||||
FROM tmp.ticketComponentPrice tcp
|
||||
JOIN vn.warehouse w ON w.id = tcp.warehouseFk`) - 1;
|
||||
|
|
|
@ -62,11 +62,12 @@ module.exports = Self => {
|
|||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
'CALL vn.catalog_calculate(?, ?, ?, ?)', [
|
||||
'CALL vn.catalog_calculate(?, ?, ?, ?, ?)', [
|
||||
order.landed,
|
||||
order.addressFk,
|
||||
order.agencyModeFk,
|
||||
false
|
||||
order.currencyFk,
|
||||
false,
|
||||
]
|
||||
);
|
||||
stmts.push(stmt);
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = Self => {
|
|||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'number',
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -25,9 +25,22 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const query = `SELECT hedera.order_getTotal(?) total;`;
|
||||
const [total] = await Self.rawSql(query, [orderFk], myOptions);
|
||||
const query = `
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.order;
|
||||
CREATE TEMPORARY TABLE tmp.order
|
||||
ENGINE = MEMORY
|
||||
SELECT ? orderFk;
|
||||
|
||||
return total.total;
|
||||
CALL hedera.order_getTotal;
|
||||
SELECT total, foreignTotal FROM tmp.orderTotal;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.order,
|
||||
tmp.orderTotal;`;
|
||||
|
||||
const totals = await Self.rawSql(query, [orderFk], myOptions);
|
||||
const INDEX_QUERY = 3;
|
||||
|
||||
return totals[INDEX_QUERY][0];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ module.exports = Self => {
|
|||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'number',
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -25,12 +25,19 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
let totalTax = 0.00;
|
||||
let vat = 0.00;
|
||||
let foreignVat = 0.00;
|
||||
const taxes = await Self.app.models.Order.getTaxes(orderId, myOptions);
|
||||
|
||||
taxes.forEach(tax => {
|
||||
totalTax += tax.tax;
|
||||
vat += tax.tax;
|
||||
foreignVat += tax.foreignTax;
|
||||
});
|
||||
|
||||
return Math.round(totalTax * 100) / 100;
|
||||
return {vat: round(vat), foreignVat: round(foreignVat)};
|
||||
};
|
||||
|
||||
function round(amount) {
|
||||
return Math.round(amount * 100) / 100;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -20,6 +20,16 @@ module.exports = Self => {
|
|||
description: 'The agencyMode for the order',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'companyId',
|
||||
description: 'The company for the order',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'currencyId',
|
||||
description: 'The currency for the order',
|
||||
type: 'number',
|
||||
required: true
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -32,7 +42,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.new = async(ctx, landed, addressId, agencyModeId, options) => {
|
||||
Self.new = async(ctx, landed, addressId, agencyModeId, companyId, currencyId, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
|
@ -59,11 +69,13 @@ module.exports = Self => {
|
|||
throw new UserError(`You can't create an order for an inactive client`);
|
||||
}
|
||||
|
||||
query = `CALL vn.orderListCreate(?, ?, ?, ?);`;
|
||||
query = `CALL vn.orderListCreate(?, ?, ?, ?, ?, ?);`;
|
||||
[result] = await Self.rawSql(query, [
|
||||
landed,
|
||||
agencyModeId,
|
||||
addressId,
|
||||
companyId,
|
||||
currencyId,
|
||||
'SALIX'
|
||||
], myOptions);
|
||||
|
||||
|
|
|
@ -31,15 +31,22 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
try {
|
||||
const ticket = await Self.app.models.Ticket.findOne({
|
||||
where: {id: ticketFk}
|
||||
}, myOptions);
|
||||
const {landed, addressFk, agencyModeFk, companyFk, currencyFk} =
|
||||
await Self.app.models.Ticket.findById(
|
||||
ticketFk,
|
||||
{fields: ['landed', 'addressFk', 'agencyModeFk', 'companyFk', 'currencyFk']},
|
||||
myOptions
|
||||
);
|
||||
|
||||
const landed = ticket.landed;
|
||||
const addressFk = ticket.addressFk;
|
||||
const agencyModeFk = ticket.agencyModeFk;
|
||||
|
||||
const orderID = await Self.app.models.Order.new(ctx, landed, addressFk, agencyModeFk, myOptions);
|
||||
const orderID = await Self.app.models.Order.new(
|
||||
ctx,
|
||||
landed,
|
||||
addressFk,
|
||||
agencyModeFk,
|
||||
companyFk,
|
||||
currencyFk,
|
||||
myOptions
|
||||
);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ module.exports = Self => {
|
|||
'landed',
|
||||
'agencyModeFk',
|
||||
'note',
|
||||
'companyFk',
|
||||
'currencyFk',
|
||||
]);
|
||||
if (Object.keys(updateParams).length)
|
||||
await order.updateAttributes(updateParams, myOptions);
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
"price": {
|
||||
"type": "number"
|
||||
},
|
||||
"foreignPrice": {
|
||||
"type": "number"
|
||||
},
|
||||
"rate": {
|
||||
"type": "number"
|
||||
},
|
||||
|
|
|
@ -82,6 +82,9 @@
|
|||
},
|
||||
"total": {
|
||||
"type": "number"
|
||||
},
|
||||
"currencyFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -114,6 +117,11 @@
|
|||
"type": "belongsTo",
|
||||
"model": "Company",
|
||||
"foreignKey": "company_id"
|
||||
},
|
||||
"currency": {
|
||||
"type": "belongsTo",
|
||||
"model": "Currency",
|
||||
"foreignKey": "currencyFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: [
|
||||
{
|
||||
|
@ -198,6 +205,7 @@ module.exports = Self => {
|
|||
const originalTicket = JSON.parse(JSON.stringify(ticketToChange));
|
||||
const ticketChanges = {
|
||||
clientFk: args.clientFk,
|
||||
currencyFk: args.currencyFk,
|
||||
nickname: args.nickname,
|
||||
agencyModeFk: args.agencyModeFk,
|
||||
addressFk: args.addressFk,
|
||||
|
@ -206,7 +214,7 @@ module.exports = Self => {
|
|||
companyFk: args.companyFk,
|
||||
shipped: args.shipped,
|
||||
landed: args.landed,
|
||||
isDeleted: args.isDeleted
|
||||
isDeleted: args.isDeleted,
|
||||
};
|
||||
|
||||
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
|
||||
);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -46,6 +46,11 @@ module.exports = Self => {
|
|||
type: 'date',
|
||||
description: 'shipped',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'currencyId',
|
||||
type: 'number',
|
||||
description: 'The currency ticket'
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
|
@ -91,7 +96,7 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
|
||||
const items = await models.Sale.find({
|
||||
const sales = await models.Sale.find({
|
||||
where: {
|
||||
ticketFk: args.id
|
||||
},
|
||||
|
@ -99,19 +104,22 @@ module.exports = Self => {
|
|||
include: 'item'
|
||||
}, myOptions);
|
||||
|
||||
const salesObj = {
|
||||
items: items,
|
||||
const salesTotals = {
|
||||
sales,
|
||||
totalUnitPrice: 0.00,
|
||||
totalNewPrice: 0.00,
|
||||
totalDifference: 0.00,
|
||||
totalForeignUnitPrice: 0.00,
|
||||
totalForeignNewPrice: 0.00,
|
||||
totalForeignDifference: 0.00,
|
||||
};
|
||||
|
||||
// Get items movable
|
||||
const ticketOrigin = await models.Ticket.findById(args.id, null, myOptions);
|
||||
const differenceShipped = ticketOrigin.shipped.getTime() > args.shipped.getTime();
|
||||
const differenceShipped = !ticketOrigin.shipped || ticketOrigin.shipped?.getTime() > args.shipped.getTime();
|
||||
const differenceWarehouse = ticketOrigin.warehouseFk != args.warehouseId;
|
||||
|
||||
salesObj.haveDifferences = differenceShipped || differenceWarehouse;
|
||||
salesTotals.haveDifferences = differenceShipped || differenceWarehouse;
|
||||
|
||||
let query = `CALL ticket_getMovable(?,?,?)`;
|
||||
let params = [args.id, args.shipped, args.warehouseId];
|
||||
|
@ -124,34 +132,35 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
// Sale price component, one per sale
|
||||
query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?)`;
|
||||
params = [args.id, args.landed, args.addressId, args.zoneId, args.warehouseId];
|
||||
query = `CALL vn.ticket_priceDifference(?, ?, ?, ?, ?, ?)`;
|
||||
params = [args.id, args.landed, args.addressId, args.zoneId, args.warehouseId, args.currencyId];
|
||||
const [difComponents] = await Self.rawSql(query, params, myOptions);
|
||||
|
||||
const map = new Map();
|
||||
for (let difComponent of difComponents)
|
||||
map.set(difComponent.saleFk, difComponent);
|
||||
|
||||
for (sale of salesObj.items) {
|
||||
for (let sale of salesTotals.sales) {
|
||||
const difComponent = map.get(sale.id);
|
||||
if (difComponent) {
|
||||
sale.component = difComponent;
|
||||
|
||||
salesObj.totalDifference += difComponent.difference;
|
||||
salesObj.totalDifference = round(salesObj.totalDifference);
|
||||
salesTotals.totalNewPrice += round(difComponent.newPrice * difComponent.quantity);
|
||||
salesTotals.totalForeignNewPrice += round(difComponent.newForeignPrice * difComponent.quantity);
|
||||
|
||||
salesObj.totalNewPrice += difComponent.newPrice;
|
||||
salesObj.totalNewPrice = round(salesObj.totalNewPrice);
|
||||
salesTotals.totalUnitPrice += round(sale.price * difComponent.quantity);
|
||||
salesTotals.totalForeignUnitPrice += round(difComponent.foreignPrice * difComponent.quantity);
|
||||
|
||||
salesTotals.totalDifference += round(difComponent.difference);
|
||||
salesTotals.totalForeignDifference += round(difComponent.foreignDifference);
|
||||
}
|
||||
|
||||
salesObj.totalUnitPrice += sale.price;
|
||||
salesObj.totalUnitPrice = round(salesObj.totalUnitPrice);
|
||||
sale.movable = itemMovable.get(sale.id);
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
return salesObj;
|
||||
return salesTotals;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
"price": {
|
||||
"type": "number"
|
||||
},
|
||||
"foreignPrice": {
|
||||
"type": "number"
|
||||
},
|
||||
"discount": {
|
||||
"type": "number"
|
||||
},
|
||||
|
|
|
@ -64,12 +64,21 @@
|
|||
"totalWithoutVat": {
|
||||
"type": "number"
|
||||
},
|
||||
"foreignTotalWithVat": {
|
||||
"type": "number"
|
||||
},
|
||||
"foreignTotalWithoutVat": {
|
||||
"type": "number"
|
||||
},
|
||||
"weight": {
|
||||
"type": "number"
|
||||
},
|
||||
"cmrFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"currencyFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"problem": {
|
||||
"type": "string"
|
||||
}
|
||||
|
@ -156,6 +165,11 @@
|
|||
"model": "Cmr",
|
||||
"foreignKey": "cmrFk"
|
||||
},
|
||||
"currency": {
|
||||
"type": "belongsTo",
|
||||
"model": "Currency",
|
||||
"foreignKey": "currencyFk"
|
||||
},
|
||||
"ticketCollections": {
|
||||
"type": "hasMany",
|
||||
"model": "TicketCollection",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"name": "Currency",
|
||||
"description": "Currencies",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
|
|
Loading…
Reference in New Issue