refactor: banking modules to nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-01-06 11:45:58 +02:00
parent ba176394c8
commit 2bf58d9cb4
22 changed files with 172 additions and 60 deletions

View File

@@ -0,0 +1,31 @@
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
import { BankingTransactionsApplication } from './BankingTransactionsApplication.service';
import { ICashflowNewCommandDTO } from './types/BankingTransactions.types';
@Controller('banking/transactions')
export class BankingTransactionsController {
constructor(
private readonly bankingTransactionsApplication: BankingTransactionsApplication,
) {}
@Post()
async createTransaction(@Body() transactionDTO: ICashflowNewCommandDTO) {
return this.bankingTransactionsApplication.createTransaction(
transactionDTO,
);
}
@Delete(':id')
async deleteTransaction(@Param('id') transactionId: string) {
return this.bankingTransactionsApplication.deleteTransaction(
Number(transactionId),
);
}
@Get(':id')
async getTransaction(@Param('id') transactionId: string) {
return this.bankingTransactionsApplication.getTransaction(
Number(transactionId),
);
}
}

View File

@@ -20,6 +20,7 @@ import { CommandBankTransactionValidator } from './commands/CommandCasflowValida
import { BranchTransactionDTOTransformer } from '../Branches/integrations/BranchTransactionDTOTransform';
import { BranchesModule } from '../Branches/Branches.module';
import { RemovePendingUncategorizedTransaction } from './commands/RemovePendingUncategorizedTransaction.service';
import { BankingTransactionsController } from './BankingTransactions.controller';
const models = [
RegisterTenancyModel(UncategorizedBankTransaction),
@@ -29,6 +30,7 @@ const models = [
@Module({
imports: [AutoIncrementOrdersModule, LedgerModule, BranchesModule],
controllers: [BankingTransactionsController],
providers: [
BankTransactionAutoIncrement,
BankTransactionGLEntriesService,

View File

@@ -7,8 +7,8 @@ import { Model } from 'objection';
// import { CASHFLOW_DIRECTION } from '@/services/Cashflow/constants';
// import { getCashflowTransactionFormattedType } from '@/utils/transactions-types';
import { BaseModel } from '@/models/Model';
import { getCashflowTransactionType } from '../utils';
import { CASHFLOW_DIRECTION } from '../constants';
import { getCashflowAccountTransactionsTypes, getCashflowTransactionType } from '../utils';
import { CASHFLOW_DIRECTION, CASHFLOW_TRANSACTION_TYPE } from '../constants';
import { BankTransactionLine } from './BankTransactionLine';
import { Account } from '@/modules/Accounts/models/Account.model';
@@ -27,9 +27,15 @@ export class BankTransaction extends BaseModel {
cashflowAccountId: number;
creditAccountId: number;
categorizeRefType: string;
categorizeRefId: number;
uncategorized: boolean;
branchId: number;
userId: number;
publishedAt: Date;
entries: BankTransactionLine[];
cashflowAccount: Account;
creditAccount: Account;
@@ -92,7 +98,9 @@ export class BankTransaction extends BaseModel {
// }
get typeMeta() {
return getCashflowTransactionType(this.transactionType);
return getCashflowTransactionType(
this.transactionType as CASHFLOW_TRANSACTION_TYPE,
);
}
/**