Files
bigcapital/packages/server/src/modules/BankingMatching/BankingMatching.controller.ts
2025-06-13 01:57:53 +02:00

45 lines
1.6 KiB
TypeScript

import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { BankingMatchingApplication } from './BankingMatchingApplication';
import { GetMatchedTransactionsFilter } from './types';
import { MatchBankTransactionDto } from './dtos/MatchBankTransaction.dto';
@Controller('banking/matching')
@ApiTags('Banking Transactions Matching')
export class BankingMatchingController {
constructor(
private readonly bankingMatchingApplication: BankingMatchingApplication,
) {}
@Get('matched')
@ApiOperation({ summary: 'Retrieves the matched transactions.' })
async getMatchedTransactions(
@Query('uncategorizedTransactionIds') uncategorizedTransactionIds: number[],
@Query() filter: GetMatchedTransactionsFilter,
) {
return this.bankingMatchingApplication.getMatchedTransactions(
uncategorizedTransactionIds,
filter,
);
}
@Post('/match')
@ApiOperation({ summary: 'Match the given uncategorized transaction.' })
async matchTransaction(@Body() matchedTransactions: MatchBankTransactionDto) {
return this.bankingMatchingApplication.matchTransaction(
matchedTransactions.uncategorizedTransactions,
matchedTransactions.matchedTransactions,
);
}
@Post('/unmatch/:uncategorizedTransactionId')
@ApiOperation({ summary: 'Unmatch the given uncategorized transaction.' })
async unmatchMatchedTransaction(
@Param('uncategorizedTransactionId') uncategorizedTransactionId: number,
) {
return this.bankingMatchingApplication.unmatchMatchedTransaction(
uncategorizedTransactionId,
);
}
}