add sell price percentage

This commit is contained in:
Rayhan Ardiansyah
2026-03-02 13:18:23 +07:00
parent 8df10aa2e3
commit 736c23227b
6 changed files with 801 additions and 0 deletions

23
src/model/item_price.ts Normal file
View File

@ -0,0 +1,23 @@
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;
}
}

View File

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