This commit is contained in:
parent
6352ef0576
commit
8089c32ec2
|
@ -1,16 +0,0 @@
|
|||
UPDATE `salix`.`ACL` SET principalId ='employee' WHERE id = 122;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
(167, 'Worker', 'isSubordinate', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(168, 'Worker', 'mySubordinates', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(169, 'WorkerTimeControl', 'filter', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(170, 'WorkerTimeControl', 'addTime', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
(171, 'TicketServiceType', '*', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
||||
|
||||
-- ONLY FOR ACL ALREADY ON PRODUCTION
|
||||
INSERT IGNORE INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
(172, 'Sms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
(173, 'Sms', 'send', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`cl_est`
|
||||
ADD COLUMN `roleFk` INT(10) UNSIGNED NOT NULL DEFAULT '1' AFTER `estado`;
|
||||
|
||||
ALTER TABLE `vn2008`.`cl_est`
|
||||
ADD INDEX `roleFgn_idx` (`roleFk` ASC);
|
||||
|
||||
ALTER TABLE `vn2008`.`cl_est`
|
||||
ADD CONSTRAINT `roleFgn`
|
||||
FOREIGN KEY (`roleFk`)
|
||||
REFERENCES `account`.`role` (`id`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -1,10 +0,0 @@
|
|||
CREATE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`clientDms` AS
|
||||
SELECT
|
||||
`g`.`Id_Cliente` AS `clientFk`,
|
||||
`g`.`gest_doc_id` AS `dmsFk`
|
||||
FROM
|
||||
`vn2008`.`clientes_gestdoc` `g`
|
|
@ -1,19 +0,0 @@
|
|||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`dms` AS
|
||||
SELECT
|
||||
`g`.`id` AS `id`,
|
||||
`g`.`gesttip_id` AS `dmsTypeFk`,
|
||||
`g`.`file` AS `file`,
|
||||
`g`.`trabajador_id` AS `workerFk`,
|
||||
`g`.`warehouse_id` AS `warehouseFk`,
|
||||
`g`.`emp_id` AS `companyFk`,
|
||||
`g`.`orden` AS `hardCopyNumber`,
|
||||
`g`.`original` AS `hasFile`,
|
||||
`g`.`sref` AS `reference`,
|
||||
`g`.`brief` AS `description`,
|
||||
`g`.`odbc_date` AS `created`
|
||||
FROM
|
||||
`vn2008`.`gestdoc` `g`
|
|
@ -1 +0,0 @@
|
|||
UPDATE `vn2008`.`mandato_tipo` SET `Nombre`='LCR' WHERE `idmandato_tipo`='3';
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
INSERT INTO `vn`.`sample`(`code`, `description`, `isVisible`, `hasCompany`)
|
||||
VALUES
|
||||
('client-lcr', 'Email de solicitud de datos bancarios LCR', 1, 1);
|
|
@ -1,2 +0,0 @@
|
|||
ALTER TABLE `bi`.`tarifa_componentes`
|
||||
ADD COLUMN `code` VARCHAR(45) NULL DEFAULT NULL AFTER `is_renewable`;
|
|
@ -1,11 +0,0 @@
|
|||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`claimState` AS
|
||||
SELECT
|
||||
`c`.`id` AS `id`,
|
||||
`c`.`estado` AS `description`,
|
||||
`c`.`roleFk` AS `roleFk`
|
||||
FROM
|
||||
`vn2008`.`cl_est` `c`;
|
|
@ -1,16 +0,0 @@
|
|||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`componentRate` AS
|
||||
SELECT
|
||||
`t`.`Id_Componente` AS `id`,
|
||||
`t`.`Componente` AS `name`,
|
||||
`t`.`tarifa_componentes_series_id` AS `componentTypeRate`,
|
||||
`t`.`tarifa_class` AS `classRate`,
|
||||
`t`.`tax` AS `tax`,
|
||||
`t`.`is_renewable` AS `isRenewable`,
|
||||
`t`.`code` AS `code`
|
||||
FROM
|
||||
`bi`.`tarifa_componentes` `t`;
|
|
@ -1,26 +0,0 @@
|
|||
CREATE OR REPLACE
|
||||
ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`ticket` AS
|
||||
SELECT
|
||||
`t`.`Id_Ticket` AS `id`,
|
||||
`t`.`Id_Cliente` AS `clientFk`,
|
||||
`t`.`warehouse_id` AS `warehouseFk`,
|
||||
`t`.`Fecha` AS `shipped`,
|
||||
`t`.`landing` AS `landed`,
|
||||
`t`.`Alias` AS `nickname`,
|
||||
`t`.`Factura` AS `refFk`,
|
||||
`t`.`Id_Consigna` AS `addressFk`,
|
||||
`t`.`Localizacion` AS `location`,
|
||||
`t`.`Solucion` AS `solution`,
|
||||
`t`.`Id_Ruta` AS `routeFk`,
|
||||
`t`.`empresa_id` AS `companyFk`,
|
||||
`t`.`Id_Agencia` AS `agencyModeFk`,
|
||||
`t`.`Prioridad` AS `priority`,
|
||||
`t`.`Bultos` AS `packages`,
|
||||
`t`.`isDeleted` AS `isDeleted`,
|
||||
`t`.`odbc_date` AS `created`,
|
||||
`t`.`zoneFk` AS `zoneFk`
|
||||
FROM
|
||||
`vn2008`.`Tickets` `t`;
|
|
@ -1,17 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` ( `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Dms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Dms', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Dms', 'downloadFile', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Client', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ClientDms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('ClientDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'uploadFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('TicketDms', 'removeFile', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('TicketDms', '*', 'READ', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Route', 'updateVolume', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss');
|
||||
|
||||
|
||||
|
||||
INSERT INTO `salix`.`ACL` (`id`, `model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('', 'Agency', 'getLanded', 'READ', 'ALLOW', 'ROLE', 'employee');
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Agency', 'getShipped', 'READ', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,15 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP FOREIGN KEY `clientes_gestdoc_ibfk_3`;
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`gest_doc_id`);
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD INDEX `fk_clientes_gestdoc_1_idx` (`Id_Cliente` ASC);
|
||||
|
||||
ALTER TABLE `vn2008`.`clientes_gestdoc`
|
||||
ADD CONSTRAINT `fk_clientes_gestdoc_3`
|
||||
FOREIGN KEY (`Id_Cliente`)
|
||||
REFERENCES `vn2008`.`Clientes` (`id_cliente`)
|
||||
ON DELETE RESTRICT
|
||||
ON UPDATE CASCADE;
|
|
@ -1,28 +0,0 @@
|
|||
DROP TRIGGER IF EXISTS `vn2008`.`expeditionsBeforeInsert`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` TRIGGER `vn2008`.`expeditionsBeforeInsert`
|
||||
BEFORE INSERT ON `expeditions` FOR EACH ROW
|
||||
-- Edit trigger body code below this line. Do not edit lines above this one
|
||||
BEGIN
|
||||
DECLARE intcounter INT;
|
||||
DECLARE vShipFk INT;
|
||||
|
||||
IF NEW.EsBulto > 0 THEN
|
||||
|
||||
UPDATE Tickets SET Bultos = nz(Bultos) + 1 WHERE Id_Ticket = NEW.ticket_id;
|
||||
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter FROM expeditions e
|
||||
INNER JOIN Tickets t1 ON e.ticket_id = t1.Id_Ticket
|
||||
LEFT JOIN vn.ticketState ts ON ts.ticket = t1.Id_Ticket
|
||||
INNER JOIN Tickets t2 ON t2.Id_Consigna = t1.Id_Consigna AND DATE(t2.Fecha) = DATE(t1.Fecha) AND t1.warehouse_id = t2.warehouse_id
|
||||
WHERE t2.Id_Ticket = NEW.ticket_id AND ts.alertLevel < 3 AND t1.empresa_id = t2.empresa_id AND t1.Id_Agencia = t2.Id_Agencia;
|
||||
SET NEW.`counter` = intcounter;
|
||||
END IF;
|
||||
|
||||
-- JGF 14/01/19 si existe un polizon queda anulado
|
||||
SELECT shipFk INTO vShipFk FROM vn.stowaway WHERE id = NEW.ticket_id;
|
||||
IF vShipFk THEN
|
||||
CALL vn.stowawayUnBoarding(vShipFk, NEW.ticket_id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,21 +0,0 @@
|
|||
-- adds column to table
|
||||
ALTER TABLE `vn2008`.`gesttip`
|
||||
ADD COLUMN `code` VARCHAR(45) NOT NULL AFTER `readRoleFk`;
|
||||
|
||||
-- adds column to view
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`dmsType` AS
|
||||
SELECT
|
||||
`g`.`id` AS `id`,
|
||||
`g`.`tipo` AS `name`,
|
||||
`g`.`path` AS `path`,
|
||||
`g`.`readRoleFk` AS `readRoleFk`,
|
||||
`g`.`writeRoleFk` AS `writeRoleFk`,
|
||||
`g`.`code` AS `code`
|
||||
FROM
|
||||
`vn2008`.`gesttip` `g`;
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`routeUpdateM3`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT)
|
||||
BEGIN
|
||||
|
||||
UPDATE vn.route r
|
||||
JOIN (SELECT routeFk, SUM(volume) AS m3
|
||||
FROM ticketGetVolume
|
||||
WHERE routeFk = vRoute
|
||||
) v ON v.routeFk = r.id
|
||||
SET r.m3 = v.m3;
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
UPDATE `bi`.`tarifa_componentes` SET `code`='specialPrices' WHERE `Id_Componente`='10';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='extraCostPerWeekDay' WHERE `Id_Componente`='14';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='delivery' WHERE `Id_Componente`='15';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='debtCollection' WHERE `Id_Componente`='17';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='adjustment' WHERE `Id_Componente`='21';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='salePerPackage' WHERE `Id_Componente`='22';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='salePerBox' WHERE `Id_Componente`='23';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='purchaseValue' WHERE `Id_Componente`='28';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='margin' WHERE `Id_Componente`='29';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='lastUnitsDiscount' WHERE `Id_Componente`='32';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='salePerBox' WHERE `Id_Componente`='33';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='buyerDiscount' WHERE `Id_Componente`='34';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='mismatch' WHERE `Id_Componente`='36';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='mana' WHERE `Id_Componente`='37';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='bagged' WHERE `Id_Componente`='38';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='autoMana' WHERE `Id_Componente`='39';
|
||||
UPDATE `bi`.`tarifa_componentes` SET `code`='freightCharge' WHERE `Id_Componente`='41';
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
DROP procedure IF EXISTS `vn`.`zoneGetWarehouse`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`zoneGetWarehouse`(vAddress INT, vLanded DATE, vWarehouse INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el listado de agencias disponibles para la fecha,
|
||||
* dirección y warehouse pasadas
|
||||
*
|
||||
* @param vAddress
|
||||
* @param vWarehouse warehouse
|
||||
* @param vLanded Fecha de recogida
|
||||
* @select Listado de agencias disponibles
|
||||
*/
|
||||
|
||||
DECLARE vPostalCode varchar(10);
|
||||
|
||||
SELECT postalCode INTO vPostalCode
|
||||
FROM address WHERE id = vAddress;
|
||||
SELECT * FROM (
|
||||
SELECT * FROM (
|
||||
SELECT am.id agencyModeFk,
|
||||
am.name agencyMode,
|
||||
am.description,
|
||||
am.deliveryMethodFk,
|
||||
TIMESTAMPADD(DAY,-z.travelingDays, vLanded) shipped,
|
||||
z.warehouseFk,
|
||||
zi.isIncluded,
|
||||
z.id zoneFk
|
||||
FROM zoneGeo zgSon
|
||||
JOIN zoneGeo zgFather ON zgSon.lft BETWEEN zgFather.lft AND zgFather.rgt
|
||||
JOIN zoneIncluded zi ON zi.geoFk = zgFather.id
|
||||
JOIN zone z ON z.id = zi.zoneFk
|
||||
JOIN zoneCalendar zc ON zc.zoneFk = z.id
|
||||
JOIN agencyMode am ON am.id = z.agencyModeFk
|
||||
WHERE zgSon.`name` LIKE vPostalCode
|
||||
AND delivered = vLanded
|
||||
AND z.warehouseFk = vWarehouse
|
||||
AND IF(TIMESTAMPADD(DAY,-z.travelingDays, vLanded) = CURDATE(), hour(now()) < hour(z.`hour`),TRUE)
|
||||
ORDER BY z.id, zgFather.depth DESC) t
|
||||
GROUP BY zoneFk
|
||||
HAVING isIncluded > 0) t
|
||||
GROUP BY agencyModeFk;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='5';
|
||||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='12';
|
||||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='14';
|
||||
UPDATE `vn2008`.`gesttip` SET `writeRoleFk`='1', `readRoleFk`='1' WHERE `id`='13';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='invoiceIn' WHERE `id`='1';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='officialDoc' WHERE `id`='2';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='hhrrData' WHERE `id`='3';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='deliveryNote' WHERE `id`='4';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='miscellaneous' WHERE `id`='5';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='tests' WHERE `id`='6';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='economicActivitiesTax' WHERE `id`='7';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='fiscal' WHERE `id`='8';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='vehicles' WHERE `id`='9';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='templates' WHERE `id`='10';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='contracts' WHERE `id`='11';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='paymentsLaw' WHERE `id`='12';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='trash' WHERE `id`='13';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='ticket' WHERE `id`='14';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='budgets' WHERE `id`='15';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='logistics' WHERE `id`='16';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='cmr' WHERE `id`='17';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='dua' WHERE `id`='18';
|
||||
UPDATE `vn2008`.`gesttip` SET `code`='fixedAssets' WHERE `id`='19';
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`Paises`
|
||||
ADD COLUMN `ibanLength` TINYINT(4) NULL DEFAULT NULL AFTER `isUeeMember`;
|
||||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`country` AS
|
||||
SELECT
|
||||
`p`.`Id` AS `id`,
|
||||
`p`.`Pais` AS `country`,
|
||||
`p`.`CEE` AS `CEE`,
|
||||
`p`.`isUeeMember` AS `isUeeMember`,
|
||||
`p`.`Codigo` AS `code`,
|
||||
`p`.`Id_Moneda` AS `currencyFk`,
|
||||
`p`.`Id_Paisreal` AS `politicalCountryFk`,
|
||||
`p`.`geoFk` AS `geoFk`,
|
||||
`p`.`ibanLength` AS `ibanLength`
|
||||
FROM
|
||||
`vn2008`.`Paises` `p`;
|
||||
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=22 WHERE `Id`=1;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=25 WHERE `Id`=2;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=20 WHERE `Id`=3;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=22 WHERE `Id`=4;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=16 WHERE `Id`=5;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=25 WHERE `Id`=19;
|
||||
UPDATE `vn2008`.`Paises` SET `ibanLength`=22 WHERE `Id`=30;
|
|
@ -1,5 +0,0 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('Zone', 'editPrices', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'),
|
||||
('Postcode', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'),
|
||||
('Ticket', 'addSale', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -1,23 +0,0 @@
|
|||
ALTER TABLE `vn2008`.`gestdoc`
|
||||
ADD COLUMN `contentType` VARCHAR(100) NULL AFTER `file`;
|
||||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`dms` AS
|
||||
SELECT
|
||||
`g`.`id` AS `id`,
|
||||
`g`.`gesttip_id` AS `dmsTypeFk`,
|
||||
`g`.`file` AS `file`,
|
||||
`g`.`contentType` AS `contentType`,
|
||||
`g`.`trabajador_id` AS `workerFk`,
|
||||
`g`.`warehouse_id` AS `warehouseFk`,
|
||||
`g`.`emp_id` AS `companyFk`,
|
||||
`g`.`orden` AS `hardCopyNumber`,
|
||||
`g`.`original` AS `hasFile`,
|
||||
`g`.`sref` AS `reference`,
|
||||
`g`.`brief` AS `description`,
|
||||
`g`.`odbc_date` AS `created`
|
||||
FROM
|
||||
`vn2008`.`gestdoc` `g`;
|
|
@ -1,3 +0,0 @@
|
|||
ALTER TABLE `vn`.`zoneCalendar`
|
||||
ADD COLUMN `price` DOUBLE NOT NULL AFTER `delivered`,
|
||||
ADD COLUMN `bonus` DOUBLE NOT NULL AFTER `price`;
|
|
@ -1,139 +0,0 @@
|
|||
DROP procedure IF EXISTS `vn`.`ticketGetProblems`;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`ticketGetProblems`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vWarehouse INT;
|
||||
DECLARE vDate DATE;
|
||||
DECLARE vAvailableCache INT;
|
||||
DECLARE vVisibleCache INT;
|
||||
DECLARE vDone INT DEFAULT 0;
|
||||
|
||||
DECLARE vCursor CURSOR FOR
|
||||
SELECT DISTINCT tt.warehouseFk, date(tt.shipped)
|
||||
FROM tmp.ticketGetProblems tt
|
||||
WHERE DATE(tt.shipped) BETWEEN CURDATE()
|
||||
AND TIMESTAMPADD(DAY, 1.9, CURDATE());
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketProblems;
|
||||
CREATE TEMPORARY TABLE tmp.ticketProblems (
|
||||
ticketFk INT(11) PRIMARY KEY,
|
||||
isFreezed INTEGER(1) DEFAULT 0,
|
||||
risk DECIMAL(10,2) DEFAULT 0,
|
||||
hasTicketRequest INTEGER(1) DEFAULT 0,
|
||||
isAvailable INTEGER(1) DEFAULT 1
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticketList;
|
||||
CREATE TEMPORARY TABLE tmp.ticketList
|
||||
(PRIMARY KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT tp.ticketFk, c.id clientFk
|
||||
FROM tmp.ticketGetProblems tp
|
||||
JOIN vn.client c ON c.id = tp.clientFk;
|
||||
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, isFreezed)
|
||||
SELECT DISTINCT tl.ticketFk, 1
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.client c ON c.id = tl.clientFk
|
||||
WHERE c.isFreezed;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt;
|
||||
CREATE TEMPORARY TABLE tmp.clientGetDebt
|
||||
(PRIMARY KEY (clientFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT clientFk
|
||||
FROM tmp.ticketList;
|
||||
|
||||
CALL clientGetDebt(CURDATE());
|
||||
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, risk)
|
||||
SELECT DISTINCT tl.ticketFk, r.risk
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticket t ON t.id = tl.ticketFk
|
||||
JOIN vn.agencyMode a ON t.agencyModeFk = a.id
|
||||
JOIN tmp.risk r ON r.clientFk = t.clientFk
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
WHERE r.risk > c.credit + 10
|
||||
AND a.deliveryMethodFk != 3
|
||||
ON DUPLICATE KEY UPDATE
|
||||
risk = r.risk;
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, hasTicketRequest)
|
||||
SELECT DISTINCT tl.ticketFk, 1
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticketRequest tr ON tr.ticketFk = tl.ticketFk
|
||||
WHERE tr.isOK IS NULL
|
||||
ON DUPLICATE KEY UPDATE
|
||||
hasTicketRequest = 1;
|
||||
|
||||
OPEN vCursor;
|
||||
|
||||
WHILE NOT vDone
|
||||
DO
|
||||
FETCH vCursor INTO vWarehouse, vDate;
|
||||
|
||||
CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouse);
|
||||
CALL cache.available_refresh(vAvailableCache, FALSE, vWarehouse, vDate);
|
||||
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, isAvailable)
|
||||
SELECT tl.ticketFk, 0
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticket t ON t.id = tl.ticketFk
|
||||
LEFT JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it on it.id = i.typeFk
|
||||
LEFT JOIN cache.available av ON av.item_id = i.id
|
||||
AND av.calc_id = vAvailableCache
|
||||
WHERE date(t.shipped) = vDate
|
||||
AND categoryFk != 6
|
||||
AND IFNULL(av.available, 0) < 0
|
||||
AND s.isPicked = FALSE
|
||||
AND NOT i.generic
|
||||
AND vWarehouse = t.warehouseFk
|
||||
GROUP BY tl.ticketFk
|
||||
ON DUPLICATE KEY UPDATE
|
||||
isAvailable = 0;
|
||||
|
||||
INSERT INTO tmp.ticketProblems(ticketFk, isAvailable)
|
||||
SELECT tl.ticketFk, 0
|
||||
FROM tmp.ticketList tl
|
||||
JOIN vn.ticket t ON t.id = tl.ticketFk
|
||||
LEFT JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = s.itemFk
|
||||
JOIN vn.itemType it on it.id = i.typeFk
|
||||
LEFT JOIN cache.visible v ON i.id = v.item_id AND v.calc_id = vVisibleCache
|
||||
LEFT JOIN cache.available av ON av.item_id = i.id AND av.calc_id = vAvailableCache
|
||||
WHERE IFNULL(av.available, 0) >= 0
|
||||
AND s.quantity > IFNULL(v.visible, 0)
|
||||
AND s.isPicked = FALSE
|
||||
AND s.reserved = FALSE
|
||||
AND it.categoryFk != 6
|
||||
AND date(t.shipped) = vDate
|
||||
AND NOT i.generic
|
||||
AND CURDATE() = vDate
|
||||
AND t.warehouseFk = vWarehouse
|
||||
GROUP BY tl.ticketFk
|
||||
ON DUPLICATE KEY UPDATE
|
||||
isAvailable = 0;
|
||||
|
||||
END WHILE;
|
||||
|
||||
CLOSE vCursor;
|
||||
|
||||
SELECT * FROM tmp.ticketProblems;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tmp.clientGetDebt,
|
||||
tmp.ticketList;
|
||||
|
||||
END$$
|
||||
|
||||
DELIMITER ;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
DROP VIEW IF EXISTS `vn`.`queuePriority` ;
|
||||
|
||||
CREATE
|
||||
OR REPLACE ALGORITHM = UNDEFINED
|
||||
DEFINER = `root`@`%`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`queuePriority` AS
|
||||
SELECT
|
||||
`p`.`Id_Prioridad` AS `id`,
|
||||
`p`.`Prioridad` AS `priority`
|
||||
FROM
|
||||
`vn2008`.`Prioridades` `p`;
|
File diff suppressed because one or more lines are too long
|
@ -1835,4 +1835,12 @@ INSERT INTO `vn`.`clientDms`(`clientFk`, `dmsFk`)
|
|||
(101, 2),
|
||||
(101, 3);
|
||||
|
||||
INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) VALUES ('aaa', 'android', '9');
|
||||
INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`)
|
||||
VALUES
|
||||
('aaa', 'android', '9');
|
||||
|
||||
INSERT INTO `vn`.`queuePriority`(`id`, `priority`)
|
||||
VALUES
|
||||
(1, 'Alta'),
|
||||
(2, 'Normal'),
|
||||
(3, 'Baja');
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,5 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
|
||||
module.exports = function(Self) {
|
||||
Self.remoteMethodCtx('makeInvoice', {
|
||||
|
@ -25,6 +26,7 @@ module.exports = function(Self) {
|
|||
});
|
||||
|
||||
Self.makeInvoice = async(ctx, id) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
let userId = ctx.req.accessToken.userId;
|
||||
let models = Self.app.models;
|
||||
let tx = await Self.beginTransaction({});
|
||||
|
@ -48,29 +50,32 @@ module.exports = function(Self) {
|
|||
let [result] = await Self.rawSql(query, [ticket.clientFk, ticket.companyFk, 'R'], options);
|
||||
let serial = result.serial;
|
||||
|
||||
query = `CALL vn.invoiceFromTicket(?)`;
|
||||
await Self.rawSql(query, [ticket.id], options);
|
||||
let stmts = [];
|
||||
|
||||
result = await Self.rawSql(
|
||||
`CALL vn.invoiceOutMake(?, ?, @invoiceId);
|
||||
SELECT @invoiceId AS invoiceId;`,
|
||||
[serial, null],
|
||||
options
|
||||
);
|
||||
let invoice = result[1][0].invoiceId;
|
||||
stmt = new ParameterizedSQL('CALL vn.invoiceOut_newFromTicket(?, ?, ?, @invoiceId)', [
|
||||
ticket.id,
|
||||
serial,
|
||||
null
|
||||
]);
|
||||
stmts.push(stmt);
|
||||
|
||||
if (serial != 'R' && invoice) {
|
||||
let invoiceIndex = stmts.push(`SELECT @invoiceId AS invoiceId`) - 1;
|
||||
|
||||
let sql = ParameterizedSQL.join(stmts, ';');
|
||||
result = await conn.executeStmt(sql);
|
||||
let invoiceId = result[invoiceIndex][0].invoiceId;
|
||||
if (serial != 'R' && invoiceId) {
|
||||
query = `CALL vn.invoiceOutBooking(?)`;
|
||||
await Self.rawSql(query, [invoice], options);
|
||||
await Self.rawSql(query, [invoiceId], options);
|
||||
}
|
||||
|
||||
let user = await models.Worker.findOne({where: {userFk: userId}}, options);
|
||||
|
||||
query = `INSERT INTO printServerQueue(reportFk, param1, workerFk) VALUES (?, ?, ?)`;
|
||||
await Self.rawSql(query, [3, invoice, user.id], options);
|
||||
await Self.rawSql(query, [3, invoiceId, user.id], options);
|
||||
await tx.commit();
|
||||
|
||||
return {invoiceFk: invoice, serial};
|
||||
return {invoiceFk: invoiceId, serial};
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
|
|
|
@ -21,7 +21,7 @@ describe('ticket makeInvoice()', () => {
|
|||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
invoice = await app.models.Ticket.makeInvoice(ctx, ticketId);
|
||||
|
||||
expect(invoice.invoiceFk).not.toBeNaN();
|
||||
expect(invoice.invoiceFk).toBeDefined();
|
||||
expect(invoice.serial).toEqual('T');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue