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

@@ -16,6 +16,7 @@ export class BillPaymentExportable extends Exportable {
public exportable(tenantId: number, query: any) {
const filterQuery = (builder) => {
builder.withGraphFetched('entries.bill');
builder.withGraphFetched('branch');
};
const parsedQuery = {
sortOrder: 'desc',

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);

View File

@@ -48,6 +48,10 @@ export default class ListVendorCredits extends BaseVendorCredit {
builder.withGraphFetched('entries');
builder.withGraphFetched('vendor');
dynamicFilter.buildQuery()(builder);
// Gives ability to inject custom query to filter results.
vendorCreditQuery?.filterQuery &&
vendorCreditQuery?.filterQuery(builder);
})
.pagination(filter.page - 1, filter.pageSize);

View File

@@ -2,6 +2,7 @@ import { Inject, Service } from 'typedi';
import { IVendorCreditsQueryDTO } from '@/interfaces';
import ListVendorCredits from './ListVendorCredits';
import { Exportable } from '@/services/Export/Exportable';
import { QueryBuilder } from 'knex';
@Service()
export class VendorCreditsExportable extends Exportable {
@@ -15,12 +16,17 @@ export class VendorCreditsExportable extends Exportable {
* @returns {}
*/
public exportable(tenantId: number, query: IVendorCreditsQueryDTO) {
const filterQuery = (query) => {
query.withGraphFetched('branch');
query.withGraphFetched('warehouse');
};
const parsedQuery = {
sortOrder: 'desc',
columnSortBy: 'created_at',
...query,
page: 1,
pageSize: 12000,
filterQuery,
} as IVendorCreditsQueryDTO;
return this.getVendorCredits