Change the code in the ValidateNextInvoicePeriod function in the Service Contract Header table (5965) as follows:
Existing code 1...
END;
PROCEDURE ValidateNextInvoicePeriod@9();
VAR
InvFrom@1001 : Date;
InvTo@1000 : Date;
NoOfMonths@1002 : Integer;
NoOfDays@1003 : Integer;
...
Replacement code 1...
END;
PROCEDURE ValidateNextInvoicePeriod@9();
VAR
// Add the following line.
ServiceContractLine@1002 : Record 5964;
InvFrom@1001 : Date;
InvTo@1000 : Date;
NoOfMonths@1002 : Integer;
NoOfDays@1003 : Integer;
...
Existing code 2...
IF Prepaid THEN BEGIN
IF (DATE2DMY(InvFrom,2) = DATE2DMY(InvTo,2)) AND
(DATE2DMY(InvFrom,3) = DATE2DMY(InvTo,3))
THEN BEGIN
// Delete the following line.
"Amount per Period" := ServContractMgt.CalcContractAmount(Rec,InvFrom,InvTo);
END ELSE BEGIN
"Amount per Period" := 0;
ServContractMgt.NoOfMonthsAndDaysInPeriod(InvFrom,InvTo,NoOfMonths,NoOfDays);
"Amount per Period" :=
...
Replacement code 2...
IF Prepaid THEN BEGIN
IF (DATE2DMY(InvFrom,2) = DATE2DMY(InvTo,2)) AND
(DATE2DMY(InvFrom,3) = DATE2DMY(InvTo,3))
THEN BEGIN
// Add the following lines.
ServiceContractLine.RESET;
ServiceContractLine.SETRANGE("Contract Type","Contract Type");
ServiceContractLine.SETRANGE("Contract No.","Contract No.");
IF ServiceContractLine.FINDSET THEN
REPEAT
"Amount per Period" := ServContractMgt.CalcContractAmount(Rec,InvFrom,InvTo,
ServiceContractLine."Line No.");
UNTIL ServiceContractLine.NEXT=0;
// End of the lines.
END ELSE BEGIN
"Amount per Period" := 0;
ServContractMgt.NoOfMonthsAndDaysInPeriod(InvFrom,InvTo,NoOfMonths,NoOfDays);
"Amount per Period" :=
...
Change the code in the DataItem 1 in the Create Contract Invoices report (6030) as follows:
Existing code 1...
IF "Amount per Period" > 0 THEN BEGIN
IF NOT ServContractMgt.CheckIfServiceExist(ServContractHeader) THEN
ResultDescription := Text006;
IF ResultDescription = '' THEN BEGIN
// Delete the following lines.
InvoicedAmount := ROUND(
ServContractMgt.CalcContractAmount(ServContractHeader,InvoiceFrom,InvoiceTo),
Currency."Amount Rounding Precision");
IF InvoicedAmount = 0 THEN BEGIN
CurrReport.SKIP;
END;
// End of the lines.
CASE TRUE OF
NOT "Combine Invoices":
BEGIN
InvoiceNo := ServContractMgt.CreateServHeader(ServContractHeader,PostingDate,ContractExist);
...
Replacement code 1...
IF "Amount per Period" > 0 THEN BEGIN
IF NOT ServContractMgt.CheckIfServiceExist(ServContractHeader) THEN
ResultDescription := Text006;
IF ResultDescription = '' THEN BEGIN
CASE TRUE OF
NOT "Combine Invoices":
BEGIN
InvoiceNo := ServContractMgt.CreateServHeader(ServContractHeader,PostingDate,ContractExist);
...
Existing code 2...
NoOfInvoices := NoOfInvoices + 1;
END;
END;
ResultDescription := InvoiceNo;
// Delete the following line.
ServContractMgt.CreateAllServLines(InvoiceNo,ServContractHeader,InvoicedAmount);
END;
LastCustomer := "Bill-to Customer No.";
LastContractCombined := "Combine Invoices";
END ELSE
...
Replacement code 2...
NoOfInvoices := NoOfInvoices + 1;
END;
END;
ResultDescription := InvoiceNo;
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
IF ServContractLine.FINDSET THEN
REPEAT
InvoicedAmount := ROUND(
ServContractMgt.CalcContractAmount(ServContractHeader,InvoiceFrom,InvoiceTo,ServContractLine."Line No."),
Currency."Amount Rounding Precision");
IF InvoicedAmount <> 0 THEN
ServContractMgt.CreateAllServLines(InvoiceNo,ServContractHeader,InvoicedAmount,ServContractLine."Line No.");
UNTIL ServContractLine.NEXT=0;
// End of the lines.
END;
LastCustomer := "Bill-to Customer No.";
LastContractCombined := "Combine Invoices";
END ELSE
...
Change the code in the CreateInvoice function in the ServContractManagement codeunit (5940) as follows:
Existing code 1...
IF ServContractToInvoice.Prepaid THEN
PostingDate := InvoiceFrom
ELSE
PostingDate := InvoiceTo;
// Delete the following line.
InvoicedAmount := CalcContractAmount(ServContractToInvoice,InvoiceFrom,InvoiceTo);
IF InvoicedAmount = 0 THEN
ERROR(Text007);
...
Replacement code 1...
IF ServContractToInvoice.Prepaid THEN
PostingDate := InvoiceFrom
ELSE
PostingDate := InvoiceTo;
IF InvoicedAmount = 0 THEN
ERROR(Text007);
...
Existing code 2...
IF InvNo = '' THEN
InvNo := CreateServHeader(ServContractToInvoice,PostingDate,FALSE);
// Delete the following lines.
IF InvoicingStartingPeriod THEN BEGIN
GetNextInvoicePeriod(ServContractToInvoice,InvoiceFrom,InvoiceTo);
PostingDate := InvoiceFrom;
InvoicedAmount := CalcContractAmount(ServContractToInvoice,InvoiceFrom,InvoiceTo);
END;
// End of the lines.
IF NOT CheckIfServiceExist(ServContractToInvoice) THEN
ERROR(
Text010,
ServContractToInvoice."Contract No.",
...
Replacement code 2...
IF InvNo = '' THEN
InvNo := CreateServHeader(ServContractToInvoice,PostingDate,FALSE);
IF NOT CheckIfServiceExist(ServContractToInvoice) THEN
ERROR(
Text010,
ServContractToInvoice."Contract No.",
...
Existing code 3...
Text010,
ServContractToInvoice."Contract No.",
ServContractToInvoice.FIELDCAPTION("Invoice after Service"));
// Delete the following lines.
CreateAllServLines(InvNo,ServContractToInvoice,InvoicedAmount);
END;
PROCEDURE CreateServiceLedgerEntry@4(ServHeader2@1001 : Record 5900;ContractType@1020 : Integer;ContractNo@1002 : Code[20];InvFrom@1003 : Date;InvTo@1004 : Date;AmountToInvoice@1005 : Decimal;SigningContract@1023 : Boolean;AddingNewLines@1012 : Boolean;VAR InvAmountRounded@8000 : Decimal) ReturnLedgerEntry@1000 : Integer;
// End of the lines.
VAR
ServContractLine@1022 : Record 5964;
ServContractHeader@1021 : Record 5965;
Currency@1026 : Record 4;
...
Replacement code 3...
Text010,
ServContractToInvoice."Contract No.",
ServContractToInvoice.FIELDCAPTION("Invoice after Service"));
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractToInvoice."Contract Type");
ServContractLine.SETRANGE("Contract No.",ServContractToInvoice."Contract No.");
IF ServContractLine.FINDSET THEN
REPEAT
IF InvoicingStartingPeriod THEN BEGIN
GetNextInvoicePeriod(ServContractToInvoice,InvoiceFrom,InvoiceTo);
PostingDate := InvoiceFrom;
InvoicedAmount := CalcContractAmount(ServContractToInvoice,InvoiceFrom,InvoiceTo,ServContractLine."Line No.")
END ELSE
InvoicedAmount := CalcContractAmount(ServContractToInvoice,InvoiceFrom,InvoiceTo,ServContractLine."Line No.");
CreateAllServLines(InvNo,ServContractToInvoice,InvoicedAmount,ServContractLine."Line No.");
UNTIL ServContractLine.NEXT=0;
END;
PROCEDURE CreateServiceLedgerEntry@4(ServHeader2@1001 : Record 5900;ContractType@1020 : Integer;ContractNo@1002 : Code[20];InvFrom@1003 : Date;InvTo@1004 : Date;AmountToInvoice@1005 : Decimal;SigningContract@1023 : Boolean;AddingNewLines@1012 : Boolean;VAR InvAmountRounded@8000 : Decimal;LineNo@1011 : Integer) ReturnLedgerEntry@1000 : Integer;
// End of the lines.
VAR
ServContractLine@1022 : Record 5964;
ServContractHeader@1021 : Record 5965;
Currency@1026 : Record 4;
...
Change the code in the CreateServiceLedgerEntry function in the ServContractManagement codeunit (5940) as follows:
Existing code 1...
InvAmountRounded := 0;
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
IF AddingNewLines THEN
ServContractLine.SETRANGE("New Line",TRUE)
ELSE
ServContractLine.SETFILTER("Starting Date",'<=%1',ServContractHeader."Next Invoice Date");
...
Replacement code 1...
InvAmountRounded := 0;
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
// Add the following line.
ServContractLine.SETRANGE("Line No.",LineNo);
IF AddingNewLines THEN
ServContractLine.SETRANGE("New Line",TRUE)
ELSE
ServContractLine.SETFILTER("Starting Date",'<=%1',ServContractHeader."Next Invoice Date");
...
Existing code 2...
ServLedgEntry."Posting Date" := ServHeader2."Posting Date";
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
IF AddingNewLines THEN
ServContractLine.SETRANGE("New Line",TRUE)
ELSE
IF (NOT SigningContract) THEN BEGIN
...
Replacement code 2...
ServLedgEntry."Posting Date" := ServHeader2."Posting Date";
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
// Add the following line.
ServContractLine.SETRANGE("Line No.",LineNo);
IF AddingNewLines THEN
ServContractLine.SETRANGE("New Line",TRUE)
ELSE
IF (NOT SigningContract) THEN BEGIN
...
Change the code in the CreateServLine function in the ServContractManagement codeunit (5940) as follows:
Existing code 1...
AdjustServiceInvoiceDimensions(ServContract2,ServInvNo);
END;
// Delete the following line.
PROCEDURE CreateServLine@9(ServHeader@1000 : Record 5900;ContractType@1010 : Integer;ContractNo@1001 : Code[20];InvFrom@1002 : Date;InvTo@1003 : Date;InvoiceAmount@1004 : Decimal;ServiceApplyEntry@1005 : Integer;SignningContract@1011 : Boolean);
// End of the line.
VAR
ServContractHeader@1009 : Record 5965;
StdText@1006 : Record 7;
Cust@1007 : Record 18;
...
Replacement code 1...
AdjustServiceInvoiceDimensions(ServContract2,ServInvNo);
END;
// Add the following line.
PROCEDURE CreateServLine@9(ServHeader@1000 : Record 5900;ContractType@1010 : Integer;ContractNo@1001 : Code[20];InvFrom@1002 : Date;InvTo@1003 : Date;InvoiceAmount@1004 : Decimal;ServiceApplyEntry@1005 : Integer;SignningContract@1011 : Boolean;LineNo@1013 : Integer);
// End of the line.
VAR
ServContractHeader@1009 : Record 5965;
StdText@1006 : Record 7;
Cust@1007 : Record 18;
...
Existing code 2...
StdText@1006 : Record 7;
Cust@1007 : Record 18;
ServDocReg@1008 : Record 5936;
ServiceLedgerEntry@1012 : Record 5907;
BEGIN
ServContractHeader.GET(ContractType,ContractNo);
IF ServContractHeader."Invoice Period" = ServContractHeader."Invoice Period"::None THEN
...
Replacement code 2...
StdText@1006 : Record 7;
Cust@1007 : Record 18;
ServDocReg@1008 : Record 5936;
ServiceLedgerEntry@1012 : Record 5907;
// Add the following line.
ServContractLine@1014 : Record 5964;
BEGIN
ServContractHeader.GET(ContractType,ContractNo);
IF ServContractHeader."Invoice Period" = ServContractHeader."Invoice Period"::None THEN
...
Existing code 3...
ServLine.RESET;
ServLine.INIT;
ServLineNo := ServLineNo + 10000;
ServLine."Document Type" := ServHeader."Document Type";
ServLine."Document No." := ServHeader."No.";
ServLine."Line No." := ServLineNo;
...
Replacement code 3...
ServLine.RESET;
ServLine.INIT;
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
ServContractLine.SETRANGE("Line No.",LineNo);
IF ServContractLine.FINDFIRST THEN
ServLine."Service Item No." := ServContractLine."Service Item No.";
// End of the lines.
ServLineNo := ServLineNo + 10000;
ServLine."Document Type" := ServHeader."Document Type";
ServLine."Document No." := ServHeader."No.";
ServLine."Line No." := ServLineNo;
...
Change the code in the CreateRemainingPeriodInvoice function in the ServContractManagement codeunit (5940) as follows:
Existing code 1...
IF (InvFrom = 0D) OR (InvFrom > InvTo) THEN
EXIT;
IF CONFIRM(Text006,TRUE,InvFrom,InvTo) THEN BEGIN
// Delete the following line.
Amt := CalcContractAmount(CurrServContract,InvFrom,InvTo);
InvoiceNo := CreateServHeader(CurrServContract,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,InvoiceNo);
ServMgtSetup.GET;
IF NOT CurrServContract.Prepaid THEN
...
Replacement code 1...
IF (InvFrom = 0D) OR (InvFrom > InvTo) THEN
EXIT;
IF CONFIRM(Text006,TRUE,InvFrom,InvTo) THEN BEGIN
InvoiceNo := CreateServHeader(CurrServContract,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,InvoiceNo);
ServMgtSetup.GET;
IF NOT CurrServContract.Prepaid THEN
...
Existing code 2...
ServHeader,
ServContractLine,
CurrServContract."Contract Type",
CurrServContract."Contract No.");
UNTIL ServContractLine.NEXT = 0;
END ELSE
CreateHeadingServLine(
ServHeader,
...
Replacement code 2...
ServHeader,
ServContractLine,
CurrServContract."Contract Type",
CurrServContract."Contract No.");
// Add the following lines.
Amt := CalcContractAmount(CurrServContract,InvFrom,InvTo,ServContractLine."Line No.");
AppliedEntry :=
CreateServiceLedgerEntry(
ServHeader,CurrServContract."Contract Type",
CurrServContract."Contract No.",InvFrom,InvTo,Amt,TRUE,FALSE,InvAmountRounded,ServContractLine."Line No.");
CreateServLine(
ServHeader,CurrServContract."Contract Type",
CurrServContract."Contract No.",InvFrom,InvTo,InvAmountRounded,AppliedEntry,TRUE,ServContractLine."Line No.");
// End of the lines.
UNTIL ServContractLine.NEXT = 0;
END ELSE
CreateHeadingServLine(
ServHeader,
...
Existing code 3...
ServHeader,
CurrServContract."Contract Type",
CurrServContract."Contract No.");
// Delete the following lines.
AppliedEntry :=
CreateServiceLedgerEntry(
ServHeader,CurrServContract."Contract Type",
CurrServContract."Contract No.",InvFrom,InvTo,Amt,TRUE,FALSE,InvAmountRounded);
CreateServLine(
ServHeader,CurrServContract."Contract Type",
CurrServContract."Contract No.",InvFrom,InvTo,InvAmountRounded,AppliedEntry,TRUE);
// End of the lines.
CurrServContract.MODIFY;
InvoicingStartingPeriod := TRUE;
END;
END;
...
Replacement code 3...
ServHeader,
CurrServContract."Contract Type",
CurrServContract."Contract No.");
CurrServContract.MODIFY;
InvoicingStartingPeriod := TRUE;
END;
END;
...
Change the code in the CreateAllServLines function in the ServContractManagement codeunit (5940) as follows:
Existing code 1...
ServContractDim,TableID,
DocumentType,DocumentNo,LineNo);
END;
// Delete the following line.
PROCEDURE CreateAllServLines@2(InvNo@1001 : Code[20];ServContractToInvoice@1000 : Record 5965;InvoicedAmount@1002 : Decimal);
// End of the line.
VAR
ServContractLine@1007 : Record 5964;
ServHeader@1006 : Record 5900;
InvoiceFrom@1004 : Date;
...
Replacement code 1...
ServContractDim,TableID,
DocumentType,DocumentNo,LineNo);
END;
// Add the following line.
PROCEDURE CreateAllServLines@2(InvNo@1001 : Code[20];ServContractToInvoice@1000 : Record 5965;InvoicedAmount@1002 : Decimal;LineNo@1009 : Integer);
// End of the line.
VAR
ServContractLine@1007 : Record 5964;
ServHeader@1006 : Record 5900;
InvoiceFrom@1004 : Date;
...
Existing code 2...
IF ServHeader.GET(ServHeader."Document Type"::Invoice,InvNo) THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type","Contract Type");
ServContractLine.SETRANGE("Contract No.","Contract No.");
IF NOT "Contract Lines on Invoice" THEN
CreateHeadingServLine(ServHeader,"Contract Type","Contract No.");
IF ServContractLine.FIND('-') THEN
REPEAT
...
Replacement code 2...
IF ServHeader.GET(ServHeader."Document Type"::Invoice,InvNo) THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type","Contract Type");
ServContractLine.SETRANGE("Contract No.","Contract No.");
// Add the following line.
ServContractLine.SETRANGE("Line No.",LineNo);
IF NOT "Contract Lines on Invoice" THEN
CreateHeadingServLine(ServHeader,"Contract Type","Contract No.");
IF ServContractLine.FIND('-') THEN
REPEAT
...
Existing code 3...
IF (ServContractLine."Contract Expiration Date" = 0D) OR
(ServContractLine."Contract Expiration Date" >= InvoiceFrom)
THEN
CreateDetailedServLine(ServHeader,ServContractLine,"Contract Type","Contract No.");
// Delete the following lines.
UNTIL ServContractLine.NEXT = 0;
END;
ServiceApplyEntry :=
CreateServiceLedgerEntry(
ServHeader,"Contract Type","Contract No.",InvoiceFrom,InvoiceTo,InvoicedAmount,FALSE,FALSE,InvAmountRounded);
CreateServLine(
ServHeader,"Contract Type","Contract No.",
InvoiceFrom,InvoiceTo,InvAmountRounded,ServiceApplyEntry,FALSE);
// End of the lines.
CreateLastServLines(ServHeader,"Contract Type","Contract No.");
VALIDATE("Last Invoice Date","Next Invoice Date");
"Print Increase Text" := FALSE;
...
Replacement code 3...
IF (ServContractLine."Contract Expiration Date" = 0D) OR
(ServContractLine."Contract Expiration Date" >= InvoiceFrom)
THEN
CreateDetailedServLine(ServHeader,ServContractLine,"Contract Type","Contract No.");
// Add the following lines.
ServiceApplyEntry :=
CreateServiceLedgerEntry(
ServHeader,"Contract Type","Contract No.",InvoiceFrom,InvoiceTo,InvoicedAmount,FALSE,FALSE,InvAmountRounded,
ServContractLine."Line No.");
CreateServLine(
ServHeader,"Contract Type","Contract No.",
InvoiceFrom,InvoiceTo,InvAmountRounded,ServiceApplyEntry,FALSE,
ServContractLine."Line No.");
UNTIL ServContractLine.NEXT = 0;
END;
// End of the lines.
CreateLastServLines(ServHeader,"Contract Type","Contract No.");
VALIDATE("Last Invoice Date","Next Invoice Date");
"Print Increase Text" := FALSE;
...
Change the code in the SignContractQuote function in the SignServContractDoc codeunit (5944) as follows:
Existing code 1...
FromServContractLine@1008 : Record 5964;
ToServContractHeader@1007 : Record 5965;
FiledServContractHeader2@1009 : Record 5970;
ServItem@1006 : Record 5940;
InvFrom@1003 : Date;
InvTo@1004 : Date;
TempDate@1005 : Date;
InvAmountRounded@1010 : Decimal;
...
Replacement code 1...
FromServContractLine@1008 : Record 5964;
ToServContractHeader@1007 : Record 5965;
FiledServContractHeader2@1009 : Record 5970;
ServItem@1006 : Record 5940;
// Add the following line.
ServContractLine@1001 : Record 5964;
InvFrom@1003 : Date;
InvTo@1004 : Date;
TempDate@1005 : Date;
InvAmountRounded@1010 : Decimal;
...
Existing code 2...
LastPrepaidPostingDate := 0D;
ToServContractHeader.TRANSFERFIELDS(FromServContractHeader);
// Delete the following lines.
IF InvoiceNow THEN BEGIN
PostingDate := InvoiceFrom;
AmountNow := ServContractMgt.CalcContractAmount(FromServContractHeader,InvoiceFrom,InvoiceTo);
InvoiceAmountDueToSigning := AmountNow;
END;
// End of the lines.
ToServContractHeader."Contract Type" := ToServContractHeader."Contract Type"::Contract;
ToServContractHeader.Status := ToServContractHeader.Status::Signed;
IF InvoiceNow THEN BEGIN
ToServContractHeader."Last Invoice Date" := ToServContractHeader."Starting Date";
...
Replacement code 2...
LastPrepaidPostingDate := 0D;
ToServContractHeader.TRANSFERFIELDS(FromServContractHeader);
ToServContractHeader."Contract Type" := ToServContractHeader."Contract Type"::Contract;
ToServContractHeader.Status := ToServContractHeader.Status::Signed;
IF InvoiceNow THEN BEGIN
ToServContractHeader."Last Invoice Date" := ToServContractHeader."Starting Date";
...
Existing code 3...
ServContractMgt.CreateServHeader(ToServContractHeader,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
ServMgtSetup.GET;
// Delete the following lines.
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,ToServContractHeader."Contract Type",
ToServContractHeader."Contract No.",InvoiceFrom,
InvoiceTo,AmountNow,TRUE,FALSE,InvAmountRounded);
// End of the lines.
IF ToServContractHeader."Contract Lines on Invoice" THEN BEGIN
ToServContractLine.RESET;
ToServContractLine.SETRANGE("Contract Type",ToServContractHeader."Contract Type");
ToServContractLine.SETRANGE("Contract No.",ToServContractHeader."Contract No.");
...
Replacement code 3...
ServContractMgt.CreateServHeader(ToServContractHeader,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
ServMgtSetup.GET;
IF ToServContractHeader."Contract Lines on Invoice" THEN BEGIN
ToServContractLine.RESET;
ToServContractLine.SETRANGE("Contract Type",ToServContractHeader."Contract Type");
ToServContractLine.SETRANGE("Contract No.",ToServContractHeader."Contract No.");
...
Existing code 4...
ServHeader,
ToServContractHeader."Contract Type",
ToServContractHeader."Contract No.");
// Delete the following lines.
ServContractMgt.CreateServLine(
ServHeader,
ToServContractHeader."Contract Type",
ToServContractHeader."Contract No.",
InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE);
// End of the lines.
ToServContractHeader.MODIFY;
ServContractMgt.FinishCodeunit;
END;
...
Replacement code 4...
ServHeader,
ToServContractHeader."Contract Type",
ToServContractHeader."Contract No.");
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
IF ServContractLine.FINDSET THEN
REPEAT
IF InvoiceNow THEN BEGIN
PostingDate := InvoiceFrom;
AmountNow := ServContractMgt.CalcContractAmount(FromServContractHeader,InvoiceFrom,InvoiceTo,ServContractLine."Line No.");
InvoiceAmountDueToSigning := AmountNow;
END;
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,ToServContractHeader."Contract Type",
ToServContractHeader."Contract No.",InvoiceFrom,
InvoiceTo,AmountNow,TRUE,FALSE,InvAmountRounded,ServContractLine."Line No.");
ServContractMgt.CreateServLine(
ServHeader,
ToServContractHeader."Contract Type",
ToServContractHeader."Contract No.",
InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE,ServContractLine."Line No.");
UNTIL ServContractLine.NEXT=0;
// End of the lines.
ToServContractHeader.MODIFY;
ServContractMgt.FinishCodeunit;
END;
...
Change the code in the SignContract function in the SignServContractDoc codeunit (5944) as follows:
Existing code 1...
END;
END;
END;
// Delete the following lines.
IF InvoiceNow THEN BEGIN
PostingDate := InvoiceFrom;
AmountNow := ServContractMgt.CalcContractAmount(ServContractHeader,InvoiceFrom,InvoiceTo);
END;
// End of the lines.
IF InvoiceNow THEN BEGIN
ServContractHeader."Last Invoice Date" := ServContractHeader."Starting Date";
ServContractHeader.VALIDATE("Last Invoice Period End",InvoiceTo);
...
Replacement code 1...
END;
END;
END;
IF InvoiceNow THEN BEGIN
ServContractHeader."Last Invoice Date" := ServContractHeader."Starting Date";
ServContractHeader.VALIDATE("Last Invoice Period End",InvoiceTo);
...
Existing code 2...
ServContractMgt.CreateServHeader(ServContractHeader,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
ServMgtSetup.GET;
// Delete the following lines.
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,ServContractHeader."Contract Type",
ServContractHeader."Contract No.",InvoiceFrom,
InvoiceTo,AmountNow,TRUE,FALSE,InvAmountRounded);
// End of the lines.
IF ServContractHeader."Contract Lines on Invoice" THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
...
Replacement code 2...
ServContractMgt.CreateServHeader(ServContractHeader,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
ServMgtSetup.GET;
IF ServContractHeader."Contract Lines on Invoice" THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
...
Existing code 3...
ServContractMgt.CreateHeadingServLine(
ServHeader,
ServContractHeader."Contract Type",
ServContractHeader."Contract No.");
// Delete the following lines.
ServContractMgt.CreateServLine(
ServHeader,
ServContractHeader."Contract Type",
ServContractHeader."Contract No.",
InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE);
// End of the lines.
ServContractHeader.MODIFY;
ServContractMgt.FinishCodeunit;
END;
...
Replacement code 3...
ServContractMgt.CreateHeadingServLine(
ServHeader,
ServContractHeader."Contract Type",
ServContractHeader."Contract No.");
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
IF ServContractLine.FINDSET THEN
REPEAT
AmountNow := ServContractMgt.CalcContractAmount(ServContractHeader,InvoiceFrom,InvoiceTo,ServContractLine."Line No.");
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,ServContractHeader."Contract Type",
ServContractHeader."Contract No.",InvoiceFrom,
InvoiceTo,AmountNow,TRUE,FALSE,InvAmountRounded,ServContractLine."Line No.");
ServContractMgt.CreateServLine(
ServHeader,
ServContractHeader."Contract Type",
ServContractHeader."Contract No.",
InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE,ServContractLine."Line No.");
UNTIL ServContractLine.NEXT = 0;
// End of the lines.
ServContractHeader.MODIFY;
ServContractMgt.FinishCodeunit;
END;
...
Change the code in the AddendumToContract function in the SignServContractDoc codeunit (5944) as follows:
Existing code 1...
ServContractMgt.InitCodeUnit;
ServHeaderNo :=
ServContractMgt.CreateServHeader(FromServContractHeader,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
// Delete the following lines.
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",InvoiceFrom,InvoiceTo,RemainingAmt,TRUE,TRUE,InvAmountRounded);
// End of the lines.
IF FromServContractHeader."Contract Lines on Invoice" THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
...
Replacement code 1...
ServContractMgt.InitCodeUnit;
ServHeaderNo :=
ServContractMgt.CreateServHeader(FromServContractHeader,PostingDate,FALSE);
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
IF FromServContractHeader."Contract Lines on Invoice" THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
...
Existing code 2...
ServHeader,
FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.");
// Delete the following lines.
ServContractMgt.CreateServLine(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE);
// End of the lines.
ServContractMgt.FinishCodeunit;
END;
IF InvoicePrepaid AND FromServContractHeader.Prepaid THEN BEGIN
...
Replacement code 2...
ServHeader,
FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.");
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
IF ServContractLine.FIND('-') THEN
REPEAT
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",InvoiceFrom,InvoiceTo,RemainingAmt,TRUE,TRUE,InvAmountRounded,
ServContractLine."Line No.");
ServContractMgt.CreateServLine(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE,
ServContractLine."Line No.");
UNTIL ServContractLine.NEXT = 0;
// End of the lines.
ServContractMgt.FinishCodeunit;
END;
IF InvoicePrepaid AND FromServContractHeader.Prepaid THEN BEGIN
...
Existing code 3...
ServContractLine."Line Amount" / 12 * NoOfMonthsAndMParts,Currency."Amount Rounding Precision");
UNTIL ServContractLine.NEXT = 0;
IF RemainingAmt <> 0 THEN BEGIN
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
AppliedEntry :=
// Delete the following lines.
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",FirstPrepaidPostingDate,
LastPrepaidPostingDate,RemainingAmt,FALSE,TRUE,InvAmountRounded);
// End of the lines.
IF FromServContractHeader."Contract Lines on Invoice" THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
...
Replacement code 3...
ServContractLine."Line Amount" / 12 * NoOfMonthsAndMParts,Currency."Amount Rounding Precision");
UNTIL ServContractLine.NEXT = 0;
IF RemainingAmt <> 0 THEN BEGIN
ServHeader.GET(ServHeader."Document Type"::Invoice,ServHeaderNo);
IF FromServContractHeader."Contract Lines on Invoice" THEN BEGIN
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
...
Existing code 4...
ServContractMgt.CreateHeadingServLine(
ServHeader,
FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.");
// Delete the following lines.
ServContractMgt.CreateServLine(
ServHeader,
FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",
FirstPrepaidPostingDate,LastPrepaidPostingDate,
InvAmountRounded,AppliedEntry,FALSE);
// End of the lines.
END;
ServContractMgt.FinishCodeunit;
END;
...
Replacement code 4...
ServContractMgt.CreateHeadingServLine(
ServHeader,
FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.");
// Add the following lines.
ServContractLine.RESET;
ServContractLine.SETRANGE("Contract Type",FromServContractHeader."Contract Type");
ServContractLine.SETRANGE("Contract No.",FromServContractHeader."Contract No.");
IF ServContractLine.FIND('-') THEN
REPEAT
AppliedEntry :=
ServContractMgt.CreateServiceLedgerEntry(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",InvoiceFrom,InvoiceTo,RemainingAmt,TRUE,TRUE,InvAmountRounded,
ServContractLine."Line No.");
ServContractMgt.CreateServLine(
ServHeader,FromServContractHeader."Contract Type",
FromServContractHeader."Contract No.",InvoiceFrom,InvoiceTo,InvAmountRounded,AppliedEntry,TRUE,
ServContractLine."Line No.");
UNTIL ServContractLine.NEXT = 0;
// End of the lines.
END;
ServContractMgt.FinishCodeunit;
END;
...