init pharmacy master data

This commit is contained in:
Muhammad Rayhan Ardiansyah
2026-02-26 16:30:08 +07:00
parent 4c861f7597
commit a2a628c1a1
18 changed files with 2659 additions and 3 deletions

View File

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

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

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

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

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

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

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

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

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

View File

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

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

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