ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Table 38 "Purchase Header".Field("Prices Including VAT")

Open Softstore opened this issue 5 years ago • 1 comments

Include the possibilty to subscrive the OnBeforePricesIncludingVAT to give the possibility to ident with other account types

trigger OnValidate()             var                 PurchLine: Record "Purchase Line";                 Currency: Record Currency;                 ConfirmManagement: Codeunit "Confirm Management";                 RecalculatePrice: Boolean;                 VatFactor: Decimal;                 LineInvDiscAmt: Decimal;                 InvDiscRounding: Decimal;             begin //------------------------------------------------- IsHandheld := false; OnBeforePricesIncludingVAT(PurchaseHeader, PurchLine, IsHandheld); IF IsHandeld then exit; //-------------------------------------------------                 TestStatusOpen();

                if "Prices Including VAT" <> xRec."Prices Including VAT" then begin                     PurchLine.SetRange("Document Type", "Document Type");                     PurchLine.SetRange("Document No.", "No.");                     PurchLine.SetFilter("Direct Unit Cost", '<>%1', 0);                     PurchLine.SetFilter("VAT %", '<>%1', 0);                     if PurchLine.Find('-') then begin                         if GetHideValidationDialog or not GuiAllowed then                             RecalculatePrice := true                         else                             RecalculatePrice :=                               ConfirmManagement.GetResponseOrDefault(                                 StrSubstNo(                                   Text025 +                                   Text027,                                   FieldCaption("Prices Including VAT"), PurchLine.FieldCaption("Direct Unit Cost")),                                 true);                         OnAfterConfirmPurchPrice(Rec, PurchLine, RecalculatePrice);                         PurchLine.SetPurchHeader(Rec);

                        Currency.Initialize("Currency Code");

                        PurchLine.FindSet;                         repeat                             PurchLine.TestField("Quantity Invoiced", 0);                             PurchLine.TestField("Prepmt. Amt. Inv.", 0);                             if not RecalculatePrice then begin                                 PurchLine."VAT Difference" := 0;                                 PurchLine.UpdateAmounts;                             end else begin                                 VatFactor := 1 + PurchLine."VAT %" / 100;                                 if VatFactor = 0 then                                     VatFactor := 1;                                 if not "Prices Including VAT" then                                     VatFactor := 1 / VatFactor;                                 if PurchLine."VAT Calculation Type" = PurchLine."VAT Calculation Type"::"Full VAT" then                                     VatFactor := 1;                                 PurchLine."Direct Unit Cost" :=                                   Round(PurchLine."Direct Unit Cost" * VatFactor, Currency."Unit-Amount Rounding Precision");                                 PurchLine."Line Discount Amount" :=                                   Round(                                     PurchLine.Quantity * PurchLine."Direct Unit Cost" * PurchLine."Line Discount %" / 100,                                     Currency."Amount Rounding Precision");                                 LineInvDiscAmt := InvDiscRounding + PurchLine."Inv. Discount Amount" * VatFactor;                                 PurchLine."Inv. Discount Amount" := Round(LineInvDiscAmt, Currency."Amount Rounding Precision");                                 InvDiscRounding := LineInvDiscAmt - PurchLine."Inv. Discount Amount";                                 if PurchLine."VAT Calculation Type" = PurchLine."VAT Calculation Type"::"Full VAT" then                                     PurchLine."Line Amount" := PurchLine."Amount Including VAT"                                 else                                     if "Prices Including VAT" then                                         PurchLine."Line Amount" := PurchLine."Amount Including VAT" + PurchLine."Inv. Discount Amount"                                     else                                         PurchLine."Line Amount" := PurchLine.Amount + PurchLine."Inv. Discount Amount";                             end;                             OnValidatePricesIncludingVATOnBeforePurchLineModify(PurchHeader, PurchLine, Currency, RecalculatePrice);                             PurchLine.Modify();                         until PurchLine.Next = 0;                     end;                     OnAfterChangePricesIncludingVAT(Rec);                 end;             end;

[IntegrationEvent(false, false)]
local procedure OnBeforePricesIncludingVAT(var PurchaseHeader: Record "Purchase Header"; var PurchLine: Record "Purchase Line"; var IsHandheld: boolean)
begin
end;

Softstore avatar Jan 27 '21 22:01 Softstore

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. We will update this issue with information about availability. 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.

JesperSchulz avatar Feb 01 '21 15:02 JesperSchulz