From 5818f7f881667b73b7513a367a116d5ad02a647a Mon Sep 17 00:00:00 2001 From: "s.hajizadeh" Date: Sat, 21 Nov 2026 10:34:07 +0330 Subject: [PATCH] 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. --- scripts/data/fanavaran-flow-ui.html | 37 +++++------- scripts/data/parsian-tehran/file-makers.json | 58 +++++++++---------- .../data/parsian-tehran/file-reviewers.json | 51 +++++++++++++--- scripts/fanavaran-flow-ui-server.js | 28 ++++++++- scripts/fanavaran-flow-ui-server.test.js | 19 ++++++ 5 files changed, 135 insertions(+), 58 deletions(-) diff --git a/scripts/data/fanavaran-flow-ui.html b/scripts/data/fanavaran-flow-ui.html index 4eb0aa0..e075f11 100644 --- a/scripts/data/fanavaran-flow-ui.html +++ b/scripts/data/fanavaran-flow-ui.html @@ -1085,13 +1085,7 @@ node scripts/fanavaran-flow-ui-server.js APP_NAME:"", APP_SECRET:"", FANAVARAN_USERNAME:"", FANAVARAN_PASSWORD:"", CORP_ID:"", CONTRACT_ID:"", CURL_PROXY:"", }; - const BRANCHES = { - "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 BRANCHES = /* PARSIAN_BRANCH_SEEDS */ {}; 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. */ @@ -1352,20 +1346,20 @@ node scripts/fanavaran-flow-ui-server.js return; } const b = BRANCHES[$("LOCATION").value]; - (b && b.makers || []).forEach((m, i) => { - const o = document.createElement("option"); - o.value = m.claim; - o.textContent = m.claim + " — " + m.name; - if ((preferredClaim && preferredClaim === m.claim) || (!preferredClaim && i === 0)) o.selected = true; - claim.appendChild(o); - }); - (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); - }); + const hull = q("FANAVARAN_PRODUCT") === "CAR_BODY"; + [[claim, b?.makers || [], hull ? "body" : "claim", preferredClaim], + [exp, b?.reviewers || [], hull ? "body" : "tp", preferredExp]] + .forEach(([select, experts, codeField, preferred]) => { + experts.forEach((expert) => { + 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); + }); + }); } function fillBranches() { @@ -2450,6 +2444,7 @@ node scripts/fanavaran-flow-ui-server.js $("LOCATION").addEventListener("change", () => refreshExperts()); $("FANAVARAN_PRODUCT").addEventListener("change", () => { syncProduct(); + refreshExperts(); $("envOut").value = envToText(collectEnv()); }); ["CLAIM_EXPERT_ID", "EXPERTISE_CLAIM_EXPERT_ID"].forEach((id) => { diff --git a/scripts/data/parsian-tehran/file-makers.json b/scripts/data/parsian-tehran/file-makers.json index a10a9b4..409f188 100644 --- a/scripts/data/parsian-tehran/file-makers.json +++ b/scripts/data/parsian-tehran/file-makers.json @@ -23,7 +23,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyClaimExpertId": "91", @@ -37,7 +37,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "4221", @@ -47,7 +47,7 @@ "nationalCode": "0492295557", "mobile": "09125409101", "firstName": "اکبر", - "lastName": "بيگ محمدي", + "lastName": "بيگ محمدي ❌", "locations": [ { "id": "111130", @@ -64,7 +64,7 @@ "nationalCode": "3220096573", "mobile": "09104933206", "firstName": "پدرام", - "lastName": "حاتمي", + "lastName": "حاتمي ❌", "locations": [ { "id": "210120", @@ -81,7 +81,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyClaimExpertId": "739", @@ -95,7 +95,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "CarBodyClaimExpertId": "3215", @@ -119,11 +119,11 @@ "nationalCode": "0084130938", "mobile": "09392558640", "firstName": "رسول", - "lastName": "کرکي", + "lastName": "کرکي ❌", "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "4662" @@ -136,7 +136,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyClaimExpertId": "4245", @@ -150,7 +150,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "CarBodyClaimExpertId": "89", @@ -164,7 +164,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "CarBodyClaimExpertId": "4455", @@ -178,7 +178,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyClaimExpertId": "742", @@ -220,7 +220,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "CarBodyClaimExpertId": "4652", @@ -244,11 +244,11 @@ "nationalCode": "0066868521", "mobile": "09129344240", "firstName": "عليرضا", - "lastName": "گودرزي پور", + "lastName": "گودرزي پور ❌", "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "4663" @@ -261,7 +261,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "CarBodyClaimExpertId": "4220", @@ -275,7 +275,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "CarBodyClaimExpertId": "4452", @@ -299,11 +299,11 @@ "nationalCode": "0056888082", "mobile": "09122406750", "firstName": "قاسم", - "lastName": "نصراللهي", + "lastName": "نصراللهي ❌", "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "4664" @@ -330,7 +330,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "CarBodyClaimExpertId": "4092", @@ -344,7 +344,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "1010", @@ -354,11 +354,11 @@ "nationalCode": "0493217789", "mobile": "09126966943", "firstName": "مصطفي", - "lastName": "محمدزاده قورقچي", + "lastName": "محمدزاده قورقچي ❌", "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "4665" @@ -371,7 +371,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "CarBodyClaimExpertId": "745", @@ -381,11 +381,11 @@ "nationalCode": "0078209129", "mobile": "09126038117", "firstName": "مهدي", - "lastName": "شاملوفرد", + "lastName": "شاملوفرد ❌", "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "4666" @@ -426,7 +426,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyClaimExpertId": "1004", @@ -440,7 +440,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyClaimExpertId": "4646", @@ -454,7 +454,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyClaimExpertId": "228", diff --git a/scripts/data/parsian-tehran/file-reviewers.json b/scripts/data/parsian-tehran/file-reviewers.json index b452214..fb92f0a 100644 --- a/scripts/data/parsian-tehran/file-reviewers.json +++ b/scripts/data/parsian-tehran/file-reviewers.json @@ -23,7 +23,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyExpertiseClaim": "29", @@ -50,7 +50,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "CarBodyExpertiseClaim": "15", @@ -74,11 +74,11 @@ "nationalCode": "0056888082", "mobile": "09122406750", "firstName": "قاسم", - "lastName": "نصراللهي", + "lastName": "نصراللهي ❌", "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyExpertiseClaim": "4645" @@ -91,7 +91,7 @@ "locations": [ { "id": "210040", - "name": "شعبه شرق تهران(210040)" + "name": "شعبه شرق تهران" } ], "ThirdPartyExpertiseClaim": "3985", @@ -119,7 +119,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" } ], "ThirdPartyExpertiseClaim": "3545", @@ -147,7 +147,7 @@ "locations": [ { "id": "210050", - "name": "شعبه غرب تهران(210050)" + "name": "شعبه غرب تهران" }, { "id": "210110", @@ -156,6 +156,43 @@ ], "CarBodyExpertiseClaim": "73", "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": "شعبه پونک" + } + ] } ] } diff --git a/scripts/fanavaran-flow-ui-server.js b/scripts/fanavaran-flow-ui-server.js index bd95a3f..7a87361 100755 --- a/scripts/fanavaran-flow-ui-server.js +++ b/scripts/fanavaran-flow-ui-server.js @@ -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 url = new URL(req.url, `http://${HOST}:${PORT}`); try { 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(/ seeds); + send(res, 200, html, "text/html; charset=utf-8"); return; } diff --git a/scripts/fanavaran-flow-ui-server.test.js b/scripts/fanavaran-flow-ui-server.test.js index 31fa96b..d3c3ffa 100644 --- a/scripts/fanavaran-flow-ui-server.test.js +++ b/scripts/fanavaran-flow-ui-server.test.js @@ -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.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"); +});