refactor api act/{id}
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m25s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m25s
This commit is contained in:
parent
5102805278
commit
baa8496a69
3 changed files with 336 additions and 319 deletions
70
src/utils/org-formatting.ts
Normal file
70
src/utils/org-formatting.ts
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { PosMaster } from "../entities/PosMaster";
|
||||
|
||||
export interface PosMasterFormatted {
|
||||
posmasterId: string;
|
||||
posNo: string;
|
||||
orgTreeId: string;
|
||||
orgLevel: number;
|
||||
fullNameCurrentHolder: string | null;
|
||||
}
|
||||
|
||||
export interface OrgTreeNode {
|
||||
orgTreeId: string;
|
||||
orgLevel: number;
|
||||
orgName: string;
|
||||
orgTreeName: string;
|
||||
orgTreeShortName: string;
|
||||
orgTreeCode: string;
|
||||
orgCode: string;
|
||||
orgRootName: string;
|
||||
labelName: string;
|
||||
posMaster: PosMasterFormatted[];
|
||||
children?: OrgTreeNode[];
|
||||
}
|
||||
|
||||
export function formatPosMaster(
|
||||
posMaster: PosMaster,
|
||||
orgShortName: string,
|
||||
orgTreeId: string,
|
||||
orgLevel: number,
|
||||
): PosMasterFormatted {
|
||||
return {
|
||||
posmasterId: posMaster.id,
|
||||
posNo: `${orgShortName} ${posMaster.posMasterNo}`,
|
||||
orgTreeId,
|
||||
orgLevel,
|
||||
fullNameCurrentHolder: posMaster.current_holder
|
||||
? `${posMaster.current_holder.prefix}${posMaster.current_holder.firstName} ${posMaster.current_holder.lastName}`
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
export function generateLabelName(
|
||||
nodeName: string,
|
||||
nodeCode: string,
|
||||
nodeShortName: string,
|
||||
rootName: string,
|
||||
rootCode: string,
|
||||
rootShortName: string,
|
||||
parentNames?: string[],
|
||||
parentCodes?: string[],
|
||||
parentShortNames?: string[],
|
||||
): string {
|
||||
const parts = [nodeName, " ", rootCode, nodeCode, " ", nodeShortName];
|
||||
|
||||
if (parentNames) {
|
||||
for (let i = 0; i < parentNames.length; i++) {
|
||||
parts.push("/", parentNames[i], " ", rootCode, parentCodes![i], " ", parentShortNames![i]);
|
||||
}
|
||||
}
|
||||
|
||||
parts.push("/", rootName, " ", rootCode, "00", " ", rootShortName);
|
||||
return parts.join("");
|
||||
}
|
||||
|
||||
export function filterPosMasters(
|
||||
posMasters: PosMaster[],
|
||||
childLevelIdKey: keyof PosMaster,
|
||||
): PosMaster[] {
|
||||
return posMasters.filter((x) => x[childLevelIdKey] == null && x.isDirector === true);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue