Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/node-zugferd/src/formatter/xml/formatter.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { describe, it, expect } from "vitest";
import { EXTENDED } from "../../profiles";
import { EXTENDED, MINIMUM } from "../../profiles";
import { zugferd } from "../../zugferd";
import type { ProfileExtended } from "../../profiles/extended";
import { getTestInstance } from "../../test-utils/test-instance";

describe("XML Formatter", () => {
describe("CategoryTradeTax element ordering", () => {
Expand Down Expand Up @@ -223,4 +224,30 @@ describe("XML Formatter", () => {
expect(typeCodeIndex).toBeLessThan(categoryCodeIndex);
});
});

describe("Buyer legal registration identifier (BT-47)", () => {
it("should emit the buyer's SpecifiedLegalOrganization just like the seller's", async () => {
const { invoicer, data } = await getTestInstance({ profile: MINIMUM });

const xml = await invoicer.create(data).toXML();

const sellerParty = xml.match(
/<ram:SellerTradeParty>([\s\S]*?)<\/ram:SellerTradeParty>/,
);
const buyerParty = xml.match(
/<ram:BuyerTradeParty>([\s\S]*?)<\/ram:BuyerTradeParty>/,
);
expect(sellerParty).toBeTruthy();
expect(buyerParty).toBeTruthy();

// The test data sets `registrationIdentifier` on both parties (BT-30 and
// BT-47), so both must reach the XML.
expect(sellerParty![1]).toContain(
'<ram:ID schemeID="0002">registrationIdentifier</ram:ID>',
);
expect(buyerParty![1]).toContain(
'<ram:ID schemeID="0002">registrationIdentifier</ram:ID>',
);
});
});
});
2 changes: 2 additions & 0 deletions packages/node-zugferd/src/profiles/minimum/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ BR-7: An Invoice shall contain the Buyer name (BT-44).`,
* Details about the organization
*/
organization: {
key: "BT-47-00",
type: "object",
description: "Details about the organization",
required: false,
Expand All @@ -456,6 +457,7 @@ BR-7: An Invoice shall contain the Buyer name (BT-44).`,
* CHORUSPRO: the identifier of the buyer (public entity) is mandatory and is always a SIRET number
*/
registrationIdentifier: {
key: "BT-47",
type: "object",
description: `**Buyer legal registration identifier**

Expand Down
Loading