mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat: auto recognize uncategorized transactions
This commit is contained in:
@@ -11,9 +11,15 @@ export default class UncategorizedCashflowTransaction extends mixin(
|
||||
[ModelSettings]
|
||||
) {
|
||||
id!: number;
|
||||
date!: Date | string;
|
||||
amount!: number;
|
||||
categorized!: boolean;
|
||||
accountId!: number;
|
||||
referenceNo!: string;
|
||||
payee!: string;
|
||||
description!: string;
|
||||
plaidTransactionId!: string;
|
||||
recognizedTransactionId!: number;
|
||||
|
||||
/**
|
||||
* Table name.
|
||||
@@ -75,11 +81,21 @@ export default class UncategorizedCashflowTransaction extends mixin(
|
||||
return 0 < this.withdrawal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detarmines whether the transaction is recognized.
|
||||
*/
|
||||
public get isRecognized(): boolean {
|
||||
return !!this.recognizedTransactionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Account = require('models/Account');
|
||||
const {
|
||||
RecognizedBankTransaction,
|
||||
} = require('models/RecognizedBankTransaction');
|
||||
|
||||
return {
|
||||
/**
|
||||
@@ -93,6 +109,18 @@ export default class UncategorizedCashflowTransaction extends mixin(
|
||||
to: 'accounts.id',
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Transaction may has association to recognized transaction.
|
||||
*/
|
||||
recognizedTransaction: {
|
||||
relation: Model.HasOneRelation,
|
||||
modelClass: RecognizedBankTransaction,
|
||||
join: {
|
||||
from: 'uncategorized_cashflow_transactions.recognizedTransactionId',
|
||||
to: 'recognized_bank_transactions.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user