mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
feat(eims): alias bare Addis Ababa sub-city names to the CSV's woreda codes
Confirmed live 2026-08-17: buyer profiles store just the sub-city name
("Bole", "Arada") as their woreda, never the source CSV's specific
example-woreda name ("Bole Woreda 01") — hit for three different
buyers in a row (Bole, Arada, Lemi Kura) before any got past this
check. Since the CSV lists exactly one representative woreda per
Addis sub-city, alias the bare name to that same code instead of
waiting on a fuller table — use what's already been supplied first.
Lemi Kura itself isn't in the source CSV at all (one of Addis
Ababa's newer sub-cities) — still needs its real code from MoR.
This commit is contained in:
@@ -113,4 +113,19 @@ describe("eims.config — baked-in Ethiopia region/zone/woreda codes", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("resolves the bare Addis Ababa sub-city name a buyer profile actually stores, not the CSV's example-woreda name", () => {
|
||||||
|
withEnv(
|
||||||
|
{ ...REQUIRED, EIMS_PRIVATE_KEY: "x", EIMS_CERTIFICATE_PATH: "/dev/null" },
|
||||||
|
() => {
|
||||||
|
const codes = eimsConfigFactory().invoice.buyerWeredaCodes;
|
||||||
|
expect(codes.Bole).toBe("01");
|
||||||
|
expect(codes.Arada).toBe("01");
|
||||||
|
expect(codes.Kirkos).toBe("01");
|
||||||
|
expect(codes.Yeka).toBe("01");
|
||||||
|
expect(codes["Nifas Silk Lafto"]).toBe("13");
|
||||||
|
expect(codes["Nefas Silk-Lafto"]).toBe("13");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -137,3 +137,24 @@ export const ETHIOPIA_REGION_CODES: Record<string, string> = buildMap((r) => [r[
|
|||||||
/** Zone name → code. Fed into `buyerCityCodes` — EIMS's "City" is really the buyer's zone. */
|
/** Zone name → code. Fed into `buyerCityCodes` — EIMS's "City" is really the buyer's zone. */
|
||||||
export const ETHIOPIA_ZONE_CODES: Record<string, string> = buildMap((r) => [r[1], r[4]]);
|
export const ETHIOPIA_ZONE_CODES: Record<string, string> = buildMap((r) => [r[1], r[4]]);
|
||||||
export const ETHIOPIA_WOREDA_CODES: Record<string, string> = buildMap((r) => [r[2], r[5]]);
|
export const ETHIOPIA_WOREDA_CODES: Record<string, string> = buildMap((r) => [r[2], r[5]]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Buyer records commonly store just the bare Addis Ababa sub-city name ("Bole", "Arada") as their
|
||||||
|
* woreda, not the source CSV's specific example-woreda name ("Bole Woreda 01") — confirmed live
|
||||||
|
* 2026-08-17 across three different buyers before any of them actually got past this check. Since
|
||||||
|
* the CSV lists exactly one representative woreda per Addis sub-city, alias the bare name to that
|
||||||
|
* same code rather than wait on a fuller table.
|
||||||
|
*/
|
||||||
|
const ADDIS_SUBCITY_ALIASES: Array<[bareName: string, csvZoneName: string]> = [
|
||||||
|
["Bole", "Bole Sub-City"],
|
||||||
|
["Kirkos", "Kirkos Sub-City"],
|
||||||
|
["Nifas Silk Lafto", "Nifas Silk Lafto"],
|
||||||
|
// Matches EIMS_BUYER_WEREDA_CODES' own existing spelling in .env — same zone, different hyphenation.
|
||||||
|
["Nefas Silk-Lafto", "Nifas Silk Lafto"],
|
||||||
|
["Yeka", "Yeka Sub-City"],
|
||||||
|
["Arada", "Arada Sub-City"],
|
||||||
|
];
|
||||||
|
for (const [bareName, csvZoneName] of ADDIS_SUBCITY_ALIASES) {
|
||||||
|
const row = ROWS.find((r) => r[1] === csvZoneName);
|
||||||
|
if (row && !(bareName in ETHIOPIA_WOREDA_CODES)) ETHIOPIA_WOREDA_CODES[bareName] = row[5];
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user