mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix: resource advanced view filter.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { difference } from "lodash";
|
||||
import { Service, Inject } from "typedi";
|
||||
import { IItemsFilter } from 'interfaces';
|
||||
import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
|
||||
@Service()
|
||||
@@ -7,6 +9,9 @@ export default class ItemsService {
|
||||
@Inject()
|
||||
tenancy: TenancyService;
|
||||
|
||||
@Inject()
|
||||
dynamicListService: DynamicListingService;
|
||||
|
||||
async newItem(tenantId: number, item: any) {
|
||||
const { Item } = this.tenancy.models(tenantId);
|
||||
const storedItem = await Item.query()
|
||||
@@ -71,4 +76,24 @@ export default class ItemsService {
|
||||
writeItemInventoryOpeningQuantity(tenantId: number, itemId: number, openingQuantity: number, averageCost: number) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve items datatable list.
|
||||
* @param {number} tenantId
|
||||
* @param {IItemsFilter} itemsFilter
|
||||
*/
|
||||
async getItemsList(tenantId: number, itemsFilter: IItemsFilter) {
|
||||
const { Item } = this.tenancy.models(tenantId);
|
||||
const dynamicFilter = await this.dynamicListService.dynamicList(tenantId, Item, itemsFilter);
|
||||
|
||||
const items = await Item.query().onBuild((builder) => {
|
||||
builder.withGraphFetched('inventoryAccount');
|
||||
builder.withGraphFetched('sellAccount');
|
||||
builder.withGraphFetched('costAccount');
|
||||
builder.withGraphFetched('category');
|
||||
|
||||
dynamicFilter.buildQuery()(builder);
|
||||
});
|
||||
return items;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user