7430_devToTest #2490
|
@ -1,5 +1,6 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsiento INT,
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(
|
||||||
|
vBookNumber INT,
|
||||||
vDated DATE,
|
vDated DATE,
|
||||||
vSubaccount VARCHAR(12),
|
vSubaccount VARCHAR(12),
|
||||||
vAccount VARCHAR(12),
|
vAccount VARCHAR(12),
|
||||||
|
@ -12,33 +13,33 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`xdiario_new`(vAsient
|
||||||
vVat DOUBLE,
|
vVat DOUBLE,
|
||||||
vRe DOUBLE,
|
vRe DOUBLE,
|
||||||
vAux TINYINT,
|
vAux TINYINT,
|
||||||
vCompany INT
|
vCompanyFk INT
|
||||||
)
|
)
|
||||||
RETURNS int(11)
|
RETURNS int(11)
|
||||||
NOT DETERMINISTIC
|
NOT DETERMINISTIC
|
||||||
NO SQL
|
NO SQL
|
||||||
BEGIN
|
BEGIN
|
||||||
IF vAsiento IS NULL THEN
|
IF vBookNumber IS NULL THEN
|
||||||
CALL vn.ledger_next(vAsiento);
|
CALL ledger_next(YEAR(vDated), vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO XDiario
|
INSERT INTO XDiario
|
||||||
SET ASIEN = vAsiento,
|
SET ASIEN = vBookNumber,
|
||||||
FECHA = vDated,
|
FECHA = vDated,
|
||||||
SUBCTA = vSubaccount,
|
SUBCTA = vSubaccount,
|
||||||
CONTRA = vAccount,
|
CONTRA = vAccount,
|
||||||
CONCEPTO = vConcept,
|
CONCEPTO = vConcept,
|
||||||
EURODEBE = vDebit,
|
EURODEBE = vDebit,
|
||||||
EUROHABER = vCredit,
|
EUROHABER = vCredit,
|
||||||
BASEEURO = vEuro,
|
BASEEURO = vEuro,
|
||||||
SERIE = vSerie,
|
SERIE = vSerie,
|
||||||
FACTURA = vInvoice,
|
FACTURA = vInvoice,
|
||||||
IVA = vVat,
|
IVA = vVat,
|
||||||
RECEQUIV = vRe,
|
RECEQUIV = vRe,
|
||||||
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
AUXILIAR = IF(vAux = FALSE, NULL, '*'),
|
||||||
MONEDAUSO = 2,
|
MONEDAUSO = 2,
|
||||||
empresa_id = vCompany;
|
empresa_id = vCompanyFk;
|
||||||
|
|
||||||
RETURN vAsiento;
|
RETURN vBookNumber;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -2,127 +2,121 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaTaxBooking`(vDuaFk INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vBookNumber INT;
|
DECLARE vBookNumber INT;
|
||||||
DECLARE vBookDated DATE;
|
DECLARE vBookDated DATE;
|
||||||
DECLARE vDiff DECIMAL(10,2);
|
DECLARE vDiff DECIMAL(10,2);
|
||||||
DECLARE vApunte BIGINT;
|
DECLARE vApunte BIGINT;
|
||||||
|
|
||||||
SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE()) INTO vBookNumber, vBookDated
|
SELECT ASIEN, IFNULL(bookEntried, util.VN_CURDATE())
|
||||||
FROM dua
|
INTO vBookNumber, vBookDated
|
||||||
|
FROM dua
|
||||||
WHERE id = vDuaFk;
|
WHERE id = vDuaFk;
|
||||||
|
|
||||||
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
||||||
CALL ledger_next(vBookNumber);
|
CALL ledger_next(YEAR(vBookDated), vBookNumber);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- Apunte de la aduana
|
-- Apunte de la aduana
|
||||||
|
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
EUROHABER,
|
EUROHABER,
|
||||||
SERIE,
|
SERIE,
|
||||||
empresa_id,
|
empresa_id,
|
||||||
CLAVE,
|
CLAVE,
|
||||||
FACTURA)
|
FACTURA)
|
||||||
|
SELECT vBookNumber,
|
||||||
|
d.bookEntried,
|
||||||
|
'4700000999',
|
||||||
|
CONCAT('DUA ',d.`code`),
|
||||||
|
sum(dt.base * dt.rate / 100) EUROHABER,
|
||||||
|
'R',
|
||||||
|
d.companyFk,
|
||||||
|
vDuaFk,
|
||||||
|
vDuaFk
|
||||||
|
FROM duaTax dt
|
||||||
|
JOIN dua d ON d.id = dt.duaFk
|
||||||
|
WHERE dt.duaFk = vDuaFk;
|
||||||
|
|
||||||
SELECT
|
-- Apuntes por tipo de IVA y proveedor
|
||||||
vBookNumber,
|
INSERT INTO XDiario(
|
||||||
d.bookEntried,
|
ASIEN,
|
||||||
'4700000999',
|
FECHA,
|
||||||
CONCAT('DUA ',d.`code`),
|
SUBCTA,
|
||||||
sum(dt.base * dt.rate / 100) EUROHABER,
|
CONTRA,
|
||||||
'R',
|
EURODEBE,
|
||||||
d.companyFk,
|
BASEEURO,
|
||||||
vDuaFk,
|
CONCEPTO,
|
||||||
vDuaFk
|
FACTURA,
|
||||||
FROM duaTax dt
|
IVA,
|
||||||
JOIN dua d ON d.id = dt.duaFk
|
AUXILIAR,
|
||||||
WHERE dt.duaFk = vDuaFk;
|
SERIE,
|
||||||
|
FECHA_EX,
|
||||||
-- Apuntes por tipo de IVA y proveedor
|
FECHA_OP,
|
||||||
|
FACTURAEX,
|
||||||
INSERT INTO XDiario(
|
NFACTICK,
|
||||||
ASIEN,
|
L340,
|
||||||
FECHA,
|
LDIFADUAN,
|
||||||
SUBCTA,
|
TIPOCLAVE,
|
||||||
CONTRA,
|
TIPOEXENCI,
|
||||||
EURODEBE,
|
TIPONOSUJE,
|
||||||
BASEEURO,
|
TIPOFACT,
|
||||||
CONCEPTO,
|
TIPORECTIF,
|
||||||
FACTURA,
|
TERIDNIF,
|
||||||
IVA,
|
TERNIF,
|
||||||
AUXILIAR,
|
TERNOM,
|
||||||
SERIE,
|
empresa_id,
|
||||||
FECHA_EX,
|
FECREGCON)
|
||||||
FECHA_OP,
|
SELECT vBookNumber ASIEN,
|
||||||
FACTURAEX,
|
vBookDated FECHA,
|
||||||
NFACTICK,
|
tr.account SUBCTA,
|
||||||
L340,
|
'4330002067' CONTRA,
|
||||||
LDIFADUAN,
|
SUM(dt.tax) EURODEBE,
|
||||||
TIPOCLAVE,
|
SUM(dt.base) BASEEURO,
|
||||||
TIPOEXENCI,
|
CONCAT('DUA nº',d.code) CONCEPTO,
|
||||||
TIPONOSUJE,
|
d.id FACTURA,
|
||||||
TIPOFACT,
|
dt.rate IVA,
|
||||||
TIPORECTIF,
|
'*' AUXILIAR,
|
||||||
TERIDNIF,
|
'D' SERIE,
|
||||||
TERNIF,
|
d.issued FECHA_EX,
|
||||||
TERNOM,
|
d.operated FECHA_OP,
|
||||||
empresa_id,
|
d.code FACTURAEX,
|
||||||
FECREGCON
|
1 NFACTICK,
|
||||||
)
|
1 L340,
|
||||||
|
TRUE LDIFADUAN,
|
||||||
SELECT
|
1 TIPOCLAVE,
|
||||||
vBookNumber ASIEN,
|
1 TIPOEXENCI,
|
||||||
vBookDated FECHA,
|
1 TIPONOSUJE,
|
||||||
tr.account SUBCTA,
|
5 TIPOFACT,
|
||||||
'4330002067' CONTRA,
|
1 TIPORECTIF,
|
||||||
sum(dt.tax) EURODEBE,
|
IF(c.code = 'ES', 1, 4) TERIDNIF,
|
||||||
sum(dt.base) BASEEURO,
|
s.nif TERNIF,
|
||||||
CONCAT('DUA nº',d.code) CONCEPTO,
|
s.name TERNOM,
|
||||||
d.id FACTURA,
|
d.companyFk,
|
||||||
dt.rate IVA,
|
d.booked FECREGCON
|
||||||
'*' AUXILIAR,
|
FROM duaTax dt
|
||||||
'D' SERIE,
|
JOIN dua d ON dt.duaFk = d.id
|
||||||
d.issued FECHA_EX,
|
JOIN (SELECT account, rate
|
||||||
d.operated FECHA_OP,
|
FROM
|
||||||
d.code FACTURAEX,
|
(SELECT rate, account
|
||||||
1 NFACTICK,
|
FROM invoiceInTaxBookingAccount ta
|
||||||
1 L340,
|
WHERE ta.effectived <= vBookDated
|
||||||
TRUE LDIFADUAN,
|
AND taxAreaFk = 'WORLD'
|
||||||
1 TIPOCLAVE,
|
ORDER BY ta.effectived DESC
|
||||||
1 TIPOEXENCI,
|
LIMIT 10000000000000000000
|
||||||
1 TIPONOSUJE,
|
) tba
|
||||||
5 TIPOFACT,
|
GROUP BY rate
|
||||||
1 TIPORECTIF,
|
|
||||||
IF(c.code = 'ES', 1, 4) TERIDNIF,
|
|
||||||
s.nif TERNIF,
|
|
||||||
s.name TERNOM,
|
|
||||||
d.companyFk,
|
|
||||||
d.booked FECREGCON
|
|
||||||
FROM duaTax dt
|
|
||||||
JOIN dua d ON dt.duaFk = d.id
|
|
||||||
JOIN (SELECT account, rate
|
|
||||||
FROM
|
|
||||||
(SELECT rate, account
|
|
||||||
FROM invoiceInTaxBookingAccount ta
|
|
||||||
WHERE ta.effectived <= vBookDated
|
|
||||||
AND taxAreaFk = 'WORLD'
|
|
||||||
ORDER BY ta.effectived DESC
|
|
||||||
LIMIT 10000000000000000000
|
|
||||||
) tba
|
|
||||||
GROUP BY rate
|
|
||||||
) tr ON tr.rate = dt.rate
|
) tr ON tr.rate = dt.rate
|
||||||
JOIN supplier s ON s.id = d.companyFk
|
JOIN supplier s ON s.id = d.companyFk
|
||||||
JOIN country c ON c.id = s.countryFk
|
JOIN country c ON c.id = s.countryFk
|
||||||
WHERE d.id = vDuaFk
|
WHERE d.id = vDuaFk
|
||||||
GROUP BY dt.rate;
|
GROUP BY dt.rate;
|
||||||
|
|
||||||
SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte
|
SELECT SUM(EURODEBE) -SUM(EUROHABER), MAX(id) INTO vDiff, vApunte
|
||||||
FROM XDiario
|
FROM XDiario
|
||||||
WHERE ASIEN = vBookNumber;
|
WHERE ASIEN = vBookNumber;
|
||||||
|
|
||||||
UPDATE XDiario
|
UPDATE XDiario
|
||||||
SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA,
|
SET BASEEURO = 100 * (EURODEBE - vDiff) / IVA,
|
||||||
EURODEBE = EURODEBE - vDiff
|
EURODEBE = EURODEBE - vDiff
|
||||||
|
@ -131,6 +125,5 @@ BEGIN
|
||||||
UPDATE dua
|
UPDATE dua
|
||||||
SET ASIEN = vBookNumber
|
SET ASIEN = vBookNumber
|
||||||
WHERE id = vDuaFk;
|
WHERE id = vDuaFk;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -2,6 +2,7 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_booking`(vSelf INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE vBookNumber INT;
|
DECLARE vBookNumber INT;
|
||||||
|
DECLARE vFiscalYear INT;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
|
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
@ -56,7 +57,8 @@ BEGIN
|
||||||
LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva
|
LEFT JOIN sage.taxType tt ON tt.id = ti.CodigoIva
|
||||||
WHERE ii.id = vSelf;
|
WHERE ii.id = vSelf;
|
||||||
|
|
||||||
CALL vn.ledger_next(vBookNumber);
|
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
||||||
|
CALL ledger_next(vFiscalYear, vBookNumber);
|
||||||
|
|
||||||
-- Apunte del proveedor
|
-- Apunte del proveedor
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceOutBooking`(IN vInvoice INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
/* Asienta la factura emitida
|
/**
|
||||||
*
|
* Asienta una factura emitida
|
||||||
* param vInvoice factura_id
|
*
|
||||||
*/
|
* @param vInvoice Id invoiceOut
|
||||||
|
*/
|
||||||
DECLARE vBookNumber INT;
|
DECLARE vBookNumber INT;
|
||||||
DECLARE vExpenseConcept VARCHAR(50);
|
DECLARE vExpenseConcept VARCHAR(50);
|
||||||
DECLARE vSpainCountryFk INT;
|
DECLARE vSpainCountryFk INT;
|
||||||
DECLARE vOldBookNumber INT;
|
DECLARE vOldBookNumber INT;
|
||||||
|
DECLARE vFiscalYear INT;
|
||||||
|
|
||||||
SELECT id INTO vSpainCountryFk FROM country WHERE code = 'ES';
|
SELECT id INTO vSpainCountryFk FROM country WHERE `code` = 'ES';
|
||||||
|
|
||||||
SELECT ASIEN
|
SELECT ASIEN
|
||||||
INTO vOldBookNumber
|
INTO vOldBookNumber
|
||||||
FROM XDiario x
|
FROM XDiario x
|
||||||
JOIN invoiceOut io ON io.id = vInvoice
|
JOIN invoiceOut io ON io.id = vInvoice
|
||||||
WHERE x.SERIE = io.serial
|
WHERE x.SERIE = io.serial
|
||||||
AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1)
|
AND x.FACTURA = RIGHT(io.ref, LENGTH(io.ref) - 1)
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
|
|
||||||
|
@ -26,140 +28,133 @@ BEGIN
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS rs;
|
DROP TEMPORARY TABLE IF EXISTS rs;
|
||||||
CREATE TEMPORARY TABLE rs
|
CREATE TEMPORARY TABLE rs
|
||||||
SELECT
|
SELECT c.accountingAccount clientBookingAccount,
|
||||||
c.accountingAccount AS clientBookingAccount,
|
io.amount totalAmount,
|
||||||
io.amount as totalAmount,
|
CONCAT('n/fra ', io.ref) simpleConcept,
|
||||||
CONCAT('n/fra ', io.ref) as simpleConcept,
|
CONCAT('n/fra ', io.ref, ' ', c.name) Concept,
|
||||||
CONCAT('n/fra ', io.ref, ' ', c.name) as Concept,
|
io.serial SERIE,
|
||||||
io.serial AS SERIE,
|
io.issued FECHA_EX,
|
||||||
io.issued AS FECHA_EX,
|
io.issued FECHA_OP,
|
||||||
io.issued AS FECHA_OP,
|
io.issued FECHA,
|
||||||
io.issued AS FECHA,
|
1 NFACTICK,
|
||||||
1 AS NFACTICK,
|
IF(ic.correctingFk,'D','') TIPOOPE,
|
||||||
IF(ic.correctingFk,'D','') AS TIPOOPE,
|
io.siiTrascendencyInvoiceOutFk TIPOCLAVE,
|
||||||
io.siiTrascendencyInvoiceOutFk AS TIPOCLAVE,
|
io.cplusTaxBreakFk TIPOEXENCI,
|
||||||
io.cplusTaxBreakFk AS TIPOEXENCI,
|
io.cplusSubjectOpFk TIPONOSUJE,
|
||||||
io.cplusSubjectOpFk AS TIPONOSUJE,
|
io.siiTypeInvoiceOutFk TIPOFACT,
|
||||||
io.siiTypeInvoiceOutFk AS TIPOFACT,
|
ic.cplusRectificationTypeFk TIPORECTIF,
|
||||||
ic.cplusRectificationTypeFk AS TIPORECTIF,
|
|
||||||
io.companyFk,
|
io.companyFk,
|
||||||
RIGHT(io.ref, LENGTH(io.ref) - 1) AS invoiceNum,
|
RIGHT(io.ref, LENGTH(io.ref) - 1) invoiceNum,
|
||||||
IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) AS TERIDNIF,
|
IF(c.countryFk = vSpainCountryFk, vSpainCountryFk, IF(ct.isUeeMember,2,4)) TERIDNIF,
|
||||||
CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) AS TERNIF,
|
CONCAT(IF(ct.isUeeMember AND c.countryFk <> vSpainCountryFk,ct.code,''),c.fi) TERNIF,
|
||||||
c.socialName AS TERNOM,
|
c.socialName TERNOM,
|
||||||
ior.serial AS SERIE_RT,
|
ior.serial SERIE_RT,
|
||||||
RIGHT(ior.ref, LENGTH(ior.ref) - 1) AS FACTU_RT,
|
RIGHT(ior.ref, LENGTH(ior.ref) - 1) FACTU_RT,
|
||||||
ior.issued AS FECHA_RT,
|
ior.issued FECHA_RT,
|
||||||
IF(ior.id,TRUE,FALSE) AS RECTIFICA
|
IF(ior.id,TRUE,FALSE) RECTIFICA
|
||||||
FROM invoiceOut io
|
FROM invoiceOut io
|
||||||
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
JOIN invoiceOutSerial ios ON ios.code = io.serial
|
||||||
JOIN client c ON c.id = io.clientFk
|
JOIN client c ON c.id = io.clientFk
|
||||||
JOIN country ct ON ct.id = c.countryFk
|
JOIN country ct ON ct.id = c.countryFk
|
||||||
LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id
|
LEFT JOIN invoiceCorrection ic ON ic.correctingFk = io.id
|
||||||
LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk
|
LEFT JOIN invoiceOut ior ON ior.id = ic.correctedFk
|
||||||
WHERE io.id = vInvoice;
|
WHERE io.id = vInvoice;
|
||||||
|
|
||||||
CALL vn.ledger_next(vBookNumber);
|
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
||||||
|
CALL ledger_next(vFiscalYear, vBookNumber);
|
||||||
-- Linea del cliente
|
-- Linea del cliente
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
EURODEBE,
|
EURODEBE,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
FECHA_EX,
|
FECHA_EX,
|
||||||
FECHA_OP,
|
FECHA_OP,
|
||||||
empresa_id
|
empresa_id)
|
||||||
)
|
SELECT vBookNumber,
|
||||||
SELECT
|
|
||||||
vBookNumber AS ASIEN,
|
|
||||||
rs.FECHA,
|
rs.FECHA,
|
||||||
rs.clientBookingAccount AS SUBCTA,
|
rs.clientBookingAccount,
|
||||||
rs.totalAmount AS EURODEBE,
|
rs.totalAmount,
|
||||||
rs.simpleConcept AS CONCEPTO,
|
rs.simpleConcept,
|
||||||
rs.FECHA_EX,
|
rs.FECHA_EX,
|
||||||
rs.FECHA_OP,
|
rs.FECHA_OP,
|
||||||
rs.companyFk AS empresa_id
|
rs.companyFk
|
||||||
FROM rs;
|
FROM rs;
|
||||||
|
|
||||||
-- Lineas de gasto
|
-- Lineas de gasto
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
CONTRA,
|
CONTRA,
|
||||||
EUROHABER,
|
EUROHABER,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
FECHA_EX,
|
FECHA_EX,
|
||||||
FECHA_OP,
|
FECHA_OP,
|
||||||
empresa_id
|
empresa_id)
|
||||||
)
|
SELECT vBookNumber,
|
||||||
SELECT
|
rs.FECHA,
|
||||||
vBookNumber AS ASIEN,
|
ioe.expenseFk,
|
||||||
rs.FECHA,
|
rs.clientBookingAccount,
|
||||||
ioe.expenseFk AS SUBCTA,
|
ioe.amount,
|
||||||
rs.clientBookingAccount AS CONTRA,
|
rs.Concept,
|
||||||
ioe.amount AS EUROHABER,
|
rs.FECHA_EX,
|
||||||
rs.Concept AS CONCEPTO,
|
rs.FECHA_OP,
|
||||||
rs.FECHA_EX,
|
rs.companyFk
|
||||||
rs.FECHA_OP,
|
FROM rs
|
||||||
rs.companyFk AS empresa_id
|
JOIN invoiceOutExpense ioe
|
||||||
FROM rs
|
WHERE ioe.invoiceOutFk = vInvoice;
|
||||||
JOIN invoiceOutExpense ioe
|
|
||||||
WHERE ioe.invoiceOutFk = vInvoice;
|
|
||||||
|
|
||||||
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
SELECT GROUP_CONCAT(`name` SEPARATOR ',')
|
||||||
INTO vExpenseConcept
|
INTO vExpenseConcept
|
||||||
FROM expense e
|
FROM expense e
|
||||||
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
JOIN invoiceOutExpense ioe ON ioe.expenseFk = e.id
|
||||||
WHERE ioe.invoiceOutFk = vInvoice;
|
WHERE ioe.invoiceOutFk = vInvoice;
|
||||||
|
|
||||||
-- Lineas de IVA
|
-- Lineas de IVA
|
||||||
INSERT INTO XDiario(
|
INSERT INTO XDiario(
|
||||||
ASIEN,
|
ASIEN,
|
||||||
FECHA,
|
FECHA,
|
||||||
SUBCTA,
|
SUBCTA,
|
||||||
CONTRA,
|
CONTRA,
|
||||||
EUROHABER,
|
EUROHABER,
|
||||||
BASEEURO,
|
BASEEURO,
|
||||||
CONCEPTO,
|
CONCEPTO,
|
||||||
FACTURA,
|
FACTURA,
|
||||||
IVA,
|
IVA,
|
||||||
RECEQUIV,
|
RECEQUIV,
|
||||||
AUXILIAR,
|
AUXILIAR,
|
||||||
SERIE,
|
SERIE,
|
||||||
SERIE_RT,
|
SERIE_RT,
|
||||||
FACTU_RT,
|
FACTU_RT,
|
||||||
RECTIFICA,
|
RECTIFICA,
|
||||||
FECHA_RT,
|
FECHA_RT,
|
||||||
FECHA_OP,
|
FECHA_OP,
|
||||||
FECHA_EX,
|
FECHA_EX,
|
||||||
TIPOOPE,
|
TIPOOPE,
|
||||||
NFACTICK,
|
NFACTICK,
|
||||||
TERIDNIF,
|
TERIDNIF,
|
||||||
TERNIF,
|
TERNIF,
|
||||||
TERNOM,
|
TERNOM,
|
||||||
L340,
|
L340,
|
||||||
TIPOCLAVE,
|
TIPOCLAVE,
|
||||||
TIPOEXENCI,
|
TIPOEXENCI,
|
||||||
TIPONOSUJE,
|
TIPONOSUJE,
|
||||||
TIPOFACT,
|
TIPOFACT,
|
||||||
TIPORECTIF,
|
TIPORECTIF,
|
||||||
empresa_id
|
empresa_id)
|
||||||
)
|
SELECT vBookNumber ASIEN,
|
||||||
SELECT
|
|
||||||
vBookNumber AS ASIEN,
|
|
||||||
rs.FECHA,
|
rs.FECHA,
|
||||||
iot.pgcFk AS SUBCTA,
|
iot.pgcFk SUBCTA,
|
||||||
rs.clientBookingAccount AS CONTRA,
|
rs.clientBookingAccount CONTRA,
|
||||||
iot.vat AS EUROHABER,
|
iot.vat EUROHABER,
|
||||||
iot.taxableBase AS BASEEURO,
|
iot.taxableBase BASEEURO,
|
||||||
CONCAT(vExpenseConcept,' : ',rs.Concept) AS CONCEPTO,
|
CONCAT(vExpenseConcept,' : ',rs.Concept) CONCEPTO,
|
||||||
rs.invoiceNum AS FACTURA,
|
rs.invoiceNum FACTURA,
|
||||||
IF(pe2.equFk,0,pgc.rate) AS IVA,
|
IF(pe2.equFk,0,pgc.rate) IVA,
|
||||||
IF(pe2.equFk,0,pgce.rate) AS RECEQUIV,
|
IF(pe2.equFk,0,pgce.rate) RECEQUIV,
|
||||||
IF(pgc.mod347,'','*') AS AUXILIAR,
|
IF(pgc.mod347,'','*') AUXILIAR,
|
||||||
rs.SERIE,
|
rs.SERIE,
|
||||||
rs.SERIE_RT,
|
rs.SERIE_RT,
|
||||||
rs.FACTU_RT,
|
rs.FACTU_RT,
|
||||||
|
@ -168,27 +163,27 @@ BEGIN
|
||||||
rs.FECHA_OP,
|
rs.FECHA_OP,
|
||||||
rs.FECHA_EX,
|
rs.FECHA_EX,
|
||||||
rs.TIPOOPE,
|
rs.TIPOOPE,
|
||||||
rs.NFACTICK,
|
rs.NFACTICK,
|
||||||
rs.TERIDNIF,
|
rs.TERIDNIF,
|
||||||
rs.TERNIF,
|
rs.TERNIF,
|
||||||
rs.TERNOM,
|
rs.TERNOM,
|
||||||
pgc.mod340 AS L340,
|
pgc.mod340 L340,
|
||||||
pgc.siiTrascendencyInvoiceOutFk AS TIPOCLAVE,
|
pgc.siiTrascendencyInvoiceOutFk TIPOCLAVE,
|
||||||
pgc.cplusTaxBreakFk as TIPOEXENCI,
|
pgc.cplusTaxBreakFk TIPOEXENCI,
|
||||||
rs.TIPONOSUJE,
|
rs.TIPONOSUJE,
|
||||||
rs.TIPOFACT,
|
rs.TIPOFACT,
|
||||||
rs.TIPORECTIF,
|
rs.TIPORECTIF,
|
||||||
rs.companyFk AS empresa_id
|
rs.companyFk
|
||||||
FROM rs
|
FROM rs
|
||||||
JOIN invoiceOutTax iot
|
JOIN invoiceOutTax iot
|
||||||
JOIN pgc ON pgc.code = iot.pgcFk
|
JOIN pgc ON pgc.code = iot.pgcFk
|
||||||
LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado
|
LEFT JOIN pgcEqu pe ON pe.vatFk = iot.pgcFk -- --------------- Comprueba si la linea es de iva con rec.equiv. asociado
|
||||||
LEFT JOIN pgc pgce ON pgce.code = pe.equFk
|
LEFT JOIN pgc pgce ON pgce.code = pe.equFk
|
||||||
LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv.
|
LEFT JOIN pgcEqu pe2 ON pe2.equFk = iot.pgcFk -- --------------- Comprueba si la linea es de rec.equiv.
|
||||||
WHERE iot.invoiceOutFk = vInvoice;
|
WHERE iot.invoiceOutFk = vInvoice;
|
||||||
|
|
||||||
UPDATE invoiceOut
|
UPDATE invoiceOut
|
||||||
SET booked = util.VN_CURDATE()
|
SET booked = util.VN_CURDATE()
|
||||||
WHERE id = vInvoice;
|
WHERE id = vInvoice;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(vDated DATE, vCompensationAccount VARCHAR(10) , vBankFk VARCHAR(10), vConcept VARCHAR(255), vAmount DECIMAL(10,2), vCompanyFk INT, vOriginalAccount VARCHAR(10))
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_doCompensation`(
|
||||||
|
vDated DATE,
|
||||||
|
vCompensationAccount VARCHAR(10),
|
||||||
|
vBankFk VARCHAR(10),
|
||||||
|
vConcept VARCHAR(255),
|
||||||
|
vAmount DECIMAL(10,2),
|
||||||
|
vCompanyFk INT,
|
||||||
|
vOriginalAccount VARCHAR(10)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Compensa un pago o un recibo insertando en contabilidad
|
* Compensa un pago o un recibo insertando en contabilidad
|
||||||
|
@ -9,29 +17,31 @@ BEGIN
|
||||||
* @param vBankFk banco de la compensacion
|
* @param vBankFk banco de la compensacion
|
||||||
* @param vConcept descripcion
|
* @param vConcept descripcion
|
||||||
* @param vAmount cantidad que se compensa
|
* @param vAmount cantidad que se compensa
|
||||||
* @param vCompany empresa
|
* @param vCompanyFk empresa
|
||||||
* @param vOriginalAccount cuenta contable desde la cual se compensa
|
* @param vOriginalAccount cuenta contable desde la cual se compensa
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
DECLARE vNewBookEntry INT;
|
DECLARE vNewBookEntry INT;
|
||||||
DECLARE vIsClientCompensation INT;
|
DECLARE vIsClientCompensation INT;
|
||||||
DECLARE vClientFk INT;
|
DECLARE vClientFk INT;
|
||||||
DECLARE vSupplierFk INT;
|
DECLARE vSupplierFk INT;
|
||||||
DECLARE vIsOriginalAClient BOOL;
|
DECLARE vIsOriginalAClient BOOL;
|
||||||
DECLARE vPayMethodCompensation INT;
|
DECLARE vPayMethodCompensation INT;
|
||||||
|
|
||||||
CALL ledger_next(vNewBookEntry);
|
|
||||||
|
|
||||||
SELECT COUNT(id) INTO vIsOriginalAClient FROM client WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
|
CALL ledger_next(YEAR(vDated), vNewBookEntry);
|
||||||
|
|
||||||
|
SELECT COUNT(id) INTO vIsOriginalAClient
|
||||||
|
FROM client
|
||||||
|
WHERE accountingAccount LIKE vOriginalAccount COLLATE utf8_general_ci;
|
||||||
|
|
||||||
SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
|
SELECT id, COUNT(id) INTO vClientFk, vIsClientCompensation
|
||||||
FROM client
|
FROM client
|
||||||
WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci;
|
WHERE accountingAccount LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||||
|
|
||||||
SET @vAmount1:= 0.0;
|
SET @vAmount1:= 0.0;
|
||||||
SET @vAmount2:= 0.0;
|
SET @vAmount2:= 0.0;
|
||||||
|
|
||||||
INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
|
INSERT INTO XDiario (ASIEN, FECHA, SUBCTA, CONTRA, CONCEPTO, EURODEBE, EUROHABER, empresa_id)
|
||||||
VALUES ( vNewBookEntry,
|
VALUES ( vNewBookEntry,
|
||||||
vDated,
|
vDated,
|
||||||
vOriginalAccount,
|
vOriginalAccount,
|
||||||
|
@ -49,30 +59,51 @@ BEGIN
|
||||||
),
|
),
|
||||||
vCompanyFk
|
vCompanyFk
|
||||||
),
|
),
|
||||||
( vNewBookEntry,
|
( vNewBookEntry,
|
||||||
vDated,
|
vDated,
|
||||||
vCompensationAccount,
|
vCompensationAccount,
|
||||||
vOriginalAccount,
|
vOriginalAccount,
|
||||||
vConcept,
|
vConcept,
|
||||||
@vAmount2,
|
@vAmount2,
|
||||||
@vAmount1,
|
@vAmount1,
|
||||||
vCompanyFk);
|
vCompanyFk);
|
||||||
|
|
||||||
IF vIsClientCompensation THEN
|
IF vIsClientCompensation THEN
|
||||||
IF vIsOriginalAClient THEN
|
IF vIsOriginalAClient THEN
|
||||||
SET vAmount = -vAmount;
|
SET vAmount = -vAmount;
|
||||||
END IF;
|
END IF;
|
||||||
INSERT INTO receipt(invoiceFk, amountPaid, payed, bankFk, companyFk, clientFk, isConciliate)
|
|
||||||
VALUES (vConcept, vAmount, vDated, vBankFk, vCompanyFk, vClientFk, TRUE);
|
INSERT INTO receipt
|
||||||
ELSE
|
SET invoiceFk = vConcept,
|
||||||
IF NOT vIsOriginalAClient THEN
|
amountPaid = vAmount,
|
||||||
SET vAmount = -vAmount;
|
payed = vDated,
|
||||||
END IF;
|
bankFk = vBankFk,
|
||||||
SELECT id INTO vSupplierFk FROM supplier WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
|
companyFk = vCompanyFk,
|
||||||
SELECT id INTO vPayMethodCompensation FROM payMethod WHERE `code` = 'compensation';
|
clientFk = vClientFk,
|
||||||
|
isConciliate = TRUE;
|
||||||
INSERT INTO payment (received, dueDated, supplierFk, amount, bankFk, payMethodFk, concept, companyFk, isConciliated)
|
ELSE
|
||||||
VALUES(vDated, vDated, vSupplierFk, vAmount, vBankFk, vPayMethodCompensation, vConcept, vCompanyFk, TRUE);
|
IF NOT vIsOriginalAClient THEN
|
||||||
END IF;
|
SET vAmount = -vAmount;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT id INTO vSupplierFk
|
||||||
|
FROM supplier
|
||||||
|
WHERE `account` LIKE vCompensationAccount COLLATE utf8_general_ci;
|
||||||
|
|
||||||
|
SELECT id INTO vPayMethodCompensation
|
||||||
|
FROM payMethod
|
||||||
|
WHERE `code` = 'compensation';
|
||||||
|
|
||||||
|
INSERT INTO payment
|
||||||
|
SET received = vDated,
|
||||||
|
dueDated = vDated,
|
||||||
|
supplierFk = vSupplierFk,
|
||||||
|
amount = vAmount,
|
||||||
|
bankFk = vBankFk,
|
||||||
|
payMethodFk = vPayMethodCompensation,
|
||||||
|
concept = vConcept,
|
||||||
|
companyFk = vCompanyFk,
|
||||||
|
isConciliated = TRUE;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(OUT vNewBookEntry INT)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(OUT vNewBookEntry INT)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
UPDATE ledgerCompany
|
||||||
UPDATE vn.ledgerConfig SET lastBookEntry = LAST_INSERT_ID(lastBookEntry + 1);
|
SET bookEntry = LAST_INSERT_ID(bookEntry + 1)
|
||||||
SET vNewBookEntry = LAST_INSERT_ID();
|
WHERE fiscalYear = vFiscalYear;
|
||||||
|
|
||||||
|
SET vNewBookEntry = LAST_INSERT_ID();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,92 +3,93 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`payment_beforeInsert`
|
||||||
BEFORE INSERT ON `payment`
|
BEFORE INSERT ON `payment`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE cuenta_banco,cuenta_proveedor DOUBLE;
|
DECLARE vBankAccount DOUBLE;
|
||||||
DECLARE vNewBookEntry INT;
|
DECLARE vSupplierAccount DOUBLE;
|
||||||
DECLARE bolCASH BOOLEAN;
|
DECLARE vNewBookEntry INT;
|
||||||
DECLARE isSupplierActive BOOLEAN;
|
DECLARE vIsCash BOOLEAN;
|
||||||
|
DECLARE vIsSupplierActive BOOLEAN;
|
||||||
|
|
||||||
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
|
-- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH
|
||||||
SELECT (at2.code = 'cash') INTO bolCASH
|
SELECT (at2.code = 'cash') INTO vIsCash
|
||||||
FROM accounting a
|
FROM accounting a
|
||||||
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
JOIN accountingType at2 ON at2.id = a.accountingTypeFk
|
||||||
WHERE a.id = NEW.bankFk;
|
WHERE a.id = NEW.bankFk;
|
||||||
|
|
||||||
IF bolCASH THEN
|
IF vIsCash THEN
|
||||||
|
SELECT account INTO vBankAccount
|
||||||
SELECT account INTO cuenta_banco
|
FROM accounting
|
||||||
FROM accounting
|
WHERE id = NEW.bankFk;
|
||||||
WHERE id = NEW.bankFk;
|
|
||||||
|
|
||||||
SELECT account INTO cuenta_proveedor
|
|
||||||
FROM supplier
|
|
||||||
WHERE id = NEW.supplierFk;
|
|
||||||
|
|
||||||
CALL ledger_next(vNewBookEntry);
|
SELECT account INTO vSupplierAccount
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
SELECT isActive INTO isSupplierActive
|
|
||||||
FROM supplier
|
FROM supplier
|
||||||
WHERE id = NEW.supplierFk;
|
WHERE id = NEW.supplierFk;
|
||||||
|
|
||||||
IF isSupplierActive = FALSE THEN
|
CALL ledger_next(YEAR(NEW.received), NEW.companyFk, vNewBookEntry);
|
||||||
CALL util.throw('SUPPLIER_INACTIVE');
|
|
||||||
END IF;
|
INSERT INTO XDiario (
|
||||||
|
ASIEN,
|
||||||
IF ISNULL(NEW.workerFk) THEN
|
FECHA,
|
||||||
SET NEW.workerFk = account.myUser_getId();
|
SUBCTA,
|
||||||
END IF;
|
CONTRA,
|
||||||
|
CONCEPTO,
|
||||||
END$$
|
EURODEBE,
|
||||||
|
EUROHABER,
|
||||||
|
empresa_id)
|
||||||
|
SELECT vNewBookEntry,
|
||||||
|
NEW.received,
|
||||||
|
SUBCTA,
|
||||||
|
CONTRA,
|
||||||
|
NEW.concept,
|
||||||
|
EURODEBE,
|
||||||
|
EUROHABER,
|
||||||
|
NEW.companyFk
|
||||||
|
FROM (SELECT vBankAccount SUBCTA,
|
||||||
|
vSupplierAccount CONTRA,
|
||||||
|
0 EURODEBE,
|
||||||
|
NEW.amount + NEW.bankingFees EUROHABER
|
||||||
|
UNION ALL
|
||||||
|
SELECT vSupplierAccount SUBCTA,
|
||||||
|
vBankAccount 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)),
|
||||||
|
vBankAccount,
|
||||||
|
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);
|
||||||
|
|
||||||
|
SELECT isActive INTO vIsSupplierActive
|
||||||
|
FROM supplier
|
||||||
|
WHERE id = NEW.supplierFk;
|
||||||
|
|
||||||
|
IF vIsSupplierActive = FALSE THEN
|
||||||
|
CALL util.throw('SUPPLIER_INACTIVE');
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF ISNULL(NEW.workerFk) THEN
|
||||||
|
SET NEW.workerFk = account.myUser_getId();
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
CREATE OR REPLACE TABLE vn.ledgerCompany (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`fiscalYear` int(10) unsigned NOT NULL COMMENT 'Año del ejercicio contable',
|
||||||
|
`bookEntry` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Contador asiento contable',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `ledgerCompany_unique` (`fiscalYear`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci
|
||||||
|
COMMENT='Contador para asientos contables';
|
||||||
|
|
Loading…
Reference in New Issue