ALAppExtensions
ALAppExtensions copied to clipboard
[W1][Codeunit][5940][ServContractManagement] New event in procedure CreateServiceLine
Why do you need this change?
Hello,
I have a need for events in the procedure CreateServiceLine to add additional lines after the service lines to add additional information in the service invoice.
Describe the request
procedure CreateServiceLine(ServHeader: Record "Service Header"; ContractType: Enum "Service Contract Type"; ContractNo: Code[20]; InvFromDate: Date; InvToDate: Date; ServiceApplyEntry: Integer; SignningContract: Boolean)
var
ServContractHeader: Record "Service Contract Header";
ServDocReg: Record "Service Document Register";
ServiceLedgerEntry: Record "Service Ledger Entry";
TotalServLine: Record "Service Line";
TotalServLineLCY: Record "Service Line";
ServContractAccGr: Record "Service Contract Account Group";
IsHandled: Boolean;
LatestInvToDate: Date;
begin
IsHandled := false;
OnBeforeCreateServiceLine(ServHeader, ContractType, ContractNo, InvFromDate, InvToDate, ServiceApplyEntry, SignningContract, IsHandled);
if IsHandled then
exit;
ServContractHeader.Get(ContractType, ContractNo);
if ServContractHeader."Invoice Period" = ServContractHeader."Invoice Period"::None then
exit;
ServLineNo := 0;
ServLine.Reset();
ServLine.SetRange("Document Type", ServLine."Document Type"::Invoice);
ServLine.SetRange("Document No.", ServHeader."No.");
if ServLine.FindLast() then
ServLineNo := ServLine."Line No.";
if ServContractHeader.Prepaid and not SignningContract then begin
ServContractHeader.TestField("Serv. Contract Acc. Gr. Code");
ServContractAccGr.Get(ServContractHeader."Serv. Contract Acc. Gr. Code");
ServContractAccGr.TestField("Prepaid Contract Acc.");
GLAcc.Get(ServContractAccGr."Prepaid Contract Acc.");
GLAcc.TestField("Direct Posting");
end else begin
ServContractHeader.TestField("Serv. Contract Acc. Gr. Code");
ServContractAccGr.Get(ServContractHeader."Serv. Contract Acc. Gr. Code");
ServContractAccGr.TestField("Non-Prepaid Contract Acc.");
GLAcc.Get(ServContractAccGr."Non-Prepaid Contract Acc.");
GLAcc.TestField("Direct Posting");
end;
AppliedGLAccount := GLAcc."No.";
LatestInvToDate := InvToDate;
if ServiceLedgerEntry.Get(ServiceApplyEntry) then begin
ServiceLedgerEntry.SetRange("Entry No.", ServiceApplyEntry, ServiceLedgerEntry."Apply Until Entry No.");
if ServiceLedgerEntry.FindSet() then
repeat
if ServiceLedgerEntry.Prepaid then begin
InvFromDate := ServiceLedgerEntry."Posting Date";
InvToDate := CalcDate('<CM>', InvFromDate);
if InvToDate > LatestInvToDate then
InvToDate := LatestInvToDate;
end;
ServLedgEntryToServiceLine(
TotalServLine,
TotalServLineLCY,
ServHeader,
ServiceLedgerEntry,
ContractNo,
InvFromDate,
InvToDate);
until ServiceLedgerEntry.Next() = 0
//NEW EVENT BEGIN
OnCreateServiceLineOnAfterServLedgEntryToServieLine(ServHeader, InvFromDate, InvToDate);
//NEW EVENT END
end else begin
Clear(ServiceLedgerEntry);
ServLedgEntryToServiceLine(
TotalServLine,
TotalServLineLCY,
ServHeader,
ServiceLedgerEntry,
ContractNo,
InvFromDate,
InvToDate);
end;
Clear(ServDocReg);
ServDocReg.InsertServiceSalesDocument(
ServDocReg."Source Document Type"::Contract, ContractNo,
ServDocReg."Destination Document Type"::Invoice, ServLine."Document No.");
end;
//NEW EVENT DEFINITION
[IntegrationEvent(false,false)]
local procedure OnCreateServiceLineOnAfterServLedgEntryToServieLine(ServiceHeader: Record "Service Header; InvoiceFromDate: Date; InvoiceToDate: Date)
begin
end;
Internal work item: AB#579885
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. 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.
Build ID: 35322.