feat: match bank transaction

This commit is contained in:
Ahmed Bouhuolia
2024-06-20 23:31:46 +02:00
parent b37002bea6
commit 738a84bb4b
20 changed files with 492 additions and 55 deletions

View File

@@ -102,6 +102,7 @@ export default class CashflowTransaction extends TenantModel {
const CashflowTransactionLine = require('models/CashflowTransactionLine');
const AccountTransaction = require('models/AccountTransaction');
const Account = require('models/Account');
const { MatchedBankTransaction } = require('models/MatchedBankTransaction');
return {
/**
@@ -158,6 +159,22 @@ export default class CashflowTransaction extends TenantModel {
to: 'accounts.id',
},
},
/**
* Cashflow transaction may belongs to matched bank transaction.
*/
matchedBankTransaction: {
relation: Model.HasManyRelation,
modelClass: MatchedBankTransaction,
join: {
from: 'cashflow_transactions.id',
to: 'matched_bank_transactions.referenceId',
},
filter: (query) => {
const referenceTypes = getCashflowAccountTransactionsTypes();
query.whereIn('reference_type', referenceTypes);
},
},
};
}
}