#2427 and migration
This commit is contained in:
parent
7f3408e2f5
commit
28b5408d5b
6 changed files with 159 additions and 5 deletions
|
|
@ -68,3 +68,42 @@ export function filterPosMasters(
|
|||
): PosMaster[] {
|
||||
return posMasters.filter((x) => x[childLevelIdKey] == null && x.isDirector === true);
|
||||
}
|
||||
|
||||
/**
|
||||
* สร้าง orgShortName จาก posMaster (ต้อง load org relations มาก่อน)
|
||||
*/
|
||||
export function getOrgShortName(posMaster: PosMaster): string {
|
||||
if (posMaster.orgChild1Id === null) {
|
||||
return posMaster.orgRoot?.orgRootShortName ?? "";
|
||||
} else if (posMaster.orgChild2Id === null) {
|
||||
return posMaster.orgChild1?.orgChild1ShortName ?? "";
|
||||
} else if (posMaster.orgChild3Id === null) {
|
||||
return posMaster.orgChild2?.orgChild2ShortName ?? "";
|
||||
} else if (posMaster.orgChild4Id === null) {
|
||||
return posMaster.orgChild3?.orgChild3ShortName ?? "";
|
||||
} else {
|
||||
return posMaster.orgChild4?.orgChild4ShortName ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* สร้างชื่อสังกัดเต็ม จาก posMaster (join ด้วย \n)
|
||||
*/
|
||||
export function getOrgFullName(posMaster: PosMaster): string {
|
||||
const parts = [
|
||||
posMaster.orgChild4?.orgChild4Name,
|
||||
posMaster.orgChild3?.orgChild3Name,
|
||||
posMaster.orgChild2?.orgChild2Name,
|
||||
posMaster.orgChild1?.orgChild1Name,
|
||||
posMaster.orgRoot?.orgRootName,
|
||||
];
|
||||
return parts.filter((part) => part !== undefined && part !== null).join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* สร้างเลขที่ตำแหน่ง เช่น "กทม. 1234"
|
||||
*/
|
||||
export function getPosMasterNo(posMaster: PosMaster): string {
|
||||
const orgShortName = getOrgShortName(posMaster);
|
||||
return `${orgShortName} ${posMaster.posMasterNo}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue