The Usage entry type is not viewable in the Service Ledger Entries dialog box when you create a service invoice for a new service contract in Microsoft Dynamics NAV 2009 Service Pack 1

Applies to: Microsoft Dynamics NAV 2009 Service Pack 1

Rapidly Published articles provide information directly from within the Microsoft support organization. The information that is contained herein is created in response to emerging or unique topics, or is intended to supplement other Knowledge Base information.
This article applies to Microsoft Dynamics NAV 2009 for all countries and all language locales.

Symptoms


When you create a service invoice for a new service contract in Microsoft Dynamics NAV 2009 Service Pack 1, the Sales entry type and the Usage entry type of the service ledger entry is updated. However, only the Sales entry type is viewable in the Service Ledger Entries dialog box. The Usage entry type is not viewable in the Service Ledger Entries dialog box.

Cause


This problem occurs because the created Usage line is posted to a general ledger (G/L) account. Additionally, the line has no value in the Service Item No. (Serviced) column or in the Item No. (Serviced) column. When you open the Service Ledger Entries dialog box from a service item card, the data is filtered on the Service Item No. (Serviced) column. Therefore, if the value does not exist, the line does not appear.

Resolution


Hotfix information

A supported hotfix is now available from Microsoft. However, it is only intended to correct the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Dynamics NAV 2009 service pack or the next Microsoft Dynamics NAV version that contains this hotfix.

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Technical Support Professional for Microsoft Dynamics and related products determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.




Installation information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Note Before you install this hotfix, verify that all Microsoft Navision client users are logged off the system. This includes Microsoft Navision Application Services (NAS) client users. You should be the only client user who is logged on when you implement this hotfix.

To implement this hotfix, you must have a developer license.

We recommend that the user account in the Windows Logins window or in the Database Logins window be assigned the "SUPER" role ID. If the user account cannot be assigned the "SUPER" role ID, you must verify that the user account has the following permissions:
  • The Modify permission for the object that you will be changing.
  • The Execute permission for the System Object ID 5210 object and for the System Object ID 9015 object.


Note You do not have to have rights to the data stores unless you have to perform data repair.

Code changes

Note Always test code fixes in a controlled environment before you apply the fixes to your production computers.
To resolve this problem, follow these steps:
  1. 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" :=
    ...
  2. 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
    ...
  3. 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;
    ...
  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
    ...
  5. 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;
    ...
  6. Change the code in the CalcContractAmount function in the ServContractManagement codeunit (5940) as follows:
    Existing code 1
    ...
    WDate := CALCDATE('<CM>',OldWDate) + 1;
    UNTIL WDate > Day2;
    END;

    // Delete the following line.
    PROCEDURE CalcContractAmount@19(ServContractHeader@1001 : Record 5965;PeriodStarts@1002 : Date;PeriodEnds@1003 : Date) AmountCalculated@1000 : Decimal;
    // End of the line.

    VAR
    ServContractLine@1004 : Record 5964;
    Currency@1008 : Record 4;
    LinePeriodStarts@1005 : Date;
    ...
    Replacement code 1
    ...
    WDate := CALCDATE('<CM>',OldWDate) + 1;
    UNTIL WDate > Day2;
    END;

    // Add the following line.
    PROCEDURE CalcContractAmount@19(ServContractHeader@1001 : Record 5965;PeriodStarts@1002 : Date;PeriodEnds@1003 : Date;LineNo@1011 : Integer) AmountCalculated@1000 : Decimal;
    // End of the line.

    VAR
    ServContractLine@1004 : Record 5964;
    Currency@1008 : Record 4;
    LinePeriodStarts@1005 : Date;
    ...
    Existing code 2
    ...
    ServContractLine.RESET;
    ServContractLine.SETRANGE("Contract Type",ServContractHeader."Contract Type");
    ServContractLine.SETRANGE("Contract No.",ServContractHeader."Contract No.");
    IF ServContractHeader.Prepaid THEN
    ServContractLine.SETFILTER("Starting Date",'<=%1',ServContractHeader."Next Invoice Date")
    ELSE IF ServContractHeader."Last Invoice Date" <> 0D
    THEN
    ...
    Replacement code 2
    ...
    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 ServContractHeader.Prepaid THEN
    ServContractLine.SETFILTER("Starting Date",'<=%1',ServContractHeader."Next Invoice Date")
    ELSE IF ServContractHeader."Last Invoice Date" <> 0D
    THEN
    ...
  7. 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;
    ...
  8. 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;
    ...
  9. 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;
    ...
  10. 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;
    ...
  11. 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;
    ...

Prerequisites

You must have Microsoft Dynamics NAV 2009 installed to apply this hotfix.

Removal information

You cannot remove this hotfix.

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, THE RELIABILITY OR THE ACCURACY OF THE INFORMATION THAT IS CONTAINED IN THE DOCUMENTS AND THE RELATED GRAPHICS PUBLISHED ON THIS WEB SITE (THE “MATERIALS”) FOR ANY PURPOSE.

THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON-INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.