mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: Categorize the bank synced transactions
This commit is contained in:
104
packages/server/src/services/Cashflow/CashflowApplication.ts
Normal file
104
packages/server/src/services/Cashflow/CashflowApplication.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { DeleteCashflowTransaction } from './DeleteCashflowTransactionService';
|
||||
import { UncategorizeCashflowTransaction } from './UncategorizeCashflowTransaction';
|
||||
import { CategorizeCashflowTransaction } from './CategorizeCashflowTransaction';
|
||||
import {
|
||||
CategorizeTransactionAsExpenseDTO,
|
||||
ICategorizeCashflowTransactioDTO,
|
||||
} from '@/interfaces';
|
||||
import { CategorizeTransactionAsExpense } from './CategorizeTransactionAsExpense';
|
||||
import { GetUncategorizedTransactions } from './GetUncategorizedTransactions';
|
||||
|
||||
@Service()
|
||||
export class CashflowApplication {
|
||||
@Inject()
|
||||
private deleteTransactionService: DeleteCashflowTransaction;
|
||||
|
||||
@Inject()
|
||||
private uncategorizeTransactionService: UncategorizeCashflowTransaction;
|
||||
|
||||
@Inject()
|
||||
private categorizeTransactionService: CategorizeCashflowTransaction;
|
||||
|
||||
@Inject()
|
||||
private categorizeAsExpenseService: CategorizeTransactionAsExpense;
|
||||
|
||||
@Inject()
|
||||
private getUncategorizedTransactionsService: GetUncategorizedTransactions;
|
||||
|
||||
/**
|
||||
* Deletes the given cashflow transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} cashflowTransactionId
|
||||
* @returns
|
||||
*/
|
||||
public deleteTransaction(tenantId: number, cashflowTransactionId: number) {
|
||||
return this.deleteTransactionService.deleteCashflowTransaction(
|
||||
tenantId,
|
||||
cashflowTransactionId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uncategorize the given cashflow transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} cashflowTransactionId
|
||||
* @returns
|
||||
*/
|
||||
public uncategorizeTransaction(
|
||||
tenantId: number,
|
||||
cashflowTransactionId: number
|
||||
) {
|
||||
return this.uncategorizeTransactionService.uncategorize(
|
||||
tenantId,
|
||||
cashflowTransactionId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Categorize the given cashflow transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} cashflowTransactionId
|
||||
* @param {ICategorizeCashflowTransactioDTO} categorizeDTO
|
||||
* @returns
|
||||
*/
|
||||
public categorizeTransaction(
|
||||
tenantId: number,
|
||||
cashflowTransactionId: number,
|
||||
categorizeDTO: ICategorizeCashflowTransactioDTO
|
||||
) {
|
||||
return this.categorizeTransactionService.categorize(
|
||||
tenantId,
|
||||
cashflowTransactionId,
|
||||
categorizeDTO
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Categorizes the given cashflow transaction as expense transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} cashflowTransactionId
|
||||
* @param {CategorizeTransactionAsExpenseDTO} transactionDTO
|
||||
* @returns
|
||||
*/
|
||||
public categorizeAsExpense(
|
||||
tenantId: number,
|
||||
cashflowTransactionId: number,
|
||||
transactionDTO: CategorizeTransactionAsExpenseDTO
|
||||
) {
|
||||
return this.categorizeAsExpenseService.categorize(
|
||||
tenantId,
|
||||
cashflowTransactionId,
|
||||
transactionDTO
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the uncategorized cashflow transactions.
|
||||
* @param {number} tenantId
|
||||
* @returns {}
|
||||
*/
|
||||
public getUncategorizedTransactions(tenantId: number) {
|
||||
return this.getUncategorizedTransactionsService.getTransactions(tenantId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user