6995-testToMaster_2410 #2139
|
@ -235,6 +235,7 @@ pipeline {
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
message = message.substring(0, index)
|
message = message.substring(0, index)
|
||||||
|
|
||||||
|
setEnv()
|
||||||
rocketSend(
|
rocketSend(
|
||||||
channel: 'vn-database',
|
channel: 'vn-database',
|
||||||
message: "*DB version uploaded:* ${message}"
|
message: "*DB version uploaded:* ${message}"
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethod('getSectors', {
|
|
||||||
description: 'Get all sectors',
|
|
||||||
accessType: 'READ',
|
|
||||||
returns: {
|
|
||||||
type: 'Object',
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/getSectors`,
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.getSectors = async() => {
|
|
||||||
const query = `CALL vn.sector_get()`;
|
|
||||||
const [result] = await Self.rawSql(query);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,11 +0,0 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
|
||||||
|
|
||||||
describe('getSectors()', () => {
|
|
||||||
it('return list of sectors', async() => {
|
|
||||||
let response = await models.Collection.getSectors();
|
|
||||||
|
|
||||||
expect(response.length).toBeGreaterThan(0);
|
|
||||||
expect(response[0].id).toEqual(1);
|
|
||||||
expect(response[0].description).toEqual('First sector');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,6 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/collection/getCollection')(Self);
|
require('../methods/collection/getCollection')(Self);
|
||||||
require('../methods/collection/getSectors')(Self);
|
|
||||||
require('../methods/collection/setSaleQuantity')(Self);
|
require('../methods/collection/setSaleQuantity')(Self);
|
||||||
require('../methods/collection/previousLabel')(Self);
|
require('../methods/collection/previousLabel')(Self);
|
||||||
require('../methods/collection/getTickets')(Self);
|
require('../methods/collection/getTickets')(Self);
|
||||||
|
|
|
@ -1750,8 +1750,6 @@ USE `vn`;
|
||||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||||
|
|
||||||
INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios');
|
|
||||||
|
|
||||||
INSERT INTO `alertLevel` VALUES ('FREE',0,1);
|
INSERT INTO `alertLevel` VALUES ('FREE',0,1);
|
||||||
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1);
|
INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1);
|
||||||
INSERT INTO `alertLevel` VALUES ('PACKED',2,0);
|
INSERT INTO `alertLevel` VALUES ('PACKED',2,0);
|
||||||
|
|
|
@ -137,9 +137,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF
|
||||||
INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded)
|
INSERT INTO vn.sale (itemFk, ticketFk, concept, quantity, originalQuantity, price, discount, priceFixed, reserved, isPicked, isPriceFixed, created, isAdded)
|
||||||
VALUES (1, 24, 'Ranged weapon longbow 2m', 1.00, NULL, 8.07, 0, 0.00, 0, 0, 0, '2022-07-06 00:00:00', 0);
|
VALUES (1, 24, 'Ranged weapon longbow 2m', 1.00, NULL, 8.07, 0, 0.00, 0, 0, 0, '2022-07-06 00:00:00', 0);
|
||||||
*/
|
*/
|
||||||
INSERT INTO vn2008.zones (zone_id,name,printingOrder)
|
|
||||||
VALUES (1,'zone Test',1);
|
|
||||||
|
|
||||||
-- XXX: lab
|
-- XXX: lab
|
||||||
|
|
||||||
INSERT INTO `vn`.`businessReasonEnd` (`id`, `reason`)
|
INSERT INTO `vn`.`businessReasonEnd` (`id`, `reason`)
|
||||||
|
|
|
@ -653,6 +653,7 @@ INSERT INTO `vn`.`expense`(`id`, `name`, `isWithheld`)
|
||||||
(7001000000, 'Mercaderia', 0),
|
(7001000000, 'Mercaderia', 0),
|
||||||
(7050000000, 'Prestacion de servicios', 1);
|
(7050000000, 'Prestacion de servicios', 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios');
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`, `created`)
|
INSERT INTO `vn`.`invoiceOutExpense`(`id`, `invoiceOutFk`, `amount`, `expenseFk`, `created`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -728,7 +729,7 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen
|
||||||
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`)
|
INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`)
|
||||||
VALUES
|
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),
|
(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),
|
||||||
(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),
|
(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),
|
||||||
(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),
|
(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),
|
||||||
(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),
|
(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),
|
||||||
(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),
|
(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),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_add`(IN vYear INT, IN vMonth INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_add`(IN vYear INT, IN vMonth INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reemplaza las ventas contables del último año.
|
* Reemplaza las ventas contables del último año.
|
||||||
* Es el origen de datos para el balance de Entradas
|
* Es el origen de datos para el balance de Entradas
|
||||||
|
@ -13,8 +13,8 @@ BEGIN
|
||||||
|
|
||||||
DECLARE TIPO_PATRIMONIAL INT DEFAULT 188;
|
DECLARE TIPO_PATRIMONIAL INT DEFAULT 188;
|
||||||
|
|
||||||
DELETE FROM bs.ventas_contables
|
DELETE FROM bs.ventas_contables
|
||||||
WHERE year = vYear
|
WHERE year = vYear
|
||||||
AND month = vMonth;
|
AND month = vMonth;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
|
||||||
|
@ -25,7 +25,7 @@ BEGIN
|
||||||
FROM vn2008.Tickets t
|
FROM vn2008.Tickets t
|
||||||
JOIN vn.invoiceOut io ON io.id = t.Factura
|
JOIN vn.invoiceOut io ON io.id = t.Factura
|
||||||
WHERE year(io.issued) = vYear
|
WHERE year(io.issued) = vYear
|
||||||
AND month(io.issued) = vMonth;
|
AND month(io.issued) = vMonth;
|
||||||
|
|
||||||
INSERT INTO bs.ventas_contables(year
|
INSERT INTO bs.ventas_contables(year
|
||||||
, month
|
, month
|
||||||
|
@ -35,7 +35,7 @@ BEGIN
|
||||||
, tipo_id
|
, tipo_id
|
||||||
, empresa_id
|
, empresa_id
|
||||||
, gasto)
|
, gasto)
|
||||||
|
|
||||||
SELECT vYear
|
SELECT vYear
|
||||||
, vMonth
|
, vMonth
|
||||||
, round(sum(Cantidad * Preu * (100 - m.Descuento)/100))
|
, round(sum(Cantidad * Preu * (100 - m.Descuento)/100))
|
||||||
|
@ -47,13 +47,13 @@ BEGIN
|
||||||
, tp.reino_id
|
, tp.reino_id
|
||||||
, a.tipo_id
|
, a.tipo_id
|
||||||
, t.empresa_id
|
, t.empresa_id
|
||||||
, 7000000000
|
, a.expenseFk
|
||||||
+ IF(e.empresa_grupo = e2.empresa_grupo
|
+ IF(e.empresa_grupo = e2.empresa_grupo
|
||||||
,1
|
,1
|
||||||
,IF(e2.empresa_grupo,2,0)
|
,IF(e2.empresa_grupo,2,0)
|
||||||
) * 1000000
|
) * 100000
|
||||||
+ tp.reino_id * 10000 as Gasto
|
+ tp.reino_id * 1000 as Gasto
|
||||||
FROM vn2008.Movimientos m
|
FROM vn2008.Movimientos m
|
||||||
JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket
|
JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket
|
||||||
JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna
|
JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna
|
||||||
JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente
|
JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente
|
||||||
|
@ -67,7 +67,7 @@ BEGIN
|
||||||
AND m.Descuento <> 100
|
AND m.Descuento <> 100
|
||||||
AND a.tipo_id != TIPO_PATRIMONIAL
|
AND a.tipo_id != TIPO_PATRIMONIAL
|
||||||
GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto;
|
GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto;
|
||||||
|
|
||||||
INSERT INTO bs.ventas_contables(year
|
INSERT INTO bs.ventas_contables(year
|
||||||
, month
|
, month
|
||||||
, venta
|
, venta
|
||||||
|
@ -86,17 +86,17 @@ BEGIN
|
||||||
) as grupo
|
) as grupo
|
||||||
, NULL
|
, NULL
|
||||||
, NULL
|
, NULL
|
||||||
, t.companyFk
|
, t.companyFk
|
||||||
, 7050000000
|
, 7050000000
|
||||||
FROM vn.ticketService ts
|
FROM vn.ticketService ts
|
||||||
JOIN vn.ticket t ON ts.ticketFk = t.id
|
JOIN vn.ticket t ON ts.ticketFk = t.id
|
||||||
JOIN vn.address a on a.id = t.addressFk
|
JOIN vn.address a on a.id = t.addressFk
|
||||||
JOIN vn.client cl on cl.id = a.clientFk
|
JOIN vn.client cl on cl.id = a.clientFk
|
||||||
JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id
|
JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id
|
||||||
JOIN vn.company c on c.id = t.companyFk
|
JOIN vn.company c on c.id = t.companyFk
|
||||||
LEFT JOIN vn.company c2 on c2.clientFk = cl.id
|
LEFT JOIN vn.company c2 on c2.clientFk = cl.id
|
||||||
GROUP BY grupo, t.companyFk ;
|
GROUP BY grupo, t.companyFk ;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket_list;
|
DROP TEMPORARY TABLE tmp.ticket_list;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`isPalletHomogeneus`(vExpedition INT)
|
|
||||||
RETURNS tinyint(1)
|
|
||||||
NOT DETERMINISTIC
|
|
||||||
READS SQL DATA
|
|
||||||
BEGIN
|
|
||||||
DECLARE vScanId INT;
|
|
||||||
DECLARE vDistinctRoutesInThePallet INT;
|
|
||||||
|
|
||||||
SELECT scan_id INTO vScanId
|
|
||||||
FROM vn2008.scan_line
|
|
||||||
WHERE code = vExpedition
|
|
||||||
LIMIT 1;
|
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vDistinctRoutesInThePallet
|
|
||||||
FROM (
|
|
||||||
SELECT DISTINCT t.Id_Ruta
|
|
||||||
FROM vn2008.scan_line sl
|
|
||||||
JOIN expedition e ON e.id = sl.code
|
|
||||||
JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticketFk
|
|
||||||
WHERE sl.scan_id = vScanId
|
|
||||||
AND t.Id_Ruta
|
|
||||||
) t1;
|
|
||||||
|
|
||||||
RETURN vDistinctRoutesInThePallet = 1;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -22,6 +22,7 @@ BEGIN
|
||||||
SET v2Years = util.VN_CURDATE() - INTERVAL 2 YEAR;
|
SET v2Years = util.VN_CURDATE() - INTERVAL 2 YEAR;
|
||||||
SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR;
|
SET v5Years = util.VN_CURDATE() - INTERVAL 5 YEAR;
|
||||||
|
|
||||||
|
DELETE FROM workerActivity WHERE created < v2Years;
|
||||||
DELETE FROM ticketParking WHERE created < vDateShort;
|
DELETE FROM ticketParking WHERE created < vDateShort;
|
||||||
DELETE FROM routesMonitor WHERE dated < vDateShort;
|
DELETE FROM routesMonitor WHERE dated < vDateShort;
|
||||||
DELETE FROM workerTimeControlLog WHERE created < vDateShort;
|
DELETE FROM workerTimeControlLog WHERE created < vDateShort;
|
||||||
|
|
|
@ -8,6 +8,7 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vTaxRowLimit INT;
|
DECLARE vTaxRowLimit INT;
|
||||||
DECLARE vLines INT;
|
DECLARE vLines INT;
|
||||||
|
DECLARE vHasDistinctTransactions INT;
|
||||||
|
|
||||||
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
|
SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig;
|
||||||
|
|
||||||
|
@ -18,6 +19,18 @@ BEGIN
|
||||||
|
|
||||||
IF vLines >= vTaxRowLimit THEN
|
IF vLines >= vTaxRowLimit THEN
|
||||||
CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit));
|
CALL util.throw (CONCAT('The maximum number of lines is ', vTaxRowLimit));
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions
|
||||||
|
FROM invoiceIn ii
|
||||||
|
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
|
||||||
|
JOIN invoiceInSerial iis ON iis.code = ii.serial
|
||||||
|
WHERE ii.id = vInvoiceInFk
|
||||||
|
AND iis.taxAreaFk = 'CEE'
|
||||||
|
AND transactionTypeSageFk;
|
||||||
|
|
||||||
|
IF vHasDistinctTransactions > 1 THEN
|
||||||
|
CALL util.throw ('This invoice does not allow different types of transactions');
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemProposal_Add`(vSaleFk INT, vMateFk INT, vQuantity INT)
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Añade un nuevo articulo para sustituir a otro, y actualiza la memoria de sustituciones.
|
|
||||||
*
|
|
||||||
* @param vSaleFk id de la tabla sale
|
|
||||||
* @param vMateFk articulo sustituto
|
|
||||||
* @ param vQuantity cantidad que se va a sustituir
|
|
||||||
*/
|
|
||||||
DECLARE vTicketFk INT;
|
|
||||||
DECLARE vItemFk INT;
|
|
||||||
DECLARE vWarehouseFk SMALLINT;
|
|
||||||
DECLARE vDate DATE;
|
|
||||||
DECLARE vGrouping INT;
|
|
||||||
DECLARE vBox INT;
|
|
||||||
DECLARE vPacking INT;
|
|
||||||
DECLARE vRoundQuantity INT DEFAULT 1;
|
|
||||||
|
|
||||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
||||||
BEGIN
|
|
||||||
ROLLBACK;
|
|
||||||
RESIGNAL;
|
|
||||||
END;
|
|
||||||
|
|
||||||
SELECT s.ticketFk, LEAST(s.quantity, vQuantity), s.itemFk,t.shipped,t.warehouseFk
|
|
||||||
INTO vTicketFk, vQuantity, vItemFk,vDate,vWarehouseFk
|
|
||||||
FROM sale s
|
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
|
||||||
WHERE s.id = vSaleFk;
|
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vDate);
|
|
||||||
|
|
||||||
SELECT `grouping`, groupingMode, packing INTO vGrouping, vBox, vPacking
|
|
||||||
FROM buy b
|
|
||||||
JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk
|
|
||||||
WHERE tmp.itemFk = vMateFk AND tmp.WarehouseFk = vWarehouseFk;
|
|
||||||
|
|
||||||
IF vBox = 2 AND vPacking > 0 THEN
|
|
||||||
SET vRoundQuantity = vPacking;
|
|
||||||
END IF;
|
|
||||||
IF vBox = 1 AND vGrouping > 0 THEN
|
|
||||||
SET vRoundQuantity = vGrouping;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
START TRANSACTION;
|
|
||||||
|
|
||||||
UPDATE sale
|
|
||||||
SET quantity = quantity - vQuantity
|
|
||||||
WHERE id = vSaleFk;
|
|
||||||
|
|
||||||
INSERT INTO sale(ticketFk, itemFk, quantity, concept)
|
|
||||||
SELECT vTicketFk,
|
|
||||||
vMateFk,
|
|
||||||
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity,
|
|
||||||
CONCAT('+ ',i.longName)
|
|
||||||
FROM item i
|
|
||||||
WHERE id = vMateFk;
|
|
||||||
|
|
||||||
SELECT LAST_INSERT_ID() INTO vSaleFk;
|
|
||||||
|
|
||||||
CALL sale_calculateComponent(vSaleFk, NULL);
|
|
||||||
|
|
||||||
INSERT INTO itemProposal(itemFk, mateFk, counter)
|
|
||||||
VALUES(vItemFk, vMateFk, 1)
|
|
||||||
ON DUPLICATE KEY UPDATE counter = counter + 1;
|
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -19,6 +19,10 @@ BEGIN
|
||||||
DECLARE vItemFk INT;
|
DECLARE vItemFk INT;
|
||||||
|
|
||||||
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
SELECT barcodeToItem(vBarcode) INTO vItemFk;
|
||||||
|
|
||||||
|
SET vPacking = COALESCE(vPacking, GREATEST(vn.itemPacking(vBarcode,vWarehouseFk), 1));
|
||||||
|
|
||||||
|
SET vQuantity = vQuantity * vPacking;
|
||||||
|
|
||||||
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
|
IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ BEGIN
|
||||||
|
|
||||||
CALL productionControl(vWarehouseFk, 0);
|
CALL productionControl(vWarehouseFk, 0);
|
||||||
|
|
||||||
-- Products with vn.item.isBoxPickingMode = TRUE, pay atention to vn.itemShelving.packing
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
(saleFk INT PRIMARY KEY)
|
(saleFk INT PRIMARY KEY)
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -29,7 +28,7 @@ BEGIN
|
||||||
MAKETIME(pb.HH,pb.mm,0) etd,
|
MAKETIME(pb.HH,pb.mm,0) etd,
|
||||||
pb.routeFk,
|
pb.routeFk,
|
||||||
FLOOR(s.quantity / ish.packing) stickers,
|
FLOOR(s.quantity / ish.packing) stickers,
|
||||||
ish.packing,
|
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
|
||||||
b.packagingFk
|
b.packagingFk
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
|
@ -52,8 +51,8 @@ BEGIN
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
||||||
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
|
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
|
||||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||||
WHERE s.quantity BETWEEN ish.packing AND (ish.visible - IFNULL(tISS.reserve,0))
|
WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut)
|
||||||
AND i.isBoxPickingMode
|
<= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0))
|
||||||
AND NOT pb.problem
|
AND NOT pb.problem
|
||||||
AND sgd.saleFk IS NULL
|
AND sgd.saleFk IS NULL
|
||||||
AND p.sectorFk = vSectorFk
|
AND p.sectorFk = vSectorFk
|
||||||
|
@ -64,47 +63,13 @@ BEGIN
|
||||||
GROUP BY s.id
|
GROUP BY s.id
|
||||||
ORDER BY etd;
|
ORDER BY etd;
|
||||||
|
|
||||||
-- Remaining products, vn.item.packingOut
|
SELECT *
|
||||||
INSERT IGNORE INTO tmp.sale
|
FROM tmp.sale
|
||||||
SELECT
|
WHERE stickers;
|
||||||
s.ticketFk,
|
|
||||||
s.id saleFk,
|
|
||||||
s.itemFk,
|
|
||||||
s.concept,
|
|
||||||
s.quantity,
|
|
||||||
MAKETIME(pb.HH,pb.mm,0) etd,
|
|
||||||
pb.routeFk,
|
|
||||||
s.quantity / i.packingOut stickers,
|
|
||||||
i.packingOut,
|
|
||||||
pc.defaultBigPackageFk
|
|
||||||
FROM sale s
|
|
||||||
JOIN item i ON i.id = s.itemFk
|
|
||||||
JOIN itemShelving ish ON ish.itemFk = s.itemFk
|
|
||||||
JOIN shelving sh ON sh.code = ish.shelvingFk
|
|
||||||
JOIN parking p ON p.id = sh.parkingFk
|
|
||||||
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
|
|
||||||
JOIN agencyMode am ON am.id = pb.agencyModeFk
|
|
||||||
JOIN packagingConfig pc
|
|
||||||
LEFT JOIN routesMonitor rm ON rm.routeFk = pb.routeFk
|
|
||||||
LEFT JOIN itemShelvingStock iss ON iss.itemFk = s.itemFk AND iss.sectorFk = p.sectorFk
|
|
||||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
|
|
||||||
WHERE s.quantity >= i.packingOut
|
|
||||||
AND NOT pb.problem
|
|
||||||
AND s.quantity > 0
|
|
||||||
AND sgd.saleFk IS NULL
|
|
||||||
AND p.sectorFk = vSectorFk
|
|
||||||
AND ts.isPreviousPreparable
|
|
||||||
AND iss.visible >= s.quantity
|
|
||||||
AND ((rm.bufferFk AND rm.isPickingAllowed)
|
|
||||||
OR am.code = 'REC_ALG')
|
|
||||||
AND pb.shipped = vDated
|
|
||||||
GROUP BY s.id
|
|
||||||
ORDER BY etd;
|
|
||||||
|
|
||||||
SELECT * FROM tmp.sale;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.productionBuffer;
|
DROP TEMPORARY TABLE tmp.productionBuffer;
|
||||||
DROP TEMPORARY TABLE tmp.sale;
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
|
CALL `vn`.`sale_getBoxPickingList`(1, curdate());
|
|
@ -8,6 +8,25 @@ BEGIN
|
||||||
* @param vSaleGroupFk Identificador de vn.saleGroup
|
* @param vSaleGroupFk Identificador de vn.saleGroup
|
||||||
* @param vSectorCollectionFk Identificador de vn.sectorCollection
|
* @param vSectorCollectionFk Identificador de vn.sectorCollection
|
||||||
*/
|
*/
|
||||||
|
DECLARE vHasSaleGroup INT;
|
||||||
|
DECLARE vHasSectorCollection INT;
|
||||||
|
|
||||||
|
SELECT COUNT(id) INTO vHasSaleGroup
|
||||||
|
FROM saleGroup
|
||||||
|
WHERE id = vSaleGroupFk;
|
||||||
|
|
||||||
|
IF !vHasSaleGroup THEN
|
||||||
|
CALL util.throw ("invalid saleGroup");
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(id) INTO vHasSectorCollection
|
||||||
|
FROM sectorCollection
|
||||||
|
WHERE id = vSectorCollectionFk;
|
||||||
|
|
||||||
|
IF !vHasSectorCollection THEN
|
||||||
|
CALL util.throw ("invalid sectorCollection");
|
||||||
|
END IF;
|
||||||
|
|
||||||
REPLACE sectorCollectionSaleGroup
|
REPLACE sectorCollectionSaleGroup
|
||||||
SET sectorCollectionFk = vSectorCollectionFk,
|
SET sectorCollectionFk = vSectorCollectionFk,
|
||||||
saleGroupFk = vSaleGroupFk;
|
saleGroupFk = vSaleGroupFk;
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sector_get`()
|
|
||||||
BEGIN
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtiene los sectores
|
|
||||||
*/
|
|
||||||
|
|
||||||
SELECT s.id,s.description,s.warehouseFk
|
|
||||||
FROM vn.sector s;
|
|
||||||
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -9,6 +9,8 @@ BEGIN
|
||||||
* @return tmp.ticketAmount (ticketFk, taxableBase, tax, code)
|
* @return tmp.ticketAmount (ticketFk, taxableBase, tax, code)
|
||||||
* @return tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) Impuesto desglosado para cada ticket.
|
* @return tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code) Impuesto desglosado para cada ticket.
|
||||||
*/
|
*/
|
||||||
|
-- Mantengo el drop porque si no da error en los tests de back de salix
|
||||||
|
-- Table 'addressCompany' was locked with a READ lock and can't be updated'
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
|
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
|
||||||
CREATE TEMPORARY TABLE tmp.addressCompany
|
CREATE TEMPORARY TABLE tmp.addressCompany
|
||||||
(INDEX (addressFk, companyFk))
|
(INDEX (addressFk, companyFk))
|
||||||
|
@ -17,24 +19,24 @@ BEGIN
|
||||||
FROM tmp.ticket tmpTicket
|
FROM tmp.ticket tmpTicket
|
||||||
JOIN ticket t ON t.id = tmpTicket.ticketFk;
|
JOIN ticket t ON t.id = tmpTicket.ticketFk;
|
||||||
|
|
||||||
CALL addressTaxArea ();
|
CALL addressTaxArea();
|
||||||
|
|
||||||
IF vTaxArea IS NOT NULL THEN
|
IF vTaxArea IS NOT NULL THEN
|
||||||
UPDATE tmp.addressTaxArea
|
UPDATE tmp.addressTaxArea
|
||||||
SET areaFk = vTaxArea;
|
SET areaFk = vTaxArea;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
/* Solo se calcula la base imponible (taxableBase) y el impuesto se calculará posteriormente
|
-- Solo se calcula la base imponible (taxableBase) y
|
||||||
* No se debería cambiar el sistema por problemas con los decimales
|
-- el impuesto se calculará posteriormente
|
||||||
*/
|
-- No se debería cambiar el sistema por problemas con los decimales
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketTax;
|
|
||||||
CREATE TEMPORARY TABLE tmp.ticketTax
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketTax
|
||||||
(PRIMARY KEY (ticketFk, code, rate))
|
(PRIMARY KEY (ticketFk, code, rate))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT * FROM (
|
SELECT * FROM (
|
||||||
SELECT tmpTicket.ticketFk,
|
SELECT tmpTicket.ticketFk,
|
||||||
bp.pgcFk,
|
bp.pgcFk,
|
||||||
SUM(s.quantity * s.price * (100 - s.discount)/100 ) taxableBase,
|
SUM(s.quantity * s.price * (100 - s.discount) / 100 ) taxableBase,
|
||||||
pgc.rate,
|
pgc.rate,
|
||||||
tc.code,
|
tc.code,
|
||||||
bp.priority
|
bp.priority
|
||||||
|
@ -43,22 +45,21 @@ BEGIN
|
||||||
JOIN item i ON i.id = s.itemFk
|
JOIN item i ON i.id = s.itemFk
|
||||||
JOIN ticket t ON t.id = tmpTicket.ticketFk
|
JOIN ticket t ON t.id = tmpTicket.ticketFk
|
||||||
JOIN supplier su ON su.id = t.companyFk
|
JOIN supplier su ON su.id = t.companyFk
|
||||||
JOIN tmp.addressTaxArea ata
|
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
|
||||||
ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
|
AND ata.companyFk = t.companyFk
|
||||||
JOIN itemTaxCountry itc
|
JOIN itemTaxCountry itc ON itc.itemFk = i.id
|
||||||
ON itc.itemFk = i.id AND itc.countryFk = su.countryFk
|
AND itc.countryFk = su.countryFk
|
||||||
JOIN bookingPlanner bp
|
JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
|
||||||
ON bp.countryFk = su.countryFk
|
AND bp.taxAreaFk = ata.areaFk
|
||||||
AND bp.taxAreaFk = ata.areaFk
|
AND bp.taxClassFk = itc.taxClassFk
|
||||||
AND bp.taxClassFk = itc.taxClassFk
|
|
||||||
JOIN pgc ON pgc.code = bp.pgcFk
|
JOIN pgc ON pgc.code = bp.pgcFk
|
||||||
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
||||||
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
|
GROUP BY tmpTicket.ticketFk, pgc.code, pgc.rate
|
||||||
HAVING taxableBase <> 0) t3
|
HAVING taxableBase
|
||||||
|
) t3
|
||||||
ORDER BY priority;
|
ORDER BY priority;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketServiceTax;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketServiceTax
|
||||||
CREATE TEMPORARY TABLE tmp.ticketServiceTax
|
|
||||||
(PRIMARY KEY (ticketFk, code, rate))
|
(PRIMARY KEY (ticketFk, code, rate))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT tt.ticketFk,
|
SELECT tt.ticketFk,
|
||||||
|
@ -70,24 +71,22 @@ BEGIN
|
||||||
JOIN ticketService ts ON ts.ticketFk = tt.ticketFk
|
JOIN ticketService ts ON ts.ticketFk = tt.ticketFk
|
||||||
JOIN ticket t ON t.id = tt.ticketFk
|
JOIN ticket t ON t.id = tt.ticketFk
|
||||||
JOIN supplier su ON su.id = t.companyFk
|
JOIN supplier su ON su.id = t.companyFk
|
||||||
JOIN tmp.addressTaxArea ata
|
JOIN tmp.addressTaxArea ata ON ata.addressFk = t.addressFk
|
||||||
ON ata.addressFk = t.addressFk AND ata.companyFk = t.companyFk
|
AND ata.companyFk = t.companyFk
|
||||||
JOIN bookingPlanner bp
|
JOIN bookingPlanner bp ON bp.countryFk = su.countryFk
|
||||||
ON bp.countryFk = su.countryFk
|
AND bp.taxAreaFk = ata.areaFk
|
||||||
AND bp.taxAreaFk = ata.areaFk
|
AND bp.taxClassFk = ts.taxClassFk
|
||||||
AND bp.taxClassFk = ts.taxClassFk
|
|
||||||
JOIN pgc ON pgc.code = bp.pgcFk
|
JOIN pgc ON pgc.code = bp.pgcFk
|
||||||
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
JOIN taxClass tc ON tc.id = bp.taxClassFk
|
||||||
GROUP BY tt.ticketFk, pgc.code
|
GROUP BY tt.ticketFk, pgc.code
|
||||||
HAVING taxableBase <> 0;
|
HAVING taxableBase;
|
||||||
|
|
||||||
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code)
|
INSERT INTO tmp.ticketTax (ticketFk, pgcFk, taxableBase, rate, code)
|
||||||
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code
|
SELECT ts.ticketFk, ts.pgcFk, ts.taxableBase, ts.rate, ts.code
|
||||||
FROM tmp.ticketServiceTax ts
|
FROM tmp.ticketServiceTax ts
|
||||||
ON DUPLICATE KEY UPDATE ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase ;
|
ON DUPLICATE KEY UPDATE ticketTax.taxableBase = VALUES (taxableBase) + ticketTax.taxableBase ;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketAmount;
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketAmount
|
||||||
CREATE TEMPORARY TABLE tmp.ticketAmount
|
|
||||||
(INDEX (ticketFk))
|
(INDEX (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT ticketFk,
|
SELECT ticketFk,
|
||||||
|
@ -97,7 +96,8 @@ BEGIN
|
||||||
FROM tmp.ticketTax
|
FROM tmp.ticketTax
|
||||||
GROUP BY ticketFk, code;
|
GROUP BY ticketFk, code;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.addressCompany;
|
DROP TEMPORARY TABLE
|
||||||
DROP TEMPORARY TABLE tmp.addressTaxArea;
|
tmp.addressCompany,
|
||||||
|
tmp.addressTaxArea;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`saleLabel_afterUpdate`
|
||||||
|
AFTER UPDATE ON `vn`.`saleLabel`
|
||||||
|
FOR EACH ROW
|
||||||
|
IF NEW.stem >= (SELECT s.quantity FROM sale s WHERE s.id = NEW.saleFk) THEN
|
||||||
|
UPDATE sale s SET s.isPicked = TRUE WHERE s.id = NEW.saleFk;
|
||||||
|
END IF$$
|
||||||
|
DELIMITER ;
|
|
@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_beforeUpdate`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vNewTime TIME;
|
DECLARE vNewTime TIME;
|
||||||
DECLARE vHasTicketRefund BOOL;
|
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
|
@ -64,14 +63,5 @@ BEGIN
|
||||||
|
|
||||||
CALL vn.routeUpdateM3(NEW.routeFk);
|
CALL vn.routeUpdateM3(NEW.routeFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vHasTicketRefund
|
|
||||||
FROM ticketRefund
|
|
||||||
WHERE originalTicketFk = NEW.id
|
|
||||||
OR refundTicketFk = NEW.id;
|
|
||||||
|
|
||||||
IF vHasTicketRefund AND NEW.clientFk <> OLD.clientFk THEN
|
|
||||||
CALL util.throw('The ticket has a refund associated');
|
|
||||||
END IF;
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn`.`exchangeInsuranceInPrevious`
|
|
||||||
AS SELECT `ei`.`finished` AS `dated`,
|
|
||||||
`ei`.`amount` AS `amount`,
|
|
||||||
`ei`.`rate` AS `rate`
|
|
||||||
FROM `vn`.`exchangeInsurance` `ei`
|
|
||||||
WHERE `ei`.`amount` <> 0
|
|
||||||
AND `ei`.`financialProductTypefk` = 'SC'
|
|
|
@ -1,6 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn`.`unaryScanLineBuy`
|
|
||||||
AS SELECT `u`.`scan_line_id` AS `unaryScanLineFk`,
|
|
||||||
`u`.`Id_Article` AS `itemFk`
|
|
||||||
FROM `vn2008`.`unary_scan_line_buy` `u`
|
|
|
@ -1,6 +0,0 @@
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
|
||||||
SQL SECURITY DEFINER
|
|
||||||
VIEW `vn`.`unaryScanLineExpedition`
|
|
||||||
AS SELECT `u`.`scan_line_id` AS `unaryScanLineFk`,
|
|
||||||
`u`.`expedition_id` AS `expeditionFk`
|
|
||||||
FROM `vn2008`.`unary_scan_line_expedition` `u`
|
|
|
@ -45,7 +45,6 @@ proc: BEGIN
|
||||||
DELETE FROM cl_main WHERE Fecha < vDate18;
|
DELETE FROM cl_main WHERE Fecha < vDate18;
|
||||||
DELETE FROM hedera.`order` WHERE date_send < vDate18;
|
DELETE FROM hedera.`order` WHERE date_send < vDate18;
|
||||||
DELETE FROM vn.message WHERE sendDate < vDate;
|
DELETE FROM vn.message WHERE sendDate < vDate;
|
||||||
DELETE FROM travel_reserve WHERE odbc_date < vDate;
|
|
||||||
|
|
||||||
DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH;
|
DELETE FROM cache.departure_limit WHERE Fecha < util.VN_CURDATE() - INTERVAL 1 MONTH;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`movement_label_afterUpdate`
|
|
||||||
AFTER UPDATE ON `movement_label`
|
|
||||||
FOR EACH ROW
|
|
||||||
IF NEW.stem >= (SELECT Cantidad FROM Movimientos WHERE Id_Movimiento = NEW.Id_Movimiento) THEN
|
|
||||||
UPDATE Movimientos SET OK = 1 WHERE Id_Movimiento = NEW.Id_Movimiento;
|
|
||||||
END IF$$
|
|
||||||
DELIMITER ;
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`financialProductType`AS
|
||||||
|
SELECT * FROM vn.financialProductType;
|
|
@ -0,0 +1,13 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`flight`
|
||||||
|
AS SELECT
|
||||||
|
`f`.`id` AS `flight_id`,
|
||||||
|
`f`.`duration` AS `duration`,
|
||||||
|
`f`.`flightPath` AS `route`,
|
||||||
|
`f`.`days` AS `days`,
|
||||||
|
`f`.`airlineFk` AS `airline_id`,
|
||||||
|
`f`.`airportArrivalFk` AS `airport_out`,
|
||||||
|
`f`.`airportDepartureFk` AS `airport_in`
|
||||||
|
FROM
|
||||||
|
`vn`.`flight` `f`;
|
|
@ -0,0 +1,11 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`gastos_resumen`
|
||||||
|
AS SELECT
|
||||||
|
`es`.`expenseFk` AS `Id_Gasto`,
|
||||||
|
`es`.`year` AS `year`,
|
||||||
|
`es`.`month` AS `month`,
|
||||||
|
`es`.`amount` AS `importe`,
|
||||||
|
`es`.`companyFk` AS `empresa_id`
|
||||||
|
FROM
|
||||||
|
`vn`.`expenseManual` `es`;
|
|
@ -0,0 +1,9 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`integra2`
|
||||||
|
AS SELECT
|
||||||
|
`i2`.`postCode` AS `postal_code`,
|
||||||
|
`i2`.`frequency` AS `frequency`,
|
||||||
|
`i2`.`warehouseFk` AS `warehouse_id`
|
||||||
|
FROM
|
||||||
|
`vn`.`integra2` `i2`;
|
|
@ -0,0 +1,8 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`integra2_province`
|
||||||
|
AS SELECT
|
||||||
|
`ip`.`provinceFk` AS `province_id`,
|
||||||
|
`ip`.`franchise` AS `franquicia`
|
||||||
|
FROM
|
||||||
|
`vn`.`integra2Province` `ip`;
|
|
@ -0,0 +1,16 @@
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`pago_sdc`
|
||||||
|
AS SELECT `ei`.`id` AS `pago_sdc_id`,
|
||||||
|
`ei`.`amount` AS `importe`,
|
||||||
|
`ei`.`dated` AS `fecha`,
|
||||||
|
`ei`.`dueDated` AS `vencimiento`,
|
||||||
|
`ei`.`entityFk` AS `entity_id`,
|
||||||
|
`ei`.`ref` AS `ref`,
|
||||||
|
`ei`.`rate` AS `rate`,
|
||||||
|
`ei`.`companyFk` AS `empresa_id`,
|
||||||
|
`ei`.`financialProductTypefk` AS `financialProductTypefk`,
|
||||||
|
`ei`.`upperBarrier` AS `upperBarrier`,
|
||||||
|
`ei`.`lowerBarrier` AS `lowerBarrier`,
|
||||||
|
`ei`.`strike` AS `strike`
|
||||||
|
FROM `vn`.`exchangeInsurance` `ei`
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`warehouse_pickup`
|
||||||
|
AS SELECT
|
||||||
|
`wp`.`warehouseFk` AS `warehouse_id`,
|
||||||
|
`wp`.`agencyModeFk` AS `agency_id`
|
||||||
|
FROM
|
||||||
|
`vn`.`warehousePickup` `wp`;
|
|
@ -0,0 +1,3 @@
|
||||||
|
USE vn;
|
||||||
|
ALTER TABLE vn.agencyTermConfig
|
||||||
|
ADD CONSTRAINT agencyTermConfig_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,11 @@
|
||||||
|
USE vn;
|
||||||
|
|
||||||
|
ALTER TABLE vn2008.gastos_resumen MODIFY COLUMN Id_Gasto varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
||||||
|
|
||||||
|
DELETE gr.*
|
||||||
|
FROM vn2008.gastos_resumen gr LEFT JOIN vn.expense e ON gr.Id_Gasto = e.id
|
||||||
|
WHERE e.id IS NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn2008.gastos_resumen
|
||||||
|
ADD CONSTRAINT gastos_resumen_expense_FK
|
||||||
|
FOREIGN KEY (Id_Gasto) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,5 @@
|
||||||
|
USE vn;
|
||||||
|
ALTER TABLE vn.invoiceOutTaxConfig MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.invoiceOutTaxConfig
|
||||||
|
ADD CONSTRAINT invoiceOutTaxConfig_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,5 @@
|
||||||
|
USE edi;
|
||||||
|
ALTER TABLE edi.item_groupToOffer MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '7001000000' NULL;
|
||||||
|
|
||||||
|
ALTER TABLE edi.item_groupToOffer
|
||||||
|
ADD CONSTRAINT item_groupToOffer_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,14 @@
|
||||||
|
USE vn;
|
||||||
|
-- Eliminar la clave primaria actual
|
||||||
|
ALTER TABLE bs.ventas_contables DROP PRIMARY KEY;
|
||||||
|
|
||||||
|
-- Agregar la nueva clave primaria incluyendo el campo `gasto`
|
||||||
|
ALTER TABLE bs.ventas_contables ADD PRIMARY KEY (`year`, `month`, `grupo`, `reino_id`, `tipo_id`, `empresa_id`, `gasto`);
|
||||||
|
|
||||||
|
DELETE vc.* FROM bs.ventas_contables vc LEFT JOIN vn.expense e ON e.id = vc.gasto WHERE e.id IS NULL;
|
||||||
|
|
||||||
|
ALTER TABLE bs.ventas_contables
|
||||||
|
MODIFY COLUMN gasto VARCHAR(10)
|
||||||
|
CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE bs.ventas_contables ADD CONSTRAINT ventas_contables_expense_FK FOREIGN KEY (gasto) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DELETE FROM vn.expense
|
||||||
|
WHERE id ='' AND id IS NULL AND isWithheld = FALSE;
|
||||||
|
UPDATE vn.expense
|
||||||
|
SET id='7002090000'
|
||||||
|
WHERE id='7002009000';
|
||||||
|
UPDATE vn.expense
|
||||||
|
SET id='7001090000'
|
||||||
|
WHERE id='7001009000';
|
|
@ -0,0 +1,44 @@
|
||||||
|
UPDATE vn.expense
|
||||||
|
SET id = CASE id
|
||||||
|
WHEN 7000010000 THEN 7001001000
|
||||||
|
WHEN 7000020000 THEN 7001002000
|
||||||
|
WHEN 7000030000 THEN 7001003000
|
||||||
|
WHEN 7000040000 THEN 7001004000
|
||||||
|
WHEN 7000050000 THEN 7001005000
|
||||||
|
WHEN 7000060000 THEN 7001006000
|
||||||
|
WHEN 7000070000 THEN 7001007000
|
||||||
|
WHEN 7002060000 THEN 7001206000
|
||||||
|
WHEN 7002070000 THEN 7001207000
|
||||||
|
WHEN 7002030000 THEN 7001203000
|
||||||
|
WHEN 7002040000 THEN 7001204000
|
||||||
|
WHEN 7002050000 THEN 7001205000
|
||||||
|
WHEN 7002020000 THEN 7001202000
|
||||||
|
WHEN 7002010000 THEN 7001201000
|
||||||
|
WHEN 7001060000 THEN 7001106000
|
||||||
|
WHEN 7001070000 THEN 7001107000
|
||||||
|
WHEN 7001030000 THEN 7001103000
|
||||||
|
WHEN 7001040000 THEN 7001104000
|
||||||
|
WHEN 7001050000 THEN 7001105000
|
||||||
|
WHEN 7001020000 THEN 7001102000
|
||||||
|
WHEN 7001010000 THEN 7001101000
|
||||||
|
WHEN 7000080000 THEN 7040008000
|
||||||
|
WHEN 7001080000 THEN 7000108000
|
||||||
|
WHEN 7002080000 THEN 7001208000
|
||||||
|
WHEN 7000090000 THEN 7001009000
|
||||||
|
WHEN 7002090000 THEN 7001209000
|
||||||
|
WHEN 7002100000 THEN 7001210000
|
||||||
|
WHEN 7001090000 THEN 7001109000
|
||||||
|
WHEN 7001100000 THEN 7001110000
|
||||||
|
WHEN 7000120000 THEN 7001012000
|
||||||
|
WHEN 7002120000 THEN 7001212000
|
||||||
|
WHEN 7000130000 THEN 7001013000
|
||||||
|
WHEN 7000140000 THEN 7001014000
|
||||||
|
ELSE id
|
||||||
|
END
|
||||||
|
WHERE id IN (7000010000, 7000020000, 7000030000, 7000040000, 7000050000,
|
||||||
|
7000060000, 7000070000, 7002060000, 7002070000, 7002030000,
|
||||||
|
7002040000, 7002050000, 7002020000, 7002010000, 7001060000,
|
||||||
|
7001070000, 7001030000, 7001040000, 7001050000, 7001020000,
|
||||||
|
7001010000, 7000080000, 7001080000, 7002080000, 7000090000,
|
||||||
|
7002090000, 7002100000, 7001090000, 7001100000,
|
||||||
|
7000120000, 7002120000, 7000130000, 7000140000);
|
|
@ -0,0 +1,6 @@
|
||||||
|
UPDATE vn.expense
|
||||||
|
SET id = CASE id
|
||||||
|
WHEN 7000100000 THEN 7001010000
|
||||||
|
ELSE id
|
||||||
|
END
|
||||||
|
WHERE id IN (7000100000);
|
|
@ -0,0 +1,37 @@
|
||||||
|
REVOKE UPDATE ON vn.ticket FROM employee;
|
||||||
|
|
||||||
|
GRANT UPDATE (id,
|
||||||
|
warehouseFk,
|
||||||
|
shipped,
|
||||||
|
nickname,
|
||||||
|
refFk,
|
||||||
|
addressFk,
|
||||||
|
workerFk,
|
||||||
|
observations,
|
||||||
|
isSigned,
|
||||||
|
isLabeled,
|
||||||
|
isPrinted,
|
||||||
|
packages,
|
||||||
|
location,
|
||||||
|
hour,
|
||||||
|
created,
|
||||||
|
isBlocked,
|
||||||
|
solution,
|
||||||
|
routeFk,
|
||||||
|
priority,
|
||||||
|
hasPriority,
|
||||||
|
companyFk,
|
||||||
|
agencyModeFk,
|
||||||
|
landed,
|
||||||
|
isBoxed,
|
||||||
|
isDeleted,
|
||||||
|
zoneFk,
|
||||||
|
zonePrice,
|
||||||
|
zoneBonus,
|
||||||
|
totalWithVat,
|
||||||
|
totalWithoutVat,
|
||||||
|
weight,
|
||||||
|
clonedFrom,
|
||||||
|
cmrFk,
|
||||||
|
editorFk)
|
||||||
|
ON vn.ticket TO employee;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`financialProductType` RENAME `vn`.`financialProductType`;
|
|
@ -0,0 +1,8 @@
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`flight` RENAME `vn`.`flight`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`flight`
|
||||||
|
CHANGE COLUMN IF EXISTS `flight_id` `id` varchar(10) NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `airline_id` `airlineFk` smallint(2) unsigned DEFAULT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `route` `flightPath` varchar(20) DEFAULT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `airport_out` `airportArrivalFk` varchar(3) NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `airport_in` `airportDepartureFk` varchar(3) NOT NULL;
|
|
@ -0,0 +1,24 @@
|
||||||
|
ALTER TABLE IF EXISTS vn2008.gastos_resumen DROP FOREIGN KEY IF EXISTS gastos_resumen_expense_FK;
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`gastos_resumen` RENAME `vn`.`expenseManual`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`expenseManual`
|
||||||
|
CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) DEFAULT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `empresa_id` `companyFk` int(11) NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.expenseManual COLLATE=utf8mb3_general_ci;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.expenseManual MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.expenseManual ADD CONSTRAINT expenseManual_expense_FK FOREIGN KEY IF NOT EXISTS (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.expenseManual MODIFY COLUMN IF EXISTS companyFk int(10) unsigned NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE vn.expenseManual MODIFY COLUMN companyFk int(10) unsigned NULL;
|
||||||
|
|
||||||
|
UPDATE vn.expenseManual
|
||||||
|
SET companyFK= NULL
|
||||||
|
WHERE companyFk= 0;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.expenseManual ADD CONSTRAINT expenseManual_company_FK FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`integra2` RENAME `vn`.`integra2`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`integra2`
|
||||||
|
CHANGE COLUMN IF EXISTS `postal_code` `postCode` varchar(10) NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `frequency` `frequency` decimal(10,2) DEFAULT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `warehouse_id` `warehouseFk` smallint(6) unsigned NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn.integra2 ADD CONSTRAINT integra2_warehouse_FK
|
||||||
|
FOREIGN KEY (warehouseFk) REFERENCES vn.warehouse(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`integra2_province` RENAME `vn`.`integra2Province`;
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`integra2Province`
|
||||||
|
CHANGE COLUMN IF EXISTS `franquicia` `franchise` varchar(65) NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `province_id` `provinceFk` smallint(6) unsigned NOT NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.intervalos__;
|
|
@ -0,0 +1 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.mail_templates__;
|
|
@ -0,0 +1 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.ticket_location__;
|
|
@ -0,0 +1 @@
|
||||||
|
DROP TABLE IF EXISTS vn2008.turn__;
|
|
@ -0,0 +1,8 @@
|
||||||
|
DROP TRIGGER IF EXISTS `vn2008`.`movement_label_afterUpdate`;
|
||||||
|
|
||||||
|
DROP VIEW IF EXISTS `vn`.`saleLabel`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`movement_label` RENAME `vn`.`saleLabel`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`saleLabel`
|
||||||
|
CHANGE COLUMN IF EXISTS `Id_movimiento` `saleFk` int(11) NOT NULL;
|
|
@ -0,0 +1,11 @@
|
||||||
|
DROP VIEW IF EXISTS `vn`.`exchangeInsurance`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`pago_sdc` RENAME `vn`.`exchangeInsurance`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`exchangeInsurance`
|
||||||
|
CHANGE COLUMN IF EXISTS `pago_sdc_id` `id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `fecha` `dated` date NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `vencimiento` `dueDated` date NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `entity_id` `entityFk` int(10) unsigned NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `empresa_id` `companyFk`int(10) unsigned NOT NULL DEFAULT 442;
|
|
@ -0,0 +1,7 @@
|
||||||
|
ALTER TABLE IF EXISTS `vn2008`.`warehouse_pickup` RENAME `vn`.`warehousePickup`;
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS `vn`.`warehousePickup`
|
||||||
|
CHANGE COLUMN IF EXISTS `warehouse_id` `warehouseFk` smallint(5) unsigned NOT NULL,
|
||||||
|
CHANGE COLUMN IF EXISTS `agency_id` `agencyModeFk` int(11) DEFAULT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`warehousePickup` COMMENT='Agencia de recogida para cada almacén';
|
|
@ -0,0 +1,155 @@
|
||||||
|
ALTER TABLE IF EXISTS vn2008.template_bionic_component RENAME vn2008.template_bionic_component__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.template_bionic_component__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.template_bionic_lot RENAME vn2008.template_bionic_lot__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.template_bionic_lot__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.template_bionic_price RENAME vn2008.template_bionic_price__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.template_bionic_price__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.tmpNEWTARIFAS RENAME vn2008.tmpNEWTARIFAS__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.tmpNEWTARIFAS__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unaryScanFilter RENAME vn2008.unaryScanFilter__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unaryScanFilter__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_source RENAME vn2008.unary_source__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_source__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.viaxpress RENAME vn2008.viaxpress__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.viaxpress__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_filtro RENAME vn2008.warehouse_filtro__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_filtro__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_group RENAME vn2008.warehouse_group__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_group__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_joined RENAME vn2008.warehouse_joined__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_joined__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_lc RENAME vn2008.warehouse_lc__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.warehouse_lc__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.wh_selection RENAME vn2008.wh_selection__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.wh_selection__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.trolley RENAME vn2008.trolley__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.trolley__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.zones RENAME vn2008.zones__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.zones__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.tblIVA RENAME vn2008.tblIVA__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.tblIVA__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.filtros RENAME vn2008.filtros__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.filtros__ COMMENT='refs #6372 @deprecated 2023-11-21;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.form_query RENAME vn2008.form_query__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.form_query__ COMMENT='refs #6372 @deprecated 2023-11-21;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.guillen RENAME vn2008.guillen__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.guillen__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.guillen_carry RENAME vn2008.guillen_carry__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.guillen_carry__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.integra2_escala RENAME vn2008.integra2_escala__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.integra2_escala__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.invoice_observation RENAME vn2008.invoice_observation__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.invoice_observation__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.nichos RENAME vn2008.nichos__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.nichos__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_bonificaciones RENAME vn2008.payroll_bonificaciones__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_bonificaciones__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_datos RENAME vn2008.payroll_datos__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_datos__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_embargos RENAME vn2008.payroll_embargos__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_embargos__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_tipobasess RENAME vn2008.payroll_tipobasess__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_tipobasess__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.preparation_exception RENAME vn2008.preparation_exception__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.preparation_exception__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payrroll_apEmpresarial RENAME vn2008.payrroll_apEmpresarial__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payrroll_apEmpresarial__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.rec_translator RENAME vn2008.rec_translator__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.rec_translator__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.recibida_agricola RENAME vn2008.recibida_agricola__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.recibida_agricola__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.rounding RENAME vn2008.rounding__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.rounding__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.scanTree RENAME vn2008.scanTree__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.scanTree__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.sort_merge_results_ernesto RENAME vn2008.sort_merge_results_ernesto__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.sort_merge_results_ernesto__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.route RENAME vn2008.route__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.route__ COMMENT='refs #6372 @deprecated 2023-11-28;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.travel_reserve RENAME vn2008.travel_reserve__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.travel_reserve__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.wks RENAME vn2008.wks__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.wks__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary RENAME vn2008.unary__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan RENAME vn2008.unary_scan__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan_line RENAME vn2008.unary_scan_line__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan_line__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan_line_buy RENAME vn2008.unary_scan_line_buy__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan_line_buy__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan_line_expedition RENAME vn2008.unary_scan_line_expedition__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.unary_scan_line_expedition__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.widget RENAME vn2008.widget__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.widget__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.scan RENAME vn2008.scan__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.scan__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.scan_line RENAME vn2008.scan_line__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.scan_line__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.tipsa RENAME vn2008.tipsa__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.tipsa__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_basess RENAME vn2008.payroll_basess__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.payroll_basess__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.pago_sdc RENAME vn2008.pago_sdc__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.pago_sdc__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.transport RENAME vn2008.transport__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.transport__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.travel_pattern RENAME vn2008.travel_pattern__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.travel_pattern__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.jerarquia RENAME vn2008.jerarquia__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.jerarquia__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.language RENAME vn2008.language__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.language__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
||||||
|
|
||||||
|
ALTER TABLE IF EXISTS vn2008.link RENAME vn2008.link__;
|
||||||
|
ALTER TABLE IF EXISTS vn2008.link__ COMMENT='refs #6372 @deprecated 2023-12-13;';
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- flight
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`flight` AS
|
||||||
|
SELECT 1;
|
||||||
|
GRANT SELECT, INSERT, UPDATE ON TABLE vn2008.flight TO `logistic`;
|
||||||
|
GRANT SELECT, INSERT, UPDATE ON TABLE vn.flight TO `logistic`;
|
||||||
|
-- integra2_province
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`integra2_province` AS
|
||||||
|
SELECT 1;
|
||||||
|
GRANT SELECT ON TABLE vn2008.integra2_province TO `employee`;
|
||||||
|
GRANT SELECT ON TABLE vn.integra2Province TO `employee`;
|
||||||
|
-- link
|
||||||
|
|
||||||
|
GRANT SELECT ON TABLE vn.company TO `administrative`;
|
||||||
|
GRANT SELECT ON TABLE vn.company TO `hr`;
|
||||||
|
|
||||||
|
-- warehouse_pickup
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||||
|
SQL SECURITY DEFINER
|
||||||
|
VIEW `vn2008`.`warehouse_pickup` AS
|
||||||
|
SELECT 1;
|
||||||
|
GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `logistic`;
|
||||||
|
GRANT SELECT ON TABLE vn.warehousePickup TO `logistic`;
|
||||||
|
GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `claimManager`;
|
||||||
|
GRANT SELECT ON TABLE vn.warehousePickup TO `claimManager`;
|
||||||
|
GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `employee`;
|
||||||
|
GRANT SELECT ON TABLE vn.warehousePickup TO `employee`;
|
||||||
|
GRANT SELECT ON TABLE vn2008.warehouse_pickup TO `deliveryAssistant`;
|
||||||
|
GRANT SELECT ON TABLE vn.warehousePickup TO `deliveryAssistant`;
|
|
@ -0,0 +1,13 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
CREATE TABLE vn.workerActivity (
|
||||||
|
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||||
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
model ENUM('COM', 'ENT', 'TPV', 'ENC', 'LAB', 'ETI') NOT NULL,
|
||||||
|
workerFk INT(10) UNSIGNED NOT NULL,
|
||||||
|
event ENUM('open', 'close', 'insert', 'delete', 'update', 'refresh') NOT NULL,
|
||||||
|
description VARCHAR(255) DEFAULT NULL,
|
||||||
|
CONSTRAINT fk_workerActivity_worker FOREIGN KEY (workerFk)
|
||||||
|
REFERENCES vn.worker (id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
|
@ -46,23 +46,19 @@ module.exports = Self => {
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.ticket`);
|
|
||||||
|
|
||||||
stmts.push(new ParameterizedSQL(
|
stmts.push(new ParameterizedSQL(
|
||||||
`CREATE TEMPORARY TABLE tmp.ticket
|
`CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
(KEY (ticketFk))
|
(KEY (ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT id ticketFk
|
SELECT id ticketFk
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
WHERE shipped BETWEEN ? AND ?
|
WHERE shipped BETWEEN ? AND util.dayEnd(?)
|
||||||
AND refFk IS NULL`, [args.from, args.to]));
|
AND refFk IS NULL`, [args.from, args.to]));
|
||||||
stmts.push(`CALL vn.ticket_getTax(NULL)`);
|
stmts.push(`CALL vn.ticket_getTax(NULL)`);
|
||||||
stmts.push(`DROP TEMPORARY TABLE IF EXISTS tmp.filter`);
|
|
||||||
stmts.push(new ParameterizedSQL(
|
stmts.push(new ParameterizedSQL(
|
||||||
`CREATE TEMPORARY TABLE tmp.filter
|
`CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT
|
SELECT co.code company,
|
||||||
co.code company,
|
|
||||||
cou.country,
|
cou.country,
|
||||||
c.id clientId,
|
c.id clientId,
|
||||||
c.socialName clientSocialName,
|
c.socialName clientSocialName,
|
||||||
|
@ -75,28 +71,26 @@ module.exports = Self => {
|
||||||
c.isTaxDataChecked,
|
c.isTaxDataChecked,
|
||||||
w.id comercialId,
|
w.id comercialId,
|
||||||
CONCAT(w.firstName, ' ', w.lastName) comercialName
|
CONCAT(w.firstName, ' ', w.lastName) comercialName
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN vn.company co ON co.id = t.companyFk
|
JOIN vn.company co ON co.id = t.companyFk
|
||||||
JOIN vn.sale s ON s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN vn.client c ON c.id = t.clientFk
|
JOIN vn.client c ON c.id = t.clientFk
|
||||||
JOIN vn.country cou ON cou.id = c.countryFk
|
JOIN vn.country cou ON cou.id = c.countryFk
|
||||||
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
LEFT JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||||
JOIN account.user u ON u.id = w.id
|
JOIN account.user u ON u.id = w.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT ticketFk, taxableBase
|
SELECT ticketFk, taxableBase
|
||||||
FROM tmp.ticketAmount
|
FROM tmp.ticketAmount
|
||||||
GROUP BY ticketFk
|
GROUP BY ticketFk
|
||||||
HAVING taxableBase < 0
|
HAVING taxableBase < 0
|
||||||
) negativeBase ON negativeBase.ticketFk = t.id
|
) negativeBase ON negativeBase.ticketFk = t.id
|
||||||
WHERE t.shipped BETWEEN ? AND ?
|
WHERE t.shipped BETWEEN ? AND util.dayEnd(?)
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
AND c.typeFk IN ('normal','trust')
|
AND c.typeFk IN ('normal','trust')
|
||||||
GROUP BY t.clientFk, negativeBase.taxableBase
|
GROUP BY t.clientFk, negativeBase.taxableBase
|
||||||
HAVING amount < 0`, [args.from, args.to]));
|
HAVING amount < 0`, [args.from, args.to]));
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`SELECT * FROM tmp.filter`);
|
||||||
SELECT f.*
|
|
||||||
FROM tmp.filter f`);
|
|
||||||
|
|
||||||
if (args.filter) {
|
if (args.filter) {
|
||||||
stmt.merge(conn.makeWhere(args.filter.where));
|
stmt.merge(conn.makeWhere(args.filter.where));
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
|
describe('ItemShelving upsertItem()', () => {
|
||||||
|
const warehouseFk = 1;
|
||||||
|
let ctx;
|
||||||
|
let options;
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
beforeEach(async() => {
|
||||||
|
ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: ctx.req
|
||||||
|
});
|
||||||
|
|
||||||
|
options = {transaction: tx};
|
||||||
|
tx = await models.ItemShelving.beginTransaction({});
|
||||||
|
options.transaction = tx;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async() => {
|
||||||
|
await tx.rollback();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add two new records', async() => {
|
||||||
|
const shelvingFk = 'ZPP';
|
||||||
|
const items = [1, 1, 1, 2];
|
||||||
|
|
||||||
|
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
|
||||||
|
const itemShelvings = await models.ItemShelving.find({where: {shelvingFk}}, options);
|
||||||
|
|
||||||
|
expect(itemShelvings.length).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the visible items', async() => {
|
||||||
|
const shelvingFk = 'GVC';
|
||||||
|
const items = [2, 2];
|
||||||
|
const {visible: itemsBefore} = await models.ItemShelving.findOne({
|
||||||
|
where: {shelvingFk, itemFk: items[0]}
|
||||||
|
}, options);
|
||||||
|
await models.ItemShelving.upsertItem(ctx, shelvingFk, items, warehouseFk, options);
|
||||||
|
const {visible: itemsAfter} = await models.ItemShelving.findOne({
|
||||||
|
where: {shelvingFk, itemFk: items[0]}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
expect(itemsAfter).toEqual(itemsBefore + 2);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,64 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('upsertItem', {
|
||||||
|
description: 'Add a record or update it if it already exists.',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'shelvingFk',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'items',
|
||||||
|
type: ['number'],
|
||||||
|
required: true,
|
||||||
|
description: 'array of item foreign keys'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arg: 'warehouseFk',
|
||||||
|
type: 'number',
|
||||||
|
required: true
|
||||||
|
}],
|
||||||
|
|
||||||
|
http: {
|
||||||
|
path: `/upsertItem`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.upsertItem = async(ctx, shelvingFk, items, warehouseFk, options) => {
|
||||||
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
const discardItems = new Set();
|
||||||
|
const itemCounts = items.reduce((acc, item) => {
|
||||||
|
acc[item] = (acc[item] || 0) + 1;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (let item of items) {
|
||||||
|
if (!discardItems.has(item)) {
|
||||||
|
let quantity = itemCounts[item];
|
||||||
|
discardItems.add(item);
|
||||||
|
|
||||||
|
await Self.rawSql('CALL vn.itemShelving_add(?, ?, ?, NULL, NULL, NULL, ?)',
|
||||||
|
[shelvingFk, item, quantity, warehouseFk], myOptions
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,4 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
require('../methods/item-shelving/deleteItemShelvings')(Self);
|
||||||
|
require('../methods/item-shelving/upsertItem')(Self);
|
||||||
require('../methods/item-shelving/getInventory')(Self);
|
require('../methods/item-shelving/getInventory')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,49 +1,60 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Ticket transferClient()', () => {
|
describe('Ticket transferClient()', () => {
|
||||||
const userId = 9;
|
const originalTicketId = 8;
|
||||||
const activeCtx = {
|
const refundTicketId = 24;
|
||||||
accessToken: {userId: userId},
|
const clientId = 1;
|
||||||
};
|
let ctx;
|
||||||
const ctx = {req: activeCtx};
|
let options;
|
||||||
|
let tx;
|
||||||
|
beforeEach(async() => {
|
||||||
|
ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
options = {transaction: tx};
|
||||||
|
tx = await models.Ticket.beginTransaction({});
|
||||||
|
options.transaction = tx;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async() => {
|
||||||
|
await tx.rollback();
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw an error as the ticket is not editable', async() => {
|
it('should throw an error as the ticket is not editable', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
|
||||||
let error;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
|
||||||
const ticketId = 4;
|
const ticketId = 4;
|
||||||
const clientId = 1;
|
const clientId = 1;
|
||||||
await models.Ticket.transferClient(ctx, ticketId, clientId, options);
|
await models.Ticket.transferClient(ctx, ticketId, clientId, options);
|
||||||
|
|
||||||
await tx.rollback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await tx.rollback();
|
expect(e.message).toEqual(`This ticket is locked`);
|
||||||
error = e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(error.message).toEqual(`This ticket is locked`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be assigned a different clientFk', async() => {
|
it('should be assigned a different clientFk in the original ticket', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
await models.Ticket.transferClient(ctx, 2, clientId, options);
|
||||||
let updatedTicket;
|
const afterTransfer = await models.Ticket.findById(2, null, options);
|
||||||
const ticketId = 10;
|
|
||||||
const clientId = 1;
|
|
||||||
|
|
||||||
try {
|
expect(afterTransfer.clientFk).toEqual(clientId);
|
||||||
const options = {transaction: tx};
|
});
|
||||||
|
|
||||||
await models.Ticket.transferClient(ctx, ticketId, clientId, options);
|
it('should be assigned a different clientFk in the original and refund ticket and claim', async() => {
|
||||||
updatedTicket = await models.Ticket.findById(ticketId, {fields: ['clientFk']}, options);
|
await models.Ticket.transferClient(ctx, originalTicketId, clientId, options);
|
||||||
|
|
||||||
await tx.rollback();
|
const [originalTicket, refundTicket] = await models.Ticket.find({
|
||||||
} catch (e) {
|
where: {id: {inq: [originalTicketId, refundTicketId]}}
|
||||||
await tx.rollback();
|
}, options);
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(updatedTicket.clientFk).toEqual(clientId);
|
const claim = await models.Claim.findOne({
|
||||||
|
where: {ticketFk: originalTicketId}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
expect(originalTicket.clientFk).toEqual(clientId);
|
||||||
|
expect(refundTicket.clientFk).toEqual(clientId);
|
||||||
|
expect(claim.clientFk).toEqual(clientId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,20 +2,17 @@ module.exports = Self => {
|
||||||
Self.remoteMethodCtx('transferClient', {
|
Self.remoteMethodCtx('transferClient', {
|
||||||
description: 'Transfering ticket to another client',
|
description: 'Transfering ticket to another client',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [{
|
||||||
{
|
arg: 'id',
|
||||||
arg: 'id',
|
type: 'number',
|
||||||
type: 'number',
|
required: true,
|
||||||
required: true,
|
description: 'the ticket id',
|
||||||
description: 'the ticket id',
|
http: {source: 'path'}
|
||||||
http: {source: 'path'}
|
}, {
|
||||||
},
|
arg: 'clientFk',
|
||||||
{
|
type: 'number',
|
||||||
arg: 'clientFk',
|
required: true,
|
||||||
type: 'number',
|
}],
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
http: {
|
http: {
|
||||||
path: `/:id/transferClient`,
|
path: `/:id/transferClient`,
|
||||||
verb: 'PATCH'
|
verb: 'PATCH'
|
||||||
|
@ -25,21 +22,51 @@ module.exports = Self => {
|
||||||
Self.transferClient = async(ctx, id, clientFk, options) => {
|
Self.transferClient = async(ctx, id, clientFk, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
let tx;
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
await Self.isEditableOrThrow(ctx, id, myOptions);
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
const ticket = await models.Ticket.findById(
|
try {
|
||||||
id,
|
await Self.isEditableOrThrow(ctx, id, myOptions);
|
||||||
{fields: ['id', 'shipped', 'clientFk', 'addressFk']},
|
|
||||||
myOptions
|
|
||||||
);
|
|
||||||
const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions);
|
|
||||||
|
|
||||||
await ticket.updateAttributes({
|
const ticketRefund = await models.TicketRefund.findOne({
|
||||||
clientFk,
|
where: {or: [{originalTicketFk: id}, {refundTicketFk: id}]},
|
||||||
addressFk: client.defaultAddressFk,
|
include: [{relation: 'refundTicket'}, {relation: 'originalTicket'}]
|
||||||
});
|
}, myOptions);
|
||||||
|
|
||||||
|
const {defaultAddressFk: addressFk} = await models.Client.findById(clientFk,
|
||||||
|
{fields: ['id', 'defaultAddressFk']}, myOptions);
|
||||||
|
|
||||||
|
const attributes = {clientFk, addressFk};
|
||||||
|
|
||||||
|
const tickets = [];
|
||||||
|
const ticketIds = [];
|
||||||
|
|
||||||
|
if (ticketRefund) {
|
||||||
|
const {refundTicket, originalTicket} = ticketRefund;
|
||||||
|
tickets.push(refundTicket(), originalTicket());
|
||||||
|
|
||||||
|
for (const ticket of tickets) {
|
||||||
|
await ticket.updateAttributes(attributes, myOptions);
|
||||||
|
ticketIds.push(ticket.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await Self.updateAll({id}, attributes, myOptions);
|
||||||
|
ticketIds.push(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
await models.Claim.updateAll({ticketFk: {inq: ticketIds}}, {clientFk}, myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,6 +36,7 @@ describe('Worker new', () => {
|
||||||
payMethodFk: 1,
|
payMethodFk: 1,
|
||||||
roleFk: 1
|
roleFk: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
const req = {accessToken: {userId: 9}};
|
const req = {accessToken: {userId: 9}};
|
||||||
|
|
||||||
it('should return error if personal mail already exists', async() => {
|
it('should return error if personal mail already exists', async() => {
|
||||||
|
@ -140,15 +141,24 @@ describe('Worker new', () => {
|
||||||
it('should create a new worker', async() => {
|
it('should create a new worker', async() => {
|
||||||
const newWorker = await models.Worker.new({args: defaultWorker, req});
|
const newWorker = await models.Worker.new({args: defaultWorker, req});
|
||||||
|
|
||||||
await models.Worker.destroyById(newWorker.id);
|
await removeWorker(newWorker.id);
|
||||||
await models.Address.destroyAll({clientFk: newWorker.id});
|
|
||||||
await models.Mandate.destroyAll({clientFk: newWorker.id});
|
|
||||||
await models.Client.destroyById(newWorker.id);
|
|
||||||
await models.VnUser.destroyById(newWorker.id);
|
|
||||||
|
|
||||||
expect(newWorker.id).toBeDefined();
|
expect(newWorker.id).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should create a new client', async() => {
|
||||||
|
let newWorker;
|
||||||
|
let client;
|
||||||
|
try {
|
||||||
|
newWorker = await models.Worker.new({args: defaultWorker, req});
|
||||||
|
client = await models.Client.findById(newWorker.id);
|
||||||
|
} finally {
|
||||||
|
await removeWorker(newWorker.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(client).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
it('should create a new worker in client', async() => {
|
it('should create a new worker in client', async() => {
|
||||||
const bruceWayneId = 1101;
|
const bruceWayneId = 1101;
|
||||||
const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']});
|
const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']});
|
||||||
|
@ -170,3 +180,11 @@ describe('Worker new', () => {
|
||||||
expect(newWorker.id).toEqual(bruceWayneId);
|
expect(newWorker.id).toEqual(bruceWayneId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function removeWorker(id) {
|
||||||
|
await models.Worker.destroyById(id);
|
||||||
|
await models.Address.destroyAll({clientFk: id});
|
||||||
|
await models.Mandate.destroyAll({clientFk: id});
|
||||||
|
await models.Client.destroyById(id);
|
||||||
|
await models.VnUser.destroyById(id);
|
||||||
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@ fixtures:
|
||||||
- module
|
- module
|
||||||
- defaultViewConfig
|
- defaultViewConfig
|
||||||
vn:
|
vn:
|
||||||
- agencyTermConfig
|
|
||||||
- alertLevel
|
- alertLevel
|
||||||
- bookingPlanner
|
- bookingPlanner
|
||||||
- businessType
|
- businessType
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "24.8.0",
|
"version": "24.10.0",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "Salix backend",
|
"description": "Salix backend",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue