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

@@ -35,6 +35,7 @@ import { MailNotificationModule } from '../MailNotification/MailNotification.mod
import { SendSaleReceiptMailProcess } from './processes/SendSaleReceiptMail.process';
import { MailModule } from '../Mail/Mail.module';
import { SendSaleReceiptMailQueue } from './constants';
import { SaleReceiptsExportable } from './commands/SaleReceiptsExportable';
@Module({
controllers: [SaleReceiptsController],
@@ -75,6 +76,7 @@ import { SendSaleReceiptMailQueue } from './constants';
SaleReceiptInventoryTransactions,
SaleReceiptInventoryTransactionsSubscriber,
SendSaleReceiptMailProcess,
SaleReceiptsExportable
],
})
export class SaleReceiptsModule {}

View File

@@ -1,35 +1,35 @@
// import { Inject, Service } from 'typedi';
// import { ISalesReceiptsFilter } from '@/interfaces';
// import { Exportable } from '@/services/Export/Exportable';
// import { SaleReceiptApplication } from './SaleReceiptApplication';
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
import { Exportable } from '@/modules/Export/Exportable';
import { Injectable } from '@nestjs/common';
import { SaleReceiptApplication } from '../SaleReceiptApplication.service';
import { ISalesReceiptsFilter } from '../types/SaleReceipts.types';
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
// @Service()
// export class SaleReceiptsExportable extends Exportable {
// @Inject()
// private saleReceiptsApp: SaleReceiptApplication;
@Injectable()
export class SaleReceiptsExportable extends Exportable {
constructor(private readonly saleReceiptsApp: SaleReceiptApplication) {
super();
}
// /**
// * Retrieves the accounts data to exportable sheet.
// * @param {number} tenantId
// * @returns
// */
// public exportable(tenantId: number, query: ISalesReceiptsFilter) {
// const filterQuery = (query) => {
// query.withGraphFetched('branch');
// query.withGraphFetched('warehouse');
// };
// const parsedQuery = {
// sortOrder: 'desc',
// columnSortBy: 'created_at',
// ...query,
// page: 1,
// pageSize: EXPORT_SIZE_LIMIT,
// filterQuery,
// } as ISalesReceiptsFilter;
/**
* Retrieves the accounts data to exportable sheet.
* @param {ISalesReceiptsFilter} query -
*/
public exportable(query: ISalesReceiptsFilter) {
const filterQuery = (query) => {
query.withGraphFetched('branch');
query.withGraphFetched('warehouse');
};
const parsedQuery = {
sortOrder: 'desc',
columnSortBy: 'created_at',
...query,
page: 1,
pageSize: EXPORT_SIZE_LIMIT,
filterQuery,
} as ISalesReceiptsFilter;
// return this.saleReceiptsApp
// .getSaleReceipts(tenantId, parsedQuery)
// .then((output) => output.data);
// }
// }
return this.saleReceiptsApp
.getSaleReceipts(parsedQuery)
.then((output) => output.data);
}
}

View File

@@ -12,6 +12,7 @@ import { MetadataModelMixin } from '@/modules/DynamicListing/models/MetadataMode
import { ResourceableModelMixin } from '@/modules/Resource/models/ResourcableModel';
import { CustomViewBaseModelMixin } from '@/modules/CustomViews/CustomViewBaseModel';
import { SearchableBaseModelMixin } from '@/modules/DynamicListing/models/SearchableBaseModel';
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
const ExtendedModel = R.pipe(
CustomViewBaseModelMixin,
@@ -20,6 +21,7 @@ const ExtendedModel = R.pipe(
MetadataModelMixin,
)(BaseModel);
@ExportableModel()
export class SaleReceipt extends ExtendedModel {
public amount!: number;
public exchangeRate!: number;