Skip to content

[W1][Report][5801][Invt. Valuation - Cost Spec.] Add integration event OnBeforeCheckSumQty in SumQty procedure #30141

@mavohra

Description

@mavohra

Why do you need this change?

The standard code in SumQty of Report 5801 "Invt. Valuation - Cost Spec." evaluates ItemLedgEntry.Quantity * AppliedQty < 0 unconditionally as part of the exit condition. Items with alternate units of measure require ItemLedgEntry.GetCostingQty() instead of ItemLedgEntry.Quantity to correctly reflect the costing quantity. The entire condition block including ItemLedgEntry."Posting Date" > ValuationDate must be re-evaluated against the costing quantity rather than the base quantity.

There is no way to override the exit condition after the fact as the exit has already been skipped or executed. No event currently exists before the condition check in SumQty of Report 5801 that allows subscribers to take full control of the exit logic.

Describe the request

Add an integration event OnBeforeCheckSumQty in SumQty of Report 5801 "Invt. Valuation - Cost Spec." before the if(ItemLedgEntry.Quantity * AppliedQty < 0)condition check, with IsHandled support to allow subscribers to override the entire exit condition and skip standard execution.

local procedure SumQty(var RemainingQty: Decimal; var PosQty: Decimal; EntryNo: Integer; AppliedQty: Decimal)
var
    ItemLedgEntry: Record "Item Ledger Entry";
    IsHandled: Boolean;
begin
    ItemLedgEntry.Get(EntryNo);

    IsHandled := false;
    OnBeforeCheckSumQty(ItemLedgEntry, AppliedQty, ValuationDate, IsHandled); 
    if IsHandled then
        exit;

    if (ItemLedgEntry.Quantity * AppliedQty < 0) or
       (ItemLedgEntry."Posting Date" > ValuationDate)
    then
        exit;

    RemainingQty := RemainingQty + AppliedQty;
    if IsPositive then
        PosQty := PosQty + AppliedQty;
end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnBeforeCheckSumQty(
    ItemLedgEntry: Record "Item Ledger Entry";
    AppliedQty: Decimal;
    ValuationDate: Date;
    var IsHandled: Boolean)
begin
end;

Alternatives evaluated:
A targeted OnAfterGetItemLedgEntryQty event replacing only the quantity source preserves the PostingDate check but does not allow full override of the exit condition. OnBeforeCheckSumQty with IsHandled is required when the subscriber needs to re-evaluate the entire condition including PostingDate against a custom quantity source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions