[Event Request] Codeunit 398 "Sales Tax Calculate" OnDistTaxBeforeFindPurchLineSetTempSalesTaxLineAmount & OnDistTaxBeforeFindPurchLineAmounts
Hi, Please add two new Event Publishers in Procedure "DistTaxOverPurchLines" , codeunit "Sales Tax Calculate". We are on 'MX Business Central 18.5', 18.0.29486.0. This change will enable us to apply further filtering over the distribution of amounts on our purchase lines.
Example code changes:
ResetTaxAmountsInPurchLines(PurchLine, PurchHeader."Tax Area Code");
PurchLine.SetPurchHeader(PurchHeader);
with TempSalesTaxAmountLine do begin
Reset;
// LOCKING
if FindSet then
repeat
if ("Tax Jurisdiction Code" <> TempSalesTaxLine2."Tax Jurisdiction Code") and RoundByJurisdiction then begin
TempSalesTaxLine2."Tax Jurisdiction Code" := "Tax Jurisdiction Code";
TotalTaxAmountRounding := 0;
ExpenseTaxAmountRounding := 0;
end;
if TaxCountry = TaxCountry::US then
PurchLine.SetRange("Tax Area Code", "Tax Area Code");
PurchLine.SetRange("Tax Group Code", "Tax Group Code");
PurchLine.SetRange("Use Tax", "Use Tax");
PurchLine.SetCurrentKey(Amount);
OnDistTaxOnBeforeFindPurchLineSetTempSalesTaxLineAmount(PurchLine, TempSalesTaxAmountLine); // New Event Publisher
PurchLine.FindSet(true);
repeat
if (TaxCountry = TaxCountry::US) or
((TaxCountry = TaxCountry::CA) and TaxAreaLine.Get(PurchLine."Tax Area Code", "Tax Jurisdiction Code"))
then begin
The first Integration Event declaration:
[IntegrationEvent(false, false)]
local procedure OnDistTaxBeforeFindPurchLineSetTempSalesTaxLineAmount(var PurchLine: Record "Purchase Line"; var TempSalesTaxAmountLine : Record "Sales Tax Amount Line" temporary)
begin
end;
The first code change can only be used if we have the ability to then reset or update our previous changes on PurchLines. Therefore a second event is requested, and essential in our case. Example:
until PurchLine.Next() = 0;
until Next() = 0;
PurchLine.SetRange("Tax Area Code");
PurchLine.SetRange("Tax Group Code");
PurchLine.SetRange("Use Tax");
PurchLine.SetRange("Document Type", PurchHeader."Document Type");
PurchLine.SetRange("Document No.", PurchHeader."No.");
OnDistTaxBeforeFindPurchLineAmounts(PurchLine, TempSalesTaxAmountLine); // New Event
if PurchLine.FindSet(true) then
repeat
PurchLine."Amount Including VAT" := Round(PurchLine."Amount Including VAT", Currency."Amount Rounding Precision");
PurchLine.Amount :=
Round(PurchLine."Line Amount" - PurchLine."Inv. Discount Amount", Currency."Amount Rounding Precision");
The second Integration Event declaration:
[IntegrationEvent(false, false)]
local procedure OnDistTaxBeforeFindPurchLineAmounts(var PurchLine: Record "Purchase Line"; var TempSalesTaxAmountLine : Record "Sales Tax Amount Line" temporary)
begin
end;
Very many thanks.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.