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
22 changes: 20 additions & 2 deletions src/Apps/W1/PEPPOL/App/src/Common/PEPPOL30Impl.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Comment thread
neeleshsinghal marked this conversation as resolved.
end;

procedure GetTaxTotals(PurchaseLine: Record "Purchase Line"; var VATAmtLine: Record "VAT Amount Line")
Expand All @@ -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";
Expand Down Expand Up @@ -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 := '';
Expand Down Expand Up @@ -1640,6 +1644,7 @@ codeunit 37201 "PEPPOL30 Impl."
end;
exit(false);
end;

procedure TransferHeaderToSalesHeader(FromRecord: Variant; var ToSalesHeader: Record "Sales Header")
var
ToRecord: Variant;
Expand Down Expand Up @@ -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
Comment thread
neeleshsinghal marked this conversation as resolved.
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;
Comment thread
neeleshsinghal marked this conversation as resolved.
}
47 changes: 47 additions & 0 deletions src/Apps/W1/PEPPOL/Test/src/PEPPOLBISBillingTests.Codeunit.al
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,40 @@ codeunit 139236 "PEPPOL BIS BillingTests"
VerifyTaxTotalAmounts(0, VatPer, 0, 0);
end;

[Test]
[Scope('OnPrem')]
procedure ExportXml_PEPPOL_BIS3_SalesInvoice_TaxCategoryEZeroValue()
Comment thread
neeleshsinghal marked this conversation as resolved.
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] <PartyTaxScheme> with Seller VAT Identifier <CompanyID> is exported even though the invoice total is zero
CompanyInformation.Get();
InitXPathXMLReaderForInvoice(TempBlob);
LibraryXPathXMLReader.VerifyNodeValueByXPath(
'//cac:PartyTaxScheme/cbc:CompanyID', GetCompanyVATRegNo(CompanyInformation));
// [THEN] <TaxCategory> has <ID> 'E'
LibraryXPathXMLReader.VerifyNodeValueByXPath('//cac:TaxCategory/cbc:ID', GetTaxCategoryE());
end;

local procedure Initialize()
var
CompanyInfo: Record "Company Information";
Expand Down Expand Up @@ -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";
Expand Down
Loading