mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
refactor: banking modules to nestjs
This commit is contained in:
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user