diff --git a/back/model-config.json b/back/model-config.json index 3173ced42..b14fad3e6 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -13,7 +13,7 @@ "AuthCode": { "dataSource": "vn" }, - "Bank": { + "Accounting": { "dataSource": "vn" }, "Buyer": { diff --git a/back/models/bank.json b/back/models/accounting.json similarity index 85% rename from back/models/bank.json rename to back/models/accounting.json index da73b1141..979947471 100644 --- a/back/models/bank.json +++ b/back/models/accounting.json @@ -1,9 +1,9 @@ { - "name": "Bank", + "name": "Accounting", "base": "VnModel", "options": { "mysql": { - "table": "bank" + "table": "accounting" } }, "properties": { @@ -22,10 +22,7 @@ }, "accountingTypeFk": { "type": "number", - "required": true, - "mysql": { - "columnName": "cash" - } + "required": true }, "entityFk": { "type": "number", diff --git a/back/models/payment.json b/back/models/payment.json index 7eca36e4d..ed354969e 100644 --- a/back/models/payment.json +++ b/back/models/payment.json @@ -47,7 +47,7 @@ }, "bank": { "type": "belongsTo", - "model": "Bank", + "model": "Accounting", "foreignKey": "bankFk" }, "payMethod": { diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index 2cb25d135..2038f976a 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -22,7 +22,7 @@ BEGIN FROM vn.component WHERE code = 'manaClaim'; SELECT id INTO vManaBankId - FROM vn.bank WHERE code = 'mana'; + FROM vn.accounting WHERE code = 'mana'; SELECT id INTO vManaGreugeTypeId FROM vn.greugeType WHERE code = 'mana'; diff --git a/db/routines/hedera/procedures/tpvTransaction_undo.sql b/db/routines/hedera/procedures/tpvTransaction_undo.sql index ed72dd76d..f31ba6a80 100644 --- a/db/routines/hedera/procedures/tpvTransaction_undo.sql +++ b/db/routines/hedera/procedures/tpvTransaction_undo.sql @@ -54,7 +54,7 @@ p: BEGIN FROM vn.`client` WHERE id = vCustomer; SELECT account INTO vAccount - FROM vn.bank WHERE id = vBank; + FROM vn.accounting WHERE id = vBank; DELETE FROM vn.XDiario WHERE SUBCTA = vSubaccount diff --git a/db/routines/sage/procedures/accountingMovements_add.sql b/db/routines/sage/procedures/accountingMovements_add.sql index bd86e132d..575c63f6c 100644 --- a/db/routines/sage/procedures/accountingMovements_add.sql +++ b/db/routines/sage/procedures/accountingMovements_add.sql @@ -253,9 +253,9 @@ BEGIN 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 + LEFT JOIN ( SELECT DISTINCT(a.account),cu.code + FROM vn.accounting a + JOIN vn.currency cu ON cu.id = a.currencyFk WHERE cu.code <> 'EUR' -- no se informa cuando la divisa en EUR )sub3 ON sub3.account = x.SUBCTA WHERE x.enlazadoSage = FALSE diff --git a/db/routines/sage/procedures/pgc_add.sql b/db/routines/sage/procedures/pgc_add.sql index 6dd5bc72d..ebcb2d043 100644 --- a/db/routines/sage/procedures/pgc_add.sql +++ b/db/routines/sage/procedures/pgc_add.sql @@ -17,15 +17,15 @@ BEGIN e.id accountFk, UCASE(e.name), '' - FROM vn.expense e + FROM expense e UNION SELECT company_getCode(vCompanyFk), - b.account, - UCASE(b.bank), + a.account, + UCASE(a.bank), '' - FROM vn.bank b - WHERE b.isActive - AND b.`account` + FROM accounting a + WHERE a.isActive + AND a.`account` UNION SELECT CodigoEmpresa, CodigoCuenta, diff --git a/db/routines/vn/functions/till_new.sql b/db/routines/vn/functions/till_new.sql index cfca5945d..24f4f2b79 100644 --- a/db/routines/vn/functions/till_new.sql +++ b/db/routines/vn/functions/till_new.sql @@ -34,7 +34,7 @@ BEGIN -- Inserta los asientos contables SELECT account INTO vAccount - FROM bank WHERE id = vBank; + FROM accounting WHERE id = vBank; SELECT accountingAccount INTO vSubaccount FROM `client` WHERE id = vClient; diff --git a/db/routines/vn/procedures/bankPolicy_notifyExpired.sql b/db/routines/vn/procedures/bankPolicy_notifyExpired.sql index 52b747659..61216938d 100644 --- a/db/routines/vn/procedures/bankPolicy_notifyExpired.sql +++ b/db/routines/vn/procedures/bankPolicy_notifyExpired.sql @@ -10,13 +10,11 @@ BEGIN INSERT INTO mail (receiver,replyTo,subject,body) SELECT 'administracion@verdnatura.es' receiver, 'noreply@verdnatura.es' replyTo, - CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') subject, - CONCAT('El seguro de la poliza ',b.id,' ',b.bank,' ha finalizado.') body - FROM vn.bankPolicy bp - LEFT JOIN vn.supplier s - ON s.id = bp.supplierFk - LEFT JOIN vn.bank b - ON b.id = bp.accountingFk + CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') subject, + CONCAT('El seguro de la poliza ',a.id,' ',a.bank,' ha finalizado.') body + FROM bankPolicy bp + LEFT JOIN supplier s ON s.id = bp.supplierFk + LEFT JOIN accounting a ON a.id = bp.accountingFk WHERE bp.insuranceExpired = util.VN_CURDATE(); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/client_getMana.sql b/db/routines/vn/procedures/client_getMana.sql index 99b00c6df..f5bb5747d 100644 --- a/db/routines/vn/procedures/client_getMana.sql +++ b/db/routines/vn/procedures/client_getMana.sql @@ -39,7 +39,8 @@ BEGIN FROM receipt r JOIN `client` c ON c.id = r.clientFk JOIN tmp.client tc ON tc.id = c.id - JOIN bank b ON r.bankFk = b.id AND b.code = 'mana' + JOIN accounting a ON r.bankFk = a.id + AND a.code = 'mana' WHERE r.payed > vFromDated AND r.payed <= util.VN_CURDATE() UNION ALL diff --git a/db/routines/vn/procedures/supplier_statement.sql b/db/routines/vn/procedures/supplier_statement.sql index 406286e9d..a03a7770c 100644 --- a/db/routines/vn/procedures/supplier_statement.sql +++ b/db/routines/vn/procedures/supplier_statement.sql @@ -94,7 +94,7 @@ BEGIN 'payment' FROM payment p LEFT JOIN currency c ON c.id = p.currencyFk - LEFT JOIN bank b ON b.id = p.bankFk + LEFT JOIN accounting a ON a.id = p.bankFk LEFT JOIN payMethod pm ON pm.id = p.payMethodFk LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id WHERE p.received > '2014-12-31' diff --git a/db/routines/vn/triggers/payment_beforeInsert.sql b/db/routines/vn/triggers/payment_beforeInsert.sql index 6a28a1382..1b343712f 100644 --- a/db/routines/vn/triggers/payment_beforeInsert.sql +++ b/db/routines/vn/triggers/payment_beforeInsert.sql @@ -10,21 +10,21 @@ BEGIN -- 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 - FROM vn.bank b - JOIN vn.accountingType at2 ON at2.id = b.cash - WHERE b.id = NEW.bankFk; + FROM accounting a + JOIN accountingType at2 ON at2.id = a.accountingTypeFk + WHERE a.id = NEW.bankFk; IF bolCASH THEN SELECT account INTO cuenta_banco - FROM bank + FROM accounting WHERE id = NEW.bankFk; SELECT account INTO cuenta_proveedor FROM supplier WHERE id = NEW.supplierFk; - CALL vn.ledger_next(vNewBookEntry); + CALL ledger_next(vNewBookEntry); INSERT INTO XDiario ( ASIEN, FECHA, diff --git a/db/routines/vn/views/bank.sql b/db/routines/vn/views/bank.sql deleted file mode 100644 index fa0d9a4f0..000000000 --- a/db/routines/vn/views/bank.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`bank` -AS SELECT `a`.`id` AS `id`, - `a`.`bank` AS `bank`, - `a`.`account` AS `account`, - `a`.`accountingTypeFk` AS `cash`, - `a`.`entityFk` AS `entityFk`, - `a`.`isActive` AS `isActive`, - `a`.`currencyFk` AS `currencyFk`, - `a`.`code` AS `code` -FROM `vn`.`accounting` `a` diff --git a/db/routines/vn/views/exchangeInsuranceOut.sql b/db/routines/vn/views/exchangeInsuranceOut.sql index f93b65331..5c41dbb24 100644 --- a/db/routines/vn/views/exchangeInsuranceOut.sql +++ b/db/routines/vn/views/exchangeInsuranceOut.sql @@ -7,9 +7,9 @@ AS SELECT `p`.`received` AS `received`, FROM ( ( `vn`.`payment` `p` - JOIN `vn`.`bank` `b` ON(`b`.`id` = `p`.`bankFk`) + JOIN `vn`.`accounting` `a` ON(`a`.`id` = `p`.`bankFk`) ) - JOIN `vn`.`accountingType` `at2` ON(`at2`.`id` = `b`.`cash`) + JOIN `vn`.`accountingType` `at2` ON(`at2`.`id` = `a`.`accountingTypeFk`) ) WHERE `p`.`currencyFk` = 2 AND `at2`.`code` = 'wireTransfer' diff --git a/db/routines/vn2008/views/Bancos.sql b/db/routines/vn2008/views/Bancos.sql index 0c6f8d1bd..6e850f365 100644 --- a/db/routines/vn2008/views/Bancos.sql +++ b/db/routines/vn2008/views/Bancos.sql @@ -1,11 +1,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`Bancos` -AS SELECT `b`.`id` AS `Id_Banco`, - `b`.`bank` AS `Banco`, - `b`.`account` AS `Cuenta`, - `b`.`cash` AS `cash`, - `b`.`entityFk` AS `entity_id`, - `b`.`isActive` AS `activo`, - `b`.`currencyFk` AS `currencyFk` -FROM `vn`.`bank` `b` +AS SELECT `a`.`id` AS `Id_Banco`, + `a`.`bank` AS `Banco`, + `a`.`account` AS `Cuenta`, + `a`.`accountingTypeFk` AS `cash`, + `a`.`entityFk` AS `entity_id`, + `a`.`isActive` AS `activo`, + `a`.`currencyFk` AS `currencyFk` +FROM `vn`.`accounting` `a` diff --git a/db/versions/10928-orangeEucalyptus/00-firstScript.sql b/db/versions/10928-orangeEucalyptus/00-firstScript.sql new file mode 100644 index 000000000..58d3605de --- /dev/null +++ b/db/versions/10928-orangeEucalyptus/00-firstScript.sql @@ -0,0 +1,5 @@ +REVOKE SELECT ON TABLE vn.bank FROM administrative, hr; +GRANT SELECT ON TABLE vn.accounting TO administrative, hr; +UPDATE salix.ACL + SET model = 'Accounting' + WHERE model = 'Bank'; diff --git a/front/salix/components/user-popover/index.html b/front/salix/components/user-popover/index.html index 0fa6800c5..06a4af1e0 100644 --- a/front/salix/components/user-popover/index.html +++ b/front/salix/components/user-popover/index.html @@ -58,7 +58,7 @@ label="Local bank" id="localBank" ng-model="$ctrl.localBankFk" - url="Banks" + url="Accountings" select-fields="['id','bank']" show-field="bank" order="id" diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index b70b9bbe0..debdaf066 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -69,7 +69,7 @@ module.exports = function(Self) { delete args.ctx; // Remove unwanted properties const originalClient = await models.Client.findById(args.clientFk, null, myOptions); - const bank = await models.Bank.findById(args.bankFk, null, myOptions); + const bank = await models.Accounting.findById(args.bankFk, null, myOptions); const accountingType = await models.AccountingType.findById(bank.accountingTypeFk, null, myOptions); if (accountingType.code == 'compensation') { diff --git a/modules/client/back/methods/receipt/balanceCompensationEmail.js b/modules/client/back/methods/receipt/balanceCompensationEmail.js index afae5dabc..994d5124a 100644 --- a/modules/client/back/methods/receipt/balanceCompensationEmail.js +++ b/modules/client/back/methods/receipt/balanceCompensationEmail.js @@ -28,7 +28,7 @@ module.exports = Self => { const models = Self.app.models; const receipt = await models.Receipt.findById(id, {fields: ['clientFk', 'bankFk']}); - const bank = await models.Bank.findById(receipt.bankFk); + const bank = await models.Accounting.findById(receipt.bankFk); if (!bank) throw new UserError(`Receipt's bank was not found`); diff --git a/modules/client/back/models/receipt.json b/modules/client/back/models/receipt.json index da7879df9..6ade21ac5 100644 --- a/modules/client/back/models/receipt.json +++ b/modules/client/back/models/receipt.json @@ -60,7 +60,7 @@ }, "bank": { "type": "belongsTo", - "model": "Bank", + "model": "Accounting", "foreignKey": "bankFk" }, "supplier": { diff --git a/modules/client/back/models/till.json b/modules/client/back/models/till.json index 4b86e50e2..6677b27d4 100644 --- a/modules/client/back/models/till.json +++ b/modules/client/back/models/till.json @@ -46,7 +46,7 @@ "relations": { "bank": { "type": "belongsTo", - "model": "Bank", + "model": "Accounting", "foreignKey": "bankFk" }, "worker": { diff --git a/modules/client/front/balance/create/index.html b/modules/client/front/balance/create/index.html index 27b182c9a..25789b01a 100644 --- a/modules/client/front/balance/create/index.html +++ b/modules/client/front/balance/create/index.html @@ -29,7 +29,7 @@