feat: endpoint to get recognized transactions

This commit is contained in:
Ahmed Bouhuolia
2024-06-27 14:23:17 +02:00
parent 7edf268e75
commit fab22c9820
3 changed files with 91 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import TenantModel from 'models/TenantModel';
import { Model } from 'objection';
export class RecognizedBankTransaction extends TenantModel {
/**
@@ -21,4 +22,38 @@ export class RecognizedBankTransaction extends TenantModel {
static get virtualAttributes() {
return [];
}
/**
* Relationship mapping.
*/
static get relationMappings() {
const UncategorizedCashflowTransaction = require('./UncategorizedCashflowTransaction');
const Account = require('./Account');
return {
/**
* Recognized bank transaction may belongs to uncategorized transactions.
*/
uncategorizedTransactions: {
relation: Model.HasManyRelation,
modelClass: UncategorizedCashflowTransaction.default,
join: {
from: 'recognized_bank_transactions.uncategorizedTransactionId',
to: 'uncategorized_cashflow_transactions.id',
},
},
/**
* Recognized bank transaction may belongs to assign account.
*/
assignAccount: {
relation: Model.BelongsToOneRelation,
modelClass: Account.default,
join: {
from: 'recognized_bank_transactions.assignedAccountId',
to: 'accounts.id',
},
},
};
}
}