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

@@ -18,6 +18,7 @@ import {
CreatePaymentReceivedDto,
EditPaymentReceivedDto,
} from './dtos/PaymentReceived.dto';
import { PaymentsReceivedPagesService } from './queries/PaymentsReceivedPages.service';
@Injectable()
export class PaymentReceivesApplication {
@@ -31,6 +32,7 @@ export class PaymentReceivesApplication {
private sendPaymentReceiveMailNotification: SendPaymentReceiveMailNotification,
private getPaymentReceivePdfService: GetPaymentReceivedPdfService,
private getPaymentReceivedStateService: GetPaymentReceivedStateService,
private paymentsReceivedPagesService: PaymentsReceivedPagesService,
) {}
/**
@@ -147,4 +149,14 @@ export class PaymentReceivesApplication {
public getPaymentReceivedState() {
return this.getPaymentReceivedStateService.getPaymentReceivedState();
}
/**
* Retrieve the payment received edit page.
* @param {number} paymentReceiveId - Payment receive id.
*/
public getPaymentReceivedEditPage(paymentReceiveId: number) {
return this.paymentsReceivedPagesService.getPaymentReceiveEditPage(
paymentReceiveId,
);
}
}

View File

@@ -44,6 +44,20 @@ export class PaymentReceivesController {
);
}
@Get(':id/edit-page')
@ApiResponse({
status: 200,
description:
'The payment received edit page has been successfully retrieved.',
})
public getPaymentReceiveEditPage(
@Param('id', ParseIntPipe) paymentReceiveId: number,
) {
return this.paymentReceivesApplication.getPaymentReceivedEditPage(
paymentReceiveId,
);
}
@Get(':id/mail')
@ApiResponse({
status: 200,

View File

@@ -36,6 +36,7 @@ import { SendPaymentReceivedMailProcessor } from './processors/PaymentReceivedMa
import { SEND_PAYMENT_RECEIVED_MAIL_QUEUE } from './constants';
import { PaymentsReceivedExportable } from './commands/PaymentsReceivedExportable';
import { PaymentsReceivedImportable } from './commands/PaymentsReceivedImportable';
import { PaymentsReceivedPagesService } from './queries/PaymentsReceivedPages.service';
@Module({
controllers: [PaymentReceivesController],
@@ -63,6 +64,7 @@ import { PaymentsReceivedImportable } from './commands/PaymentsReceivedImportabl
SendPaymentReceivedMailProcessor,
PaymentsReceivedExportable,
PaymentsReceivedImportable,
PaymentsReceivedPagesService
],
exports: [
PaymentReceivesApplication,

View File

@@ -41,11 +41,10 @@ export class PaymentsReceivedPagesService {
/**
* Retrieve payment receive new page receivable entries.
* @param {number} tenantId - Tenant id.
* @param {number} vendorId - Vendor id.
* @return {IPaymentReceivePageEntry[]}
*/
public async getNewPageEntries(tenantId: number, customerId: number) {
public async getNewPageEntries(customerId: number) {
// Retrieve due invoices.
const entries = await this.saleInvoice()
.query()
@@ -62,10 +61,7 @@ export class PaymentsReceivedPagesService {
* @param {number} tenantId - Tenant id.
* @param {Integer} paymentReceiveId - Payment receive id.
*/
public async getPaymentReceiveEditPage(
tenantId: number,
paymentReceiveId: number,
): Promise<{
public async getPaymentReceiveEditPage(paymentReceiveId: number): Promise<{
paymentReceive: Omit<PaymentReceived, 'entries'>;
entries: IPaymentReceivePageEntry[];
}> {