feat(flow-ui): load branch staff from parsian seeds

Load seeded staff and product-specific codes, preserve intentional missing-code markers, and disable options without codes.
This commit is contained in:
2026-11-21 10:34:07 +03:30
parent 5242a22c6c
commit 5818f7f881
5 changed files with 135 additions and 58 deletions
+14 -19
View File
@@ -1085,13 +1085,7 @@ node scripts/fanavaran-flow-ui-server.js</pre>
APP_NAME:"", APP_SECRET:"", FANAVARAN_USERNAME:"", FANAVARAN_PASSWORD:"", CORP_ID:"", CONTRACT_ID:"", APP_NAME:"", APP_SECRET:"", FANAVARAN_USERNAME:"", FANAVARAN_PASSWORD:"", CORP_ID:"", CONTRACT_ID:"",
CURL_PROXY:"", CURL_PROXY:"",
}; };
const BRANCHES = { const BRANCHES = /* PARSIAN_BRANCH_SEEDS */ {};
"210110":{name:"شعبه پونک (210110)",makers:[{name:"احمد بستان پیرا",claim:"32"},{name:"مهسا وطن نیا",claim:"34"}],reviewers:[{name:"مهدی روشن دل",tp:"3989"},{name:"مهدی شاملوفرد",tp:"72"}]},
"210050":{name:"شعبه غرب تهران (210050)",makers:[{name:"رسول کرکی",claim:"4662"},{name:"اسماعیل سلطانمحمدی",claim:"4221"},{name:"علیرضا گودرزی پور",claim:"4663"},{name:"مهیار کیایی",claim:"1004"}],reviewers:[{name:"رسول کرکی",tp:"29"},{name:"علیرضا گودرزی پور",tp:"16"},{name:"مهدی شاملوفرد",tp:"72"}]},
"210040":{name:"شعبه شرق تهران (210040)",makers:[{name:"اسداله نجفی پور",claim:"91"},{name:"سهیلا شکوری",claim:"88"},{name:"ناصر عیوضی",claim:"228"}],reviewers:[{name:"مجید امیری",tp:"3985"}]},
"210120":{name:"شعبه والفجر (210120)",makers:[{name:"علیرضا درگاهی",claim:"57"},{name:"داود صدیق",claim:"222"},{name:"مهدی معمارباشی",claim:"216"}],reviewers:[{name:"حسین جعفری",tp:"3542"},{name:"مجید کاظمی",tp:"3992"}]},
"110011":{name:"ستاد مرکزی (110011)",makers:[{name:"اکبر بیگ محمدی",claim:"278"}],reviewers:[{name:"فرهاد ملکی",tp:"60"}]}
};
const ID_KEYS = ["POLICY_ID","CLAIM_ID","CLAIM_NO","DRIVER_ID","DMG_CASE_ID","EXPERTISE_ID","DMG_NOTIFICATION_ID","INSURANCE_CORP_ID_NUM","ACCIDENT_CULPRIT_ID"]; const ID_KEYS = ["POLICY_ID","CLAIM_ID","CLAIM_NO","DRIVER_ID","DMG_CASE_ID","EXPERTISE_ID","DMG_NOTIFICATION_ID","INSURANCE_CORP_ID_NUM","ACCIDENT_CULPRIT_ID"];
/** Cleared when starting a new Fanavaran submit; person/lookup ids like ACCIDENT_CULPRIT_ID stay. */ /** Cleared when starting a new Fanavaran submit; person/lookup ids like ACCIDENT_CULPRIT_ID stay. */
@@ -1352,19 +1346,19 @@ node scripts/fanavaran-flow-ui-server.js</pre>
return; return;
} }
const b = BRANCHES[$("LOCATION").value]; const b = BRANCHES[$("LOCATION").value];
(b && b.makers || []).forEach((m, i) => { const hull = q("FANAVARAN_PRODUCT") === "CAR_BODY";
const o = document.createElement("option"); [[claim, b?.makers || [], hull ? "body" : "claim", preferredClaim],
o.value = m.claim; [exp, b?.reviewers || [], hull ? "body" : "tp", preferredExp]]
o.textContent = m.claim + " — " + m.name; .forEach(([select, experts, codeField, preferred]) => {
if ((preferredClaim && preferredClaim === m.claim) || (!preferredClaim && i === 0)) o.selected = true; experts.forEach((expert) => {
claim.appendChild(o); const code = expert[codeField] || "";
const option = document.createElement("option");
option.value = code;
option.textContent = (code || "❌ کد موجود نیست") + " — " + expert.name;
option.disabled = !code;
if (code && String(preferred || "") === code) option.selected = true;
select.appendChild(option);
}); });
(b && b.reviewers || []).filter((r) => r.tp).forEach((r, i) => {
const o = document.createElement("option");
o.value = r.tp;
o.textContent = r.tp + " — " + r.name;
if ((preferredExp && preferredExp === r.tp) || (!preferredExp && i === 0)) o.selected = true;
exp.appendChild(o);
}); });
} }
@@ -2450,6 +2444,7 @@ node scripts/fanavaran-flow-ui-server.js</pre>
$("LOCATION").addEventListener("change", () => refreshExperts()); $("LOCATION").addEventListener("change", () => refreshExperts());
$("FANAVARAN_PRODUCT").addEventListener("change", () => { $("FANAVARAN_PRODUCT").addEventListener("change", () => {
syncProduct(); syncProduct();
refreshExperts();
$("envOut").value = envToText(collectEnv()); $("envOut").value = envToText(collectEnv());
}); });
["CLAIM_EXPERT_ID", "EXPERTISE_CLAIM_EXPERT_ID"].forEach((id) => { ["CLAIM_EXPERT_ID", "EXPERTISE_CLAIM_EXPERT_ID"].forEach((id) => {
+29 -29
View File
@@ -23,7 +23,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyClaimExpertId": "91", "ThirdPartyClaimExpertId": "91",
@@ -37,7 +37,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4221", "ThirdPartyClaimExpertId": "4221",
@@ -47,7 +47,7 @@
"nationalCode": "0492295557", "nationalCode": "0492295557",
"mobile": "09125409101", "mobile": "09125409101",
"firstName": "اکبر", "firstName": "اکبر",
"lastName": "بيگ محمدي", "lastName": "بيگ محمدي ❌",
"locations": [ "locations": [
{ {
"id": "111130", "id": "111130",
@@ -64,7 +64,7 @@
"nationalCode": "3220096573", "nationalCode": "3220096573",
"mobile": "09104933206", "mobile": "09104933206",
"firstName": "پدرام", "firstName": "پدرام",
"lastName": "حاتمي", "lastName": "حاتمي ❌",
"locations": [ "locations": [
{ {
"id": "210120", "id": "210120",
@@ -81,7 +81,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyClaimExpertId": "739", "ThirdPartyClaimExpertId": "739",
@@ -95,7 +95,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"CarBodyClaimExpertId": "3215", "CarBodyClaimExpertId": "3215",
@@ -119,11 +119,11 @@
"nationalCode": "0084130938", "nationalCode": "0084130938",
"mobile": "09392558640", "mobile": "09392558640",
"firstName": "رسول", "firstName": "رسول",
"lastName": "کرکي", "lastName": "کرکي ❌",
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4662" "ThirdPartyClaimExpertId": "4662"
@@ -136,7 +136,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4245", "ThirdPartyClaimExpertId": "4245",
@@ -150,7 +150,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"CarBodyClaimExpertId": "89", "CarBodyClaimExpertId": "89",
@@ -164,7 +164,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"CarBodyClaimExpertId": "4455", "CarBodyClaimExpertId": "4455",
@@ -178,7 +178,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyClaimExpertId": "742", "ThirdPartyClaimExpertId": "742",
@@ -220,7 +220,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"CarBodyClaimExpertId": "4652", "CarBodyClaimExpertId": "4652",
@@ -244,11 +244,11 @@
"nationalCode": "0066868521", "nationalCode": "0066868521",
"mobile": "09129344240", "mobile": "09129344240",
"firstName": "عليرضا", "firstName": "عليرضا",
"lastName": "گودرزي پور", "lastName": "گودرزي پور ❌",
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4663" "ThirdPartyClaimExpertId": "4663"
@@ -261,7 +261,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"CarBodyClaimExpertId": "4220", "CarBodyClaimExpertId": "4220",
@@ -275,7 +275,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"CarBodyClaimExpertId": "4452", "CarBodyClaimExpertId": "4452",
@@ -299,11 +299,11 @@
"nationalCode": "0056888082", "nationalCode": "0056888082",
"mobile": "09122406750", "mobile": "09122406750",
"firstName": "قاسم", "firstName": "قاسم",
"lastName": "نصراللهي", "lastName": "نصراللهي ❌",
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4664" "ThirdPartyClaimExpertId": "4664"
@@ -330,7 +330,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"CarBodyClaimExpertId": "4092", "CarBodyClaimExpertId": "4092",
@@ -344,7 +344,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "1010", "ThirdPartyClaimExpertId": "1010",
@@ -354,11 +354,11 @@
"nationalCode": "0493217789", "nationalCode": "0493217789",
"mobile": "09126966943", "mobile": "09126966943",
"firstName": "مصطفي", "firstName": "مصطفي",
"lastName": "محمدزاده قورقچي", "lastName": "محمدزاده قورقچي ❌",
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4665" "ThirdPartyClaimExpertId": "4665"
@@ -371,7 +371,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"CarBodyClaimExpertId": "745", "CarBodyClaimExpertId": "745",
@@ -381,11 +381,11 @@
"nationalCode": "0078209129", "nationalCode": "0078209129",
"mobile": "09126038117", "mobile": "09126038117",
"firstName": "مهدي", "firstName": "مهدي",
"lastName": "شاملوفرد", "lastName": "شاملوفرد ❌",
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4666" "ThirdPartyClaimExpertId": "4666"
@@ -426,7 +426,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyClaimExpertId": "1004", "ThirdPartyClaimExpertId": "1004",
@@ -440,7 +440,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyClaimExpertId": "4646", "ThirdPartyClaimExpertId": "4646",
@@ -454,7 +454,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyClaimExpertId": "228", "ThirdPartyClaimExpertId": "228",
@@ -23,7 +23,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyExpertiseClaim": "29", "ThirdPartyExpertiseClaim": "29",
@@ -50,7 +50,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"CarBodyExpertiseClaim": "15", "CarBodyExpertiseClaim": "15",
@@ -74,11 +74,11 @@
"nationalCode": "0056888082", "nationalCode": "0056888082",
"mobile": "09122406750", "mobile": "09122406750",
"firstName": "قاسم", "firstName": "قاسم",
"lastName": "نصراللهي", "lastName": "نصراللهي ❌",
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyExpertiseClaim": "4645" "ThirdPartyExpertiseClaim": "4645"
@@ -91,7 +91,7 @@
"locations": [ "locations": [
{ {
"id": "210040", "id": "210040",
"name": "شعبه شرق تهران(210040)" "name": "شعبه شرق تهران"
} }
], ],
"ThirdPartyExpertiseClaim": "3985", "ThirdPartyExpertiseClaim": "3985",
@@ -119,7 +119,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
} }
], ],
"ThirdPartyExpertiseClaim": "3545", "ThirdPartyExpertiseClaim": "3545",
@@ -147,7 +147,7 @@
"locations": [ "locations": [
{ {
"id": "210050", "id": "210050",
"name": "شعبه غرب تهران(210050)" "name": "شعبه غرب تهران"
}, },
{ {
"id": "210110", "id": "210110",
@@ -156,6 +156,43 @@
], ],
"CarBodyExpertiseClaim": "73", "CarBodyExpertiseClaim": "73",
"ThirdPartyExpertiseClaim": "72" "ThirdPartyExpertiseClaim": "72"
},
{
"nationalCode": "3781847039",
"firstName": "اکبر",
"lastName": "ديني ❌",
"locations": [
{
"id": "210040",
"name": "شعبه شرق تهران"
}
]
},
{
"nationalCode": "0759153981",
"firstName": "رضا",
"lastName": "صالحي زاده ❌",
"locations": [
{
"id": "210040",
"name": "شعبه شرق تهران"
}
]
},
{
"nationalCode": "0013480261",
"firstName": "عليرضا",
"lastName": "خازني ❌",
"locations": [
{
"id": "210040",
"name": "شعبه شرق تهران"
},
{
"id": "210110",
"name": "شعبه پونک"
}
]
} }
] ]
} }
+27 -1
View File
@@ -1018,12 +1018,38 @@ function runStage(stage, options = {}) {
}); });
} }
function parsianBranchSeeds() {
const dir = path.join(__dirname, "data", "parsian-tehran");
const read = (file) => JSON.parse(fs.readFileSync(path.join(dir, file), "utf8"));
const branches = Object.fromEntries(read("branches.json").branches.map((b) => [
b.code, { name: `${b.name} (${b.code})`, makers: [], reviewers: [] },
]));
for (const [file, key, role, thirdParty, body] of [
["file-makers.json", "fileMakers", "makers", "ThirdPartyClaimExpertId", "CarBodyClaimExpertId"],
["file-reviewers.json", "fileReviewers", "reviewers", "ThirdPartyExpertiseClaim", "CarBodyExpertiseClaim"],
]) {
for (const expert of read(file)[key]) {
for (const location of expert.locations || []) {
if (!branches[location.id]) continue;
branches[location.id][role].push({
name: `${expert.firstName} ${expert.lastName}`,
[role === "makers" ? "claim" : "tp"]: expert[thirdParty] || "",
body: expert[body] || "",
});
}
}
}
return branches;
}
const server = http.createServer(async (req, res) => { const server = http.createServer(async (req, res) => {
const url = new URL(req.url, `http://${HOST}:${PORT}`); const url = new URL(req.url, `http://${HOST}:${PORT}`);
try { try {
if (req.method === "GET" && (url.pathname === "/" || url.pathname === "/index.html")) { if (req.method === "GET" && (url.pathname === "/" || url.pathname === "/index.html")) {
send(res, 200, fs.readFileSync(UI_HTML, "utf8"), "text/html; charset=utf-8"); const seeds = JSON.stringify(parsianBranchSeeds()).replace(/</g, "\\u003c");
const html = fs.readFileSync(UI_HTML, "utf8").replace("/* PARSIAN_BRANCH_SEEDS */ {}", () => seeds);
send(res, 200, html, "text/html; charset=utf-8");
return; return;
} }
+19
View File
@@ -58,3 +58,22 @@ test("policy aliases used by existing inquiry mappings populate all three fields
assert.equal(result.vehicle.BEGIN_DATE, "1404/02/01"); assert.equal(result.vehicle.BEGIN_DATE, "1404/02/01");
assert.equal(result.vehicle.END_DATE, "1405/02/01"); assert.equal(result.vehicle.END_DATE, "1405/02/01");
}); });
test("flow UI includes every seed expert in each assigned branch and both Kazemi codes", () => {
const context = inquiryContext({});
const branches = vm.runInContext("parsianBranchSeeds()", context);
for (const [file, key, role] of [
["file-makers.json", "fileMakers", "makers"],
["file-reviewers.json", "fileReviewers", "reviewers"],
]) {
const seeds = JSON.parse(fs.readFileSync(path.join(__dirname, "data/parsian-tehran", file)))[key];
for (const expert of seeds) {
for (const location of expert.locations) {
assert.ok(branches[location.id][role].some(r => r.name === `${expert.firstName} ${expert.lastName}`));
}
}
}
const kazemi = branches["210120"].reviewers.find(r => r.name.includes("کاظمي دولت سرا"));
assert.equal(kazemi.tp, "3992");
assert.equal(kazemi.body, "3991");
});