mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 12:28:21 +00:00
feat(eims): derive sales receipt fields from recorded invoice payment
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user