Why do you need this change?
We need to override the logic that calculates ShareOfCost inside procedure UpdateCostShareBufFromInvAdjmtEntryOrder of Report 5848 "Cost Shares Breakdown". The standard code uses:
ShareOfCost := ItemLedgEntry.GetCostingQty / OutputQty;
But custom costing scenarios require different logic to calculate the cost share correctly.
All subsequent updates to Capacity, "Capacity Overhead", "Material Overhead", and Subcontracted depend on ShareOfCost being calculated correctly at this point. There is no way to correct these values later without re-entering the procedure. No event currently exists before the ShareOfCost calculation that allows subscribers to override or skip the standard logic.
Describe the request
Add an integration event OnBeforeUpdateCostShareBufFromInvAdjmtEntryOrder in procedure UpdateCostShareBufFromInvAdjmtEntryOrder before the ShareOfCost assignment.
local procedure UpdateCostShareBufFromInvAdjmtEntryOrder(ItemLedgEntry: Record "Item Ledger Entry"; var CostShareBuffer: Record "Cost Share Buffer")
var
InvtAdjmtEntryOrder: Record "Inventory Adjmt. Entry (Order)";
CalcInvtAdjmtOrder: Codeunit "Calc. Inventory Adjmt. - Order";
ShareOfCost: Decimal;
OutputQty: Decimal;
IsHandled: Boolean;
begin
if not InvtAdjmtEntryOrder.Get(ItemLedgEntry."Order Type", ItemLedgEntry."Order No.", ItemLedgEntry."Order Line No.") then
exit;
OutputQty := CalcInvtAdjmtOrder.CalcOutputQty(InvtAdjmtEntryOrder, false);
CalcInvtAdjmtOrder.CalcActualUsageCosts(InvtAdjmtEntryOrder, OutputQty, InvtAdjmtEntryOrder);
IsHandled := false;
OnBeforeUpdateCostShareBufFromInvAdjmtEntryOrder(ItemLedgEntry, CostShareBuffer, InvtAdjmtEntryOrder, OutputQty, ShareOfCost, IsHandled);
if not IsHandled then
if OutputQty <> 0 then begin
ShareOfCost := ItemLedgEntry.Quantity / OutputQty;
CostShareBuffer.Capacity *= ShareOfCost;
CostShareBuffer."Capacity Overhead" *= ShareOfCost;
CostShareBuffer."Material Overhead" *= ShareOfCost;
CostShareBuffer.Subcontracted *= ShareOfCost;
end;
end;
Event Signature:
[IntegrationEvent(false, false)]
local procedure OnBeforeUpdateCostShareBufFromInvAdjmtEntryOrder(
ItemLedgEntry: Record "Item Ledger Entry";
var CostShareBuffer: Record "Cost Share Buffer";
var InvtAdjmtEntryOrder: Record "Inventory Adjmt. Entry (Order)";
OutputQty: Decimal;
var ShareOfCost: Decimal;
var IsHandled: Boolean)
begin
end;
Alternatives evaluated:
The existing code always uses ShareOfCost := ItemLedgEntry.Quantity / OutputQty, so subscribers cannot replace the calculation with custom logic. No event currently exists before the ShareOfCost computation in UpdateCostShareBufFromInvAdjmtEntryOrder.
Internal work item: AB#639379
Why do you need this change?
We need to override the logic that calculates
ShareOfCostinside procedureUpdateCostShareBufFromInvAdjmtEntryOrderof Report 5848 "Cost Shares Breakdown". The standard code uses:ShareOfCost := ItemLedgEntry.GetCostingQty / OutputQty;But custom costing scenarios require different logic to calculate the cost share correctly.
All subsequent updates to Capacity, "Capacity Overhead", "Material Overhead", and Subcontracted depend on
ShareOfCostbeing calculated correctly at this point. There is no way to correct these values later without re-entering the procedure. No event currently exists before theShareOfCostcalculation that allows subscribers to override or skip the standard logic.Describe the request
Add an integration event
OnBeforeUpdateCostShareBufFromInvAdjmtEntryOrderin procedureUpdateCostShareBufFromInvAdjmtEntryOrderbefore theShareOfCostassignment.Event Signature:
Alternatives evaluated:
The existing code always uses
ShareOfCost := ItemLedgEntry.Quantity / OutputQty, so subscribers cannot replace the calculation with custom logic. No event currently exists before theShareOfCostcomputation inUpdateCostShareBufFromInvAdjmtEntryOrder.Internal work item: AB#639379