diff --git a/db/changes/10370-cucumber/00-acl.sql b/db/changes/10370-cucumber/00-acl.sql deleted file mode 100644 index 5d8d73e5a..000000000 --- a/db/changes/10370-cucumber/00-acl.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) - VALUES('InvoiceInDueDay', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10390-constitution/00-acl.sql b/db/changes/10390-constitution/00-acl.sql new file mode 100644 index 000000000..dedbd24f3 --- /dev/null +++ b/db/changes/10390-constitution/00-acl.sql @@ -0,0 +1,2 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES('InvoiceInDueDay', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10370-cucumber/00-booking.sql b/db/changes/10390-constitution/00-booking.sql similarity index 76% rename from db/changes/10370-cucumber/00-booking.sql rename to db/changes/10390-constitution/00-booking.sql index 2e86198cf..b89234139 100644 --- a/db/changes/10370-cucumber/00-booking.sql +++ b/db/changes/10390-constitution/00-booking.sql @@ -23,16 +23,16 @@ BEGIN -- Apunte del proveedor INSERT INTO XDiario(ASIEN, - FECHA, - SUBCTA, - EUROHABER, - CONCEPTO, - CAMBIO, - HABERME, - NFACTICK, - CLAVE, - empresa_id - ) + FECHA, + SUBCTA, + EUROHABER, + CONCEPTO, + CAMBIO, + HABERME, + NFACTICK, + CLAVE, + empresa_id + ) SELECT vBookNumber, n.bookEntried, @@ -49,18 +49,18 @@ BEGIN -- Línea de Gastos INSERT INTO XDiario ( ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - EUROHABER, - CONCEPTO, - CAMBIO, - DEBEME, - HABERME, - NFACTICK, - empresa_id - ) + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + EUROHABER, + CONCEPTO, + CAMBIO, + DEBEME, + HABERME, + NFACTICK, + empresa_id + ) SELECT vBookNumber ASIEN, n.bookEntried FECHA, IF(e.isWithheld , LPAD(RIGHT(s.supplierAccount,5),10,iit.expenceFk),iit.expenceFk) SUBCTA, @@ -83,34 +83,34 @@ BEGIN -- Líneas de IVA INSERT INTO XDiario( ASIEN, - FECHA, - SUBCTA, - CONTRA, - EURODEBE, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - TIPOOPE, - FECHA_EX, - FECHA_OP, - NFACTICK, - FACTURAEX, - L340, - LRECT349, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - FECREGCON, - empresa_id - ) + FECHA, + SUBCTA, + CONTRA, + EURODEBE, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + FECREGCON, + empresa_id + ) SELECT vBookNumber ASIEN, n.bookEntried FECHA, IF(n.expenceFkDeductible>0, n.expenceFkDeductible, ti.CuentaIvaSoportado) SUBCTA, @@ -146,11 +146,12 @@ BEGIN JOIN sage.TiposTransacciones ttr ON ttr.CodigoTransaccion = it.transactionTypeSageFk JOIN invoiceInSerial iis ON iis.code = n.serial JOIN (SELECT * FROM expence e GROUP BY e.id)e ON e.id = it.expenceFk - LEFT JOIN (SELECT eWithheld.id - FROM invoiceInTax hold - JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld - WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1 - ) eWithheld ON TRUE + LEFT JOIN ( + SELECT eWithheld.id + FROM invoiceInTax hold + JOIN expence eWithheld ON eWithheld.id = hold.expenceFk AND eWithheld.isWithheld + WHERE hold.invoiceInFk = vInvoiceInId LIMIT 1 + ) eWithheld ON TRUE WHERE it.taxTypeSageFk IS NOT NULL AND it.taxTypeSageFk NOT IN (22, 90) GROUP BY ti.PorcentajeIva, e.id; @@ -158,33 +159,33 @@ BEGIN -- Línea iva inversor sujeto pasivo INSERT INTO XDiario( ASIEN, - FECHA, - SUBCTA, - CONTRA, - EUROHABER, - BASEEURO, - CONCEPTO, - FACTURA, - IVA, - AUXILIAR, - SERIE, - TIPOOPE, - FECHA_EX, - FECHA_OP, - NFACTICK, - FACTURAEX, - L340, - LRECT349, - TIPOCLAVE, - TIPOEXENCI, - TIPONOSUJE, - TIPOFACT, - TIPORECTIF, - TERIDNIF, - TERNIF, - TERNOM, - empresa_id - ) + FECHA, + SUBCTA, + CONTRA, + EUROHABER, + BASEEURO, + CONCEPTO, + FACTURA, + IVA, + AUXILIAR, + SERIE, + TIPOOPE, + FECHA_EX, + FECHA_OP, + NFACTICK, + FACTURAEX, + L340, + LRECT349, + TIPOCLAVE, + TIPOEXENCI, + TIPONOSUJE, + TIPOFACT, + TIPORECTIF, + TERIDNIF, + TERNIF, + TERNOM, + empresa_id + ) SELECT vBookNumber ASIEN, n.bookEntried FECHA, ti.CuentaIvaRepercutido SUBCTA, @@ -224,7 +225,7 @@ BEGIN -- Actualización del registro original UPDATE invoiceIn ii - JOIN newInvoiceIn ni ON ii.id = ni.id + JOIN newInvoiceIn ni ON ii.id = ni.id SET ii.serialNumber = vSerialNumber, ii.isBooked = TRUE; @@ -232,7 +233,8 @@ BEGIN UPDATE XDiario SET EURODEBE = EURODEBE - (SELECT IF(ABS(sub.difference) = 0.01, sub.difference, 0) - FROM(SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference + FROM( + SELECT SUM(IFNULL(ROUND(EURODEBE, 2),0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) difference FROM XDiario WHERE ASIEN = vBookNumber )sub