Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Event Request] Codeunit 5896 "Calc. Inventory Adjmt. - Order" - Procedure CalcStandardCost - OnBeforeCalcStandardCost #28012

Open
mavohra opened this issue Jan 29, 2025 · 0 comments
Labels
event-request Request for adding an event SCM GitHub request for SCM area

Comments

@mavohra
Copy link

mavohra commented Jan 29, 2025

Describe the request

Please add the event OnBeforeCalcStandardCost in Procedure CalcStandardCost in Codeunit 5896 "Calc. Inventory Adjmt. - Order"

 local procedure CalcStandardCost(var InvtAdjmtEntryOrder: Record "Inventory Adjmt. Entry (Order)"; OutputQty: Decimal)
    var
        IsHandled: Boolean;
    begin
        OnBeforeCalcStandardCost(InvtAdjmtEntryOrder, OutputQty, IsHandled); // <--- New Event
        if IsHandled then
            exit;


        if not InvtAdjmtEntryOrder.Find() or not InvtAdjmtEntryOrder."Completely Invoiced" then
            InvtAdjmtEntryOrder.GetCostsFromItem(OutputQty)
        else begin
            InvtAdjmtEntryOrder.RoundCosts(OutputQty);

            // !!! Our Custom logic needs to be added in this else statement. We would like an event either at start i.e (OnBeforeCalcStandardCost) or right after InvtAdjmtEntryOrder.RoundCosts(OutputQty); in the else statement. !!!


            InvtAdjmtEntryOrder.CalcDirectCostFromCostShares();
            InvtAdjmtEntryOrder.CalcIndirectCostFromCostShares();
            InvtAdjmtEntryOrder.CalcUnitCost();
        end;
    end;

    [IntegrationEvent(false, false)]
    local procedure OnBeforeCalcStandardCost(var InvtAdjmtEntryOrder: Record "Inventory Adjmt. Entry (Order)"; OutputQty: Decimal; var IsHandled: Boolean)
    begin
    end;

Additional context

We need to adjust inventory adjustment costs for custom order types specifically within the else block of the CalcStandardCost procedure. Our logic must run either:

  1. At the start of the procedure (to conditionally skip standard logic via IsHandled), or
  2. Immediately after RoundCosts(OutputQty) in the else block (to inject adjustments after rounding).
    Internal work item: AB#563988
@AndersLarsenMicrosoft AndersLarsenMicrosoft added event-request Request for adding an event SCM GitHub request for SCM area labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event-request Request for adding an event SCM GitHub request for SCM area
Projects
None yet
Development

No branches or pull requests

2 participants