refactor: refs #6948 Bank to Accouting
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-03-05 10:25:23 +01:00
parent 05380df4f8
commit e0732835d0
21 changed files with 46 additions and 60 deletions

View File

@ -13,7 +13,7 @@
"AuthCode": {
"dataSource": "vn"
},
"Bank": {
"Accounting": {
"dataSource": "vn"
},
"Buyer": {

View File

@ -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",

View File

@ -47,7 +47,7 @@
},
"bank": {
"type": "belongsTo",
"model": "Bank",
"model": "Accounting",
"foreignKey": "bankFk"
},
"payMethod": {

View File

@ -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';

View File

@ -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

View File

@ -254,8 +254,8 @@ BEGIN
) 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
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

View File

@ -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,

View File

@ -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;

View File

@ -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 ;

View File

@ -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

View File

@ -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'

View File

@ -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,

View File

@ -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`

View File

@ -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'

View File

@ -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`

View File

@ -0,0 +1,2 @@
REVOKE SELECT ON TABLE vn.bank FROM administrative, hr;
GRANT SELECT ON TABLE vn.accounting TO administrative, hr;

View File

@ -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') {

View File

@ -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`);

View File

@ -60,7 +60,7 @@
},
"bank": {
"type": "belongsTo",
"model": "Bank",
"model": "Accounting",
"foreignKey": "bankFk"
},
"supplier": {

View File

@ -46,7 +46,7 @@
"relations": {
"bank": {
"type": "belongsTo",
"model": "Bank",
"model": "Accounting",
"foreignKey": "bankFk"
},
"worker": {

View File

@ -34,7 +34,7 @@
"relations": {
"bank": {
"type": "belongsTo",
"model": "Bank",
"model": "Accounting",
"foreignKey": "bankFk"
}
}