Day 3: Add Supplier & Buyer Details to UBL Invoice XML #ublinvoice #irbinvoice

SEO Title: Day 3: Add Supplier & Buyer Details to UBL Invoice XML #ublinvoice #irbinvoice
Focus Keyphrase: IRB e-invoice integration
Meta Description: Enhance your IRB e-invoice integration by adding supplier, buyer, and address details to your UBL XML using correct UBL 2.1 schema and tags.

Expanding the UBL Invoice with Buyer & Supplier Info

To make your IRB e-invoice integration valid, you must include business identities โ€” both the issuer (supplier) and the receiver (buyer). This includes company name, TIN (Taxpayer Identification Number), registration number, and address.

Step 1: Sample Data for Invoice Parties

$invoiceData = [
    'supplier' => [
        'companyName' => 'Company Name Inc.',
        'companyTIN' => 'C123456789',
        'companyRegNo' => 'ABC123-U',
        'street' => 'Address Street',
        'city' => 'City Name',
        'postcode' => '12345',
        'state' => 'State Name',
        'countryCode' => 'US'
    ],
    'customer' => [
        'companyName' => 'ABC Logistics Inc.',
        'companyTIN' => 'IG123456789',
        'companyRegNo' => '123456-M',
        'street' => 'Address Street',
        'city' => 'City Name',
        'postcode' => '12345',
        'state' => 'State Name',
        'countryCode' => 'MY'
    ]
];

Step 2: Add `cac:AccountingSupplierParty` and `cac:AccountingCustomerParty`

Update your generate() method in IRBInvoiceXmlGenerator:

use DOMElement;

// ...

// Append AccountingSupplierParty
$supplier = $doc->createElementNS($cac, 'cac:AccountingSupplierParty');
$party = $doc->createElementNS($cac, 'cac:Party');

$partyId = $doc->createElementNS($cac, 'cac:PartyIdentification');
$partyId->appendChild($doc->createElementNS($cbc, 'cbc:ID', $invoiceData['supplier']['companyTIN']));
$party->appendChild($partyId);

$partyName = $doc->createElementNS($cac, 'cac:PartyName');
$partyName->appendChild($doc->createElementNS($cbc, 'cbc:Name', $invoiceData['supplier']['companyName']));
$party->appendChild($partyName);

// Address
$postalAddress = $doc->createElementNS($cac, 'cac:PostalAddress');
$postalAddress->appendChild($doc->createElementNS($cbc, 'cbc:StreetName', $invoiceData['supplier']['street']));
$postalAddress->appendChild($doc->createElementNS($cbc, 'cbc:CityName', $invoiceData['supplier']['city']));
$postalAddress->appendChild($doc->createElementNS($cbc, 'cbc:PostalZone', $invoiceData['supplier']['postcode']));
$postalAddress->appendChild($doc->createElementNS($cbc, 'cbc:CountrySubentity', $invoiceData['supplier']['state']));

$country = $doc->createElementNS($cac, 'cac:Country');
$country->appendChild($doc->createElementNS($cbc, 'cbc:IdentificationCode', $invoiceData['supplier']['countryCode']));
$postalAddress->appendChild($country);

$party->appendChild($postalAddress);
$supplier->appendChild($party);
$invoice->appendChild($supplier);

// Repeat for customer
$customer = $doc->createElementNS($cac, 'cac:AccountingCustomerParty');
$party2 = $doc->createElementNS($cac, 'cac:Party');
// ... continue with customer elements

Repeat the block for customer, changing the data to $invoiceData['customer'].

Step 3: View the Updated XML

Visit http://localhost:8000/irb/xml-preview to confirm your XML now includes:

  • cac:AccountingSupplierParty
  • cac:AccountingCustomerParty
  • Full address + TIN data

Next Step: Add Invoice Lines

Tomorrow, weโ€™ll add one or more <cac:InvoiceLine> entries, including quantity, unit price, tax rate, and amount โ€” exactly how IRBM expects for e-invoice submission.

๐Ÿ”— Reference UBL Tags


Tags: #UBL #IRBIntegration #EInvoiceXML #Laravel #AccountingSupplierParty

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.