Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The "Prepmt. Amount Inv. (LCY)" value is incorrect after you post a prepayment invoice in Microsoft Dynamics NAV 2009


View products that this article applies to.

This article applies to Microsoft Dynamics NAV 2009 for all countries and all language locales.

↑ Back to the top


Symptoms

Assume that you set the invoice rounding precision to one in the General Ledger Setup dialog box in Microsoft Dynamics NAV 2009 R2 and in Microsoft Dynamics NAV 2009 Service Pack 1 (SP1). When you post a prepayment invoice for a sales order or a purchase order, the value in the Prepmt. Amount Inv. (LCY) field on the order line is incorrect.

↑ Back to the top


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.

↑ Back to the top




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 of the Data Item Number 7 in the Sales Prepmt. Document Test report (212) as follows:
    Existing code
    ...
    END;

    IF ErrorCounter = CurrentErrorCount THEN BEGIN
    IF SalesPostPrepmt.PrepmtAmount("Sales Line",DocumentType) <> 0 THEN BEGIN
    SalesPostPrepmt.FillInvLineBuffer("Sales Header","Sales Line",GLAcc,PrepmtInvBuf2,DocDim);

    // Delete the following line.
    SalesPostPrepmt.InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,"Sales Header","Sales Line",0,FALSE);

    END;
    END;
    END;
    END;
    ...
    Replacement code
    ...
    END;

    IF ErrorCounter = CurrentErrorCount THEN BEGIN
    IF SalesPostPrepmt.PrepmtAmount("Sales Line",DocumentType) <> 0 THEN BEGIN
    SalesPostPrepmt.FillInvLineBuffer("Sales Header","Sales Line",GLAcc,PrepmtInvBuf2,DocDim);

    // Add the following line.
    SalesPostPrepmt.InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,"Sales Header","Sales Line",0,FALSE,FALSE);

    END;
    END;
    END;
    END;
    ...
  2. Change the code of the Data Item Number 7 in the Purchase Prepmt. Doc. - Test report (412) as follows:
    Existing code
    ...
    AddError(STRSUBSTNO(Text007,GLAcc.TABLECAPTION,GenPostingSetup."Purch. Prepayments Account"));

    IF ErrorCounter = CurrentErrorCount THEN BEGIN
    IF PurchPostPrepmt.PrepmtAmount("Purchase Line",DocumentType) <> 0 THEN BEGIN
    PurchPostPrepmt.FillInvLineBuffer("Purchase Header","Purchase Line",GLAcc,PrepmtInvBuf2,DocDim);

    // Delete the following line.
    PurchPostPrepmt.InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,"Purchase Header","Purchase Line",0,FALSE);

    END;
    END;
    END;
    ...
    Replacement code
    ...
    AddError(STRSUBSTNO(Text007,GLAcc.TABLECAPTION,GenPostingSetup."Purch. Prepayments Account"));

    IF ErrorCounter = CurrentErrorCount THEN BEGIN
    IF PurchPostPrepmt.PrepmtAmount("Purchase Line",DocumentType) <> 0 THEN BEGIN
    PurchPostPrepmt.FillInvLineBuffer("Purchase Header","Purchase Line",GLAcc,PrepmtInvBuf2,DocDim);

    // Add the following line.
    PurchPostPrepmt.InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,"Purchase Header","Purchase Line",0,FALSE,FALSE);

    END;
    END;
    END;

    IF ISSERVICETIER THEN BEGIN
    ...
  3. Change the code in the BuildInvLineBuffer function in the Sales-Post Prepayments codeunit (442) as follows:
    Existing code 1
    ...
    GenPostingSetup.TESTFIELD("Sales Prepayments Account");
    END;
    GLAcc.GET(GenPostingSetup."Sales Prepayments Account");
    FillInvLineBuffer(SalesHeader,SalesLine,GLAcc,PrepmtInvBuf2,TempDocDim);

    // Delete the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,SalesHeader,SalesLine,DocumentType,UpdateLines);

    IF InvoiceRounding THEN
    RoundAmounts(
    SalesHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,TotalPrepmtInvLineBufferDummy);
    END;
    UNTIL SalesLine.NEXT = 0;
    ...
    Replacement code 1
    ...
    SalesLine."Gen. Bus. Posting Group",SalesLine."Gen. Prod. Posting Group");
    GenPostingSetup.TESTFIELD("Sales Prepayments Account");
    END;
    GLAcc.GET(GenPostingSetup."Sales Prepayments Account");
    FillInvLineBuffer(SalesHeader,SalesLine,GLAcc,PrepmtInvBuf2,TempDocDim);

    // Add the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,SalesHeader,SalesLine,DocumentType,UpdateLines,TRUE);

    IF InvoiceRounding THEN
    RoundAmounts(
    SalesHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,TotalPrepmtInvLineBufferDummy);
    END;
    UNTIL SalesLine.NEXT = 0;
    ...
    Existing code 2
    ...
    UNTIL SalesLine.NEXT = 0;
    IF InvoiceRounding THEN
    IF InsertInvoiceRounding(
    SalesHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,SalesLine."Line No.")
    THEN

    // Delete the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,SalesHeader,SalesLine,DocumentType,UpdateLines);

    END;
    END;

    PROCEDURE BuildInvLineBuffer2@19(SalesHeader@1000 : Record 36;VAR SalesLine@1001 : Record 37;DocumentType@1005 : 'Invoice,Credit Memo,Statistic';VAR PrepmtInvBuf@1002 : Record 461;VAR TempDocDim@1004 : Record 357);
    VAR
    ...
    Replacement code 2
    ...
    UNTIL SalesLine.NEXT = 0;
    IF InvoiceRounding THEN
    IF InsertInvoiceRounding(
    SalesHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,SalesLine."Line No.")
    THEN

    // Add the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,SalesHeader,SalesLine,DocumentType,UpdateLines,FALSE);

    END;
    END;

    PROCEDURE BuildInvLineBuffer2@19(SalesHeader@1000 : Record 36;VAR SalesLine@1001 : Record 37;DocumentType@1005 : 'Invoice,Credit Memo,Statistic';VAR PrepmtInvBuf@1002 : Record 461;VAR TempDocDim@1004 : Record 357);
    VAR
    ...
  4. Change the code in the InsertInvLineBuffer function in the Sales-Post Prepayments codeunit (442) as follows:
    Existing code 1
    ...
    SalesSetup.GET;
    BuildInvLineBuffer(
    SalesHeader,SalesLine,DocumentType,PrepmtInvBuf,TempDocDim,SalesSetup."Invoice Rounding",FALSE);
    END;

    // Delete the following line.
    PROCEDURE InsertInvLineBuffer@11(VAR PrepmtInvBuf@1001 : Record 461;PrepmtInvBuf2@1000 : Record 461;SalesHeader@1003 : Record 36;SalesLine@1002 : Record 37;DocumentType@1004 : 'Invoice,Credit Memo';UpdateLine@1005 : Boolean);

    VAR
    PrePmtAmount@1006 : Decimal;
    BEGIN
    WITH PrepmtInvBuf DO BEGIN
    PrepmtInvBuf := PrepmtInvBuf2;
    ...
    Replacement code 1
    ...
    SalesSetup.GET;
    BuildInvLineBuffer(
    SalesHeader,SalesLine,DocumentType,PrepmtInvBuf,TempDocDim,SalesSetup."Invoice Rounding",FALSE);
    END;

    // Add the following line.
    PROCEDURE InsertInvLineBuffer@11(VAR PrepmtInvBuf@1001 : Record 461;PrepmtInvBuf2@1000 : Record 461;SalesHeader@1003 : Record 36;SalesLine@1002 : Record 37;DocumentType@1004 : 'Invoice,Credit Memo';UpdateLine@1005 : Boolean;TotalInvoiceRounding@1010 : Boolean);

    VAR
    PrePmtAmount@1006 : Decimal;
    BEGIN
    WITH PrepmtInvBuf DO BEGIN
    PrepmtInvBuf := PrepmtInvBuf2;
    ...
    Existing code 2
    ...
    IF UpdateLine THEN BEGIN
    IF SalesHeader."Prices Including VAT" THEN
    PrePmtAmount := "Amount Incl. VAT"
    ELSE
    PrePmtAmount := Amount;

    // Delete the following lines.
    IF DocumentType = DocumentType::Invoice THEN
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" +
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    SalesHeader."Posting Date",
    SalesHeader."Currency Code",
    PrePmtAmount,
    SalesHeader."Currency Factor"))
    ELSE
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" -
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    SalesHeader."Posting Date",
    SalesHeader."Currency Code",
    PrePmtAmount,
    SalesHeader."Currency Factor"));
    SalesLine.MODIFY;
    // End of the lines.

    END;
    INSERT;
    END;
    END;
    END;
    ...
    Replacement code 2
    ...
    IF UpdateLine THEN BEGIN
    IF SalesHeader."Prices Including VAT" THEN
    PrePmtAmount := "Amount Incl. VAT"
    ELSE
    PrePmtAmount := Amount;

    // Add the following lines.
    IF TotalInvoiceRounding THEN BEGIN
    IF DocumentType = DocumentType::Invoice THEN
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" +
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    SalesHeader."Posting Date",
    SalesHeader."Currency Code",
    PrePmtAmount,
    SalesHeader."Currency Factor"))
    ELSE
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" -
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    SalesHeader."Posting Date",
    SalesHeader."Currency Code",
    PrePmtAmount,
    SalesHeader."Currency Factor"));
    SalesLine.MODIFY;
    END;
    // End of the lines.

    END;
    INSERT;
    END;
    END;
    END;
    ...
  5. Change the code in the BuildInvLineBuffer function in the Purchase-Post Prepayments codeunit (444) as follows:
    Existing code 1
    ...
    PurchLine."Gen. Bus. Posting Group",PurchLine."Gen. Prod. Posting Group");
    GenPostingSetup.TESTFIELD("Purch. Prepayments Account");
    END;
    GLAcc.GET(GenPostingSetup."Purch. Prepayments Account");
    FillInvLineBuffer(PurchHeader,PurchLine,GLAcc,PrepmtInvBuf2,TempDocDim);

    // Delete the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,PurchHeader,PurchLine,DocumentType,UpdateLines);

    IF InvoiceRounding THEN
    RoundAmounts(PurchHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,TotalPrepmtInvLineBufferDummy);
    END;
    UNTIL PurchLine.NEXT = 0;
    IF InvoiceRounding THEN
    ...
    Replacement code 1
    ...
    PurchLine."Gen. Bus. Posting Group",PurchLine."Gen. Prod. Posting Group");
    GenPostingSetup.TESTFIELD("Purch. Prepayments Account");
    END;
    GLAcc.GET(GenPostingSetup."Purch. Prepayments Account");
    FillInvLineBuffer(PurchHeader,PurchLine,GLAcc,PrepmtInvBuf2,TempDocDim);

    // Add the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,PurchHeader,PurchLine,DocumentType,UpdateLines,TRUE);

    IF InvoiceRounding THEN
    RoundAmounts(PurchHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,TotalPrepmtInvLineBufferDummy);
    END;
    UNTIL PurchLine.NEXT = 0;
    IF InvoiceRounding THEN
    ...
    Existing code 2
    ...
    UNTIL PurchLine.NEXT = 0;
    IF InvoiceRounding THEN
    IF InsertInvoiceRounding(
    PurchHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,PurchLine."Line No.")
    THEN

    // Delete the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,PurchHeader,PurchLine,DocumentType,UpdateLines);

    END;
    END;

    PROCEDURE BuildInvLineBuffer2@9(PurchHeader@1000 : Record 38;VAR PurchLine@1001 : Record 39;DocumentType@1005 : 'Invoice,Credit Memo,Statistic';VAR PrepmtInvBuf@1002 : Record 461;VAR TempDocDim@1004 : Record 357);
    VAR
    ...
    Replacement code 2
    ...
    UNTIL PurchLine.NEXT = 0;
    IF InvoiceRounding THEN
    IF InsertInvoiceRounding(
    PurchHeader,PrepmtInvBuf2,TotalPrepmtInvLineBuffer,PurchLine."Line No.")
    THEN

    // Add the following line.
    InsertInvLineBuffer(PrepmtInvBuf,PrepmtInvBuf2,PurchHeader,PurchLine,DocumentType,UpdateLines,FALSE);

    END;
    END;

    PROCEDURE BuildInvLineBuffer2@9(PurchHeader@1000 : Record 38;VAR PurchLine@1001 : Record 39;DocumentType@1005 : 'Invoice,Credit Memo,Statistic';VAR PrepmtInvBuf@1002 : Record 461;VAR TempDocDim@1004 : Record 357);
    VAR
    ...
  6. Change the code in the InsertInvLineBuffer function in the Purchase-Post Prepayments codeunit (444) as follows:
    Existing code 1
    ...
    PurchSetup.GET;
    BuildInvLineBuffer(
    PurchHeader,PurchLine,DocumentType,PrepmtInvBuf,TempDocDim,PurchSetup."Invoice Rounding",FALSE);
    END;

    // Delete the following line.
    PROCEDURE InsertInvLineBuffer@11(VAR PrepmtInvBuf@1001 : Record 461;PrepmtInvBuf2@1000 : Record 461;PurchHeader@1002 : Record 38;PurchLine@1003 : Record 39;DocumentType@1004 : 'Invoice,Credit Memo';UpdateLine@1005 : Boolean);

    VAR
    PrePmtAmount@1006 : Decimal;
    BEGIN
    WITH PrepmtInvBuf DO BEGIN
    PrepmtInvBuf := PrepmtInvBuf2;
    ...
    Replacement code 1
    ...
    PurchSetup.GET;
    BuildInvLineBuffer(
    PurchHeader,PurchLine,DocumentType,PrepmtInvBuf,TempDocDim,PurchSetup."Invoice Rounding",FALSE);
    END;

    // Add the following line.
    PROCEDURE InsertInvLineBuffer@11(VAR PrepmtInvBuf@1001 : Record 461;PrepmtInvBuf2@1000 : Record 461;PurchHeader@1002 : Record 38;PurchLine@1003 : Record 39;DocumentType@1004 : 'Invoice,Credit Memo';UpdateLine@1005 : Boolean;TotalInvoiceRounding@1010 : Boolean);

    VAR
    PrePmtAmount@1006 : Decimal;
    BEGIN
    WITH PrepmtInvBuf DO BEGIN
    PrepmtInvBuf := PrepmtInvBuf2;
    ...
    Existing code 2
    ...
    IF UpdateLine THEN BEGIN
    IF PurchHeader."Prices Including VAT" THEN
    PrePmtAmount := "Amount Incl. VAT"
    ELSE
    PrePmtAmount := Amount;

    // Delete the following lines.
    IF DocumentType = DocumentType::Invoice THEN
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" +
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    PurchHeader."Posting Date",
    PurchHeader."Currency Code",
    PrePmtAmount,
    PurchHeader."Currency Factor"))
    ELSE
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" -
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    PurchHeader."Posting Date",
    PurchHeader."Currency Code",
    PrePmtAmount,
    PurchHeader."Currency Factor"));
    PurchLine.MODIFY;
    // End of the lines.

    END;
    INSERT;
    END;
    END;
    END;
    ...
    Replacement code 2
    ...
    IF UpdateLine THEN BEGIN
    IF PurchHeader."Prices Including VAT" THEN
    PrePmtAmount := "Amount Incl. VAT"
    ELSE
    PrePmtAmount := Amount;

    // Add the following lines.
    IF TotalInvoiceRounding THEN BEGIN
    IF DocumentType = DocumentType::Invoice THEN
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" +
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    PurchHeader."Posting Date",
    PurchHeader."Currency Code",
    PrePmtAmount,
    PurchHeader."Currency Factor"))
    ELSE
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" -
    ROUND(CurrExchRate.ExchangeAmtFCYToLCY(
    PurchHeader."Posting Date",
    PurchHeader."Currency Code",
    PrePmtAmount,
    PurchHeader."Currency Factor"));
    PurchLine.MODIFY;
    END;
    // End of the lines.

    END;
    INSERT;
    END;
    END;
    END;
    ...

Prerequisites

You must have one of the following products installed to apply this hotfix:
  • Microsoft Dynamics NAV 2009 R2
  • Microsoft Dynamics NAV 2009 Service Pack 1

Removal information

You cannot remove this hotfix.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

↑ Back to the top


Keywords: kbqfe, kbmbspartner, kbmbsmigrate, kbmbscodefix, kbmbsquickpub, kbnoloc, kbsurveynew, kb

↑ Back to the top

Article Info
Article ID : 2620733
Revision : 1
Created on : 1/7/2017
Published on : 10/14/2011
Exists online : False
Views : 229