You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To implement a complex change in the calculation of the service ledger entry, i need the following four events. Please add them, if possible.
procedure InsertMultipleServLedgEntries(var NoOfPayments: Integer; var DueDate: Date; var NonDistrAmount: array[4] of Decimal; var InvRoundedAmount: array[4] of Decimal; var ServHeader: Record "Service Header"; InvFrom: Date; NextInvDate: Date; AddingNewLines: Boolean; CountOfEntryLoop: Integer; ServContractLine: Record "Service Contract Line"; AmountRoundingPrecision: Decimal)
var
ServContractHeader: Record "Service Contract Header";
Index: Integer;
IsHandled: Boolean;
begin
if CountOfEntryLoop = 0 then
exit;
OnBeforeInsertMultipleServLedgEntries(ServLedgEntry, ServContractLine);
CheckMParts := false;
if DueDate <> CalcDate('<CM>', DueDate) then begin
DueDate := CalcDate('<-CM-1D>', DueDate);
ServContractHeader.Get(ServContractLine."Contract Type", ServContractLine."Contract No.");
CheckMParts := true;
end;
//FIRST EVENT BEGIN
OnInsertMultipleServLedgEntriesUpdateDateFieldsBeforeCalcNonDistrAmount(InvFrom, DueDate, NoOfPayments);
//FIRST EVENT END
NonDistrAmount[AmountType::Amount] :=
-CalcContractLineAmount(ServContractLine."Line Amount", InvFrom, DueDate);
NonDistrAmount[AmountType::UnitPrice] :=
-CalcContractLineAmount(ServContractLine."Line Value", InvFrom, DueDate);
NonDistrAmount[AmountType::UnitCost] :=
CalcContractLineAmount(ServContractLine."Line Cost", InvFrom, DueDate);
NonDistrAmount[AmountType::DiscAmount] :=
CalcContractLineAmount(ServContractLine."Line Discount Amount", InvFrom, DueDate);
ServLedgEntry."Service Item No. (Serviced)" := ServContractLine."Service Item No.";
ServLedgEntry."Item No. (Serviced)" := ServContractLine."Item No.";
ServLedgEntry."Serial No. (Serviced)" := ServContractLine."Serial No.";
DueDate := NextInvDate;
if CheckMParts and (NoOfPayments > 1) then begin
//SECOND EVENT BEGIN
IsHandled := false;
OnInsertMultipleServLedgEntriesUpdateOnBeforeUpdateNoOfPayments(CheckMParts, NoOfPayments, IsHandled);
if not IsHandled then
//SECOND EVENT END
NoOfPayments := NoOfPayments - 1;
// the count of invoice lines should never exceed the count of payments
if CountOfEntryLoop > NoOfPayments then
CountOfEntryLoop := NoOfPayments;
end;
if AddingNewLines then
DueDate := InvFrom;
for Index := 1 to CountOfEntryLoop do begin
//THIRD EVENT BEGIN
IsHandled := false;
OnInsertMultipleServLedgEntriesOnBeforeSetSetServLedgEntryAmounts(ServLedgEntry,InvRoundedAmount,NonDistrAmount,NoOfPayments,Index,CountOfEntryLoop,AmountRoundingPrecision,DueDate,IsHandled);
if not IsHandled then
//THIRD EVENT END
SetServLedgEntryAmounts(
ServLedgEntry, InvRoundedAmount,
NonDistrAmount[AmountType::Amount] / (NoOfPayments + 1 - Index),
NonDistrAmount[AmountType::UnitPrice] / (NoOfPayments + 1 - Index),
NonDistrAmount[AmountType::UnitCost] / (NoOfPayments + 1 - Index),
NonDistrAmount[AmountType::DiscAmount] / (NoOfPayments + 1 - Index),
AmountRoundingPrecision);
ServLedgEntry."Cost Amount" := ServLedgEntry."Charged Qty." * ServLedgEntry."Unit Cost";
NonDistrAmount[AmountType::Amount] -= ServLedgEntry."Amount (LCY)";
NonDistrAmount[AmountType::UnitPrice] -= ServLedgEntry."Unit Price";
NonDistrAmount[AmountType::UnitCost] -= ServLedgEntry."Unit Cost";
NonDistrAmount[AmountType::DiscAmount] -= ServLedgEntry."Contract Disc. Amount";
ServLedgEntry."Entry No." := NextEntry;
UpdateServLedgEntryAmount(ServLedgEntry, ServHeader);
ServLedgEntry."Posting Date" := DueDate;
ServLedgEntry.Prepaid := true;
IsHandled := false;
OnInsertMultipleServLedgEntriesOnBeforeServLedgEntryInsert(ServLedgEntry, ServContractHeader, ServContractLine, NonDistrAmount, IsHandled, ServHeader);
if IsHandled then
exit;
ServLedgEntry.Insert();
NextEntry += 1;
DueDate := CalcDate('<1M>', DueDate);
//FOURTH EVENT BEGIN
OnInsertMultipleServLedgEntriesOnAfterSetDueDate(Index, FirstServEntryNo, DueDate, ServLedgEntry, CountOfEntryLoop, InvRoundedAmount, NonDistrAmount, ServHeader, AmountRoundingPrecision);
//FOURTH EVENT END
end;
end;
The integration events:
[IntegrationEvent(false,false)]
local procedure OnInsertMultipleServLedgEntriesUpdateDateFieldsBeforeCalcNonDistrAmount(var InvFrom: Date; var DueDate: Date; NoOfPayments: Integer)
begin
end;
[IntegrationEvent(false,false)]
local procedure OnInsertMultipleServLedgEntriesUpdateOnBeforeUpdateNoOfPayments(CheckMParts: Boolean; var NoOfPayments: Integer; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false,false)]
local procedure OnInsertMultipleServLedgEntriesOnBeforeSetSetServLedgEntryAmounts(var ServLedgEntry: Record "Service Ledger Entry"; var InvRoundedAmount: array[4] of Decimal; NonDistrAmount: array[4] of Decimal; NoOfPayments: Integer; Index: Integer; CountOfEntryLoop: Integer; AmountRoundingPrecision: Decimal; DueDate: Date; var IsHandled: Boolean)
begin
end;
[IntegrationEvent(false, false)]
local procedure OnInsertMultipleServLedgEntriesOnAfterSetDueDate(Index: Integer; var FirstServEntryNo: Integer; var DueDate: Date; ServLedgEntry: Record "Service Ledger Entry"; CountOfEntryLoop: Integer; InvRoundedAmount: array[4] of Decimal; var NonDistrAmount: array[4] of Decimal; var ServHeader: Record "Service Header"; AmountRoundingPrecision: Decimal)
begin
end;
Additional context
Please add these events to allow me to implement the necessary changes
Internal work item: AB#558846
The text was updated successfully, but these errors were encountered:
Describe the request
To implement a complex change in the calculation of the service ledger entry, i need the following four events. Please add them, if possible.
The integration events:
Additional context
Please add these events to allow me to implement the necessary changes
Internal work item: AB#558846
The text was updated successfully, but these errors were encountered: