mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
refactor(nestjs): export module
This commit is contained in:
@@ -26,6 +26,7 @@ import { BillInventoryTransactions } from './commands/BillInventoryTransactions'
|
||||
import { GetBillsService } from './queries/GetBills.service';
|
||||
import { DynamicListModule } from '../DynamicListing/DynamicList.module';
|
||||
import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
||||
import { BillsExportable } from './commands/BillsExportable';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -57,6 +58,7 @@ import { InventoryCostModule } from '../InventoryCost/InventoryCost.module';
|
||||
BillGLEntriesSubscriber,
|
||||
BillInventoryTransactions,
|
||||
BillWriteInventoryTransactionsSubscriber,
|
||||
BillsExportable
|
||||
],
|
||||
controllers: [BillsController],
|
||||
})
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
// import { Inject, Service } from 'typedi';
|
||||
// import { Knex } from 'knex';
|
||||
// import { IBillsFilter } from '@/interfaces';
|
||||
// import { Exportable } from '@/services/Export/Exportable';
|
||||
// import { BillsApplication } from '../Bills.application';
|
||||
// import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
|
||||
// import Objection from 'objection';
|
||||
import { Knex } from 'knex';
|
||||
import { BillsApplication } from '../Bills.application';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Exportable } from '@/modules/Export/Exportable';
|
||||
import { IBillsFilter } from '../Bills.types';
|
||||
import { EXPORT_SIZE_LIMIT } from '@/modules/Export/constants';
|
||||
|
||||
// @Service()
|
||||
// export class BillsExportable extends Exportable {
|
||||
// @Inject()
|
||||
// private billsApplication: BillsApplication;
|
||||
@Injectable()
|
||||
export class BillsExportable extends Exportable {
|
||||
constructor(private readonly billsApplication: BillsApplication) {
|
||||
super();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Retrieves the accounts data to exportable sheet.
|
||||
// * @param {number} tenantId
|
||||
// * @returns
|
||||
// */
|
||||
// public exportable(tenantId: number, query: IBillsFilter) {
|
||||
// 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 IBillsFilter;
|
||||
/**
|
||||
* Retrieves the accounts data to exportable sheet.
|
||||
*/
|
||||
public exportable(query: IBillsFilter) {
|
||||
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 IBillsFilter;
|
||||
|
||||
// return this.billsApplication
|
||||
// .getBills(tenantId, parsedQuery)
|
||||
// .then((output) => output.bills);
|
||||
// }
|
||||
// }
|
||||
return this.billsApplication
|
||||
.getBills(parsedQuery)
|
||||
.then((output) => output.bills);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ import { BillLandedCost } from '@/modules/BillLandedCosts/models/BillLandedCost'
|
||||
import { DiscountType } from '@/common/types/Discount';
|
||||
import type { Knex, QueryBuilder } from 'knex';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { ExportableModel } from '@/modules/Export/decorators/ExportableModel.decorator';
|
||||
|
||||
@ExportableModel()
|
||||
export class Bill extends TenantBaseModel {
|
||||
public amount: number;
|
||||
public paymentAmount: number;
|
||||
|
||||
@@ -13,8 +13,7 @@ export class GetBillPayments {
|
||||
|
||||
/**
|
||||
* Retrieve the specific bill associated payment transactions.
|
||||
* @param {number} billId
|
||||
* @returns {}
|
||||
* @param {number} billId - Bill id.
|
||||
*/
|
||||
public getBillPayments = async (billId: number) => {
|
||||
const billsEntries = await this.billPaymentEntryModel
|
||||
|
||||
Reference in New Issue
Block a user