Files
service-master-data-revenue/src/model/item_price.ts
2026-03-02 13:18:23 +07:00

23 lines
947 B
TypeScript

import { SelectQueryBuilder } from "typeorm";
import CommonHelper from "../helpers/common";
import { OrmHelper } from "../helpers/orm";
import { ItemPrice } from "entity";
export class ItemPriceModel {
static async list(filter = {}): Promise<SelectQueryBuilder<any>> {
const repo = OrmHelper.DB.getRepository(ItemPrice);
let whereAttr: string[] = [];
let whereVal: any = {};
if (filter && Object.keys(filter).length > 0) {
whereAttr = [...whereAttr, ...CommonHelper.handleQueryFilter(filter, "item_price").whereAttr];
whereVal = { ...whereVal, ...CommonHelper.handleQueryFilter(filter, "item_price").whereVal };
}
var query = repo.createQueryBuilder("item_price").leftJoinAndSelect("item_price.item_master", "item_master");
if (whereAttr.length != 0) {
query = query.where(whereAttr.join(" and "), whereVal);
}
return query;
}
}