refactor(nestjs): wip

This commit is contained in:
Ahmed Bouhuolia
2025-05-28 21:32:48 +02:00
parent c51347d3ec
commit 66a2261e50
32 changed files with 206 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { Body, Controller, Delete, Param, Post } from '@nestjs/common';
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
import { ICreditNoteRefundDTO } from '../CreditNotes/types/CreditNotes.types';
import { CreditNotesRefundsApplication } from './CreditNotesRefundsApplication.service';
import { RefundCreditNote } from './models/RefundCreditNote';
@@ -12,6 +12,14 @@ export class CreditNoteRefundsController {
private readonly creditNotesRefundsApplication: CreditNotesRefundsApplication,
) {}
@Get(':creditNoteId/refunds')
@ApiOperation({ summary: 'Retrieve the credit note graph.' })
getCreditNoteRefunds(@Param('creditNoteId') creditNoteId: number) {
return this.creditNotesRefundsApplication.getCreditNoteRefunds(
creditNoteId,
);
}
/**
* Create a refund credit note.
* @param {number} creditNoteId - The credit note ID.

View File

@@ -6,6 +6,7 @@ import { RefundSyncCreditNoteBalanceService } from './commands/RefundSyncCreditN
import { CreditNotesRefundsApplication } from './CreditNotesRefundsApplication.service';
import { CreditNoteRefundsController } from './CreditNoteRefunds.controller';
import { CreditNotesModule } from '../CreditNotes/CreditNotes.module';
import { GetCreditNoteRefundsService } from './queries/GetCreditNoteRefunds.service';
@Module({
imports: [forwardRef(() => CreditNotesModule)],
@@ -15,10 +16,9 @@ import { CreditNotesModule } from '../CreditNotes/CreditNotes.module';
RefundCreditNoteService,
RefundSyncCreditNoteBalanceService,
CreditNotesRefundsApplication,
GetCreditNoteRefundsService,
],
exports: [
RefundSyncCreditNoteBalanceService
],
exports: [RefundSyncCreditNoteBalanceService],
controllers: [CreditNoteRefundsController],
})
export class CreditNoteRefundsModule {}

View File

@@ -5,16 +5,27 @@ import { DeleteRefundCreditNoteService } from './commands/DeleteRefundCreditNote
import { RefundCreditNoteService } from './commands/RefundCreditNote.service';
import { RefundSyncCreditNoteBalanceService } from './commands/RefundSyncCreditNoteBalance';
import { CreditNoteRefundDto } from './dto/CreditNoteRefund.dto';
import { GetCreditNoteRefundsService } from './queries/GetCreditNoteRefunds.service';
@Injectable()
export class CreditNotesRefundsApplication {
constructor(
private readonly createRefundCreditNoteService: CreateRefundCreditNoteService,
private readonly deleteRefundCreditNoteService: DeleteRefundCreditNoteService,
private readonly getCreditNoteRefundsService: GetCreditNoteRefundsService,
private readonly refundCreditNoteService: RefundCreditNoteService,
private readonly refundSyncCreditNoteBalanceService: RefundSyncCreditNoteBalanceService,
) {}
/**
* Retrieve the credit note graph.
* @param {number} creditNoteId - Credit note id.
* @returns {Promise<IRefundCreditNotePOJO[]>}
*/
public getCreditNoteRefunds(creditNoteId: number) {
return this.getCreditNoteRefundsService.getCreditNoteRefunds(creditNoteId);
}
/**
* Create a refund credit note.
* @param {number} creditNoteId - The credit note ID.

View File

@@ -6,7 +6,7 @@ import { IRefundCreditNotePOJO } from '../types/CreditNoteRefunds.types';
import { TenantModelProxy } from '@/modules/System/models/TenantBaseModel';
@Injectable()
export class ListCreditNoteRefunds {
export class GetCreditNoteRefundsService {
constructor(
private readonly transformer: TransformerInjectable,
@@ -18,7 +18,7 @@ export class ListCreditNoteRefunds {
/**
* Retrieve the credit note graph.
* @param {number} creditNoteId
* @param {number} creditNoteId - Credit note id.
* @returns {Promise<IRefundCreditNotePOJO[]>}
*/
public async getCreditNoteRefunds(