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 transaction cannot be completed because it will cause inconsistencies in the G/L Entry table" error message when you post a prepayment invoice in Microsoft Dynamics NAV 2009


View products that this article applies to.

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

↑ Back to the top


Symptoms

Assume that you set the 0.001 value in the Amount Rounding Precision field for a foreign currency in a company. When you post a prepayment invoice that uses the foreign currency, you receive the following error message:
The transaction cannot be completed because it will cause inconsistencies in the G/L Entry table. Check where and how the CONSISTENT function is used in the transaction to find the reason for the error. Contact your system administrator.
Tables can be marked as inconsistent during comprehensive tasks, such as posting. This prevents data from being updated incorrectly.
The consistency error occurs because the debit and credit for the additional reporting currency (ARC) do not match. Therefore, the debit and credit for the local currency (LCY) do match as expected.
This problem occurs if the company has existing entries.

This problem occurs in the following products:
  • Microsoft Dynamics NAV 2009 R2
  • Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)

↑ 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 in the OnRun trigger in the Sales-Post codeunit (80) as follows:
    Existing code
    ...
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    GenJnlLine."Currency Code" := "Currency Code";
    GenJnlLine.Amount := -TotalSalesLine."Amount Including VAT";
    GenJnlLine."Source Currency Code" := "Currency Code";
    GenJnlLine."Source Currency Amount" := -TotalSalesLine."Amount Including VAT";

    // Delete the following line.
    GenJnlLine."Amount (LCY)" := -TotalSalesLineLCY."Amount Including VAT";

    IF SalesHeader."Currency Code" = '' THEN
    GenJnlLine."Currency Factor" := 1
    ELSE
    GenJnlLine."Currency Factor" := SalesHeader."Currency Factor";
    GenJnlLine.Correction := Correction;
    ...
    IF SalesLine."Qty. to Invoice" <> 0 THEN BEGIN
    SalesLine."Prepmt Amt Deducted" :=
    SalesLine."Prepmt Amt Deducted" + SalesLine."Prepmt Amt to Deduct";
    SalesLine."Prepmt VAT Diff. Deducted" :=
    SalesLine."Prepmt VAT Diff. Deducted" + SalesLine."Prepmt VAT Diff. to Deduct";

    // Delete the following lines.
    IF "Currency Code" <> '' THEN BEGIN
    TempPrePayDeductLCYSalesLine := SalesLine;
    IF TempPrePayDeductLCYSalesLine.FIND THEN
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" -
    TempPrePayDeductLCYSalesLine."Prepmt. Amount Inv. (LCY)";
    END ELSE
    SalesLine."Prepmt. Amount Inv. (LCY)" :=
    ROUND(
    ROUND(
    ROUND(SalesLine."Unit Price" * (SalesLine.Quantity - SalesLine."Quantity Shipped"),
    Currency."Amount Rounding Precision") *
    (1 - SalesLine."Line Discount %" / 100),Currency."Amount Rounding Precision") *
    SalesLine."Prepayment %" / 100,Currency."Amount Rounding Precision");
    // End of the lines.

    SalesLine."Prepmt Amt to Deduct" :=
    SalesLine."Prepmt. Amt. Inv." - SalesLine."Prepmt Amt Deducted";
    SalesLine."Prepmt VAT Diff. to Deduct" := 0;
    END;
    END;
    ...
    IF ABS(TempSalesLine."Quantity Invoiced") > ABS(TempSalesLine."Quantity Shipped") THEN
    ERROR(
    Text014,
    TempSalesLine."Document No.");
    TempSalesLine.InitQtyToInvoice;

    // Delete the following lines.
    TempSalesLine."Prepmt Amt Deducted" := TempSalesLine."Prepmt Amt Deducted" + SalesLine."Prepmt Amt to Deduct";
    TempSalesLine."Prepmt VAT Diff. Deducted" :=
    TempSalesLine."Prepmt VAT Diff. Deducted" + SalesLine."Prepmt VAT Diff. to Deduct";
    IF "Currency Code" <> '' THEN BEGIN
    TempPrePayDeductLCYSalesLine := SalesLine;
    IF TempPrePayDeductLCYSalesLine.FIND THEN
    TempSalesLine."Prepmt. Amount Inv. (LCY)" := TempSalesLine."Prepmt. Amount Inv. (LCY)" -
    TempPrePayDeductLCYSalesLine."Prepmt. Amount Inv. (LCY)";
    END ELSE
    TempSalesLine."Prepmt. Amount Inv. (LCY)" := TempSalesLine."Prepmt. Amount Inv. (LCY)" -
    SalesLine."Prepmt Amt to Deduct";
    IF (TempSalesLine."Quantity Invoiced" = TempSalesLine.Quantity) AND
    (TempSalesLine."Prepayment %" <> 0) THEN
    PrepayRealizeGainLoss(TempSalesLine);
    TempSalesLine."Prepmt Amt to Deduct" := TempSalesLine."Prepmt. Amt. Inv." - TempSalesLine."Prepmt Amt Deducted";
    TempSalesLine."Prepmt VAT Diff. to Deduct" := 0;
    // End of the lines.

    TempSalesLine.InitOutstanding;
    IF (TempSalesLine."Purch. Order Line No." <> 0) AND
    (TempSalesLine.Quantity = TempSalesLine."Quantity Invoiced")
    THEN
    UpdateAssocLines(TempSalesLine);
    ...
    InsertTrackingSpecification;
    IF SalesLine.FINDSET THEN
    REPEAT
    IF SalesLine."Purch. Order Line No." <> 0 THEN
    UpdateAssocLines(SalesLine);

    // Delete the following lines.
    IF (SalesLine."Prepayment %" <> 0) THEN BEGIN
    IF "Currency Code" <> '' THEN BEGIN
    TempPrePayDeductLCYSalesLine := SalesLine;
    IF TempPrePayDeductLCYSalesLine.FIND THEN
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" -
    TempPrePayDeductLCYSalesLine."Prepmt. Amount Inv. (LCY)";
    END ELSE
    SalesLine."Prepmt. Amount Inv. (LCY)" := SalesLine."Prepmt. Amount Inv. (LCY)" - SalesLine."Prepmt Amt to Deduct";
    PrepayRealizeGainLoss(SalesLine);
    END;
    // End of the lines.

    UNTIL SalesLine.NEXT = 0;
    END;
    END;

    SalesLine.SETFILTER("Blanket Order Line No.",'<>0');
    ...
    Replacement code
    ...
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    GenJnlLine."Currency Code" := "Currency Code";
    GenJnlLine.Amount := -TotalSalesLine."Amount Including VAT";
    GenJnlLine."Source Currency Code" := "Currency Code";
    GenJnlLine."Source Currency Amount" := -TotalSalesLine."Amount Including VAT";

    // Add the following line.
    GenJnlLine."Amount (LCY)" := ROUND(-TotalSalesLineLCY."Amount Including VAT",GLSetup."Amount Rounding Precision");

    IF SalesHeader."Currency Code" = '' THEN
    GenJnlLine."Currency Factor" := 1
    ELSE
    GenJnlLine."Currency Factor" := SalesHeader."Currency Factor";
    GenJnlLine.Correction := Correction;
    ...
    IF SalesLine."Qty. to Invoice" <> 0 THEN BEGIN
    SalesLine."Prepmt Amt Deducted" :=
    SalesLine."Prepmt Amt Deducted" + SalesLine."Prepmt Amt to Deduct";
    SalesLine."Prepmt VAT Diff. Deducted" :=
    SalesLine."Prepmt VAT Diff. Deducted" + SalesLine."Prepmt VAT Diff. to Deduct";

    // Add the following line.
    DecrementPrepmtAmtInvLCY(SalesLine,SalesLine."Prepmt. Amount Inv. (LCY)");

    SalesLine."Prepmt Amt to Deduct" :=
    SalesLine."Prepmt. Amt. Inv." - SalesLine."Prepmt Amt Deducted";
    SalesLine."Prepmt VAT Diff. to Deduct" := 0;
    END;
    END;
    ...
    IF ABS(TempSalesLine."Quantity Invoiced") > ABS(TempSalesLine."Quantity Shipped") THEN
    ERROR(
    Text014,
    TempSalesLine."Document No.");
    TempSalesLine.InitQtyToInvoice;

    // Add the following lines.
    IF TempSalesLine."Prepayment %" <> 0 THEN BEGIN
    TempSalesLine."Prepmt Amt Deducted" := TempSalesLine."Prepmt Amt Deducted" + SalesLine."Prepmt Amt to Deduct";
    TempSalesLine."Prepmt VAT Diff. Deducted" :=
    TempSalesLine."Prepmt VAT Diff. Deducted" + SalesLine."Prepmt VAT Diff. to Deduct";
    DecrementPrepmtAmtInvLCY(SalesLine,TempSalesLine."Prepmt. Amount Inv. (LCY)");
    TempSalesLine."Prepmt Amt to Deduct" := TempSalesLine."Prepmt. Amt. Inv." - TempSalesLine."Prepmt Amt Deducted";
    TempSalesLine."Prepmt VAT Diff. to Deduct" := 0;
    END;
    // End of the lines.

    TempSalesLine.InitOutstanding;
    IF (TempSalesLine."Purch. Order Line No." <> 0) AND
    (TempSalesLine.Quantity = TempSalesLine."Quantity Invoiced")
    THEN
    UpdateAssocLines(TempSalesLine);
    ...
    InsertTrackingSpecification;
    IF SalesLine.FINDSET THEN
    REPEAT
    IF SalesLine."Purch. Order Line No." <> 0 THEN
    UpdateAssocLines(SalesLine);

    // Add the following lines.
    IF (SalesLine."Prepayment %" <> 0) THEN
    DecrementPrepmtAmtInvLCY(SalesLine,SalesLine."Prepmt. Amount Inv. (LCY)");
    // End of the lines.

    UNTIL SalesLine.NEXT = 0;
    END;
    END;

    SalesLine.SETFILTER("Blanket Order Line No.",'<>0');
    ...
  2. Change the code in the FillInvPostingBuffer function in the Sales-Post codeunit (80) as follows:
    Existing code
    ...
    TempDocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
    TempDocDim.SETRANGE("Line No.",SalesLine."Line No.");
    TotalVAT := SalesLine."Amount Including VAT" - SalesLine.Amount;
    TotalVATACY := SalesLineACY."Amount Including VAT" - SalesLineACY.Amount;

    // Delete the following line.
    TotalAmount := SalesLine.Amount;

    TotalAmountACY := SalesLineACY.Amount;

    IF SalesSetup."Discount Posting" IN
    [SalesSetup."Discount Posting"::"Invoice Discounts",SalesSetup."Discount Posting"::"All Discounts"] THEN BEGIN
    IF SalesLine."VAT Calculation Type" = SalesLine."VAT Calculation Type"::"Reverse Charge VAT" THEN
    ...
    Replacement code
    ...
    TempDocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
    TempDocDim.SETRANGE("Line No.",SalesLine."Line No.");
    TotalVAT := SalesLine."Amount Including VAT" - SalesLine.Amount;
    TotalVATACY := SalesLineACY."Amount Including VAT" - SalesLineACY.Amount;

    // Add the following line.
    TotalAmount := ROUND(SalesLine.Amount,GLSetup."Amount Rounding Precision");

    TotalAmountACY := SalesLineACY.Amount;

    IF SalesSetup."Discount Posting" IN
    [SalesSetup."Discount Posting"::"Invoice Discounts",SalesSetup."Discount Posting"::"All Discounts"] THEN BEGIN
    IF SalesLine."VAT Calculation Type" = SalesLine."VAT Calculation Type"::"Reverse Charge VAT" THEN
    ...
  3. Add a new DecrementPrepmtAmtInvLCY function in the Sales-Post codeunit (80) as follows:
    LOCAL PROCEDURE DecrementPrepmtAmtInvLCY@86(SalesLine@1000 : Record 37;VAR PrepmtAmountInvLCY@1001 : Decimal);

    TempPrePayDeductLCYSalesLine := SalesLine;
    IF TempPrePayDeductLCYSalesLine.FIND THEN
    PrepmtAmountInvLCY := PrepmtAmountInvLCY - TempPrePayDeductLCYSalesLine."Prepmt. Amount Inv. (LCY)";
  4. Change the code in the OnRun trigger in the Purch.-Post codeunit (90) as follows:
    Existing code
    ...
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    GenJnlLine."Currency Code" := "Currency Code";
    GenJnlLine.Amount := -TotalPurchLine."Amount Including VAT";
    GenJnlLine."Source Currency Code" := "Currency Code";
    GenJnlLine."Source Currency Amount" := -TotalPurchLine."Amount Including VAT";

    // Delete the following line.
    GenJnlLine."Amount (LCY)" := -TotalPurchLineLCY."Amount Including VAT";

    IF PurchHeader."Currency Code" = '' THEN
    GenJnlLine."Currency Factor" := 1
    ELSE
    GenJnlLine."Currency Factor" := PurchHeader."Currency Factor";
    GenJnlLine."Sales/Purch. (LCY)" := -TotalPurchLineLCY.Amount;
    ...
    IF PurchLine."Qty. to Invoice" <> 0 THEN BEGIN
    PurchLine."Prepmt Amt Deducted" :=
    PurchLine."Prepmt Amt Deducted" + PurchLine."Prepmt Amt to Deduct";
    PurchLine."Prepmt VAT Diff. Deducted" :=
    PurchLine."Prepmt VAT Diff. Deducted" + PurchLine."Prepmt VAT Diff. to Deduct";

    // Delete the following line.
    IF "Currency Code" <> '' THEN BEGIN
    TempPrePayDeductLCYPurchLine := PurchLine;
    IF TempPrePayDeductLCYPurchLine.FIND THEN
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" -
    TempPrePayDeductLCYPurchLine."Prepmt. Amount Inv. (LCY)";
    END ELSE
    PurchLine."Prepmt. Amount Inv. (LCY)" :=
    ROUND(
    ROUND(
    ROUND(PurchLine."Direct Unit Cost" * (PurchLine.Quantity - PurchLine."Quantity Received"),
    Currency."Amount Rounding Precision") *
    (1 - PurchLine."Line Discount %" / 100),Currency."Amount Rounding Precision") *
    PurchLine."Prepayment %" / 100,Currency."Amount Rounding Precision");
    PurchLine."Prepmt Amt to Deduct" :=
    PurchLine."Prepmt. Amt. Inv." - PurchLine."Prepmt Amt Deducted";
    // End of the lines.

    PurchLine."Prepmt VAT Diff. to Deduct" := 0;
    END;
    END;

    UpdateBlanketOrderLine(PurchLine,Receive,Ship,Invoice);
    ...
    Text018 +
    Text99000000,
    TempPurchLine."Sales Order No.");
    END;
    TempPurchLine.InitQtyToInvoice;

    // Delete the following lines.
    TempPurchLine."Prepmt Amt Deducted" := TempPurchLine."Prepmt Amt Deducted" + PurchLine."Prepmt Amt to Deduct";
    TempPurchLine."Prepmt VAT Diff. Deducted" :=
    TempPurchLine."Prepmt VAT Diff. Deducted" + PurchLine."Prepmt VAT Diff. to Deduct";
    IF "Currency Code" <> '' THEN BEGIN
    TempPrePayDeductLCYPurchLine := PurchLine;
    IF TempPrePayDeductLCYPurchLine.FIND THEN
    TempPurchLine."Prepmt. Amount Inv. (LCY)" := TempPurchLine."Prepmt. Amount Inv. (LCY)" -
    TempPrePayDeductLCYPurchLine."Prepmt. Amount Inv. (LCY)";
    END ELSE
    TempPurchLine."Prepmt. Amount Inv. (LCY)" := TempPurchLine."Prepmt. Amount Inv. (LCY)" -
    PurchLine."Prepmt Amt to Deduct";
    IF (TempPurchLine."Quantity Invoiced" = TempPurchLine.Quantity) AND
    (TempPurchLine."Prepayment %" <> 0) THEN
    PrepayRealizeGainLoss(TempPurchLine);
    TempPurchLine."Prepmt Amt to Deduct" := TempPurchLine."Prepmt. Amt. Inv." - TempPurchLine."Prepmt Amt Deducted";
    TempPurchLine."Prepmt VAT Diff. to Deduct" := 0;
    // End of the lines.

    TempPurchLine.InitOutstanding;
    TempPurchLine.MODIFY;
    END;
    UNTIL PurchLine.NEXT = 0;
    InsertTrackingSpecification;
    ...
    PurchLine.SETRANGE("Return Shipment No.");
    END;
    ELSE
    IF PurchLine.FINDSET THEN
    REPEAT

    // Delete the following lines.
    IF (PurchLine."Prepayment %" <> 0) THEN BEGIN
    IF "Currency Code" <> '' THEN BEGIN
    TempPrePayDeductLCYPurchLine := PurchLine;
    IF TempPrePayDeductLCYPurchLine.FIND THEN
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" -
    TempPrePayDeductLCYPurchLine."Prepmt. Amount Inv. (LCY)";
    END ELSE
    PurchLine."Prepmt. Amount Inv. (LCY)" := PurchLine."Prepmt. Amount Inv. (LCY)" - PurchLine."Prepmt Amt to Deduct";
    PrepayRealizeGainLoss(PurchLine);
    END;
    // End of the lines.

    UNTIL PurchLine.NEXT = 0;
    END;

    PurchLine.SETFILTER("Blanket Order Line No.",'<>0');
    IF PurchLine.FINDSET THEN
    ...
    Replacement code
    ...
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    GenJnlLine."Currency Code" := "Currency Code";
    GenJnlLine.Amount := -TotalPurchLine."Amount Including VAT";
    GenJnlLine."Source Currency Code" := "Currency Code";
    GenJnlLine."Source Currency Amount" := -TotalPurchLine."Amount Including VAT";

    // Add the following line.
    GenJnlLine."Amount (LCY)" := ROUND(-TotalPurchLineLCY."Amount Including VAT",GLSetup."Amount Rounding Precision");

    IF PurchHeader."Currency Code" = '' THEN
    GenJnlLine."Currency Factor" := 1
    ELSE
    GenJnlLine."Currency Factor" := PurchHeader."Currency Factor";
    GenJnlLine."Sales/Purch. (LCY)" := -TotalPurchLineLCY.Amount;
    ...
    IF PurchLine."Qty. to Invoice" <> 0 THEN BEGIN
    PurchLine."Prepmt Amt Deducted" :=
    PurchLine."Prepmt Amt Deducted" + PurchLine."Prepmt Amt to Deduct";
    PurchLine."Prepmt VAT Diff. Deducted" :=
    PurchLine."Prepmt VAT Diff. Deducted" + PurchLine."Prepmt VAT Diff. to Deduct";

    // Add the following lines.
    DecrementPrepmtAmtInvLCY(PurchLine,PurchLine."Prepmt. Amount Inv. (LCY)");
    PurchLine."Prepmt Amt to Deduct" :=
    PurchLine."Prepmt. Amt. Inv." - PurchLine."Prepmt Amt Deducted";
    // End of the lines.

    PurchLine."Prepmt VAT Diff. to Deduct" := 0;
    END;
    END;

    UpdateBlanketOrderLine(PurchLine,Receive,Ship,Invoice);
    ...
    Text018 +
    Text99000000,
    TempPurchLine."Sales Order No.");
    END;
    TempPurchLine.InitQtyToInvoice;

    // Add the following lines.
    IF TempPurchLine."Prepayment %" <> 0 THEN BEGIN
    TempPurchLine."Prepmt Amt Deducted" := TempPurchLine."Prepmt Amt Deducted" + PurchLine."Prepmt Amt to Deduct";
    TempPurchLine."Prepmt VAT Diff. Deducted" :=
    TempPurchLine."Prepmt VAT Diff. Deducted" + PurchLine."Prepmt VAT Diff. to Deduct";
    DecrementPrepmtAmtInvLCY(PurchLine,TempPurchLine."Prepmt. Amount Inv. (LCY)");
    TempPurchLine."Prepmt Amt to Deduct" := TempPurchLine."Prepmt. Amt. Inv." - TempPurchLine."Prepmt Amt Deducted";
    TempPurchLine."Prepmt VAT Diff. to Deduct" := 0;
    END;
    // End of the lines.

    TempPurchLine.InitOutstanding;
    TempPurchLine.MODIFY;
    END;
    UNTIL PurchLine.NEXT = 0;
    InsertTrackingSpecification;
    ...
    // Add the following lines.
    IF (PurchLine."Prepayment %" <> 0) THEN
    DecrementPrepmtAmtInvLCY(PurchLine,PurchLine."Prepmt. Amount Inv. (LCY)");
    // End of the lines.
    ...
  5. Change the code in the FillInvPostingBuffer function in the Purch.-Post codeunit (90) as follows:
    Existing code
    ...
    TempDocDim.SETRANGE("Table ID",DATABASE::"Purchase Line");
    TempDocDim.SETRANGE("Line No.",PurchLine."Line No.");
    TotalVAT := PurchLine."Amount Including VAT" - PurchLine.Amount;
    TotalVATACY := PurchLineACY."Amount Including VAT" - PurchLineACY.Amount;

    // Delete the following line.
    TotalAmount := PurchLine.Amount;

    TotalAmountACY := PurchLineACY.Amount;

    IF PurchSetup."Discount Posting" IN
    [PurchSetup."Discount Posting"::"Invoice Discounts",PurchSetup."Discount Posting"::"All Discounts"] THEN BEGIN
    CASE PurchLine."VAT Calculation Type" OF
    ...
    Replacement code
    ...
    TempDocDim.SETRANGE("Table ID",DATABASE::"Purchase Line");
    TempDocDim.SETRANGE("Line No.",PurchLine."Line No.");
    TotalVAT := PurchLine."Amount Including VAT" - PurchLine.Amount;
    TotalVATACY := PurchLineACY."Amount Including VAT" - PurchLineACY.Amount;

    // Add the following line.
    TotalAmount := ROUND(PurchLine.Amount,GLSetup."Amount Rounding Precision");

    TotalAmountACY := PurchLineACY.Amount;
    TotalAmountACY := PurchLineACY.Amount;

    IF PurchSetup."Discount Posting" IN
    [PurchSetup."Discount Posting"::"Invoice Discounts",PurchSetup."Discount Posting"::"All Discounts"] THEN BEGIN
    CASE PurchLine."VAT Calculation Type" OF
    ...
  6. Add a new DecrementPrepmtAmtInvLCY function in the Purch.-Post codeunit (90) as follows:
    LOCAL PROCEDURE DecrementPrepmtAmtInvLCY@86(PurchLine@1000 : Record 39;VAR PrepmtAmountInvLCY@1001 : Decimal);

    TempPrePayDeductLCYPurchLine := PurchLine;
    IF TempPrePayDeductLCYPurchLine.FIND THEN
    PrepmtAmountInvLCY := PrepmtAmountInvLCY - TempPrePayDeductLCYPurchLine."Prepmt. Amount Inv. (LCY)";
  7. Change the code in the RoundAmounts function in the Sales-Post Prepayments codeunit (442) as follows:
    Existing code
    ...
    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBuf,SalesHeader,DummySalesLine,FALSE,0);

    IF SalesHeader."Currency Code" <> '' THEN BEGIN
    VAT := PrepmtInvLineBuf.Amount <> PrepmtInvLineBuf."Amount Incl. VAT";

    // Delete the following lines.
    PrepmtInvLineBuf."Amount Incl. VAT" :=
    AmountToLCY(
    SalesHeader,TotalPrepmtInvLineBuf."Amount Incl. VAT",TotalPrepmtInvLineBufLCY."Amount Incl. VAT");
    // End of the lines.

    IF VAT THEN
    PrepmtInvLineBuf.Amount := ROUND(PrepmtInvLineBuf."Amount Incl. VAT" / (1 + PrepmtInvLineBuf."VAT %" / 100))
    ELSE
    PrepmtInvLineBuf.Amount := PrepmtInvLineBuf."Amount Incl. VAT";
    PrepmtInvLineBuf."VAT Amount" := PrepmtInvLineBuf."Amount Incl. VAT" - PrepmtInvLineBuf.Amount;
    IF PrepmtInvLineBuf."VAT Base Amount" <> 0 THEN
    PrepmtInvLineBuf."VAT Base Amount" := PrepmtInvLineBuf.Amount;
    END;

    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBufLCY,SalesHeader,DummySalesLine,FALSE,0);
    ...
    Replacement code
    ...
    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBuf,SalesHeader,DummySalesLine,FALSE,0);

    IF SalesHeader."Currency Code" <> '' THEN BEGIN
    VAT := PrepmtInvLineBuf.Amount <> PrepmtInvLineBuf."Amount Incl. VAT";

    // Add the following lines.
    PrepmtInvLineBuf."Amount Incl. VAT" :=
    ROUND(
    AmountToLCY(
    SalesHeader,TotalPrepmtInvLineBuf."Amount Incl. VAT",TotalPrepmtInvLineBufLCY."Amount Incl. VAT"),
    GLSetup."Amount Rounding Precision");
    // End of the lines.

    IF VAT THEN
    PrepmtInvLineBuf.Amount := ROUND(PrepmtInvLineBuf."Amount Incl. VAT" / (1 + PrepmtInvLineBuf."VAT %" / 100))
    ELSE
    PrepmtInvLineBuf.Amount := PrepmtInvLineBuf."Amount Incl. VAT";
    PrepmtInvLineBuf."VAT Amount" := PrepmtInvLineBuf."Amount Incl. VAT" - PrepmtInvLineBuf.Amount;
    IF PrepmtInvLineBuf."VAT Base Amount" <> 0 THEN
    PrepmtInvLineBuf."VAT Base Amount" := PrepmtInvLineBuf.Amount;
    END;

    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBufLCY,SalesHeader,DummySalesLine,FALSE,0);
    ...
  8. Change the code in the InitInvoiceRoundingLine function in the Sales-Post Prepayments codeunit (442) as follows:
    Existing code
    ...
    "Unit Price",
    ROUND(
    InvoiceRoundingAmount /
    (1 + (1 - SalesHeader."VAT Base Discount %" / 100) * "VAT %" / 100),
    Currency."Amount Rounding Precision"));
    VALIDATE("Amount Including VAT",InvoiceRoundingAmount);
    END;
    EXIT(TRUE);
    Replacement code
    ...
    "Unit Price",
    ROUND(
    InvoiceRoundingAmount /
    (1 + (1 - SalesHeader."VAT Base Discount %" / 100) * "VAT %" / 100),
    Currency."Amount Rounding Precision"));

    // Add the following line.
    VALIDATE("Prepayment Amount",InvoiceRoundingAmount);

    VALIDATE("Amount Including VAT",InvoiceRoundingAmount);
    END;
    EXIT(TRUE);
  9. Change the code in the RoundAmounts function in the Purchase-Post Prepayments codeunit (444) as follows:
    Existing code
    ...
    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBuf,PurchHeader,DummyPurchLine,FALSE,0);

    IF PurchHeader."Currency Code" <> '' THEN BEGIN
    VAT := PrepmtInvLineBuf.Amount <> PrepmtInvLineBuf."Amount Incl. VAT";

    PrepmtInvLineBuf."Amount Incl. VAT" :=

    // Delete the following lines.
    AmountToLCY(
    PurchHeader,TotalPrepmtInvLineBuf."Amount Incl. VAT",TotalPrepmtInvLineBufLCY."Amount Incl. VAT");
    IF VAT THEN
    PrepmtInvLineBuf.Amount := ROUND(PrepmtInvLineBuf."Amount Incl. VAT" / (1 + PrepmtInvLineBuf."VAT %" / 100))
    ELSE
    PrepmtInvLineBuf.Amount := PrepmtInvLineBuf."Amount Incl. VAT";
    // End of the lines.

    PrepmtInvLineBuf."VAT Amount" := PrepmtInvLineBuf."Amount Incl. VAT" - PrepmtInvLineBuf.Amount;
    IF PrepmtInvLineBuf."VAT Base Amount" <> 0 THEN
    PrepmtInvLineBuf."VAT Base Amount" := PrepmtInvLineBuf.Amount;
    END;

    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBufLCY,PurchHeader,DummyPurchLine,FALSE,0);
    ...
    Replacement code
    ...
    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBuf,PurchHeader,DummyPurchLine,FALSE,0);

    IF PurchHeader."Currency Code" <> '' THEN BEGIN
    VAT := PrepmtInvLineBuf.Amount <> PrepmtInvLineBuf."Amount Incl. VAT";

    PrepmtInvLineBuf."Amount Incl. VAT" :=

    // Add the following lines.
    ROUND(
    AmountToLCY(
    PurchHeader,TotalPrepmtInvLineBuf."Amount Incl. VAT",TotalPrepmtInvLineBufLCY."Amount Incl. VAT"),
    GLSetup."Amount Rounding Precision");
    IF VAT THEN
    PrepmtInvLineBuf.Amount := ROUND(PrepmtInvLineBuf."Amount Incl. VAT" / (1 + PrepmtInvLineBuf."VAT %" / 100))
    ELSE
    PrepmtInvLineBuf.Amount := PrepmtInvLineBuf."Amount Incl. VAT";
    // End of the lines.

    PrepmtInvLineBuf."VAT Amount" := PrepmtInvLineBuf."Amount Incl. VAT" - PrepmtInvLineBuf.Amount;
    IF PrepmtInvLineBuf."VAT Base Amount" <> 0 THEN
    PrepmtInvLineBuf."VAT Base Amount" := PrepmtInvLineBuf.Amount;
    END;

    IncrAmounts(PrepmtInvLineBuf,TotalPrepmtInvLineBufLCY,PurchHeader,DummyPurchLine,FALSE,0);
    ...
  10. Change the code in the InitInvoiceRoundingLine function in the Purchase-Post Prepayments codeunit (444) as follows:
    Existing code
    ...
    "Direct Unit Cost",
    ROUND(
    InvoiceRoundingAmount /
    (1 + (1 - PurchHeader."VAT Base Discount %" / 100) * "VAT %" / 100),
    Currency."Amount Rounding Precision"));
    VALIDATE("Amount Including VAT",InvoiceRoundingAmount);
    END;
    EXIT(TRUE);
    Replacement code
    ...
    "Direct Unit Cost",
    ROUND(
    InvoiceRoundingAmount /
    (1 + (1 - PurchHeader."VAT Base Discount %" / 100) * "VAT %" / 100),
    Currency."Amount Rounding Precision"));

    // Add the following line.
    VALIDATE("Prepayment Amount",InvoiceRoundingAmount);

    VALIDATE("Amount Including VAT",InvoiceRoundingAmount);
    END;
    EXIT(TRUE);

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: kbmbscodefix, kberrmsg, kbnoloc, kbsurveynew, kbmbspartner, kbmbsmigrate, kb, kbqfe, kbmbsquickpub

↑ Back to the top

Article Info
Article ID : 2627706
Revision : 1
Created on : 1/7/2017
Published on : 11/18/2011
Exists online : False
Views : 172