diff --git a/Apps/APAC/EDocumentFormats/PINT A-NZ/app/src/Core/PINTANZImport.Codeunit.al b/Apps/APAC/EDocumentFormats/PINT A-NZ/app/src/Core/PINTANZImport.Codeunit.al
index d7258a9cd4..93565c3f73 100644
--- a/Apps/APAC/EDocumentFormats/PINT A-NZ/app/src/Core/PINTANZImport.Codeunit.al
+++ b/Apps/APAC/EDocumentFormats/PINT A-NZ/app/src/Core/PINTANZImport.Codeunit.al
@@ -19,57 +19,56 @@ codeunit 28007 "PINT A-NZ Import"
procedure ParseBasicInfo(var EDocument: Record "E-Document"; var TempBlob: Codeunit "Temp Blob")
var
- TempXMLBuffer: Record "XML Buffer" temporary;
GeneralLedgerSetup: Record "General Ledger Setup";
+ TempXMLBuffer: Record "XML Buffer" temporary;
+ DocStream: InStream;
+ CreditNoteTok: Label 'CREDITNOTE', Locked = true;
+ InvoiceTok: Label 'INVOICE', Locked = true;
DueDate, IssueDate : Text;
- DocumentType: Text;
- InvoiceTok: Label '/Invoice', Locked = true;
- CreditNoteTok: Label '/CreditNote', Locked = true;
Currency: Text[10];
- DocStream: InStream;
+ RootPath: Text;
begin
TempXMLBuffer.DeleteAll();
TempBlob.CreateInStream(DocStream, TextEncoding::UTF8);
TempXMLBuffer.LoadFromStream(DocStream);
- if GetDocumentType(TempXMLBuffer) = 'Invoice' then begin
- DocumentType := InvoiceTok;
- EDocument."Document Type" := EDocument."Document Type"::"Purchase Invoice";
- end else begin
- DocumentType := CreditNoteTok;
- EDocument."Document Type" := EDocument."Document Type"::"Purchase Credit Memo";
+ case UpperCase(GetDocumentType(TempXMLBuffer, RootPath)) of
+ InvoiceTok:
+ EDocument."Document Type" := EDocument."Document Type"::"Purchase Invoice";
+ CreditNoteTok:
+ EDocument."Document Type" := EDocument."Document Type"::"Purchase Credit Memo";
end;
EDocument.Direction := EDocument.Direction::Incoming;
- EDocument."Incoming E-Document No." := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cbc:ID'), 1, MaxStrLen(EDocument."Document No."));
+ EDocument."Incoming E-Document No." := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cbc:ID'), 1, MaxStrLen(EDocument."Document No."));
- ParseAccountingSupplierParty(EDocument, TempXMLBuffer, DocumentType);
- ParseAccountingCustomerParty(EDocument, TempXMLBuffer, DocumentType);
+ ParseAccountingSupplierParty(EDocument, TempXMLBuffer, RootPath);
+ ParseAccountingCustomerParty(EDocument, TempXMLBuffer, RootPath);
- DueDate := GetNodeByPath(TempXMLBuffer, DocumentType + '/cbc:DueDate');
+ DueDate := GetNodeByPath(TempXMLBuffer, RootPath + '/cbc:DueDate');
if DueDate <> '' then
Evaluate(EDocument."Due Date", DueDate, 9);
- IssueDate := GetNodeByPath(TempXMLBuffer, DocumentType + '/cbc:IssueDate');
+ IssueDate := GetNodeByPath(TempXMLBuffer, RootPath + '/cbc:IssueDate');
if IssueDate <> '' then
Evaluate(EDocument."Document Date", IssueDate, 9);
- Evaluate(EDocument."Amount Excl. VAT", GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount'), 9);
- Evaluate(EDocument."Amount Incl. VAT", GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:LegalMonetaryTotal/cbc:PayableAmount'), 9);
+ Evaluate(EDocument."Amount Excl. VAT", GetNodeByPath(TempXMLBuffer, RootPath + '/cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount'), 9);
+ Evaluate(EDocument."Amount Incl. VAT", GetNodeByPath(TempXMLBuffer, RootPath + '/cac:LegalMonetaryTotal/cbc:PayableAmount'), 9);
- EDocument."Order No." := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:OrderReference/cbc:ID'), 1, MaxStrLen(EDocument."Order No."));
+ EDocument."Order No." := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:OrderReference/cbc:ID'), 1, MaxStrLen(EDocument."Order No."));
- Currency := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cbc:DocumentCurrencyCode'), 1, MaxStrLen(EDocument."Currency Code"));
+ Currency := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cbc:DocumentCurrencyCode'), 1, MaxStrLen(EDocument."Currency Code"));
GeneralLedgerSetup.Get();
if GeneralLedgerSetup."LCY Code" <> Currency then
EDocument."Currency Code" := Currency;
end;
- local procedure ParseAccountingSupplierParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentType: Text)
+ local procedure ParseAccountingSupplierParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; RootPath: Text)
var
Vendor: Record Vendor;
EDocumentImportHelper: Codeunit "E-Document Import Helper";
VendorNo: Code[20];
begin
- TryMatchVendor(EDocument, TempXMLBuffer, DocumentType, VendorNo);
+ TryMatchVendor(EDocument, TempXMLBuffer, RootPath, VendorNo);
Vendor := EDocumentImportHelper.GetVendor(EDocument, VendorNo);
if Vendor."No." <> '' then begin
@@ -78,15 +77,15 @@ codeunit 28007 "PINT A-NZ Import"
end;
end;
- local procedure TryMatchVendor(EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentType: Text; var VendorNo: Code[20])
+ local procedure TryMatchVendor(EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; RootPath: Text; var VendorNo: Code[20])
var
EDocumentImportHelper: Codeunit "E-Document Import Helper";
- VendorName, VendorAddress, VendorParticipantId : Text;
- VATRegistrationNo: Text[20];
- GLN: Code[13];
ABN: Code[11];
+ GLN: Code[13];
+ VendorAddress, VendorName, VendorParticipantId : Text;
+ VATRegistrationNo: Text[20];
begin
- GetVendorRelatedData(TempXMLBuffer, DocumentType, ABN, GLN, VATRegistrationNo, VendorParticipantId, VendorName, VendorAddress);
+ GetVendorRelatedData(TempXMLBuffer, RootPath, ABN, GLN, VATRegistrationNo, VendorParticipantId, VendorName, VendorAddress);
if FindVendorByABN(VendorNo, ABN) then
exit;
@@ -100,20 +99,20 @@ codeunit 28007 "PINT A-NZ Import"
VendorNo := EDocumentImportHelper.FindVendorByNameAndAddress(VendorName, VendorAddress);
end;
- local procedure GetVendorRelatedData(var TempXMLBuffer: Record "XML Buffer" temporary; DocumentType: Text; var ABN: Code[11]; var GLN: Code[13]; var VATRegistrationNo: Text[20]; VendorParticipantId: Text; VendorName: Text; VendorAddress: Text)
+ local procedure GetVendorRelatedData(var TempXMLBuffer: Record "XML Buffer" temporary; RootPath: Text; var ABN: Code[11]; var GLN: Code[13]; var VATRegistrationNo: Text[20]; VendorParticipantId: Text; VendorName: Text; VendorAddress: Text)
var
ABNSchemeIdTok: Label '0151', Locked = true;
GLNSchemeIdTok: Label '0088', Locked = true;
begin
- if GetNodeAttributeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') = ABNSchemeIdTok then
- ABN := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(ABN));
- if GetNodeAttributeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') = GLNSchemeIdTok then
- GLN := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(GLN));
- VATRegistrationNo := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID'), 1, MaxStrLen(VATRegistrationNo));
- VendorParticipantId := GetNodeAttributeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') + ':';
- VendorParticipantId += this.GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID');
- VendorName := GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name');
- VendorAddress := GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName');
+ if GetNodeAttributeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') = ABNSchemeIdTok then
+ ABN := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(ABN));
+ if GetNodeAttributeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') = GLNSchemeIdTok then
+ GLN := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(GLN));
+ VATRegistrationNo := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID'), 1, MaxStrLen(VATRegistrationNo));
+ VendorParticipantId := GetNodeAttributeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID/@schemeID') + ':';
+ VendorParticipantId += this.GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cbc:EndpointID');
+ VendorName := GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name');
+ VendorAddress := GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingSupplierParty/cac:Party/cac:PostalAddress/cbc:StreetName');
end;
local procedure FindVendorByABN(var VendorNo: Code[20]; InputABN: Code[11]): Boolean
@@ -156,21 +155,20 @@ codeunit 28007 "PINT A-NZ Import"
exit(VendorNo <> '');
end;
- local procedure ParseAccountingCustomerParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; DocumentType: Text)
+ local procedure ParseAccountingCustomerParty(var EDocument: Record "E-Document"; var TempXMLBuffer: Record "XML Buffer" temporary; RootPath: Text)
var
ReceivingId: Text[250];
begin
- EDocument."Receiving Company Name" := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PartyName/cbc:Name'), 1, MaxStrLen(EDocument."Receiving Company Name"));
- EDocument."Receiving Company Address" := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:StreetName'), 1, MaxStrLen(EDocument."Receiving Company Address"));
- EDocument."Receiving Company GLN" := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID'), 1, MaxStrLen(EDocument."Receiving Company GLN"));
- EDocument."Receiving Company VAT Reg. No." := CopyStr(GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID'), 1, MaxStrLen(EDocument."Receiving Company VAT Reg. No."));
- ReceivingId := CopyStr(this.GetNodeAttributeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID/@schemeID'), 1, (MaxStrLen(EDocument."Receiving Company Id") - 1)) + ':';
- ReceivingId += CopyStr(this.GetNodeByPath(TempXMLBuffer, DocumentType + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(EDocument."Receiving Company Id") - StrLen(ReceivingId));
+ EDocument."Receiving Company Name" := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingCustomerParty/cac:Party/cac:PartyName/cbc:Name'), 1, MaxStrLen(EDocument."Receiving Company Name"));
+ EDocument."Receiving Company Address" := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingCustomerParty/cac:Party/cac:PostalAddress/cbc:StreetName'), 1, MaxStrLen(EDocument."Receiving Company Address"));
+ EDocument."Receiving Company GLN" := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingCustomerParty/cac:Party/cac:PartyIdentification/cbc:ID'), 1, MaxStrLen(EDocument."Receiving Company GLN"));
+ EDocument."Receiving Company VAT Reg. No." := CopyStr(GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID'), 1, MaxStrLen(EDocument."Receiving Company VAT Reg. No."));
+ ReceivingId := CopyStr(this.GetNodeAttributeByPath(TempXMLBuffer, RootPath + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID/@schemeID'), 1, (MaxStrLen(EDocument."Receiving Company Id") - 1)) + ':';
+ ReceivingId += CopyStr(this.GetNodeByPath(TempXMLBuffer, RootPath + '/cac:AccountingCustomerParty/cac:Party/cbc:EndpointID'), 1, MaxStrLen(EDocument."Receiving Company Id") - StrLen(ReceivingId));
EDocument."Receiving Company Id" := ReceivingId;
end;
- local procedure GetDocumentType(var TempXMLBuffer: Record "XML Buffer" temporary): Text
- var
+ local procedure GetDocumentType(var TempXMLBuffer: Record "XML Buffer" temporary; var RootPath: Text): Text
begin
TempXMLBuffer.Reset();
TempXMLBuffer.SetRange(Type, TempXMLBuffer.Type::Element);
@@ -179,6 +177,7 @@ codeunit 28007 "PINT A-NZ Import"
if not TempXMLBuffer.FindFirst() then
Error('Invalid XML file');
+ RootPath := TempXMLBuffer.Path;
TempXMLBuffer.Reset();
exit(TempXMLBuffer.Name);
end;
diff --git a/Apps/APAC/EDocumentFormats/PINT A-NZ/test/.resources/pint-anz/pint-anz-invoice-prefixed-ns.xml b/Apps/APAC/EDocumentFormats/PINT A-NZ/test/.resources/pint-anz/pint-anz-invoice-prefixed-ns.xml
new file mode 100644
index 0000000000..a3df5f63cc
--- /dev/null
+++ b/Apps/APAC/EDocumentFormats/PINT A-NZ/test/.resources/pint-anz/pint-anz-invoice-prefixed-ns.xml
@@ -0,0 +1,92 @@
+
+
+ urn:peppol:pint:billing-1@aunz-1
+ urn:peppol:bis:billing
+ INV-001
+ 2026-01-15
+ 2026-02-15
+ 380
+ AUD
+ BR-001
+
+ PO-001
+
+
+
+ 51824753556
+
+ Supplier Pty Ltd
+
+
+ 100 Queen Street
+ Sydney
+ 2000
+
+ AU
+
+
+
+ 51824753556
+
+ GST
+
+
+
+ Supplier Pty Ltd
+
+
+
+
+
+ 12345678901
+
+ Buyer Pty Ltd
+
+
+ 200 George Street
+ Melbourne
+ 3000
+
+ AU
+
+
+
+ 12345678901
+
+ GST
+
+
+
+ Buyer Pty Ltd
+
+
+
+
+ 150.00
+
+
+ 1500.00
+ 1650.00
+ 1650.00
+
+
+ 1
+ 10
+ 1500.00
+
+ Test Item
+
+ S
+ 10
+
+ GST
+
+
+
+
+ 150.00
+
+
+
diff --git a/Apps/APAC/EDocumentFormats/PINT A-NZ/test/.resources/pint-anz/pint-anz-invoice.xml b/Apps/APAC/EDocumentFormats/PINT A-NZ/test/.resources/pint-anz/pint-anz-invoice.xml
new file mode 100644
index 0000000000..95f0666276
--- /dev/null
+++ b/Apps/APAC/EDocumentFormats/PINT A-NZ/test/.resources/pint-anz/pint-anz-invoice.xml
@@ -0,0 +1,92 @@
+
+
+ urn:peppol:pint:billing-1@aunz-1
+ urn:peppol:bis:billing
+ INV-001
+ 2026-01-15
+ 2026-02-15
+ 380
+ AUD
+ BR-001
+
+ PO-001
+
+
+
+ 51824753556
+
+ Supplier Pty Ltd
+
+
+ 100 Queen Street
+ Sydney
+ 2000
+
+ AU
+
+
+
+ 51824753556
+
+ GST
+
+
+
+ Supplier Pty Ltd
+
+
+
+
+
+ 12345678901
+
+ Buyer Pty Ltd
+
+
+ 200 George Street
+ Melbourne
+ 3000
+
+ AU
+
+
+
+ 12345678901
+
+ GST
+
+
+
+ Buyer Pty Ltd
+
+
+
+
+ 150.00
+
+
+ 1500.00
+ 1650.00
+ 1650.00
+
+
+ 1
+ 10
+ 1500.00
+
+ Test Item
+
+ S
+ 10
+
+ GST
+
+
+
+
+ 150.00
+
+
+
diff --git a/Apps/APAC/EDocumentFormats/PINT A-NZ/test/src/PINTANZXML.Codeunit.al b/Apps/APAC/EDocumentFormats/PINT A-NZ/test/src/PINTANZXML.Codeunit.al
index 79f59339b5..28e291398c 100644
--- a/Apps/APAC/EDocumentFormats/PINT A-NZ/test/src/PINTANZXML.Codeunit.al
+++ b/Apps/APAC/EDocumentFormats/PINT A-NZ/test/src/PINTANZXML.Codeunit.al
@@ -246,6 +246,38 @@ codeunit 148004 "PINT A-NZ XML"
VerifyNumberOfLines(TempXMLBuffer, '/Invoice', NumberOfLines);
end;
+ [Test]
+ procedure ImportInvoice_ParseBasicInfo()
+ var
+ EDocument: Record "E-Document";
+ begin
+ // [SCENARIO] Import PINT A-NZ invoice with standard namespace and verify basic info is parsed correctly
+ Initialize();
+
+ // [GIVEN] A PINT A-NZ invoice XML with standard namespace (root element: )
+ // [WHEN] ParseBasicInfo is called
+ ImportInvoiceFromResource(EDocument, 'pint-anz/pint-anz-invoice.xml');
+
+ // [THEN] Basic info is parsed correctly
+ VerifyImportedBasicInfo(EDocument);
+ end;
+
+ [Test]
+ procedure ImportInvoice_NamespacePrefixedRootElement()
+ var
+ EDocument: Record "E-Document";
+ begin
+ // [SCENARIO] Import PINT A-NZ invoice with namespace-prefixed root element and verify basic info is parsed correctly
+ Initialize();
+
+ // [GIVEN] A PINT A-NZ invoice XML with prefixed namespace (root element: )
+ // [WHEN] ParseBasicInfo is called
+ ImportInvoiceFromResource(EDocument, 'pint-anz/pint-anz-invoice-prefixed-ns.xml');
+
+ // [THEN] Basic info is parsed correctly regardless of namespace prefix
+ VerifyImportedBasicInfo(EDocument);
+ end;
+
local procedure Initialize()
begin
LibraryTestInitialize.OnTestInitialize(Codeunit::"PINT A-NZ XML");
@@ -483,4 +515,28 @@ codeunit 148004 "PINT A-NZ XML"
TempXMLBuffer.SetRange(Path, DocumentPrefix + InvoiceLineTok);
Assert.RecordCount(TempXMLBuffer, NumberOfLines);
end;
+
+ local procedure ImportInvoiceFromResource(var EDocument: Record "E-Document"; ResourcePath: Text)
+ var
+ PINTANZImport: Codeunit "PINT A-NZ Import";
+ TempBlob: Codeunit "Temp Blob";
+ OutStream: OutStream;
+ begin
+ TempBlob.CreateOutStream(OutStream, TextEncoding::UTF8);
+ OutStream.WriteText(NavApp.GetResourceAsText(ResourcePath));
+ PINTANZImport.ParseBasicInfo(EDocument, TempBlob);
+ end;
+
+ local procedure VerifyImportedBasicInfo(EDocument: Record "E-Document")
+ begin
+ Assert.AreEqual(EDocument."Document Type"::"Purchase Invoice", EDocument."Document Type", 'Document Type should be Purchase Invoice');
+ Assert.AreEqual('INV-001', EDocument."Incoming E-Document No.", 'Incoming E-Document No. should match');
+ Assert.AreEqual(DMY2Date(15, 1, 2026), EDocument."Document Date", 'Document Date should match');
+ Assert.AreEqual(DMY2Date(15, 2, 2026), EDocument."Due Date", 'Due Date should match');
+ Assert.AreEqual(1500, EDocument."Amount Excl. VAT", 'Amount Excl. VAT should match');
+ Assert.AreEqual(1650, EDocument."Amount Incl. VAT", 'Amount Incl. VAT should match');
+ Assert.AreEqual('PO-001', EDocument."Order No.", 'Order No. should match');
+ Assert.AreEqual('Buyer Pty Ltd', EDocument."Receiving Company Name", 'Receiving Company Name should match');
+ Assert.AreEqual('200 George Street', EDocument."Receiving Company Address", 'Receiving Company Address should match');
+ end;
}