refactor(nestjs): export module

This commit is contained in:
Ahmed Bouhuolia
2025-04-08 16:19:35 +02:00
parent 6287f8b6e3
commit 04c25bd31a
60 changed files with 748 additions and 504 deletions

View File

@@ -16,6 +16,7 @@ import { BillPaymentGLEntries } from './commands/BillPaymentGLEntries';
import { BillPaymentGLEntriesSubscriber } from './subscribers/BillPaymentGLEntriesSubscriber';
import { LedgerModule } from '../Ledger/Ledger.module';
import { AccountsModule } from '../Accounts/Accounts.module';
import { BillPaymentsExportable } from './queries/BillPaymentsExportable';
@Module({
imports: [LedgerModule, AccountsModule],
@@ -34,6 +35,7 @@ import { AccountsModule } from '../Accounts/Accounts.module';
TenancyContext,
BillPaymentGLEntries,
BillPaymentGLEntriesSubscriber,
BillPaymentsExportable
],
exports: [BillPaymentValidators, CreateBillPaymentService],
controllers: [BillPaymentsController],

View File

@@ -20,12 +20,12 @@ export class BillPaymentsApplication {
private deleteBillPaymentService: DeleteBillPayment,
private getBillPaymentService: GetBillPayment,
private getPaymentBillsService: GetPaymentBills,
// private getBillPaymentsService: GetBillPayments,
private getBillPaymentsService: GetBillPayments,
) {}
/**
* Creates a bill payment with associated GL entries.
* @param {IBillPaymentDTO} billPaymentDTO
* @param {IBillPaymentDTO} billPaymentDTO - Create bill payment dto.
* @returns {Promise<IBillPayment>}
*/
public createBillPayment(billPaymentDTO: CreateBillPaymentDto) {
@@ -34,7 +34,7 @@ export class BillPaymentsApplication {
/**
* Delets the given bill payment with associated GL entries.
* @param {number} billPaymentId
* @param {number} billPaymentId - Bill payment id.
*/
public deleteBillPayment(billPaymentId: number) {
return this.deleteBillPaymentService.deleteBillPayment(billPaymentId);
@@ -58,13 +58,10 @@ export class BillPaymentsApplication {
/**
* Retrieves bill payments list.
* @param {number} tenantId
* @param filterDTO
* @returns
*/
// public getBillPayments(filterDTO: IBillPaymentsFilter) {
// return this.getBillPaymentsService.getBillPayments(filterDTO);
// }
public getBillPayments(filterDTO: IBillPaymentsFilter) {
return this.getBillPaymentsService.getBillPayments(filterDTO);
}
/**
* Retrieve specific bill payment.

View File

@@ -1,34 +0,0 @@
// import { Inject, Service } from 'typedi';
// import { Exportable } from '@/services/Export/Exportable';
// import { BillPaymentsApplication } from './BillPaymentsApplication';
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
// @Service()
// export class BillPaymentExportable extends Exportable {
// @Inject()
// private billPaymentsApplication: BillPaymentsApplication;
// /**
// * Retrieves the accounts data to exportable sheet.
// * @param {number} tenantId
// * @returns
// */
// public exportable(tenantId: number, query: any) {
// const filterQuery = (builder) => {
// builder.withGraphFetched('entries.bill');
// builder.withGraphFetched('branch');
// };
// const parsedQuery = {
// sortOrder: 'desc',
// columnSortBy: 'created_at',
// ...query,
// page: 1,
// pageSize: EXPORT_SIZE_LIMIT,
// filterQuery
// } as any;
// return this.billPaymentsApplication
// .getBillPayments(tenantId, parsedQuery)
// .then((output) => output.billPayments);
// }
// }

View File

@@ -0,0 +1,42 @@
import { Injectable } from "@nestjs/common";
import { BillPaymentsApplication } from "../BillPaymentsApplication.service";
import { Exportable } from "@/modules/Export/Exportable";
import { EXPORT_SIZE_LIMIT } from "@/modules/Export/constants";
import { ExportableService } from "@/modules/Export/decorators/ExportableModel.decorator";
import { BillPayment } from "../models/BillPayment";
@Injectable()
@ExportableService({ name: BillPayment.name })
export class BillPaymentsExportable extends Exportable {
constructor(
private readonly billPaymentsApplication: BillPaymentsApplication
) {
super();
}
/**
* Retrieves the accounts data to exportable sheet.
* @param {number} tenantId
* @returns
*/
public exportable(query: any) {
const filterQuery = (builder) => {
builder.withGraphFetched('entries.bill');
builder.withGraphFetched('branch');
};
const parsedQuery = {
sortOrder: 'desc',
columnSortBy: 'created_at',
...query,
page: 1,
pageSize: EXPORT_SIZE_LIMIT,
filterQuery
} as any;
return [];
// return this.billPaymentsApplication
// .billPayments(tenantId, parsedQuery)
// .then((output) => output.billPayments);
}
}