refs #6915 test_master24_8 #2067
|
@ -22,6 +22,7 @@ proc:BEGIN
|
|||
DECLARE vHasItemGroup BOOL;
|
||||
DECLARE vDescription VARCHAR(255);
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vDefaultEntry INT;
|
||||
|
||||
-- Carga los datos necesarios del EKT
|
||||
SELECT e.ref, qty, package, putOrderFk MOD 1000000, i2.id , NOT ISNULL(eea.addressFk), NOT ISNULL(igto.group_code),
|
||||
|
@ -42,6 +43,9 @@ proc:BEGIN
|
|||
LEAVE proc;
|
||||
END IF;
|
||||
|
||||
SELECT defaultEntry INTO vDefaultEntry
|
||||
FROM vn.entryConfig;
|
||||
|
||||
-- Asigna la entrada
|
||||
SELECT vn.ekt_getEntry(vSelf) INTO vEntryFk;
|
||||
|
||||
|
@ -100,10 +104,9 @@ proc:BEGIN
|
|||
LEFT JOIN ekt l ON l.ref = e.ref
|
||||
LEFT JOIN vn.buy b ON b.ektFk = l.id
|
||||
LEFT JOIN vn.item i ON i.id = b.itemFk
|
||||
JOIN vn2008.config cfg
|
||||
WHERE e.id = vSelf
|
||||
AND l.id != vSelf
|
||||
AND b.itemFk != cfg.generic_item
|
||||
AND b.itemFk != vDefaultEntry
|
||||
AND IF(t.s1, l.s1 = e.s1, TRUE)
|
||||
AND IF(t.s2, l.s2 = e.s2, TRUE)
|
||||
AND IF(t.s3, l.s3 = e.s3, TRUE)
|
||||
|
@ -142,7 +145,7 @@ proc:BEGIN
|
|||
SELECT vEntryFk,
|
||||
vSelf,
|
||||
(@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue,
|
||||
IFNULL(vItem, cfg.generic_item) itemFk,
|
||||
IFNULL(vItem, vDefaultEntry) itemFk,
|
||||
e.qty stickers,
|
||||
@pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing,
|
||||
IFNULL(b.`grouping`, e.pac),
|
||||
|
@ -154,7 +157,6 @@ proc:BEGIN
|
|||
LEFT JOIN vn.buy b ON b.id = vBuy
|
||||
LEFT JOIN vn.item i ON i.id = b.itemFk
|
||||
LEFT JOIN vn.supplier s ON e.pro = s.id
|
||||
JOIN vn2008.config cfg
|
||||
WHERE e.id = vSelf
|
||||
LIMIT 1;
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `edi`.`ektK2`
|
||||
AS SELECT `eek`.`id` AS `id`,
|
||||
`eek`.`description` AS `description`
|
||||
FROM `edi`.`ektK1` `eek`
|
|
@ -0,0 +1,15 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`accountReconciliation_beforeInsert`
|
||||
BEFORE INSERT ON `accountReconciliation`
|
||||
FOR EACH ROW
|
||||
|
||||
SET NEW.calculatedCode = REPLACE(
|
||||
REPLACE(
|
||||
REPLACE(
|
||||
REPLACE(
|
||||
CONCAT(NEW.supplierAccountFk,NEW.operationDated,NEW.amount,NEW.concept,NEW.debitCredit)
|
||||
,' ','')
|
||||
,":",'')
|
||||
,'-','')
|
||||
,'.','')$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,15 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`awbInvoiceIn_afterDelete`
|
||||
AFTER DELETE ON `awbInvoiceIn`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF (SELECT COUNT(*) FROM invoiceInTax where invoiceInFk = OLD.invoiceInFk) = 0
|
||||
AND
|
||||
(SELECT COUNT(*) FROM invoiceInDueDay where invoiceInFk = OLD.invoiceInFk) = 0
|
||||
AND
|
||||
(SELECT isBooked FROM invoiceIn WHERE id = OLD.invoiceInFk) = 0
|
||||
THEN
|
||||
DELETE FROM invoiceIn WHERE id = OLD.invoiceInFk;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,24 +0,0 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn`.`bankPolicy`
|
||||
AS SELECT `bp`.`poliza_id` AS `id`,
|
||||
`bp`.`referencia` AS `ref`,
|
||||
`bp`.`importe` AS `amount`,
|
||||
`bp`.`com_dispuesto` AS `balanceInterestDrawn`,
|
||||
`bp`.`com_no_dispuesto` AS `commissionAvailableBalances`,
|
||||
`bp`.`com_anual` AS `openingCommission`,
|
||||
`bp`.`apertura` AS `started`,
|
||||
`bp`.`cierre` AS `ended`,
|
||||
`bp`.`Id_Banco` AS `bankFk`,
|
||||
`bp`.`empresa_id` AS `companyFk`,
|
||||
`bp`.`supplierFk` AS `supplierFk`,
|
||||
`bp`.`description` AS `description`,
|
||||
`bp`.`hasGuarantee` AS `hasGuarantee`,
|
||||
`bp`.`dmsFk` AS `dmsFk`,
|
||||
`bp`.`notaryFk` AS `notaryFk`,
|
||||
`bp`.`currencyFk` AS `currencyFk`,
|
||||
`bp`.`amortizationTypeFk` AS `amortizationTypeFk`,
|
||||
`bp`.`periodicityTypeFk` AS `periodicityTypeFk`,
|
||||
`bp`.`insuranceExpired` AS `insuranceExpired`
|
||||
FROM `vn2008`.`Bancos_poliza` `bp`
|
||||
ORDER BY `bp`.`poliza_id` DESC
|
|
@ -1,14 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`Conteo_afterInsert`
|
||||
AFTER INSERT ON `Conteo`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE intTravel INTEGER;
|
||||
SELECT t.id INTO intTravel FROM Compres c JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada
|
||||
JOIN travel t ON t.id = e.travel_id
|
||||
WHERE landing = util.VN_CURDATE() AND c.Id_Article = NEW.Id_Article AND warehouse_id = NEW.warehouse_id AND received <> TRUE LIMIT 1;
|
||||
IF (intTravel) then
|
||||
UPDATE travel SET received = TRUE WHERE id = intTravel;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,14 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`account_conciliacion_beforeInsert`
|
||||
BEFORE INSERT ON `account_conciliacion`
|
||||
FOR EACH ROW
|
||||
set new.id_calculated = replace(
|
||||
replace(
|
||||
replace(
|
||||
replace(
|
||||
concat(new.Id_Proveedores_account,new.Fechaoperacion,new.importe,new.Concepto,new.DebeHaber)
|
||||
,' ','')
|
||||
,":",'')
|
||||
,'-','')
|
||||
,'.','')$$
|
||||
DELIMITER ;
|
|
@ -1,18 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hour_afterUpdate`
|
||||
AFTER UPDATE ON `agency_hour`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM vn2008.agency_hour
|
||||
WHERE NEW.week_day <=> week_day AND NEW.province_id <=> province_id
|
||||
AND NEW.warehouse_id <=> warehouse_id AND NEW.max_hour <=> max_hour
|
||||
AND NEW.agency_id <=> agency_id;
|
||||
|
||||
IF vAlreadyExists > 1 THEN
|
||||
CALL util.throw('ALREADY_EXISTS');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,21 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`agency_hour_beforeInsert`
|
||||
BEFORE INSERT ON `agency_hour`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE vAlreadyExists BOOLEAN DEFAULT FALSE;
|
||||
IF NEW.week_day IS NULL AND NEW.province_id IS NULL AND NEW.subtract_day = 0 AND NEW.max_hour = 0 THEN
|
||||
CALL util.throw ('FILL_MORE_FIELDS');
|
||||
END IF;
|
||||
|
||||
SELECT COUNT(*) INTO vAlreadyExists
|
||||
FROM vn2008.agency_hour
|
||||
WHERE NEW.week_day <=> week_day AND NEW.province_id <=> province_id
|
||||
AND NEW.warehouse_id <=> warehouse_id AND NEW.max_hour <=> max_hour
|
||||
AND NEW.agency_id <=> agency_id;
|
||||
|
||||
IF vAlreadyExists > 1 THEN
|
||||
CALL util.throw('ALREADY_EXISTS');
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,13 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn2008`.`awb_recibida_afterDelete`
|
||||
AFTER DELETE ON `awb_recibida`
|
||||
FOR EACH ROW
|
||||
IF (SELECT COUNT(*) FROM recibida_iva where recibida_id = OLD.recibida_id) = 0
|
||||
AND
|
||||
(SELECT COUNT(*) FROM recibida_vencimiento where recibida_id = OLD.recibida_id) = 0
|
||||
AND
|
||||
(SELECT contabilizada FROM recibida WHERE id = OLD.recibida_id) = 0
|
||||
THEN
|
||||
DELETE FROM recibida WHERE id = OLD.recibida_id;
|
||||
END IF$$
|
||||
DELIMITER ;
|
|
@ -0,0 +1,24 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`Bancos_poliza`
|
||||
AS SELECT `bp`.`id` AS `poliza_id`,
|
||||
`bp`.`ref` AS `referencia`,
|
||||
`bp`.`amount` AS `importe`,
|
||||
`bp`.`committedFee` AS `com_dispuesto`,
|
||||
`bp`.`nonCommittedFee` AS `com_no_dispuesto`,
|
||||
`bp`.`annualFee` AS `com_anual`,
|
||||
`bp`.`started` AS `apertura`,
|
||||
`bp`.`ended` AS `cierre`,
|
||||
`bp`.`accountingFk` AS `Id_Banco`,
|
||||
`bp`.`companyFk` AS `empresa_id`,
|
||||
`bp`.`supplierFk` AS `supplierFk`,
|
||||
`bp`.`description` AS `description`,
|
||||
`bp`.`hasGuarantee` AS `hasGuarantee`,
|
||||
`bp`.`dmsFk` AS `dmsFk`,
|
||||
`bp`.`notaryFk` AS `notaryFk`,
|
||||
`bp`.`currencyFk` AS `currencyFk`,
|
||||
`bp`.`amortizationTypeFk` AS `amortizationTypeFk`,
|
||||
`bp`.`periodicityTypeFk` AS `periodicityTypeFk`,
|
||||
`bp`.`insuranceExpired` AS `insuranceExpired`
|
||||
FROM `vn`.`bankPolicy` `bp`
|
||||
ORDER BY `bp`.`id` DESC
|
|
@ -0,0 +1,6 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`Entradas_orden`
|
||||
AS SELECT `eo`.`entryFk` AS `Id_Entrada`,
|
||||
`eo`.`order` AS `orden`
|
||||
FROM `vn`.`entryOrder` `eo`
|
|
@ -0,0 +1,6 @@
|
|||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`Proveedores_gestdoc`
|
||||
AS SELECT `sd`.`supplierFk` AS `Id_Proveedor`,
|
||||
`sd`.`dmsFk` AS `gestdoc_id`
|
||||
FROM `vn`.`supplierDms` `sd`
|
|
@ -1,4 +1,4 @@
|
|||
ls CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
||||
SQL SECURITY DEFINER
|
||||
VIEW `vn2008`.`Splits`
|
||||
AS SELECT `s`.`id` AS `Id_Split`,
|
||||
|
|
Loading…
Reference in New Issue