Inject
TSXinject
1import {
2 ContainerRegistryManager,
3 BranchService,
4 Inject,
5 Service,
6} from "@quan-erp/shared-backend-core";
7
8@Service()
9export class MyPluginService {
10 @Inject(BranchService, ContainerRegistryManager.BUILTIN_PLUGIN)
11 private branchService: BranchService;
12}Lookup methods
- getById(id: number) — branch by id (with related fields as loaded by the service)
- get({ skip?, limit?, search? }): Promise<BranchEntity[]> — paginated search (defaults skip 0, limit 20)
- sportlightSearch(dto: SportlightSearchDto, user: RequestedUser) — Spotlight search (spelling matches source)
TSXlookup
1import {
2 BranchService,
3 ContainerRegistryManager,
4 Inject,
5 Service,
6} from "@quan-erp/shared-backend-core";
7
8@Service()
9export class BranchLookupService {
10 @Inject(BranchService, ContainerRegistryManager.BUILTIN_PLUGIN)
11 private branchService: BranchService;
12
13 async list(search?: string) {
14 return this.branchService.get({ skip: 0, limit: 50, search });
15 }
16}Create / update / default
- create(params: CreateServiceProps<CreateBranchDto & OptionalCreatedByUser>) — create branch (name required; address fields optional)
- update(id: number, data: any, updatedByUserId?: number) — update branch fields
- markDefault(id: number, userId: number) — mark this branch as the system default
TSXcreate
1import {
2 BranchService,
3 ContainerRegistryManager,
4 Inject,
5 Service,
6} from "@quan-erp/shared-backend-core";
7
8@Service()
9export class BranchAdminService {
10 @Inject(BranchService, ContainerRegistryManager.BUILTIN_PLUGIN)
11 private branchService: BranchService;
12
13 async openBranch(createdByUserId: number) {
14 return this.branchService.create({
15 createdByUserId,
16 data: {
17 id: 0,
18 name: "Downtown",
19 city: "Yangon",
20 country: "MM",
21 },
22 });
23 }
24
25 async makeDefault(branchId: number, userId: number) {
26 await this.branchService.markDefault(branchId, userId);
27 }
28}