feat: recognize the syncd bank transactions

This commit is contained in:
Ahmed Bouhuolia
2024-06-23 18:49:46 +02:00
parent 589b29bbdd
commit 8dc2b18707
12 changed files with 150 additions and 29 deletions

View File

@@ -50,14 +50,21 @@ export class RecognizeTranasctionsService {
* @param {number} tenantId -
* @param {Knex.Transaction} trx -
*/
public async recognizeTransactions(tenantId: number, trx?: Knex.Transaction) {
public async recognizeTransactions(
tenantId: number,
batch: string = '',
trx?: Knex.Transaction
) {
const { UncategorizedCashflowTransaction, BankRule } =
this.tenancy.models(tenantId);
const uncategorizedTranasctions =
await UncategorizedCashflowTransaction.query()
.where('recognized_transaction_id', null)
.where('categorized', false);
await UncategorizedCashflowTransaction.query().onBuild((query) => {
query.where('recognized_transaction_id', null);
query.where('categorized', false);
if (batch) query.where('batch', batch);
});
const bankRules = await BankRule.query().withGraphFetched('conditions');
const bankRulesByAccountId = transformToMapBy(
@@ -93,8 +100,8 @@ export class RecognizeTranasctionsService {
}
/**
*
* @param {number} uncategorizedTransaction
*
* @param {number} uncategorizedTransaction
*/
public async regonizeTransaction(
uncategorizedTransaction: UncategorizedCashflowTransaction