diff --git a/db/changes/225201/00-accountingMovements_add.sql b/db/changes/225201/00-accountingMovements_add.sql
new file mode 100644
index 000000000..12dc176bc
--- /dev/null
+++ b/db/changes/225201/00-accountingMovements_add.sql
@@ -0,0 +1,438 @@
+DROP PROCEDURE IF EXISTS `sage`.`accountingMovements_add`;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` PROCEDURE `sage`.`accountingMovements_add`(vYear INT, vCompanyFk INT)
+BEGIN
+/**
+ * Traslada la info de contabilidad generada en base a vn.XDiario a la tabla sage.movConta para poder ejecutar posteriormente el proceso de importación de datos de SQL Server
+ * Solo traladará los asientos marcados con el campo vn.XDiario.enlazadoSage = FALSE
+ * @vYear Año contable del que se quiere trasladar la información
+ * @vCompanyFk Empresa de la que se quiere trasladar datos
+ */
+ DECLARE vDatedFrom DATETIME;
+ DECLARE vDatedTo DATETIME;
+ DECLARE vDuaTransactionFk INT;
+ DECLARE vTaxImportFk INT;
+ DECLARE vTaxImportReducedFk INT;
+ DECLARE vTaxImportSuperReducedFk INT;
+ DECLARE vTransactionExportFk INT;
+ DECLARE vTransactionExportTaxFreeFk INT;
+ DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
+ DECLARE vInvoiceTypeInformativeCode VARCHAR(1);
+ DECLARE vCountryCanariasCode, vCountryCeutaMelillaCode VARCHAR(2) ;
+ DECLARE vBookEntries TEXT;
+
+ SELECT SiglaNacion INTO vCountryCanariasCode
+ FROM Naciones
+ WHERE Nacion ='ISLAS CANARIAS';
+
+ SELECT SiglaNacion INTO vCountryCeutaMelillaCode
+ FROM Naciones
+ WHERE Nacion ='CEUTA Y MELILLA';
+
+ SELECT CodigoTransaccion INTO vDuaTransactionFk
+ FROM TiposTransacciones
+ WHERE Transaccion = 'Import. bienes y serv. corrientes pdte. liquidar';
+
+ SELECT CodigoIva INTO vTaxImportFk
+ FROM TiposIva
+ WHERE Iva = 'IVA 21% importaciones';
+
+ SELECT CodigoIva INTO vTaxImportReducedFk
+ FROM TiposIva
+ WHERE Iva = 'IVA 10% importaciones';
+
+ SELECT CodigoIva INTO vTaxImportSuperReducedFk
+ FROM TiposIva
+ WHERE Iva = 'H.P. IVA Soportado Impor 4%';
+
+ SELECT CodigoTransaccion INTO vTransactionExportFk
+ FROM TiposTransacciones
+ WHERE Transaccion = 'Exportaciones definitivas';
+
+ SELECT CodigoTransaccion INTO vTransactionExportTaxFreeFk
+ FROM TiposTransacciones
+ WHERE Transaccion = 'Envíos definitivos a Canarias, Ceuta y Melilla';
+
+ SELECT codeSage INTO vInvoiceTypeInformativeCode
+ FROM invoiceType WHERE code ='informative';
+
+ SELECT CAST(CONCAT(vYear, '-01-01') AS DATETIME), util.dayEnd(CAST(CONCAT(vYear, '-12-31') AS DATE))
+ INTO vDatedFrom, vDatedTo;
+
+ TRUNCATE movContaIVA;
+
+ DELETE FROM movConta
+ WHERE enlazadoSage = FALSE
+ AND Asiento <> 1 ;
+
+ CALL clientSupplier_add(vCompanyFk);
+ CALL pgc_add(vCompanyFk);
+ CALL invoiceOut_manager(vYear, vCompanyFk);
+ CALL invoiceIn_manager(vYear, vCompanyFk);
+
+ INSERT INTO movConta(TipoEntrada,
+ Ejercicio,
+ CodigoEmpresa,
+ Asiento,
+ CargoAbono,
+ CodigoCuenta,
+ Contrapartida,
+ FechaAsiento,
+ Comentario,
+ ImporteAsiento,
+ NumeroPeriodo,
+ FechaGrabacion,
+ CodigoDivisa,
+ ImporteCambio,
+ ImporteDivisa,
+ FactorCambio,
+ IdProcesoIME,
+ TipoCarteraIME,
+ TipoAnaliticaIME,
+ StatusTraspasadoIME,
+ TipoImportacionIME,
+ Metalico347,
+ BaseIva1,
+ PorBaseCorrectora1,
+ PorIva1,
+ CuotaIva1,
+ PorRecargoEquivalencia1,
+ RecargoEquivalencia1,
+ CodigoTransaccion1,
+ BaseIva2,
+ PorBaseCorrectora2,
+ PorIva2,
+ CuotaIva2,
+ PorRecargoEquivalencia2,
+ RecargoEquivalencia2,
+ CodigoTransaccion2,
+ BaseIva3,
+ PorBaseCorrectora3,
+ PorIva3,
+ CuotaIva3,
+ PorRecargoEquivalencia3,
+ RecargoEquivalencia3,
+ CodigoTransaccion3,
+ BaseIva4,
+ PorBaseCorrectora4,
+ PorIva4,
+ CuotaIva4,
+ PorRecargoEquivalencia4,
+ RecargoEquivalencia4,
+ CodigoTransaccion4,
+ Año,
+ Serie,
+ Factura,
+ SuFacturaNo,
+ FechaFactura,
+ ImporteFactura,
+ TipoFactura,
+ CodigoCuentaFactura,
+ CifDni,
+ Nombre,
+ CodigoRetencion,
+ BaseRetencion,
+ PorRetencion,
+ ImporteRetencion,
+ SiglaNacion,
+ EjercicioFactura,
+ FechaOperacion,
+ Exclusion347,
+ MantenerAsiento,
+ ClaveOperacionFactura_,
+ TipoRectificativa,
+ FechaFacturaOriginal,
+ BaseImponibleOriginal,
+ CuotaIvaOriginal,
+ ClaseAbonoRectificativas,
+ RecargoEquivalenciaOriginal,
+ LibreA1,
+ CodigoIva1,
+ CodigoIva2,
+ CodigoIva3,
+ CodigoIva4,
+ IvaDeducible1,
+ IvaDeducible2,
+ IvaDeducible3,
+ IvaDeducible4,
+ Intracomunitaria
+ )
+ SELECT 'EN' TipoEntrada,
+ YEAR(x.FECHA) Ejercicio,
+ company_getCode(vCompanyFk) AS CodigoEmpresa,
+ x.ASIEN Asiento,
+ IF(EURODEBE <> 0 OR (EURODEBE = 0 AND EUROHABER IS NULL), 'D', 'H') CargoAbono,
+ x.SUBCTA CodigoCuenta,
+ x.CONTRA Contrapartida,
+ x.FECHA FechaAsiento,
+ x.CONCEPTO Comentario,
+ IF(x.EURODEBE, x.EURODEBE, x.EUROHABER) ImporteAsiento,
+ MONTH(x.FECHA) NumeroPeriodo,
+ IF(sub2.FECREGCON IS NULL, sub2.FECHA_EX, sub2.FECREGCON) FechaGrabacion,
+ IF(x.CAMBIO, IFNULL(mci.CodigoDivisa, sub3.code), '') CodigoDivisa,
+ x.CAMBIO ImporteCambio,
+ IFNULL(x.DEBEME, x.HABERME) ImporteDivisa,
+ IF(x.CAMBIO, TRUE, FALSE) FactorCambio,
+ NULL IdProcesoIME,
+ 0 TipoCarteraIME,
+ 0 TipoAnaliticaIME,
+ 0 StatusTraspasadoIME,
+ 0 TipoImportacionIME,
+ x.METAL Metalico347,
+ mci.BaseIva1,
+ mci.PorBaseCorrectora1,
+ mci.PorIva1,
+ mci.CuotaIva1,
+ mci.PorRecargoEquivalencia1,
+ mci.RecargoEquivalencia1,
+ mci.CodigoTransaccion1,
+ mci.BaseIva2,
+ mci.PorBaseCorrectora2,
+ mci.PorIva2,
+ mci.CuotaIva2,
+ mci.PorRecargoEquivalencia2,
+ mci.RecargoEquivalencia2,
+ mci.CodigoTransaccion2,
+ mci.BaseIva3,
+ mci.PorBaseCorrectora3,
+ mci.PorIva3,
+ mci.CuotaIva3,
+ mci.PorRecargoEquivalencia3,
+ mci.RecargoEquivalencia3,
+ mci.CodigoTransaccion3,
+ mci.BaseIva4,
+ mci.PorBaseCorrectora4,
+ mci.PorIva4,
+ mci.CuotaIva4,
+ mci.PorRecargoEquivalencia4,
+ mci.RecargoEquivalencia4,
+ mci.CodigoTransaccion4,
+ mci.Año,
+ mci.Serie,
+ mci.Factura,
+ mci.SuFacturaNo,
+ mci.FechaFactura,
+ mci.ImporteFactura,
+ mci.TipoFactura,
+ mci.CodigoCuentaFactura,
+ mci.CifDni,
+ mci.Nombre,
+ mci.CodigoRetencion,
+ mci.BaseRetencion,
+ mci.PorRetencion,
+ mci.ImporteRetencion,
+ mci.SiglaNacion,
+ mci.EjercicioFactura,
+ mci.FechaOperacion,
+ mci.Exclusion347,
+ TRUE,
+ mci.ClaveOperacionFactura,
+ mci.TipoRectificativa,
+ mci.FechaFacturaOriginal,
+ mci.BaseImponibleOriginal,
+ mci.CuotaIvaOriginal,
+ mci.ClaseAbonoRectificativas,
+ mci.RecargoEquivalenciaOriginal,
+ mci.LibreA1,
+ mci.CodigoIva1,
+ mci.CodigoIva2,
+ mci.CodigoIva3,
+ mci.CodigoIva4,
+ mci.IvaDeducible1,
+ mci.IvaDeducible2,
+ mci.IvaDeducible3,
+ mci.IvaDeducible4,
+ mci.Intracomunitaria
+ FROM vn.XDiario x
+ LEFT JOIN movContaIVA mci ON mci.id = x.id
+ LEFT JOIN (SELECT *
+ FROM (SELECT DISTINCT ASIEN, FECREGCON, FECHA_EX
+ FROM vn.XDiario
+ WHERE enlazadoSage = FALSE
+ ORDER BY ASIEN, FECREGCON DESC, FECHA_EX DESC
+ LIMIT 10000000000000000000
+ ) sub GROUP BY ASIEN
+ )sub2 ON sub2.ASIEN = x.ASIEN
+ LEFT JOIN ( SELECT DISTINCT(account),cu.code
+ FROM vn.bank b
+ 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
+ WHERE x.enlazadoSage = FALSE
+ AND x.empresa_id = vCompanyFk
+ AND x.FECHA BETWEEN vDatedFrom AND vDatedTo;
+
+-- Metálicos
+ UPDATE movConta m
+ JOIN (SELECT Asiento,
+ c.socialName name,
+ c.fi,
+ n.SiglaNacion,
+ m.CodigoCuenta,
+ m.Contrapartida
+ FROM movConta m
+ LEFT JOIN vn.client c ON c.id = IF(m.CargoAbono = 'H',
+ CAST(SUBSTRING(m.CodigoCuenta, 3, LENGTH(m.CodigoCuenta)) AS UNSIGNED),
+ CAST(SUBSTRING(m.Contrapartida, 3, LENGTH(m.Contrapartida)) AS UNSIGNED))
+ LEFT JOIN Naciones n ON n.countryFk = c.countryFk
+ WHERE m.Metalico347 = TRUE
+ AND m.enlazadoSage = FALSE
+ )sub ON m.Asiento = sub.Asiento
+ SET m.Metalico347 = TRUE,
+ m.TipoFactura = vInvoiceTypeInformativeCode,
+ m.CifDni = sub.fi,
+ m.Nombre = sub.name,
+ m.SiglaNacion = sub.SiglaNacion
+ WHERE m.enlazadoSage = FALSE;
+
+ UPDATE movConta m
+ SET m.Metalico347 = FALSE,
+ m.TipoFactura = ''
+ WHERE m.CargoAbono = 'D'
+ AND m.enlazadoSage = FALSE;
+
+-- Elimina cuentas de cliente/proveedor que no se utilizarán en la importación
+ DELETE cp
+ FROM clientesProveedores cp
+ LEFT JOIN movConta mc ON mc.codigoCuenta = cp.codigoCuenta
+ AND mc.enlazadoSage = FALSE
+ WHERE mc.codigoCuenta IS NULL;
+
+-- Elimina cuentas contables que no se utilizarán en la importación
+ DELETE pc
+ FROM planCuentasPGC pc
+ LEFT JOIN movConta mc ON mc.codigoCuenta = pc.codigoCuenta
+ AND mc.enlazadoSage = FALSE
+ WHERE mc.codigoCuenta IS NULL;
+
+-- DUAS
+ UPDATE movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ JOIN TiposIva ti ON ti.CodigoIva = x.IVA
+ JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8mb3_unicode_ci
+ SET mci.BaseIva1 = x.BASEEURO,
+ mci.PorIva1 = x.IVA,
+ mci.CuotaIva1 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2)),
+ mci.CodigoTransaccion1 = vDuaTransactionFk,
+ mci.CodigoIva1 = vTaxImportReducedFk,
+ mci.IvaDeducible1 = TRUE,
+ mci.FechaFacturaOriginal = x.FECHA_EX,
+ mci.SuFacturaNo = x.FACTURAEX,
+ mci.FechaOperacion = x.FECHA_OP,
+ mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
+ WHERE pm.description = 'HP Iva pendiente'
+ AND mci.enlazadoSage = FALSE
+ AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
+ AND ti.Iva = 'I.V.A. 10% Nacional';
+
+ UPDATE movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ JOIN TiposIva ti ON ti.CodigoIva = x.IVA
+ JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8mb3_unicode_ci
+ SET mci.BaseIva2 = x.BASEEURO ,
+ mci.PorIva2 = x.IVA,
+ mci.CuotaIva2 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)),
+ mci.CodigoTransaccion2 = vDuaTransactionFk ,
+ mci.CodigoIva2 = vTaxImportFk,
+ mci.IvaDeducible2 = TRUE,
+ mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
+ WHERE pm.description = 'HP Iva pendiente'
+ AND mci.enlazadoSage = FALSE
+ AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
+ AND ti.Iva = 'I.V.A. 21%';
+
+ UPDATE movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ JOIN TiposIva ti ON ti.CodigoIva = x.IVA
+ JOIN vn.pgcMaster pm ON pm.code = mci.CodigoCuenta COLLATE utf8mb3_unicode_ci
+ SET mci.BaseIva3 = x.BASEEURO ,
+ mci.PorIva3 = x.IVA,
+ mci.CuotaIva3 = CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10,2)),
+ mci.CodigoTransaccion3 = vDuaTransactionFk ,
+ mci.CodigoIva3 = vTaxImportSuperReducedFk,
+ mci.IvaDeducible3 = TRUE,
+ mci.ImporteFactura = mci.ImporteFactura + x.BASEEURO + CAST((x.IVA / 100) * x.BASEEURO AS DECIMAL(10, 2))
+ WHERE pm.description = 'HP Iva pendiente'
+ AND mci.enlazadoSage = FALSE
+ AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
+ AND ti.Iva = 'I.V.A. 4%';
+
+-- Rectificativas
+ UPDATE movConta mci
+ JOIN (SELECT x.ASIEN, x.FECHA_RT, x.SERIE_RT, x.FACTU_RT
+ FROM movConta mci
+ JOIN vn.XDiario x ON x.ASIEN = mci.Asiento
+ WHERE mci.TipoRectificativa > 0
+ AND mci.enlazadoSage = FALSE
+ AND x.FACTU_RT IS NOT NULL
+ GROUP BY x.ASIEN
+ ) sub ON sub.ASIEN = mci.Asiento
+ SET mci.EjercicioFacturaOriginal = YEAR(sub.FECHA_RT),
+ mci.SerieFacturaOriginal = sub.SERIE_RT,
+ mci.NumeroFacturaOriginal = sub.FACTU_RT
+ WHERE mci.TipoRectificativa > 0 AND
+ mci.enlazadoSage = FALSE ;
+
+-- Exportaciones Andorras y Canarias cambia TT (la cuenta es compartida)
+ UPDATE movConta mci
+ SET CodigoTransaccion1 = vTransactionExportTaxFreeFk,
+ CodigoTransaccion2 = IF(CodigoTransaccion2 = 0, 0, vTransactionExportTaxFreeFk),
+ CodigoTransaccion3 = IF(CodigoTransaccion3 = 0, 0, vTransactionExportTaxFreeFk),
+ CodigoTransaccion4 = IF(CodigoTransaccion4 = 0, 0, vTransactionExportTaxFreeFk)
+ WHERE enlazadoSage = FALSE
+ AND (CodigoTransaccion1 = vTransactionExportFk
+ OR CodigoTransaccion2 = vTransactionExportFk
+ OR CodigoTransaccion3 = vTransactionExportFk
+ OR CodigoTransaccion4 = vTransactionExportFk)
+ AND SiglaNacion IN (vCountryCanariasCode COLLATE utf8mb3_unicode_ci, vCountryCeutaMelillaCode COLLATE utf8mb3_unicode_ci);
+
+ UPDATE movConta mc
+ SET CodigoDivisa = 'USD',
+ FactorCambio = TRUE,
+ ImporteCambio = ABS( CAST( IF( ImporteDivisa <> 0 AND ImporteCambio = 0, ImporteAsiento / ImporteDivisa, ImporteCambio) AS DECIMAL( 10, 2)))
+ WHERE enlazadoSage = FALSE
+ AND (ImporteCambio <> 0 OR ImporteDivisa <> 0 OR FactorCambio);
+
+ UPDATE movConta mc
+ SET importeDivisa= -importeDivisa
+ WHERE enlazadoSage = FALSE
+ AND importeDivisa > 0
+ AND ImporteAsiento < 0;
+
+ -- Comprobación que los importes e ivas sean correctos, avisa vía CAU
+ SELECT GROUP_CONCAT(Asiento ORDER BY Asiento ASC SEPARATOR ',') INTO vBookEntries
+ FROM(SELECT sub.Asiento
+ FROM (SELECT mc.Asiento, SUM(mc.ImporteAsiento) amount
+ FROM movConta mc
+ WHERE mc.enlazadoSage = FALSE
+ GROUP BY mc.Asiento)sub
+ JOIN (SELECT x.ASIEN, SUM(IFNULL(x.EURODEBE,0) + IFNULL(x.EUROHABER,0)) amount
+ FROM vn.XDiario x
+ WHERE x.enlazadoSage = FALSE
+ GROUP BY ASIEN)sub2 ON sub2.ASIEN = sub.Asiento
+ WHERE sub.amount <> sub2.amount
+ UNION ALL
+ SELECT sub.Asiento
+ FROM (SELECT Asiento, SUM(BaseIva1 + BaseIva2 + BaseIva3 + BaseIva4) amountTaxableBase
+ FROM movConta
+ WHERE TipoFactura <> 'I'
+ AND enlazadoSage = FALSE
+ GROUP BY Asiento) sub
+ JOIN (SELECT ASIEN, SUM(BASEEURO) amountTaxableBase
+ FROM (SELECT ASIEN, SUM(BASEEURO) BASEEURO
+ FROM vn.XDiario
+ WHERE FACTURA
+ AND auxiliar <> '*'
+ AND enlazadoSage = FALSE
+ GROUP BY FACTURA, ASIEN)sub3
+ GROUP BY ASIEN) sub2 ON sub2.ASIEN = sub.Asiento
+ WHERE sub.amountTaxableBase<>sub2.amountTaxableBase
+ AND sub.amountTaxableBase/2 <> sub2.amountTaxableBase) sub;
+
+ IF vBookEntries IS NOT NULL THEN
+ SELECT util.notification_send ("book-entries-imported-incorrectly", CONCAT('{"bookEntries":"', vBookEntries,'"}'), null);
+ END IF;
+END$$
+DELIMITER ;
diff --git a/db/changes/225201/00-notification_send.sql b/db/changes/225201/00-notification_send.sql
new file mode 100644
index 000000000..a422cebac
--- /dev/null
+++ b/db/changes/225201/00-notification_send.sql
@@ -0,0 +1,24 @@
+DROP FUNCTION IF EXISTS `util`.`notification_send`;
+
+DELIMITER $$
+$$
+CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`notification_send`(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT) RETURNS int(11)
+ MODIFIES SQL DATA
+BEGIN
+/**
+ * Sends a notification.
+ *
+ * @param vNotificationName The notification name
+ * @param vParams The notification parameters formatted as JSON
+ * @param vAuthorFk The notification author or %NULL if there is no author
+ * @return The notification id
+ */
+
+ INSERT INTO notificationQueue
+ SET notificationFk = vNotificationName,
+ params = vParams,
+ authorFk = vAuthorFk;
+
+ RETURN LAST_INSERT_ID();
+END$$
+DELIMITER ;
diff --git a/db/changes/225201/00-utilNotification.sql b/db/changes/225201/00-utilNotification.sql
new file mode 100644
index 000000000..5c80b81b3
--- /dev/null
+++ b/db/changes/225201/00-utilNotification.sql
@@ -0,0 +1,4 @@
+INSERT INTO `util`.`notification` (id, name, description) VALUES(3, 'book-entries-imported-incorrectly', 'accounting entries exported incorrectly');
+INSERT INTO `util`.`notificationAcl` (notificationFk, roleFk) VALUES(3, 5);
+INSERT INTO `util`.`notificationSubscription` (notificationFk, userFk) VALUES(3, 19663);
+
diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql
index 485802a34..3eced92a4 100644
--- a/db/dump/fixtures.sql
+++ b/db/dump/fixtures.sql
@@ -2692,7 +2692,7 @@ INSERT INTO `util`.`notificationConfig`
INSERT INTO `util`.`notification` (`id`, `name`, `description`)
VALUES
(1, 'print-email', 'notification fixture one'),
- (3, 'supplier-pay-method-update', 'A supplier pay method has been updated');
+ (4, 'supplier-pay-method-update', 'A supplier pay method has been updated');
INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`)
VALUES
@@ -2707,7 +2707,8 @@ INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `autho
INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
VALUES
(1, 1109),
- (1, 1110);
+ (1, 1110),
+ (3, 1109);
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
VALUES
diff --git a/db/dump/structure.sql b/db/dump/structure.sql
index 9a77662ea..47fdd6d74 100644
--- a/db/dump/structure.sql
+++ b/db/dump/structure.sql
@@ -16340,6 +16340,185 @@ CREATE TABLE `invoiceType` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `movConta`
+--
+
+DROP TABLE IF EXISTS `movConta`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `movConta` (
+ `OrdenMovimientos` int(11) NOT NULL AUTO_INCREMENT,
+ `MovPosicion` varchar(64) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Ejercicio` smallint(6) NOT NULL,
+ `CodigoEmpresa` smallint(6) NOT NULL,
+ `Asiento` int(11) NOT NULL,
+ `CargoAbono` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoCuenta` varchar(15) CHARACTER SET utf8mb3 NOT NULL,
+ `Contrapartida` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `FechaAsiento` datetime NOT NULL,
+ `TipoDocumento` varchar(6) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `DocumentoConta` varchar(9) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Comentario` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `ImporteAsiento` decimal(28,10) NOT NULL,
+ `CodigoDiario` smallint(6) NOT NULL,
+ `CodigoCanal` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoActividad` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `FechaVencimiento` datetime DEFAULT NULL,
+ `NumeroPeriodo` smallint(6) NOT NULL,
+ `CodigoUsuario` smallint(6) NOT NULL,
+ `FechaGrabacion` datetime NOT NULL,
+ `TipoEntrada` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoDepartamento` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoSeccion` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoDivisa` varchar(3) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `ImporteCambio` decimal(28,10) NOT NULL,
+ `ImporteDivisa` decimal(28,10) NOT NULL,
+ `FactorCambio` decimal(28,10) NOT NULL,
+ `CodigoProyecto` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `LibreN1` int(11) NOT NULL,
+ `LibreN2` int(11) NOT NULL,
+ `LibreA1` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `LibreA2` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdDelegacion` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `MovCartera` varchar(64) COLLATE utf8mb3_unicode_ci DEFAULT NULL,
+ `IdProcesoIME` varchar(64) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `TipoCarteraIME` smallint(6) NOT NULL,
+ `TipoAnaliticaIME` smallint(6) NOT NULL,
+ `StatusTraspasadoIME` tinyint(4) NOT NULL,
+ `TipoImportacionIME` tinyint(4) NOT NULL,
+ `BaseIva1` decimal(28,10) NOT NULL,
+ `PorBaseCorrectora1` decimal(28,10) NOT NULL,
+ `PorIva1` decimal(28,10) NOT NULL,
+ `CuotaIva1` decimal(28,10) NOT NULL,
+ `PorRecargoEquivalencia1` decimal(28,10) NOT NULL,
+ `RecargoEquivalencia1` decimal(28,10) NOT NULL,
+ `CodigoTransaccion1` tinyint(4) NOT NULL,
+ `BaseIva2` decimal(28,10) NOT NULL,
+ `PorBaseCorrectora2` decimal(28,10) NOT NULL,
+ `PorIva2` decimal(28,10) NOT NULL,
+ `CuotaIva2` decimal(28,10) NOT NULL,
+ `PorRecargoEquivalencia2` decimal(28,10) NOT NULL,
+ `RecargoEquivalencia2` decimal(28,10) NOT NULL,
+ `CodigoTransaccion2` tinyint(4) NOT NULL,
+ `BaseIva3` decimal(28,10) NOT NULL,
+ `PorBaseCorrectora3` decimal(28,10) NOT NULL,
+ `PorIva3` decimal(28,10) NOT NULL,
+ `CuotaIva3` decimal(28,10) NOT NULL,
+ `PorRecargoEquivalencia3` decimal(28,10) NOT NULL,
+ `RecargoEquivalencia3` decimal(28,10) NOT NULL,
+ `CodigoTransaccion3` tinyint(4) NOT NULL,
+ `baseIva4` decimal(28,10) NOT NULL,
+ `PorBaseCorrectora4` decimal(28,10) NOT NULL,
+ `PorIva4` decimal(28,10) NOT NULL,
+ `CuotaIva4` decimal(28,10) NOT NULL,
+ `PorRecargoEquivalencia4` decimal(28,10) NOT NULL,
+ `RecargoEquivalencia4` decimal(28,10) NOT NULL,
+ `CodigoTransaccion4` tinyint(4) NOT NULL,
+ `Año` smallint(6) NOT NULL,
+ `Serie` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Factura` int(11) NOT NULL,
+ `SuFacturaNo` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `FechaFactura` datetime NOT NULL,
+ `ImporteFactura` decimal(28,10) NOT NULL,
+ `TipoFactura` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoCuentaFactura` varchar(15) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CifDni` varchar(13) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Nombre` varchar(35) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `CodigoRetencion` smallint(6) NOT NULL,
+ `BaseRetencion` decimal(28,10) NOT NULL,
+ `PorRetencion` decimal(28,10) NOT NULL,
+ `ImporteRetencion` decimal(28,10) NOT NULL,
+ `AbonoIva` smallint(6) NOT NULL,
+ `CodigoActividadF` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Intracomunitaria` smallint(6) NOT NULL,
+ `CodigoTerritorio` smallint(6) NOT NULL,
+ `SiglaNacion` varchar(2) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `RetencionInformativa` smallint(6) NOT NULL,
+ `EjercicioFacturaOriginal` smallint(6) NOT NULL,
+ `SerieFacturaOriginal` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `NumeroFacturaOriginal` int(11) NOT NULL,
+ `EjercicioFactura` smallint(6) NOT NULL,
+ `CobroPagoRetencion` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `FechaOperacion` datetime NOT NULL,
+ `Exclusion347` smallint(6) NOT NULL,
+ `MovIdentificadorIME` varchar(64) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Previsiones` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `MantenerAsiento` tinyint(4) NOT NULL,
+ `OrdenMovIME` smallint(6) NOT NULL,
+ `Metalico347` smallint(6) NOT NULL,
+ `ClaveOperacionFactura_` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `SerieAgrupacion_` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `NumeroFacturaInicial_` int(11) NOT NULL,
+ `NumeroFacturaFinal_` int(11) NOT NULL,
+ `IdAsientoExterno` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdDiarioExterno` varchar(10) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdFacturaExterno` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdMovimiento` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdCuadre` smallint(6) NOT NULL,
+ `FechaCuadre` datetime NOT NULL,
+ `TipoCuadre` varchar(4) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `AgrupacionCuadre` int(11) NOT NULL,
+ `StatusSaldo` smallint(6) NOT NULL,
+ `StatusConciliacion` smallint(6) NOT NULL,
+ `CodigoConciliacion` int(11) NOT NULL,
+ `FechaConciliacion` datetime NOT NULL,
+ `TipoConciliacion` smallint(6) NOT NULL,
+ `IndicadorContaBanco` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion3` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion4` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion5` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion6` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion7` varchar(40) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion8` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion9` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion2` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Descripcion1` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `Punteo1` smallint(6) NOT NULL,
+ `Punteo9` smallint(6) NOT NULL,
+ `Punteo8` smallint(6) NOT NULL,
+ `Punteo7` smallint(6) NOT NULL,
+ `Punteo6` smallint(6) NOT NULL,
+ `Punteo5` smallint(6) NOT NULL,
+ `Punteo4` smallint(6) NOT NULL,
+ `Punteo3` smallint(6) NOT NULL,
+ `Punteo2` smallint(6) NOT NULL,
+ `CodigoIva1` smallint(6) NOT NULL,
+ `CodigoIva2` smallint(6) NOT NULL,
+ `CodigoIva3` smallint(6) NOT NULL,
+ `CodigoIva4` smallint(6) NOT NULL,
+ `CriterioIva` tinyint(4) NOT NULL,
+ `FechaMaxVencimiento` datetime NOT NULL,
+ `TipoCriterioCaja` tinyint(4) NOT NULL,
+ `MovFacturaOrigenIME` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdFacturaExternoFinal` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdFacturaExternoInicial` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IdFacturaExternoOriginal` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `NumFacturasExternoAgrupacion` int(11) NOT NULL,
+ `CodigoMedioCobro` varchar(1) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `MedioCobro` varchar(31) COLLATE utf8mb3_unicode_ci NOT NULL,
+ `IvaDeducible1` smallint(6) NOT NULL DEFAULT 1,
+ `IvaDeducible2` smallint(6) NOT NULL DEFAULT 1,
+ `IvaDeducible3` smallint(6) NOT NULL DEFAULT 1,
+ `IvaDeducible4` smallint(6) NOT NULL DEFAULT 1,
+ `TipoRectificativa` smallint(6) NOT NULL,
+ `FechaFacturaOriginal` datetime NOT NULL,
+ `BaseImponibleOriginal` decimal(28,10) NOT NULL,
+ `CuotaIvaOriginal` decimal(28,10) NOT NULL,
+ `ClaseAbonoRectificativas` smallint(6) NOT NULL,
+ `RecargoEquivalenciaOriginal` decimal(28,10) NOT NULL,
+ `ObjetoFactura` text COLLATE utf8mb3_unicode_ci NOT NULL,
+ `enlazadoSage` tinyint(1) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`OrdenMovimientos`,`LibreN1`),
+ KEY `ix_movconta2` (`IdProcesoIME`),
+ KEY `CodigoCuenta` (`CodigoCuenta`),
+ KEY `movConta_Asiento` (`Asiento`),
+ KEY `ix_movconta` (`enlazadoSage`,`IdProcesoIME`),
+ KEY `movConta_IdProcesoIME` (`IdProcesoIME`),
+ KEY `movConta_Asiento2` (`Asiento`,`IdProcesoIME`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `movContaIVA`
--
diff --git a/db/export-structure.sh b/db/export-structure.sh
index f52819c54..a4fd4a8c6 100755
--- a/db/export-structure.sh
+++ b/db/export-structure.sh
@@ -84,7 +84,6 @@ IGNORETABLES=(
--ignore-table=vn.warehouseJoined
--ignore-table=vn.workerTeam__
--ignore-table=vn.XDiario__
- --ignore-table=sage.movConta
--ignore-table=sage.movContaCopia
)
mysqldump \
diff --git a/print/templates/email/book-entries-imported-incorrectly/assets/css/import.js b/print/templates/email/book-entries-imported-incorrectly/assets/css/import.js
new file mode 100644
index 000000000..1582b82c5
--- /dev/null
+++ b/print/templates/email/book-entries-imported-incorrectly/assets/css/import.js
@@ -0,0 +1,12 @@
+const Stylesheet = require(`vn-print/core/stylesheet`);
+
+const path = require('path');
+const vnPrintPath = path.resolve('print');
+
+module.exports = new Stylesheet([
+ `${vnPrintPath}/common/css/spacing.css`,
+ `${vnPrintPath}/common/css/misc.css`,
+ `${vnPrintPath}/common/css/layout.css`,
+ `${vnPrintPath}/common/css/email.css`])
+ .mergeStyles();
+
diff --git a/print/templates/email/book-entries-imported-incorrectly/book-entries-imported-incorrectly.html b/print/templates/email/book-entries-imported-incorrectly/book-entries-imported-incorrectly.html
new file mode 100644
index 000000000..044ae0312
--- /dev/null
+++ b/print/templates/email/book-entries-imported-incorrectly/book-entries-imported-incorrectly.html
@@ -0,0 +1,8 @@
+
+
+
diff --git a/print/templates/email/book-entries-imported-incorrectly/book-entries-imported-incorrectly.js b/print/templates/email/book-entries-imported-incorrectly/book-entries-imported-incorrectly.js
new file mode 100755
index 000000000..c8a427d30
--- /dev/null
+++ b/print/templates/email/book-entries-imported-incorrectly/book-entries-imported-incorrectly.js
@@ -0,0 +1,15 @@
+const Component = require(`vn-print/core/component`);
+const emailBody = new Component('email-body');
+
+module.exports = {
+ name: 'book-entries-imported-incorrectly',
+ components: {
+ 'email-body': emailBody.build(),
+ },
+ props: {
+ bookEntries: {
+ type: String,
+ required: true
+ }
+ }
+};
diff --git a/print/templates/email/book-entries-imported-incorrectly/locale/en.yml b/print/templates/email/book-entries-imported-incorrectly/locale/en.yml
new file mode 100644
index 000000000..30c5dd292
--- /dev/null
+++ b/print/templates/email/book-entries-imported-incorrectly/locale/en.yml
@@ -0,0 +1,5 @@
+subject: Book entries imported incorrectly
+title: Book entries imported incorrectly
+description: There are book entries that differ between the info from XDiario and the one that has been imported into Sage.
+ Book entries nº {0}
+ If you consider that it is due to a computer error, forward this email to cau@verdnatura.es
diff --git a/print/templates/email/book-entries-imported-incorrectly/locale/es.yml b/print/templates/email/book-entries-imported-incorrectly/locale/es.yml
new file mode 100644
index 000000000..f48ad0a3b
--- /dev/null
+++ b/print/templates/email/book-entries-imported-incorrectly/locale/es.yml
@@ -0,0 +1,5 @@
+subject: Asientos contables importados incorrectamente
+title: Asientos contables importados incorrectamente
+description: Existen asientos que difieren entre la info. de XDiario y la que se ha importado a Sage.
+ Asientos nº {0}
+ Si considera que es debido a un error informático, reenvíe este correo a cau@verdnatura.es