From c38d66696c378be0f8f5c0d93d014bb336f199e1 Mon Sep 17 00:00:00 2001 From: v-nesinghal Date: Tue, 18 Aug 2026 05:15:09 +0000 Subject: [PATCH] 633222 finitial commit --- .../App/src/Common/PEPPOL30Impl.Codeunit.al | 22 ++++++++- .../src/PEPPOLBISBillingTests.Codeunit.al | 47 +++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al b/src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al index 1e6de96b025..92606e79eee 100644 --- a/src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al +++ b/src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al @@ -1324,7 +1324,8 @@ codeunit 37201 "PEPPOL30 Impl." if VATAmtLine.InsertLine() then begin VATAmtLine."Line Amount" += SalesLine."Line Amount"; VATAmtLine.Modify(); - end; + end else + InsertZeroAmountVATAmtLine(VATAmtLine, SalesLine."Line Amount"); end; procedure GetTaxTotals(PurchaseLine: Record "Purchase Line"; var VATAmtLine: Record "VAT Amount Line") @@ -1349,8 +1350,10 @@ codeunit 37201 "PEPPOL30 Impl." if VATAmtLine.InsertLine() then begin VATAmtLine."Line Amount" += PurchaseLine."Line Amount"; VATAmtLine.Modify(); - end; + end else + InsertZeroAmountVATAmtLine(VATAmtLine, PurchaseLine."Line Amount"); end; + procedure GetTaxCategories(SalesLine: Record "Sales Line"; var VATProductPostingGroupCategory: Record "VAT Product Posting Group") var VATPostingSetup: Record "VAT Posting Setup"; @@ -1404,6 +1407,7 @@ codeunit 37201 "PEPPOL30 Impl." TempPurchaseLine.Insert(); end; end; + procedure GetTaxExemptionReason(var VATProductPostingGroupCategory: Record "VAT Product Posting Group"; var TaxExemptionReasonTxt: Text; TaxCategoryID: Text) begin TaxExemptionReasonTxt := ''; @@ -1640,6 +1644,7 @@ codeunit 37201 "PEPPOL30 Impl." end; exit(false); end; + procedure TransferHeaderToSalesHeader(FromRecord: Variant; var ToSalesHeader: Record "Sales Header") var ToRecord: Variant; @@ -1847,4 +1852,17 @@ codeunit 37201 "PEPPOL30 Impl." IdentificationCode := GetCountryISOCode(PurchaseHeader."Ship-to Country/Region Code"); ListID := GetISO3166_1Alpha2(); end; + + local procedure InsertZeroAmountVATAmtLine(var VATAmtLine: Record "VAT Amount Line"; LineAmount: Decimal) + begin + VATAmtLine.Validate(Positive, LineAmount >= 0); + if VATAmtLine.Find() then begin + VATAmtLine."Line Amount" += LineAmount; + VATAmtLine.Modify(); + end else begin + VATAmtLine."VAT Amount" := VATAmtLine."Amount Including VAT" - VATAmtLine."VAT Base"; + VATAmtLine."Line Amount" += LineAmount; + VATAmtLine.Insert(); + end; + end; } diff --git a/src/Apps/W1/PEPPOL/Test/src/PEPPOLBISBillingTests.Codeunit.al b/src/Apps/W1/PEPPOL/Test/src/PEPPOLBISBillingTests.Codeunit.al index 6507c3b7c3d..e14c1870a02 100644 --- a/src/Apps/W1/PEPPOL/Test/src/PEPPOLBISBillingTests.Codeunit.al +++ b/src/Apps/W1/PEPPOL/Test/src/PEPPOLBISBillingTests.Codeunit.al @@ -1548,6 +1548,40 @@ codeunit 139236 "PEPPOL BIS BillingTests" VerifyTaxTotalAmounts(0, VatPer, 0, 0); end; + [Test] + [Scope('OnPrem')] + procedure ExportXml_PEPPOL_BIS3_SalesInvoice_TaxCategoryEZeroValue() + var + SalesHeader: Record "Sales Header"; + SalesInvoiceHeader: Record "Sales Invoice Header"; + CompanyInformation: Record "Company Information"; + TempBlob: Codeunit "Temp Blob"; + begin + // [FEATURE] [Invoice] [Tax Category] + // [SCENARIO 633222] PEPPOL BIS3. Export zero-value Sales Invoice with Tax Category 'E' - VAT Exempt still exports Seller VAT Identifier + Initialize(); + + // [GIVEN] Company has "VAT Registration No." = 'NO1234567890' + UpdateCompanyVATRegNo(); + + // [GIVEN] Posted Sales Invoice with Tax Category 'E' and a fully discounted (zero-value) line + SalesInvoiceHeader.Get( + CreatePostSalesDocWithTaxCategoryAndFullLineDiscount( + CreateCustomerWithAddressAndVATRegNo(), SalesHeader."Document Type"::Invoice, GetTaxCategoryE(), 0)); + + // [WHEN] Export Sales Invoice with PEPPOL BIS3 + SalesInvoiceHeader.SetRecFilter(); + PEPPOLXMLExportToBlob(SalesInvoiceHeader, CreateBISElectronicDocumentFormatSalesInvoice(), TempBlob); + + // [THEN] with Seller VAT Identifier is exported even though the invoice total is zero + CompanyInformation.Get(); + InitXPathXMLReaderForInvoice(TempBlob); + LibraryXPathXMLReader.VerifyNodeValueByXPath( + '//cac:PartyTaxScheme/cbc:CompanyID', GetCompanyVATRegNo(CompanyInformation)); + // [THEN] has 'E' + LibraryXPathXMLReader.VerifyNodeValueByXPath('//cac:TaxCategory/cbc:ID', GetTaxCategoryE()); + end; + local procedure Initialize() var CompanyInfo: Record "Company Information"; @@ -1753,6 +1787,19 @@ codeunit 139236 "PEPPOL BIS BillingTests" exit(LibrarySales.PostSalesDocument(SalesHeader, true, true)); end; + local procedure CreatePostSalesDocWithTaxCategoryAndFullLineDiscount(CustomerNo: Code[20]; DocumentType: Enum "Sales Document Type"; TaxCategory: Code[10]; VATPct: Decimal): Code[20] + var + SalesHeader: Record "Sales Header"; + SalesLine: Record "Sales Line"; + begin + CreateSalesDoc(SalesHeader, SalesLine, CustomerNo, DocumentType, ''); + SalesLine.Validate( + "VAT Prod. Posting Group", CreateVATPostingSetupWithTaxCategory(SalesHeader."VAT Bus. Posting Group", TaxCategory, VATPct)); + SalesLine.Validate("Line Discount %", 100); + SalesLine.Modify(true); + exit(LibrarySales.PostSalesDocument(SalesHeader, true, true)); + end; + local procedure CreatePostSalesDocWithTaxCategoryReverseVAT(CustomerNo: Code[20]; DocumentType: Enum "Sales Document Type"; TaxCategory: Code[10]; VATPct: Decimal): Code[20] var SalesHeader: Record "Sales Header";