test back-front fixed
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
parent
f871879ee5
commit
e01765e34e
|
@ -0,0 +1,5 @@
|
|||
|
||||
ALTER TABLE `vn`.`zone`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD INDEX `zone_name_idx` (`name` ASC);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,61 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`available_calc`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`available_calc`(
|
||||
vDate DATE,
|
||||
vAddress INT,
|
||||
vAgencyMode INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calculates the available for all available stores
|
||||
* according to the given parameters.
|
||||
*
|
||||
* @param vDate The delivery date
|
||||
* @param vAddress The delivery address id
|
||||
* @param vAgencyMode The shipping agency
|
||||
* @return tmp.availableCalc(calcFk) The available cache ids
|
||||
*/
|
||||
DECLARE vCalcFk INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vWarehouse INT;
|
||||
DECLARE vDone BOOL;
|
||||
|
||||
DECLARE cWarehouses CURSOR FOR
|
||||
SELECT warehouseFk, shipped FROM tmp.zoneGetShipped;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
||||
-- Establecemos los almacenes y las fechas que van a entrar al disponible
|
||||
|
||||
CALL vn.zoneGetShippedWarehouse(vDate, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.availableCalc;
|
||||
CREATE TEMPORARY TABLE tmp.availableCalc(
|
||||
calcFk INT UNSIGNED,
|
||||
PRIMARY KEY (calcFk)
|
||||
)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
OPEN cWarehouses;
|
||||
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cWarehouses INTO vWarehouse, vShipment;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL `cache`.available_refresh(vCalcFk, FALSE, vWarehouse, vShipment);
|
||||
|
||||
INSERT IGNORE INTO tmp.availableCalc
|
||||
SET calcFk = vCalcFk;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cWarehouses;
|
||||
DROP TEMPORARY TABLE tmp.zoneGetShipped;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`catalog_calcFromItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`catalog_calcFromItem`(
|
||||
vLanded DATE,
|
||||
vAddressFk INT,
|
||||
vAgencyModeFk INT,
|
||||
vItemFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calculates available and price for a single item.
|
||||
*
|
||||
* @param vItemFk The item id
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
ENGINE = MEMORY
|
||||
SELECT vItemFk itemFk;
|
||||
|
||||
CALL ticketCalculate(vLanded, vAddressFk, vAgencyModeFk);
|
||||
DROP TEMPORARY TABLE tmp.item;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,240 @@
|
|||
|
||||
USE `vn2008`;
|
||||
DROP procedure IF EXISTS `vn2008`.`bionic_available_`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn2008`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_available_`(
|
||||
vDate DATE,
|
||||
vAddress INT,
|
||||
vAgency INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula el disponible para un conjunto de almacenes y fechas
|
||||
* devueltos por el procedimiento agencyHourGetShipped()
|
||||
*
|
||||
* @deprecated Use vn.available_calc()
|
||||
* @table t_bionic_available Tabla con los ids de cache
|
||||
*/
|
||||
DECLARE vAvailableCalc INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vAgencyId INT;
|
||||
DECLARE vWh INT;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE cTravelTree CURSOR FOR
|
||||
SELECT warehouseFk, shipped FROM tmp.agencyHourGetShipped;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
-- Establecemos los almacenes y las fechas que van a entrar al disponible
|
||||
|
||||
SELECT agency_id INTO vAgencyId
|
||||
FROM Agencias WHERE Id_Agencia = vAgency;
|
||||
|
||||
CALL vn.agencyHourGetShipped (vDate, vAddress, vAgencyId);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS t_bionic_available;
|
||||
CREATE TEMPORARY TABLE t_bionic_available(
|
||||
calc_id INT UNSIGNED,
|
||||
PRIMARY KEY (calc_id)
|
||||
)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
OPEN cTravelTree;
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cTravelTree INTO vWh, vShipment;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWh, vShipment);
|
||||
|
||||
INSERT IGNORE INTO t_bionic_available
|
||||
SET calc_id = vAvailableCalc;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cTravelTree;
|
||||
DROP TEMPORARY TABLE tmp.agencyHourGetShipped;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`bionic_from_item`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_item`(vItem INT)
|
||||
BEGIN
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT sent, addressFk, agencyModeFk
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM myBasket;
|
||||
|
||||
CALL vn2008.bionic_from_item(vDate, vAddress, vAgencyMode, vItem);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `vn2008`;
|
||||
DROP procedure IF EXISTS `vn2008`.`bionic_from_order`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `vn2008`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_from_order`(
|
||||
v_date DATE, -- fecha de recepcion de mercancia
|
||||
v_consigna INT,
|
||||
v_agencia INT,
|
||||
v_order INT)
|
||||
BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.bionic_calc;
|
||||
CREATE TEMPORARY TABLE tmp.bionic_calc
|
||||
(PRIMARY KEY (item_id))
|
||||
ENGINE = MEMORY
|
||||
SELECT item_id FROM order_row
|
||||
WHERE order_id = v_order GROUP BY item_id;
|
||||
|
||||
CALL bionic_calc (v_date, v_consigna, v_agencia);
|
||||
DROP TEMPORARY TABLE tmp.bionic_calc;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`bionicCalcWithDate`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionicCalcWithDate`(vDate DATE)
|
||||
BEGIN
|
||||
DECLARE vMyAddressFk INTEGER;
|
||||
DECLARE vMyAgencyModeFk INTEGER;
|
||||
|
||||
SELECT id, agencyModeFk INTO vMyAddressFk, vMyAgencyModeFk
|
||||
FROM myAddress
|
||||
WHERE isDefaultAddress;
|
||||
|
||||
CALL vn2008.bionic_calc(vDate, vMyAddressFk, vMyAgencyModeFk);
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`bionic_calc`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__bionic_calc`()
|
||||
BEGIN
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT sent, addressFk, agencyModeFk
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM myBasket;
|
||||
|
||||
CALL vn2008.bionic_calc(vDate, vAddress, vAgencyMode);
|
||||
|
||||
IF account.myUserGetName() = 'visitor'
|
||||
THEN
|
||||
DROP TEMPORARY TABLE tmp.bionic_component;
|
||||
UPDATE tmp.bionic_item SET price = NULL;
|
||||
END IF;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`itemGetAvailableOrder`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailableOrder`(vOrder INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list with an order params.
|
||||
*
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE vDelivery DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgency INT;
|
||||
|
||||
SELECT landed, addressFk, agencyModeFk
|
||||
INTO vDelivery, vAddress, vAgency
|
||||
FROM myOrder
|
||||
WHERE id = vOrder;
|
||||
|
||||
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
|
||||
CREATE TEMPORARY TABLE tmp.itemAvailable
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id id
|
||||
FROM cache.available c
|
||||
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
DROP TEMPORARY TABLE vn2008.t_bionic_available;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
||||
|
||||
|
||||
USE `hedera`;
|
||||
DROP procedure IF EXISTS `hedera`.`itemGetAvailable`;
|
||||
|
||||
DELIMITER $$
|
||||
USE `hedera`$$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `__itemGetAvailable`()
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE vDelivery DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgency INT;
|
||||
|
||||
SELECT sent, addressFk, agencyModeFk
|
||||
INTO vDelivery, vAddress, vAgency
|
||||
FROM myBasket;
|
||||
|
||||
CALL vn2008.bionic_available_ (vDelivery, vAddress, vAgency);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
|
||||
CREATE TEMPORARY TABLE tmp.itemAvailable
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT c.item_id id
|
||||
FROM cache.available c
|
||||
JOIN vn2008.t_bionic_available a ON c.calc_id = a.calc_id
|
||||
WHERE c.available > 0
|
||||
GROUP BY c.item_id;
|
||||
|
||||
DROP TEMPORARY TABLE vn2008.t_bionic_available;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
;
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myBasket_calcCatalogFromItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_calcCatalogFromItem`(vItem INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given item
|
||||
* using current user basket parameters.
|
||||
*
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
*/
|
||||
CALL order_calcCatalogFromItem(myBasket_getId(), vItem);
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myBasket_calcCatalogFull`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_calcCatalogFull`()
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given items
|
||||
* using current user basket parameters.
|
||||
*
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketLot
|
||||
*/
|
||||
CALL order_calcCatalogFull(myBasket_getId());
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myBasket_getAvailable`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myBasket_getAvailable`()
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
CALL order_getAvailable(myBasket_getId());
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`myOrder_getAvailable`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`myOrder_getAvailable`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE isMine BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO isMine
|
||||
FROM myOrder
|
||||
WHERE id = vSelf;
|
||||
|
||||
IF isMine THEN
|
||||
CALL order_getAvailable(vSelf);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,97 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_addItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_addItem`(
|
||||
vSelf INT,
|
||||
vWarehouse INT,
|
||||
vItem INT,
|
||||
vAmount INT)
|
||||
BEGIN
|
||||
DECLARE vRow INT;
|
||||
DECLARE vAdd INT;
|
||||
DECLARE vAvailable INT;
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vGrouping INT;
|
||||
DECLARE vRate INT;
|
||||
DECLARE vShipment DATE;
|
||||
DECLARE vPrice DECIMAL(10,2);
|
||||
DECLARE cur CURSOR FOR
|
||||
SELECT `grouping`, price, rate
|
||||
FROM tmp.ticketComponentPrice
|
||||
WHERE warehouseFk = vWarehouse
|
||||
AND itemFk = vItem
|
||||
ORDER BY `grouping` DESC;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
CALL order_calcCatalogFromItem(vSelf, vItem);
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT shipped INTO vShipment
|
||||
FROM tmp.zoneGetShipped
|
||||
WHERE warehouseFk = vWarehouse;
|
||||
|
||||
SELECT available INTO vAvailable
|
||||
FROM tmp.ticketLot
|
||||
WHERE warehouseFk = vWarehouse
|
||||
AND itemFk = vItem;
|
||||
|
||||
IF vAmount > IFNULL(vAvailable, 0) THEN
|
||||
CALL util.throw ('ORDER_ROW_UNAVAILABLE');
|
||||
END IF;
|
||||
|
||||
OPEN cur;
|
||||
|
||||
l: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cur INTO vGrouping, vPrice, vRate;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vAdd = vAmount - MOD(vAmount, vGrouping);
|
||||
SET vAmount = vAmount - vAdd;
|
||||
|
||||
IF vAdd = 0 THEN
|
||||
ITERATE l;
|
||||
END IF;
|
||||
|
||||
INSERT INTO orderRow SET
|
||||
orderFk = vSelf,
|
||||
itemFk = vItem,
|
||||
warehouseFk = vWarehouse,
|
||||
shipment = vShipment,
|
||||
rate = vRate,
|
||||
amount = vAdd,
|
||||
price = vPrice;
|
||||
|
||||
SET vRow = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO orderRowComponent (rowFk, componentFk, price)
|
||||
SELECT vRow, c.componentFk, c.cost
|
||||
FROM tmp.ticketComponent c
|
||||
JOIN vn.component t
|
||||
ON t.id = c.componentFk
|
||||
AND (t.classRate IS NULL OR t.classRate = vRate)
|
||||
WHERE c.warehouseFk = vWarehouse
|
||||
AND c.itemFk = vItem;
|
||||
END LOOP;
|
||||
|
||||
CLOSE cur;
|
||||
|
||||
IF vAmount > 0 THEN
|
||||
CALL util.throw ('AMOUNT_NOT_MATCH_GROUPING');
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
CALL vn.ticketCalculatePurge;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_calcCatalog`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalog`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for order items.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.item;
|
||||
CREATE TEMPORARY TABLE tmp.item
|
||||
(PRIMARY KEY (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT itemFk FROM orderRow
|
||||
WHERE orderFk = vSelf
|
||||
GROUP BY itemFk;
|
||||
|
||||
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE tmp.item;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFromItem`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFromItem`(vSelf INT, vItem INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given item
|
||||
* using the order parameters.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketComponent
|
||||
* @return tmp.ticketLot
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL vn.catalog_calcFromItem(vDate, vAddress, vAgencyMode, vItem);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFull`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the availability and prices for the given items
|
||||
* using the order parameters.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.item(itemFk)
|
||||
* @return tmp.ticketCalculateItem
|
||||
* @return tmp.ticketComponentPrice
|
||||
* @return tmp.ticketLot
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDate, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);
|
||||
|
||||
IF account.myUserGetName() = 'visitor'
|
||||
THEN
|
||||
DROP TEMPORARY TABLE tmp.ticketComponent;
|
||||
UPDATE tmp.ticketCalculateItem SET price = NULL;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,34 @@
|
|||
DROP procedure IF EXISTS `hedera`.`order_getAvailable`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_getAvailable`(vSelf INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Gets the available items list.
|
||||
*
|
||||
* @param vSelf The order id
|
||||
* @table tmp.itemAvailable
|
||||
*/
|
||||
DECLARE vDelivery DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
|
||||
SELECT date_send, address_id, agency_id
|
||||
INTO vDelivery, vAddress, vAgencyMode
|
||||
FROM `order`
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL vn.available_calc(vDelivery, vAddress, vAgencyMode);
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.itemAvailable;
|
||||
CREATE TEMPORARY TABLE tmp.itemAvailable
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT a.item_id id
|
||||
FROM `cache`.available a
|
||||
JOIN tmp.availableCalc c ON c.calcFk = a.calc_id
|
||||
WHERE a.available > 0;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.availableCalc;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
DROP procedure IF EXISTS `hedera`.`order_update`;
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_update`(vSelf INT)
|
||||
proc: BEGIN
|
||||
/**
|
||||
* Actualiza la líneas de un pedido.
|
||||
*
|
||||
* @param vSelf Id del pedido
|
||||
*/
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAddress INT;
|
||||
DECLARE vAgencyMode INT;
|
||||
DECLARE vNRows INT;
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
ROLLBACK;
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT COUNT(*) INTO vNRows
|
||||
FROM orderRow WHERE orderFk = vSelf;
|
||||
|
||||
IF vNRows > 0
|
||||
THEN
|
||||
CALL order_calcCatalog(vSelf);
|
||||
|
||||
DELETE c
|
||||
FROM orderRow r
|
||||
JOIN orderRowComponent c ON c.rowFk = r.id
|
||||
WHERE r.orderFk = vSelf;
|
||||
|
||||
UPDATE orderRow r
|
||||
LEFT JOIN tmp.ticketComponentPrice p
|
||||
ON p.warehouseFk = r.warehouseFk
|
||||
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,
|
||||
r.amount = IF(p.itemFk IS NOT NULL,
|
||||
r.amount + IF(@m := MOD(r.amount, p.`grouping`), p.`grouping` - @m, 0), 0),
|
||||
r.shipment = t.shipped
|
||||
WHERE r.orderFk = vSelf;
|
||||
|
||||
INSERT INTO orderRowComponent(rowFk, componentFk, price)
|
||||
SELECT r.id, c.componentFk, c.cost
|
||||
FROM orderRow r
|
||||
JOIN tmp.ticketComponent c
|
||||
ON c.warehouseFk = r.warehouseFk
|
||||
AND c.itemFk = r.itemFk
|
||||
JOIN vn.component t
|
||||
ON t.id = c.componentFk
|
||||
AND (t.classRate IS NULL OR t.classRate = r.rate)
|
||||
WHERE r.orderFk = vSelf;
|
||||
|
||||
CALL vn.ticketCalculatePurge;
|
||||
END IF;
|
||||
|
||||
UPDATE `order` SET date_make = NOW()
|
||||
WHERE id = vSelf;
|
||||
|
||||
COMMIT;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
GRANT EXECUTE ON PROCEDURE vn.zoneGetAgency TO `account`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myBasket_calcCatalogFromItem TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myBasket_calcCatalogFull TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myBasket_getAvailable TO `guest`@`%`;
|
||||
GRANT EXECUTE ON PROCEDURE hedera.myOrder_getAvailable TO `guest`@`%`;
|
||||
CALL account.privSync;
|
|
@ -230,8 +230,8 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
|
|||
(8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 1),
|
||||
(9, 'Bruce Banner', 'Somewhere in New York', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 1),
|
||||
(10, 'Jessica Jones', 'NYCC 2015 Poster', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 1),
|
||||
(11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 1),
|
||||
(12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 1),
|
||||
(11, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 10, NULL, NULL, 0, 1),
|
||||
(12, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 10, NULL, NULL, 0, 1),
|
||||
(101, 'address 01', 'Somewhere in Thailand', 'Silla', 46460, 1, 1111111111, 222222222, 1, 109, 2, NULL, NULL, 0, 0),
|
||||
(102, 'address 02', 'Somewhere in Poland', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0),
|
||||
(103, 'address 03', 'Somewhere in Japan', 'Silla', 46460, 1, 3333333333, 444444444, 1, 109, 2, NULL, NULL, 0, 0),
|
||||
|
@ -262,8 +262,8 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr
|
|||
(128, 'address 28', 'Cerebro', 'Silla', 46460, 1, 1111111111, 222222222, 1, 108, 2, NULL, NULL, 0, 0),
|
||||
(129, 'address 29', 'Luke Cages Bar', 'Silla', 46460, 1, 1111111111, 222222222, 1, 110, 2, NULL, NULL, 0, 0),
|
||||
(130, 'address 30', 'Non valid address', 'Silla', 46460, 1, 1111111111, 222222222, 0, 101, 2, NULL, NULL, 0, 0),
|
||||
(131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 2, NULL, NULL, 0, 0),
|
||||
(132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 2, NULL, NULL, 0, 0);
|
||||
(131, 'Missing', 'The space', 'Silla', 46460, 1, 1111111111, 222222222, 1, 200, 10, NULL, NULL, 0, 0),
|
||||
(132, 'Trash', 'New York city', 'Silla', 46460, 1, 1111111111, 222222222, 1, 400, 10, NULL, NULL, 0, 0);
|
||||
|
||||
INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`)
|
||||
SELECT name, CONCAT(name, 'Street'), 'SILLA', 46460, 1, 1, id, 2, 1
|
||||
|
@ -434,7 +434,7 @@ INSERT INTO `vn`.`ticket`(`id`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped
|
|||
(8 , 1, 1, 4, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 104, 'address 24', 124, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH) ),
|
||||
(9 , 5, 5, 4, DATE_ADD(CURDATE(), INTERVAL -2 MONTH), DATE_ADD(CURDATE(), INTERVAL -2 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -2 MONTH) ),
|
||||
(10, 6, 5, 5, DATE_ADD(CURDATE(), INTERVAL -3 MONTH), DATE_ADD(CURDATE(), INTERVAL -3 MONTH), 105, 'address 25', 125, 'A1111111', 0, DATE_ADD(CURDATE(), INTERVAL -3 MONTH) ),
|
||||
(11, 7, 1, 1, CURDATE() , CURDATE() , 101, 'address 21', 121, NULL, 0, CURDATE() ),
|
||||
(11, 7, 1, 1, CURDATE() , DATE_ADD(CURDATE(), INTERVAL +1 DAY) , 101, 'address 21', 121, NULL, 0, CURDATE() ),
|
||||
(12, 1, 1, 1, DATE_ADD(CURDATE(), INTERVAL +1 MONTH), DATE_ADD(CURDATE(), INTERVAL +1 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +1 MONTH) ),
|
||||
(13, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +2 MONTH), DATE_ADD(CURDATE(), INTERVAL +2 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +2 MONTH) ),
|
||||
(14, 2, 2, 2, DATE_ADD(CURDATE(), INTERVAL +3 MONTH), DATE_ADD(CURDATE(), INTERVAL +3 MONTH), 101, 'address 21', 121, NULL, 0, DATE_ADD(CURDATE(), INTERVAL +3 MONTH) ),
|
||||
|
@ -635,8 +635,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
|
|||
(4, 4, 1, 'Melee weapon heavy shield 1x0.5m', 20, 3.06, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -15 DAY)),
|
||||
(5, 1, 2, 'Ranged weapon longbow 2m', 10, 9.10, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
|
||||
(6, 1, 3, 'Ranged weapon longbow 2m', 15, 6.50, 0, 0, 0, DATE_ADD(CURDATE(), INTERVAL -5 DAY)),
|
||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 1.46, 0, 0, 0, CURDATE()),
|
||||
(8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 3.04, 0, 0, 0, CURDATE()),
|
||||
(7, 2, 11, 'Melee weapon combat fist 15cm', 15, 1.02, 0, 0, 0, CURDATE()),
|
||||
(8, 4, 11, 'Melee weapon heavy shield 1x0.5m', 10, 3.01, 0, 0, 0, CURDATE()),
|
||||
(9, 1, 16, 'Ranged weapon longbow 2m', 5, 9.10, 0, 0, 0, CURDATE()),
|
||||
(10, 2, 16, 'Melee weapon combat fist 15cm', 10, 1.07, 0, 0, 0, CURDATE()),
|
||||
(11, 1, 16, 'Ranged weapon longbow 2m', 2, 9.10, 0, 0, 0, CURDATE()),
|
||||
|
@ -688,13 +688,11 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
|||
(5, 29, -18.72),
|
||||
(5, 39, 0.02),
|
||||
(6, 23, 6.5),
|
||||
(7, 15, 0.2839),
|
||||
(7, 21, 0.166),
|
||||
(7, 15, 0.0114),
|
||||
(7, 28, 5.6),
|
||||
(7, 29, -4.6),
|
||||
(7, 39, 0.01),
|
||||
(8, 15, 0.039),
|
||||
(8, 21, -0.003),
|
||||
(8, 15, 0.0016),
|
||||
(8, 28, 20.72),
|
||||
(8, 29, -19.72),
|
||||
(8, 37, 2),
|
||||
|
@ -1290,37 +1288,6 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC
|
|||
(4, 'Documentos', 1, 2.00, 1, 9),
|
||||
(5, 'Documentos', 1, 2.00, 1, 8);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)
|
||||
VALUES
|
||||
(1, 'Zone 1 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2.3', '2.3'),
|
||||
(2, 'Zone 1 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2.3', '2.3'),
|
||||
(3, 'Zone 2 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '2', '1', '2', '1.2', '1.2'),
|
||||
(4, 'Zone 2 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '2', '1', '2', '1.2', '1.2'),
|
||||
(5, 'Zone 3 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2', '2'),
|
||||
(6, 'Zone 3 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '2', '2');
|
||||
|
||||
INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
|
||||
VALUES
|
||||
(1, 3, 0),
|
||||
(1, 4, 1),
|
||||
(1, 5, 1),
|
||||
(2, 3, 1),
|
||||
(2, 4, 0),
|
||||
(2, 5, 1),
|
||||
(3, 2, 1),
|
||||
(3, 3, 0),
|
||||
(3, 4, 0),
|
||||
(3, 5, 1),
|
||||
(4, 2, 0),
|
||||
(4, 3, 1),
|
||||
(4, 4, 1),
|
||||
(4, 5, 0),
|
||||
(5, 2, 1),
|
||||
(5, 3, 1),
|
||||
(5, 4, 1),
|
||||
(5, 5, 1);
|
||||
|
||||
INSERT INTO `pbx`.`sip`(`user_id`, `extension`, `secret`, `caller_id`)
|
||||
VALUES
|
||||
(1, 1010, '123456', 'employee'),
|
||||
|
@ -1408,13 +1375,14 @@ INSERT INTO `vn`.`sharingCart`(`id`, `workerFk`, `started`, `ended`, `workerSubs
|
|||
|
||||
INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `warehouseFk`, `agencyModeFk`, `travelingDays`, `price`, `bonus`)
|
||||
VALUES
|
||||
(1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '1', '1', '0', '0'),
|
||||
(2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '2', '1', '2', '0', '0'),
|
||||
(3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '7', '2', '2', '0'),
|
||||
(4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '2', '7', '1', '2', '0'),
|
||||
(5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '8', '2', '5', '-1'),
|
||||
(6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), '1', '8', '1', '5', '-1');
|
||||
|
||||
(1, 'Zone pickup A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 1, 0, '0', '0'),
|
||||
(2, 'Zone pickup B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 1, 0, '0', '0'),
|
||||
(3, 'Zone 247 A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 7, 1, '2', '0'),
|
||||
(4, 'Zone 247 B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 7, 1, '2', '0'),
|
||||
(5, 'Zone expensive A', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 8, 1, '5', '-1'),
|
||||
(6, 'Zone expensive B', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 2, 8, 1, '5', '-1'),
|
||||
(7, 'Zone refund', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 10, 0, 0, 0),
|
||||
(8, 'Zone others', CONCAT(CURRENT_DATE(), ' ', TIME('22:00')), 1, 23, 0, 0, 0);
|
||||
|
||||
INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
|
||||
VALUES
|
||||
|
@ -1441,7 +1409,15 @@ INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`)
|
|||
(6, 3, 1),
|
||||
(6, 4, 0),
|
||||
(6, 5, 1),
|
||||
(6, 2, 1);
|
||||
(6, 2, 1),
|
||||
(7, 3, 0),
|
||||
(7, 4, 0),
|
||||
(7, 5, 0),
|
||||
(7, 2, 1),
|
||||
(8, 3, 0),
|
||||
(8, 4, 0),
|
||||
(8, 5, 0),
|
||||
(8, 2, 1);
|
||||
|
||||
INSERT INTO `vn`.`zoneCalendar`(`zoneFk`, `delivered`)
|
||||
VALUES
|
||||
|
@ -1482,4 +1458,18 @@ INSERT INTO `vn`.`zoneCalendar`(`zoneFk`, `delivered`)
|
|||
(6, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
|
||||
(6, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
|
||||
(6, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
|
||||
(6, DATE_ADD(CURDATE(), INTERVAL +6 DAY));
|
||||
(6, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
|
||||
(7, CURDATE()),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
|
||||
(7, DATE_ADD(CURDATE(), INTERVAL +6 DAY)),
|
||||
(8, CURDATE()),
|
||||
(8, DATE_ADD(CURDATE(), INTERVAL +1 DAY)),
|
||||
(8, DATE_ADD(CURDATE(), INTERVAL +2 DAY)),
|
||||
(8, DATE_ADD(CURDATE(), INTERVAL +3 DAY)),
|
||||
(8, DATE_ADD(CURDATE(), INTERVAL +4 DAY)),
|
||||
(8, DATE_ADD(CURDATE(), INTERVAL +5 DAY)),
|
||||
(8, DATE_ADD(CURDATE(), INTERVAL +6 DAY));
|
||||
|
|
|
@ -97,7 +97,7 @@ for DIR_PATH in "$DIR/changes/"*; do
|
|||
for FILE in "$DIR_PATH/"*; do
|
||||
FILE_NAME=$(basename "$FILE")
|
||||
|
||||
if [[ ! "$FILE_NAME" =~ ^[0-9]{2}-[a-zA-Z0-9]+\.sql$ ]]; then
|
||||
if [[ ! "$FILE_NAME" =~ ^[0-9]{2}-[a-zA-Z0-9_]+\.sql$ ]]; then
|
||||
echo "[WARN] Ignoring wrong file name: $FILE_NAME"
|
||||
continue
|
||||
fi
|
||||
|
|
|
@ -82,5 +82,6 @@
|
|||
"That item is not available on that day": "El item no esta disponible para esa fecha",
|
||||
"That item doesn't exists": "That item doesn't exists",
|
||||
"You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado",
|
||||
"This ticket can not be modified": "Este ticket no puede ser modificado"
|
||||
"This ticket can not be modified": "Este ticket no puede ser modificado",
|
||||
"NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada"
|
||||
}
|
|
@ -1,12 +1,32 @@
|
|||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getLanded', {
|
||||
Self.remoteMethodCtx('getLanded', {
|
||||
description: 'Returns the first shipped and landed possible for params',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'shipped, addressFk, agencyModeFk, warehouseFk'
|
||||
type: 'Object',
|
||||
description: `shipped, addressFk, agencyModeFk, warehouseFk`
|
||||
}, {
|
||||
arg: 'shipped',
|
||||
type: 'date',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'addressFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'agencyModeFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'warehouseFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
|
@ -18,11 +38,24 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getLanded = async params => {
|
||||
let query = `CALL vn.zoneGetLanded(?, ?, ?, ?);
|
||||
SELECT * FROM tmp.zoneGetLanded`;
|
||||
let result = await Self.rawSql(query, [params.shipped, params.addressFk || null, params.agencyModeFk, params.warehouseFk]);
|
||||
Self.getLanded = async(ctx, params) => {
|
||||
let stmts = [];
|
||||
params = params || ctx.args;
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`CALL vn.zoneGetLanded(?, ?, ?, ?)`, [
|
||||
params.shipped,
|
||||
params.addressFk,
|
||||
params.agencyModeFk,
|
||||
params.warehouseFk
|
||||
]
|
||||
));
|
||||
|
||||
return result[1][0].landed;
|
||||
let rsIndex = stmts.push(
|
||||
`SELECT * FROM tmp.zoneGetLanded`) - 1;
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let landed = await Self.rawStmt(sql);
|
||||
|
||||
return landed[rsIndex][0];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,15 +1,33 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getShipped', {
|
||||
Self.remoteMethodCtx('getShipped', {
|
||||
description: 'Returns the first shipped possible for params',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'params',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'landed, addressFk, agencyModeFk'
|
||||
type: 'Object',
|
||||
description: `landed, addressFk, agencyModeFk, warehouseFk`
|
||||
}, {
|
||||
arg: 'landed',
|
||||
type: 'date',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'addressFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'agencyModeFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'warehouseFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
type: 'date',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
|
@ -18,10 +36,15 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getShipped = async params => {
|
||||
Self.getShipped = async(ctx, params)=> {
|
||||
params = params || ctx.args;
|
||||
let query = `CALL vn.zoneGetShipped(?, ?, ?, ?)`;
|
||||
let result = await Self.rawSql(query, [params.landed, params.addressFk, params.agencyModeFk, 1]);
|
||||
|
||||
return result[0][0].shipped || null;
|
||||
let [response] = await Self.rawSql(query, [
|
||||
params.landed,
|
||||
params.addressFk,
|
||||
params.agencyModeFk,
|
||||
params.warehouseFk
|
||||
]);
|
||||
return (response[0] && response[0].shipped && response[0].shipped.toJSON()) || null;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -19,9 +19,10 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
Self.landsThatDay = async filter => {
|
||||
let query = `CALL vn.zoneGetAgency(?, ?)`;
|
||||
let query = `CALL vn.zoneGetAgency(?, ?);
|
||||
SELECT * FROM tmp.zoneGetAgency`;
|
||||
let result = await Self.rawSql(query, [filter.addressFk, filter.landed]);
|
||||
|
||||
return result;
|
||||
return result[1];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket getLanded()', () => {
|
||||
describe('agency getLanded()', () => {
|
||||
it('should return a landing date', async() => {
|
||||
let data = {
|
||||
shipped: new Date(),
|
||||
|
@ -8,7 +8,7 @@ describe('ticket getLanded()', () => {
|
|||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Ticket.getLanded(data);
|
||||
let result = await app.models.Agency.getLanded({}, data);
|
||||
|
||||
expect(result.landed).toBeDefined();
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket getShipped()', () => {
|
||||
describe('agency getShipped()', () => {
|
||||
it('should return a shipment date', async() => {
|
||||
let data = {
|
||||
landed: new Date(),
|
||||
|
@ -8,9 +8,9 @@ describe('ticket getShipped()', () => {
|
|||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Ticket.getShipped(data);
|
||||
let result = await app.models.Agency.getShipped({}, data);
|
||||
|
||||
expect(result.shipped).toBeDefined();
|
||||
expect(result).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not return a shipment date', async() => {
|
||||
|
@ -23,8 +23,8 @@ describe('ticket getShipped()', () => {
|
|||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Ticket.getShipped(data);
|
||||
let result = await app.models.Agency.getShipped({}, data);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
|
@ -11,7 +11,7 @@ describe('agency clone()', () => {
|
|||
it('should clone a zone', async() => {
|
||||
newZone = await app.models.Zone.clone(1);
|
||||
|
||||
expect(newZone.name).toEqual('Zone 1 A');
|
||||
expect(newZone.name).toEqual('Zone pickup A');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -7,6 +7,6 @@ describe('Client get', () => {
|
|||
|
||||
expect(result.id).toEqual(101);
|
||||
expect(result.name).toEqual('Bruce Wayne');
|
||||
expect(result.debt).toEqual(-14.78);
|
||||
expect(result.debt).toEqual(-22.4);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ describe('client getDebt()', () => {
|
|||
it('should return the client debt', async() => {
|
||||
let result = await app.models.Client.getDebt(101);
|
||||
|
||||
expect(result.debt).toEqual(-14.78);
|
||||
expect(result.debt).toEqual(-22.4);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('client summary()', () => {
|
|||
it('should return a summary object containing debt', async() => {
|
||||
let result = await app.models.Client.summary(101);
|
||||
|
||||
expect(result.debt.debt).toEqual(-14.78);
|
||||
expect(result.debt.debt).toEqual(-22.4);
|
||||
});
|
||||
|
||||
it('should return a summary object containing averageInvoiced', async() => {
|
||||
|
|
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
|||
params.items.forEach(item => {
|
||||
promises.push(
|
||||
Self.rawSql(
|
||||
`CALL hedera.orderAddItem(?, ?, ?, ?)`,
|
||||
`CALL hedera.order_addItem(?, ?, ?, ?)`,
|
||||
[params.orderFk, item.warehouseFk, item.itemFk, item.quantity]
|
||||
)
|
||||
);
|
||||
|
|
|
@ -166,11 +166,7 @@ module.exports = Self => {
|
|||
JOIN vn.tag t ON t.id = it.tagFk`) - 1;
|
||||
|
||||
// Clean temporary tables
|
||||
stmts.push(
|
||||
`DROP TEMPORARY TABLE
|
||||
tmp.item,
|
||||
tmp.ticketCalculateItem,
|
||||
tmp.ticketComponentPrice`);
|
||||
stmts.push('CALL vn.ticketCalculatePurge()');
|
||||
|
||||
const sql = ParameterizedSQL.join(stmts, ';');
|
||||
const result = await conn.executeStmt(sql);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('confirm', {
|
||||
Self.remoteMethodCtx('confirm', {
|
||||
description: 'Confirms an order',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -19,8 +19,9 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.confirm = async orderFk => {
|
||||
let query = `CALL hedera.orderConfirm(?)`;
|
||||
return await Self.rawSql(query, [orderFk]);
|
||||
Self.confirm = async(ctx, orderFk) => {
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
let query = `CALL hedera.order_confirmWithUser(?, ?)`;
|
||||
return await Self.rawSql(query, [orderFk, userId]);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ describe('order catalogFilter()', () => {
|
|||
}
|
||||
};
|
||||
let tags = [];
|
||||
let orderFk = 11;
|
||||
let orderFk = 20;
|
||||
let orderBy = {field: 'relevancy DESC, name', way: 'DESC'};
|
||||
let result = await app.models.Order.catalogFilter(orderFk, orderBy, filter, tags);
|
||||
let firstItemId = result[0].id;
|
||||
|
@ -25,13 +25,14 @@ describe('order catalogFilter()', () => {
|
|||
}
|
||||
};
|
||||
|
||||
let tags = [{tagFk: 56, value: 'Melee weapon'}];
|
||||
let orderFk = 11;
|
||||
let tags = [{tagFk: 56, value: 'Melee Reinforced weapon'}];
|
||||
let orderFk = 20;
|
||||
let orderBy = {field: 'relevancy DESC, name', way: 'DESC'};
|
||||
let result = await app.models.Order.catalogFilter(orderFk, orderBy, filter, tags);
|
||||
|
||||
let firstItemId = result[0].id;
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(firstItemId).toEqual(2);
|
||||
expect(firstItemId).toEqual(9);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -84,7 +84,7 @@ class Controller {
|
|||
filter = encodeURIComponent(JSON.stringify(filter));
|
||||
let query = `/api/Agencies/landsThatDay?filter=${filter}`;
|
||||
this.$http.get(query).then(res => {
|
||||
this._availableAgencies = res.data[0];
|
||||
this._availableAgencies = res.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,19 @@ let UserError = require('vn-loopback/util/user-error');
|
|||
|
||||
describe('sale priceDifference()', () => {
|
||||
it('should return ticket price differences', async() => {
|
||||
let tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
let data = {
|
||||
landed: new Date(),
|
||||
landed: tomorrow,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 1,
|
||||
agencyModeFk: 7,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let result = await app.models.Sale.priceDifference(11, data);
|
||||
|
||||
expect(result.totalUnitPrice).toEqual(4.5);
|
||||
expect(result.totalNewPrice).toEqual(4.24);
|
||||
expect(result.totalDifference).toEqual(3.75);
|
||||
expect(result.totalUnitPrice).toEqual(4.03);
|
||||
expect(result.totalNewPrice).toEqual(4.03);
|
||||
expect(result.totalDifference).toEqual(0);
|
||||
});
|
||||
|
||||
it('should return an error if the ticket state is not valid for modifications', async() => {
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getLanded', {
|
||||
description: 'Returns ticket available landed date',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'data',
|
||||
type: 'Object',
|
||||
required: true,
|
||||
description: 'shipped, addressFk, agencyModeFk, warehouseFk',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getLanded`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getLanded = async data => {
|
||||
let stmts = [];
|
||||
|
||||
stmts.push(new ParameterizedSQL(
|
||||
`CALL vn.zoneGetLanded(?, ?, ?, ?)`, [
|
||||
data.shipped,
|
||||
data.addressFk,
|
||||
data.agencyModeFk,
|
||||
data.warehouseFk
|
||||
]
|
||||
));
|
||||
|
||||
let rsIndex = stmts.push(
|
||||
`SELECT * FROM tmp.zoneGetLanded`) - 1;
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
let landed = await Self.rawStmt(sql);
|
||||
|
||||
return landed[rsIndex][0];
|
||||
};
|
||||
};
|
|
@ -1,33 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('getShipped', {
|
||||
description: 'Returns ticket available shipment date',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'data',
|
||||
type: 'Object',
|
||||
required: true,
|
||||
description: 'landed, addressFk, agencyModeFk',
|
||||
http: {source: 'body'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getShipped`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getShipped = async data => {
|
||||
let query = `CALL vn.zoneGetShipped(?, ?, ?, ?)`;
|
||||
let [response] = await Self.rawSql(query, [
|
||||
data.landed,
|
||||
data.addressFk,
|
||||
data.agencyModeFk,
|
||||
data.warehouseFk
|
||||
]);
|
||||
|
||||
return (response[0] && response[0].shipped) || null;
|
||||
};
|
||||
};
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
if (params && params.agencyModeFk)
|
||||
agencyMode = await Self.app.models.AgencyMode.findById(params.agencyModeFk);
|
||||
|
||||
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.name != 'refund')) {
|
||||
if (address.client().type().code === 'normal' && (!agencyMode || agencyMode.code != 'refund')) {
|
||||
if (address.client().isFreezed)
|
||||
throw new UserError(`You can't create a ticket for a frozen client`);
|
||||
|
||||
|
@ -56,21 +56,22 @@ module.exports = Self => {
|
|||
|
||||
try {
|
||||
if (!params.shipped && params.landed) {
|
||||
params.shipped = await Self.app.models.Agency.getShipped({
|
||||
params.shipped = await Self.app.models.Agency.getShipped(ctx, {
|
||||
landed: params.landed,
|
||||
addressFk: address.id,
|
||||
agencyModeFk: agency.agencyModeFk,
|
||||
agencyModeFk: params.agencyModeFk,
|
||||
warehouseFk: params.warehouseFk
|
||||
});
|
||||
}
|
||||
|
||||
if (params.shipped && !params.landed) {
|
||||
params.landed = await Self.app.models.Agency.getLanded({
|
||||
const landedResult = await Self.app.models.Agency.getLanded(ctx, {
|
||||
shipped: params.shipped,
|
||||
addressFk: address.id,
|
||||
agencyModeFk: params.agencyModeFk,
|
||||
warehouseFk: params.warehouseFk
|
||||
});
|
||||
params.landed = landedResult.landed;
|
||||
}
|
||||
|
||||
if (!params.userId && ctx.req && ctx.req.accessToken.userId)
|
||||
|
|
|
@ -9,6 +9,8 @@ describe('ticket componentUpdate()', () => {
|
|||
let componentOfSaleEight = `SELECT value FROM vn.saleComponent
|
||||
WHERE saleFk = 8 AND componentFk = 15`;
|
||||
const today = new Date();
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
let ticketId = 11;
|
||||
|
||||
beforeAll(async done => {
|
||||
|
@ -29,7 +31,7 @@ describe('ticket componentUpdate()', () => {
|
|||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
shipped: today,
|
||||
landed: today,
|
||||
landed: tomorrow,
|
||||
isDeleted: false,
|
||||
hasToBeUnrouted: false,
|
||||
option: 1
|
||||
|
@ -57,7 +59,7 @@ describe('ticket componentUpdate()', () => {
|
|||
warehouseFk: 1,
|
||||
companyFk: 442,
|
||||
shipped: today,
|
||||
landed: today,
|
||||
landed: tomorrow,
|
||||
isDeleted: false,
|
||||
hasToBeUnrouted: false,
|
||||
option: 1
|
||||
|
|
|
@ -14,8 +14,6 @@ module.exports = Self => {
|
|||
require('../methods/ticket/getVAT')(Self);
|
||||
require('../methods/ticket/getSales')(Self);
|
||||
require('../methods/ticket/getSalesPersonMana')(Self);
|
||||
require('../methods/ticket/getShipped')(Self);
|
||||
require('../methods/ticket/getLanded')(Self);
|
||||
require('../methods/ticket/filter')(Self);
|
||||
require('../methods/ticket/getPossibleStowaways')(Self);
|
||||
require('../methods/ticket/canBeInvoiced')(Self);
|
||||
|
|
|
@ -64,15 +64,15 @@ class Controller {
|
|||
}
|
||||
|
||||
onChangeShipped(value) {
|
||||
let data = {
|
||||
let params = {
|
||||
shipped: value,
|
||||
addressFk: this.ticket.addressFk,
|
||||
agencyModeFk: this.ticket.agencyModeFk,
|
||||
warehouseFk: this.ticket.warehouseFk
|
||||
};
|
||||
|
||||
let query = `/api/Tickets/getLanded`;
|
||||
this.$http.post(query, data).then(res => {
|
||||
let query = `/api/Agencies/getLanded`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
if (res.data && res.data.landed)
|
||||
this.ticket.landed = res.data.landed;
|
||||
else {
|
||||
|
@ -84,17 +84,17 @@ class Controller {
|
|||
}
|
||||
|
||||
onChangeLanded(value) {
|
||||
let data = {
|
||||
let params = {
|
||||
landed: value,
|
||||
addressFk: this.ticket.addressFk,
|
||||
agencyModeFk: this.ticket.agencyModeFk,
|
||||
warehouseFk: this.ticket.warehouseFk
|
||||
};
|
||||
|
||||
let query = `/api/Tickets/getShipped`;
|
||||
this.$http.post(query, data).then(res => {
|
||||
if (res.data && res.data.shipped)
|
||||
this.ticket.shipped = res.data.shipped;
|
||||
let query = `/api/Agencies/getShipped`;
|
||||
this.$http.get(query, {params}).then(res => {
|
||||
if (res.data)
|
||||
this.ticket.shipped = res.data;
|
||||
else {
|
||||
return this.vnApp.showError(
|
||||
this.$translate.instant(`There's no available agency for this landing date`)
|
||||
|
|
|
@ -5,12 +5,15 @@ describe('Ticket', () => {
|
|||
let $state;
|
||||
let controller;
|
||||
let $httpBackend;
|
||||
let $httpParamSerializer;
|
||||
|
||||
|
||||
beforeEach(ngModule('ticket'));
|
||||
|
||||
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_) => {
|
||||
beforeEach(angular.mock.inject(($componentController, _$state_, _$httpBackend_, _$httpParamSerializer_) => {
|
||||
$state = _$state_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$httpParamSerializer = _$httpParamSerializer_;
|
||||
controller = $componentController('vnTicketBasicDataStepOne', {$state});
|
||||
}));
|
||||
|
||||
|
@ -66,15 +69,17 @@ describe('Ticket', () => {
|
|||
agencyModeFk: 2,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let data = {
|
||||
let params = {
|
||||
shipped: shipped,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 2,
|
||||
warehouseFk: 1
|
||||
};
|
||||
|
||||
$httpBackend.whenPOST(`/api/Tickets/getLanded`, data).respond(200);
|
||||
$httpBackend.expectPOST(`/api/Tickets/getLanded`, data);
|
||||
let serializedParams = $httpParamSerializer(params);
|
||||
$httpBackend.when('GET', `/api/Agencies/getLanded?${serializedParams}`).respond(200);
|
||||
$httpBackend.expect('GET', `/api/Agencies/getLanded?${serializedParams}`);
|
||||
|
||||
controller.onChangeShipped(shipped);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
@ -83,11 +88,24 @@ describe('Ticket', () => {
|
|||
describe('onChangeLanded()', () => {
|
||||
it('should return an available shipment date', async() => {
|
||||
let landed = new Date();
|
||||
controller._ticket = {id: 1, landed: landed, addressFk: 121, agencyModeFk: 2};
|
||||
let data = {landed: landed, addressFk: 121, agencyModeFk: 2};
|
||||
controller._ticket = {
|
||||
id: 1,
|
||||
landed: landed,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 2,
|
||||
warehouseFk: 1
|
||||
};
|
||||
let params = {
|
||||
landed: landed,
|
||||
addressFk: 121,
|
||||
agencyModeFk: 2,
|
||||
warehouseFk: 1
|
||||
};
|
||||
|
||||
let serializedParams = $httpParamSerializer(params);
|
||||
$httpBackend.when('GET', `/api/Agencies/getShipped?${serializedParams}`).respond(200);
|
||||
$httpBackend.expect('GET', `/api/Agencies/getShipped?${serializedParams}`);
|
||||
|
||||
$httpBackend.whenPOST(`/api/Tickets/getShipped`, data).respond(200);
|
||||
$httpBackend.expectPOST(`/api/Tickets/getShipped`, data);
|
||||
controller.onChangeLanded(landed);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue