feat: integrate multiple branches and warehouses with import

This commit is contained in:
Ahmed Bouhuolia
2024-09-02 14:42:05 +02:00
parent 266902026e
commit bfb3909d26
41 changed files with 392 additions and 11 deletions

View File

@@ -1,8 +1,10 @@
import { Inject, Service } from 'typedi';
import { Knex } from 'knex';
import { IBillsFilter } from '@/interfaces';
import { Exportable } from '@/services/Export/Exportable';
import { BillsApplication } from './BillsApplication';
import { EXPORT_SIZE_LIMIT } from '@/services/Export/constants';
import Objection from 'objection';
@Service()
export class BillsExportable extends Exportable {
@@ -15,12 +17,17 @@ export class BillsExportable extends Exportable {
* @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;
return this.billsApplication

View File

@@ -51,6 +51,9 @@ export class GetBills {
builder.withGraphFetched('vendor');
builder.withGraphFetched('entries.item');
dynamicFilter.buildQuery()(builder);
// Filter query.
filterDTO?.filterQuery && filterDTO?.filterQuery(builder);
})
.pagination(filter.page - 1, filter.pageSize);