export table payment
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Bernat Exposito 2021-01-08 10:24:41 +01:00
parent 2a948ddc33
commit a2550ce128
2 changed files with 1404 additions and 1124 deletions

View File

@ -13144,9 +13144,9 @@ DELIMITER ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ; /*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8 */ ; /*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;; DELIMITER ;;
@ -13162,7 +13162,7 @@ BEGIN
DECLARE vOk BOOL; DECLARE vOk BOOL;
DECLARE vDone BOOL DEFAULT FALSE; DECLARE vDone BOOL DEFAULT FALSE;
DECLARE vWarehouse INT; DECLARE vWarehouse INT;
DECLARE vShipment DATETIME; DECLARE vShipment DATE;
DECLARE vTicket INT; DECLARE vTicket INT;
DECLARE vNotes VARCHAR(255); DECLARE vNotes VARCHAR(255);
DECLARE vItem INT; DECLARE vItem INT;
@ -16842,7 +16842,7 @@ CREATE TABLE `clientesProveedores` (
`IBAN` varchar(34) COLLATE utf8_unicode_ci NOT NULL, `IBAN` varchar(34) COLLATE utf8_unicode_ci NOT NULL,
`CodigoCondiciones` smallint(6) NOT NULL, `CodigoCondiciones` smallint(6) NOT NULL,
`StatusTraspasadoIME` tinyint(4) NOT NULL, `StatusTraspasadoIME` tinyint(4) NOT NULL,
`TipoImportacionIME` tinyint(4) NOT NULL, `TipoImportacionIME` tinyint(4) NOT NULL DEFAULT '2',
`TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT '2', `TipoPlanCuentaIME` smallint(6) NOT NULL DEFAULT '2',
`Contrapartida` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `Contrapartida` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`CodigoCuentaImpagado` varchar(15) COLLATE utf8_unicode_ci NOT NULL, `CodigoCuentaImpagado` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
@ -17481,8 +17481,7 @@ BEGIN
*/ */
TRUNCATE XDiario_movConta_IVA; TRUNCATE XDiario_movConta_IVA;
DELETE FROM movConta WHERE enlazadoSage = FALSE ; DELETE FROM movConta WHERE enlazadoSage = FALSE AND Asiento <> 1 ;
CALL clientesProveedoresAdd; CALL clientesProveedoresAdd;
CALL planCuentasPgcAdd; CALL planCuentasPgcAdd;
CALL XDiario_movConta_IVA_InvoiceOutAdd_Manager; CALL XDiario_movConta_IVA_InvoiceOutAdd_Manager;
@ -17588,7 +17587,7 @@ BEGIN
IF(x.EURODEBE,x.EURODEBE,x.EUROHABER) AS ImporteAsiento, -- DOBLE(19) IF(x.EURODEBE,x.EURODEBE,x.EUROHABER) AS ImporteAsiento, -- DOBLE(19)
MONTH(x.FECHA) AS NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento MONTH(x.FECHA) AS NumeroPeriodo, -- ENT(2) "-1" Al informar este valor se calcula automát. A partir de la fecha de asiento
IF( sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion, -- FECHA(8) IF( sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion, -- FECHA(8)
IFNULL(xmi.CodigoDivisa, sub3.code) CodigoDivisa, -- VARCHAR(3) IF(x.CAMBIO,IFNULL(xmi.CodigoDivisa, sub3.code),'') CodigoDivisa, -- VARCHAR(3)
x.CAMBIO AS ImporteCambio, -- DOBLE(19) x.CAMBIO AS ImporteCambio, -- DOBLE(19)
IFNULL(x.DEBEME,x.HABERME) AS ImporteDivisa, -- DOBLE(19) IFNULL(x.DEBEME,x.HABERME) AS ImporteDivisa, -- DOBLE(19)
IF(x.CAMBIO,1,0) AS FactorCambio, -- DOBLE(19) IF(x.CAMBIO,1,0) AS FactorCambio, -- DOBLE(19)
@ -17675,6 +17674,7 @@ BEGIN
LEFT JOIN ( SELECT DISTINCT(account),cu.code LEFT JOIN ( SELECT DISTINCT(account),cu.code
FROM vn.bank b FROM vn.bank b
JOIN vn.currency cu ON cu.id = b.currencyFk JOIN vn.currency cu ON cu.id = b.currencyFk
WHERE cu.code <> "EUR" -- no se informa cuando la divisa en EUR
)sub3 ON sub3.account = x.SUBCTA )sub3 ON sub3.account = x.SUBCTA
WHERE x.enlazadoSage = 0 WHERE x.enlazadoSage = 0
AND c.companyCode; AND c.companyCode;
@ -30637,6 +30637,100 @@ CREATE TABLE `payMethod` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `payment`
--
DROP TABLE IF EXISTS `payment`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `payment` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`received` date NOT NULL,
`supplierFk` int(11) NOT NULL,
`amount` decimal(10,2) NOT NULL DEFAULT '0.00',
`currencyFk` tinyint(3) unsigned NOT NULL DEFAULT '1',
`divisa` decimal(10,2) DEFAULT NULL,
`bankFk` int(11) NOT NULL DEFAULT '0',
`payMethodFk` tinyint(3) unsigned NOT NULL,
`bankingFees` double(6,2) unsigned NOT NULL DEFAULT '0.00',
`concept` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL,
`companyFk` smallint(5) unsigned NOT NULL DEFAULT '442',
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`isConciliated` tinyint(1) unsigned zerofill NOT NULL DEFAULT '0',
`exchangeInsuranceFk` int(11) DEFAULT NULL,
`dueDated` date DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `empresa_id` (`companyFk`),
KEY `id_banco` (`bankFk`),
KEY `id_moneda` (`currencyFk`),
KEY `pay_met` (`payMethodFk`),
KEY `fk_pago_pago_sdc1_idx` (`exchangeInsuranceFk`),
KEY `pagoDueDatedIdx` (`dueDated`),
KEY `pago_ibfk_3` (`supplierFk`),
CONSTRAINT `pago_ibfk_3` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE,
CONSTRAINT `pago_moneda_1` FOREIGN KEY (`currencyFk`) REFERENCES `currency` (`id`) ON UPDATE CASCADE,
CONSTRAINT `pago_pay_met` FOREIGN KEY (`payMethodFk`) REFERENCES `payMethod` (`id`) ON UPDATE CASCADE,
CONSTRAINT `payment_ibfk_1` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE,
CONSTRAINT `payment_ibfk_2` FOREIGN KEY (`bankFk`) REFERENCES `bank` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW
-- Edit trigger body code below this line. Do not edit lines above this one
BEGIN
DECLARE cuenta_banco,cuenta_proveedor DOUBLE;
DECLARE vNewBookEntry INT;
DECLARE bolCASH BOOLEAN;
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
SELECT (cash = 1) INTO bolCASH FROM bank WHERE bank.id = NEW.bankFk ;
IF bolCASH THEN
SELECT account INTO cuenta_banco
FROM bank
WHERE id = NEW.bankFk;
SELECT account INTO cuenta_proveedor
FROM supplier
WHERE id = NEW.supplierFk;
CALL vn.ledger_next(vNewBookEntry);
INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id)
SELECT vNewBookEntry,NEW.received,SUBCTA,CONTRA,NEW.concept,EURODEBE,EUROHABER,NEW.companyFk
FROM
( SELECT cuenta_banco SUBCTA,cuenta_proveedor CONTRA,0 EURODEBE, NEW.amount + NEW.bankingFees EUROHABER
UNION ALL
SELECT cuenta_proveedor SUBCTA, cuenta_banco CONTRA,NEW.amount EURODEBE, 0 EUROHABER
) gf;
IF NEW.bankingFees <> 0 THEN
INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id)
SELECT vNewBookEntry,NEW.received,IF(c.id = 1,6260000002,IF(CEE = 1,6260000003,6260000004)),cuenta_banco,NEW.concept,NEW.bankingFees,0,NEW.companyFk
FROM supplier s
JOIN country c ON s.countryFk = c.id
WHERE s.id = NEW.supplierFk;
END IF;
END IF;
SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received);
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-- --
-- Temporary table structure for view `payment__` -- Temporary table structure for view `payment__`
-- --
@ -33333,7 +33427,26 @@ CREATE TABLE `tag` (
CONSTRAINT `fgnTag` FOREIGN KEY (`ediTypeFk`) REFERENCES `edi`.`type` (`type_id`) ON DELETE SET NULL ON UPDATE CASCADE CONSTRAINT `fgnTag` FOREIGN KEY (`ediTypeFk`) REFERENCES `edi`.`type` (`type_id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos'; ) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Categorias para etiquetar los productos';
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `vn`.`tag_BEFORE_INSERT` BEFORE INSERT ON `tag` FOR EACH ROW
BEGIN
IF NEW.ediTypeFk IS NULL AND (SELECT COUNT(*) FROM tag WHERE `name` = NEW.`name`) THEN
CALL util.throw('name duplicated');
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
-- --
-- Table structure for table `tagAbbreviation` -- Table structure for table `tagAbbreviation`
@ -33622,7 +33735,7 @@ DELIMITER ;
/*!50003 SET character_set_results = utf8 */ ; /*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ; /*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;; DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `ticket_beforeUpdate` /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`%`*/ /*!50003 TRIGGER `ticket_beforeUpdate`
BEFORE UPDATE ON `ticket` BEFORE UPDATE ON `ticket`
@ -33668,6 +33781,9 @@ BEGIN
' a ', ' a ',
TIME(NEW.shipped)); TIME(NEW.shipped));
END IF; END IF;
INSERT IGNORE INTO zoneAgencyMode (agencyModeFk,zoneFk)
SELECT r.agencyModeFk, NEW.zoneFk FROM route r
WHERE r.id = NEW.routeFk;
END IF; END IF;
END */;; END */;;
DELIMITER ; DELIMITER ;
@ -36110,6 +36226,25 @@ CREATE TABLE `zone` (
) ENGINE=InnoDBDEFAULT CHARSET=utf8; ) ENGINE=InnoDBDEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `zoneAgencyMode`
--
DROP TABLE IF EXISTS `zoneAgencyMode`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `zoneAgencyMode` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`agencyModeFk` int(11) NOT NULL,
`zoneFk` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `zoneAgencyMode_UN` (`agencyModeFk`,`zoneFk`),
KEY `zoneAgencyMode_FK_1` (`zoneFk`),
CONSTRAINT `zoneAgencyMode_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `zoneAgencyMode_FK_1` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDBDEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='junta agencias con zonas para que al enrutar se puedan proponer tickets.';
/*!40101 SET character_set_client = @saved_cs_client */;
-- --
-- Table structure for table `zoneClosure` -- Table structure for table `zoneClosure`
-- --
@ -40362,7 +40497,7 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;; DELIMITER ;;
CREATE DEFINER=`root`@`%` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8 COLLATE utf8_unicode_ci CREATE DEFINER=`root`@`%` FUNCTION `ticketSplitCounter`(vTicketFk INT) RETURNS varchar(15) CHARSET utf8
READS SQL DATA READS SQL DATA
BEGIN BEGIN
DECLARE vSplitCounter VARCHAR(15); DECLARE vSplitCounter VARCHAR(15);
@ -40375,7 +40510,9 @@ BEGIN
LEFT JOIN vn2008.movement_label l ON l.Id_Movimiento = s.id LEFT JOIN vn2008.movement_label l ON l.Id_Movimiento = s.id
WHERE ticketFk = vTicketFk WHERE ticketFk = vTicketFk
) sub; ) sub;
RETURN vSplitCounter;
RETURN IFNULL(vSplitCounter,'--');
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -42906,7 +43043,7 @@ proc: BEGIN
FROM edi.warehouseFloramondo FROM edi.warehouseFloramondo
WHERE warehouseFk = vWarehouseFk; WHERE warehouseFk = vWarehouseFk;
CALL cache.visible_refresh(vVisibleCache, FALSE, vWarehouseFk); CALL cache.visible_refresh(vVisibleCache, TRUE, vWarehouseFk);
IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk) IF (NOT vIsLogifloraAllowed AND vVNHWarehouseFk != vWarehouseFk)
OR (vShipped > TIMESTAMPADD(DAY, vMaxLogifloraDays + vRangeLogifloraDays, CURDATE()) ) OR (vShipped > TIMESTAMPADD(DAY, vMaxLogifloraDays + vRangeLogifloraDays, CURDATE()) )
@ -65147,6 +65284,150 @@ BEGIN
CLOSE rsTicket; CLOSE rsTicket;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ticket_cloneWeekly__3` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `ticket_cloneWeekly__3`(IN vWeek INT)
BEGIN
DECLARE vIsDone BOOL;
DECLARE vLanding DATE;
DECLARE vShipment DATE;
DECLARE vWarehouse INT;
DECLARE vTicket INT;
DECLARE vWeekDay INT;
DECLARE vClient INT;
DECLARE vEmpresa INT;
DECLARE vConsignatario INT;
DECLARE vAgencia INT;
DECLARE vNewTicket INT;
DECLARE vYear INT;
DECLARE rsTicket CURSOR FOR
SELECT tt.Id_Ticket, weekDay, Id_Cliente, warehouse_id, empresa_id, Id_Consigna, Id_Agencia
FROM Tickets_turno tt
JOIN Tickets t ON tt.Id_Ticket = t.Id_Ticket;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
SET vYear = YEAR(CURDATE()) + IF(vWeek < WEEK(CURDATE()),1, 0);
OPEN rsTicket;
myLoop: LOOP
BEGIN
DECLARE vSalesPersonEmail VARCHAR(150);
DECLARE vMailSent BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vMessage TEXT;
/*DECLARE vError TEXT;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
BEGIN
GET DIAGNOSTICS CONDITION 1
vError = MESSAGE_TEXT;
END;*/
SET vIsDone = FALSE;
FETCH rsTicket INTO vTicket, vWeekDay, vClient, vWarehouse, vEmpresa, vConsignatario, vAgencia;
IF vIsDone THEN
LEAVE myLoop;
END IF;
SELECT date INTO vShipment
FROM `time`
WHERE `year` = vYear AND `week` = vWeek
AND WEEKDAY(date) = vWeekDay;
-- busca si el ticket ya ha sido clonado
IF (SELECT COUNT(*) FROM vn.ticket tOrig
JOIN vn.sale saleOrig ON tOrig.id = saleOrig.ticketFk
JOIN vn.saleCloned sc ON sc.saleOriginalFk = saleOrig.id
JOIN vn.sale saleClon ON saleClon.id = sc.saleClonedFk
JOIN vn.ticket tClon ON tClon.id = saleClon.ticketFk
WHERE tOrig.id = vTicket AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) > 0
THEN
ITERATE myLoop;
END IF;
CALL vn.zone_getLanded(vShipment, vConsignatario, vAgencia, vWarehouse,FALSE);
SELECT landed INTO vLanding from tmp.zoneGetLanded LIMIT 1;
IF (SELECT COUNT(*) FROM Agencias WHERE Id_Agencia = vAgencia AND Agencia LIKE '%turno%') THEN
SET vAgencia = NULL;
END IF;
CALL vn.ticketCreateWithoutZone(vClient, vShipment, vWarehouse, vEmpresa, vConsignatario, vAgencia, NULL, vLanding,account.userGetId(), vNewTicket);
IF (vLanding IS NULL) THEN
SELECT e.email INTO vSalesPersonEmail
FROM vn.client c
JOIN vn.worker sp ON sp.id = c.salesPersonFk
JOIN account.emailUser e ON e.userFk = sp.userFk
WHERE c.id = vClient;
SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicket,
' para el dia: ', vShipment);
SET vMessage = CONCAT('No se ha podido clonar el ticket ', vTicket,
' para el dia: ', vShipment,
' porque no hay una zona de envío disponible. Se ha creado el ticket: ', vNewTicket,
' pero ha que revisar las fechas y la agencia');
SELECT COUNT(*) INTO vMailSent
FROM vn.mail
WHERE sender = vSalesPersonEmail
AND subject = vSubject;
IF NOT vMailSent THEN
INSERT INTO vn2008.mail (`to`,`subject`,`text`)
VALUES (vSalesPersonEmail, vSubject, vMessage);
END IF;
CALL vn.ticketStateUpdate (vNewTicket, 'FIXING');
END IF;
INSERT INTO vn.sale (ticketFk, itemFk, concept, quantity, price, discount, priceFixed, isPriceFixed)
SELECT vNewTicket, saleOrig.itemFk , saleOrig.concept , saleOrig.quantity, saleOrig.price , saleOrig.discount, saleOrig.priceFixed, saleOrig.isPriceFixed
FROM vn.sale saleOrig
WHERE saleOrig.ticketFk = vTicket;
INSERT IGNORE INTO vn.saleCloned(saleOriginalFk, saleClonedFk)
SELECT saleOriginal.id, saleClon.id
FROM vn.sale saleOriginal
JOIN vn.sale saleClon ON saleOriginal.itemFk = saleClon.itemFk AND saleOriginal.quantity = saleClon.quantity
WHERE saleOriginal.ticketFk = vTicket AND saleClon.ticketFk = vNewTicket;
INSERT INTO Ordenes (orden,datorden,datticket,codvendedor,codcomprador,cantidad,preciomax,preu,id_article,id_cliente,comentario,
ok, total,datcompra,ko,id_movimiento)
SELECT o.orden,o.datorden,vShipment,o.codvendedor,o.codcomprador,o.cantidad,o.preciomax,o.preu,o.id_article,o.id_cliente,o.comentario,
o.ok, o.total,o.datcompra,o.ko,m2.Id_Movimiento
FROM Movimientos m JOIN Ordenes o ON o.Id_Movimiento = m.Id_Movimiento
JOIN Movimientos m2 ON m.Concepte = m2.Concepte AND m.Cantidad = m2.Cantidad AND m.Id_Article = m2.Id_Article
WHERE m.Id_Ticket = vTicket AND m2.Id_Ticket = vNewTicket;
INSERT INTO ticket_observation(Id_Ticket,observation_type_id,text) VALUES(vNewTicket,4,CONCAT('turno desde ticket: ',vTicket))
ON DUPLICATE KEY UPDATE text = CONCAT(ticket_observation.text,VALUES(text),' ');
INSERT INTO ticket_observation(Id_Ticket,observation_type_id,text) VALUES(vNewTicket,1,'ATENCION: Contiene lineas de TURNO')
ON DUPLICATE KEY UPDATE text = CONCAT(ticket_observation.text,VALUES(text),' ');
CALL vn.ticketCalculateClon(vNewTicket, vTicket);
END;
END LOOP;
CLOSE rsTicket;
END ;; END ;;
DELIMITER ; DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ; /*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -76215,4 +76496,4 @@ USE `vncontrol`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2021-01-05 9:34:47 -- Dump completed on 2021-01-08 10:00:22

View File

@ -59,7 +59,6 @@ IGNORETABLES=(
--ignore-table=vn.mail__ --ignore-table=vn.mail__
--ignore-table=vn.manaSpellers --ignore-table=vn.manaSpellers
--ignore-table=vn.outgoingInvoiceKk --ignore-table=vn.outgoingInvoiceKk
--ignore-table=vn.payment
--ignore-table=vn.paymentExchangeInsurance --ignore-table=vn.paymentExchangeInsurance
--ignore-table=vn.payrollCenter --ignore-table=vn.payrollCenter
--ignore-table=vn.plantpassport__ --ignore-table=vn.plantpassport__