feat(eims): derive sales receipt fields from recorded invoice payment

This commit is contained in:
Hagernesh
2026-08-24 12:48:41 +00:00
parent 377ab136a5
commit 565265af79
25 changed files with 108 additions and 17 deletions

View File

@@ -86,17 +86,16 @@ describe("toEimsInvoice", () => {
expect(doc.SellerDetails).toBe(seller);
});
it("maps the buyer from the company row and leaves unmodelled fields null", () => {
it("maps the buyer from the company row and omits Id fields for a TIN-identified buyer", () => {
const doc = toEimsInvoice(invoice(), seller, context());
// MoR rule 7004 rejects an explicit IdType/IdNumber null — the keys must be absent.
expect(doc.BuyerDetails).toEqual({
// Resolved by the registration service before the counter was reserved; the mapper copies.
City: "31",
Country: "70",
Email: "buyer@abc.et",
HouseNumber: "NEW",
IdNumber: null,
IdType: null,
Tin: "0999930000",
LegalName: "ABC Trading PLC",
Phone: "0912345678",

View File

@@ -35,8 +35,9 @@ export interface EimsBuyerDetails {
City: string | null;
Email: string | null;
HouseNumber: string | null;
IdNumber: string | null;
IdType: string | null;
/** Omitted entirely for a TIN-identified buyer — MoR rule 7004 rejects an explicit null. */
IdNumber?: string;
IdType?: string;
Tin: string;
LegalName: string;
Phone: string | null;
@@ -410,8 +411,8 @@ export function toEimsInvoice(
City: context.buyerGeo.City,
Email: company.email ?? null,
HouseNumber: company.houseNo ?? null,
IdNumber: context.buyerIdNumber ?? null,
IdType: context.buyerIdType ?? null,
...(context.buyerIdNumber != null ? { IdNumber: context.buyerIdNumber } : {}),
...(context.buyerIdType != null ? { IdType: context.buyerIdType } : {}),
Tin: company.tin,
LegalName: company.name,
Phone: company.phone ?? null,