mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: integrate multiple branches and warehouses with import
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user