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.

Incorrect amount is calculated in the VAT entries when you apply a bill that uses a value-added tax (VAT) posting group for unrealized VAT in the Spanish version of Microsoft Dynamics NAV 2009


View products that this article applies to.

This article applies to Microsoft Dynamics NAV for the Spain (es) language locale.

↑ Back to the top


Symptoms

Assume that you post an invoice that uses a VAT posting group for unrealized VAT in the Spanish version of Microsoft Dynamics NAV 2009. Next, you create a bill from the invoice in the Cartera module. Then you apply the bill to a payment by using the remaining amount in the bill. In this situation, when you view the corresponding VAT entry, the Amount value is incorrect. This problem occurs in the following products:
  • The Spanish version of Microsoft Dynamics NAV 2009 R2
  • The Spanish version of Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)

↑ Back to the top


Cause

This problem occurs because the system calculates the original amount instead of the remaining amount when you apply a bill that uses a VAT posting group for unrealized VAT.

↑ 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 Global Variables in the VAT Entry table (254) as follows:
    Existing code
    ...
    GLSetupRead@1004 : Boolean;
    VATPostingSetup@1100000 : Record 325;
    ...
    Replacement code
    ...
    GLSetupRead@1004 : Boolean;

    // Add the following line.
    IsBillDoc@1100001 : Boolean;

    VATPostingSetup@1100000 : Record 325;
    ...
  2. Change the code in the GetUnRealizedVATPart function in the VAT Entry table (254) as follows:
    Existing code
    ...
    UnrealizedVatType::Percentage:

    // Delete the following line.
    EXIT(ABS(SettledAmount) / (ABS(Full) - (ABS(Paid) - ABS(SettledAmount))));

    UnrealizedVatType::First:
    ...
    Replacement code
    ...
    UnrealizedVatType::Percentage:

    // Add the following lines.
    BEGIN
    IF IsBillDoc THEN
    EXIT(ABS(SettledAmount) / ABS(Full));
    EXIT(ABS(SettledAmount) / (ABS(Full) - (ABS(Paid) - ABS(SettledAmount))));
    END;
    // End of the lines.

    UnrealizedVatType::First:
    ...
  3. Add a new procedure in the VAT Entry table (254) as follows:
    PROCEDURE SetBillDoc@1100000(NewIsBillDoc@1100000 : Boolean);
    BEGIN
    IsBillDoc := NewIsBillDoc;
    END;
  4. Change the code in the CustUnrealizedVAT function in the "Gen. Jnl.-Post Line" codeunit (12) as follows:
    Existing code 1
    ...
    END;

    // Delete the following lines.
    IF CustLedgEntry4."Document Type" = CustLedgEntry4."Document Type"::Bill THEN
    VATPart :=
    VATEntry2.GetUnRealizedVATPart(
    ROUND(SettledAmount / CustLedgEntry3.GetOriginalCurrencyFactor),
    PaidAmount,
    CustLedgEntry3."Original Amt. (LCY)",
    TotalUnrealVATAmountFirst,
    TotalUnrealVATAmountLast)
    ELSE
    VATPart :=
    VATEntry2.GetUnRealizedVATPart(
    ROUND(SettledAmount / CustLedgEntry2.GetOriginalCurrencyFactor),
    PaidAmount,
    CustLedgEntry2."Original Amt. (LCY)",
    TotalUnrealVATAmountFirst,
    TotalUnrealVATAmountLast);
    // End of the lines.
    ...
    Replacement code 1
    ...
    END;

    // Add the following lines.
    VATEntry2.SetBillDoc(IsCustBillDoc(CustLedgEntry4));
    VATPart :=
    VATEntry2.GetUnRealizedVATPart(
    GetCustSettledAmount(SettledAmount,CustLedgEntry4,CustLedgEntry3,CustLedgEntry2),
    PaidAmount,
    GetCustOriginalAmtLCY(CustLedgEntry4,CustLedgEntry3,CustLedgEntry2),
    TotalUnrealVATAmountFirst,
    TotalUnrealVATAmountLast);
    // End of the lines.
    ...
    Existing code 2
    ...
    VATBaseAddCurr := VATEntry2."Add.-Curr. Rem. Unreal. Base";

    // Delete the following lines.
    END ELSE BEGIN
    VATAmount := ROUND(VATEntry2."Unrealized Amount" * VATPart);
    VATBase := ROUND(VATEntry2."Unrealized Base" * VATPart);
    VATAmountAddCurr :=
    ROUND(
    VATEntry2."Add.-Currency Unrealized Amt." * VATPart,
    AddCurrency."Amount Rounding Precision");
    VATBaseAddCurr :=
    ROUND(
    VATEntry2."Add.-Currency Unrealized Base" * VATPart,
    AddCurrency."Amount Rounding Precision");
    END;
    // End of the lines.
    ...
    Replacement code 2
    ...
    VATBaseAddCurr := VATEntry2."Add.-Curr. Rem. Unreal. Base";

    // Add the following lines.
    END ELSE
    CalcCustRealizedVATAmt(
    VATBase,VATAmount,
    VATBaseAddCurr,VATAmountAddCurr,
    VATEntry2,CustLedgEntry4,VATPart);
    // End of the lines.
    ...
  5. Change the code in the VendUnrealizedVAT function in the "Gen. Jnl.-Post Line" codeunit (12) as follows:
    Existing code 1
    ...
    IF VendLedgEntry3.FIND('-') THEN BEGIN
    VendLedgEntry2.Open := TRUE;
    ...
    Replacement code 1
    ...
    IF VendLedgEntry3.FIND('-') THEN BEGIN

    // Add the following line.
    VendLedgEntry3.CALCFIELDS("Original Amt. (LCY)");

    VendLedgEntry2.Open := TRUE;
    ...
    Existing code 2
    ...
    // Delete the following lines.
    VATPart :=
    VATEntry2.GetUnRealizedVATPart(
    ROUND(SettledAmount / VendLedgEntry2.GetOriginalCurrencyFactor),
    PaidAmount,
    VendLedgEntry2."Original Amt. (LCY)",
    // End of the lines.

    TotalUnrealVATAmountFirst,
    ...
    Replacement code 2
    ...
    // Add the following lines.
    VATEntry2.SetBillDoc(IsVendBillDoc(VendLedgEntry4));
    VATPart :=
    VATEntry2.GetUnRealizedVATPart(
    GetVendSettledAmount(SettledAmount,VendLedgEntry4,VendLedgEntry3,VendLedgEntry2),
    PaidAmount,
    GetVendOriginalAmtLCY(VendLedgEntry4,VendLedgEntry3,VendLedgEntry2),
    // End of the lines.

    TotalUnrealVATAmountFirst,
    ...
    Existing code 3
    ...
    VATBaseAddCurr := VATEntry2."Add.-Curr. Rem. Unreal. Base";

    // Delete the following lines.
    END
    END ELSE BEGIN
    VATAmount := ROUND(VATEntry2."Remaining Unrealized Amount" * VATPart);
    VATBase := ROUND(VATEntry2."Remaining Unrealized Base" * VATPart);
    VATAmountAddCurr :=
    ROUND(
    VATEntry2."Add.-Curr. Rem. Unreal. Amount" * VATPart,
    AddCurrency."Amount Rounding Precision");
    VATBaseAddCurr :=
    ROUND(
    VATEntry2."Add.-Curr. Rem. Unreal. Base" * VATPart,
    AddCurrency."Amount Rounding Precision");
    END;
    // End of the lines.
    ...
    Replacement code 3
    ...
    VATBaseAddCurr := VATEntry2."Add.-Curr. Rem. Unreal. Base";

    // Add the following lines.
    END;
    END ELSE
    CalcVendRealizedVATAmt(
    VATBase,VATAmount,
    VATBaseAddCurr,VATAmountAddCurr,
    VATEntry2,VendLedgEntry4,VATPart);
    // End of the lines.
    ...
  6. Add the following new local procedures in the "Gen. Jnl.-Post Line" codeunit (12) as follows:
    LOCAL PROCEDURE GetVendOriginalAmtLCY@1100004(VendLedgEntry4@1100001 : Record 25;VendLedgEntry3@1100002 : Record 25;VendLedgEntry2@1100000 : Record 25) : Decimal;
    BEGIN
    WITH VendLedgEntry4 DO BEGIN
    IF IsVendBillDoc(VendLedgEntry4) THEN
    EXIT(VendLedgEntry3."Original Amt. (LCY)");
    EXIT(VendLedgEntry2."Original Amt. (LCY)");
    END;
    END;

    LOCAL PROCEDURE GetCustOriginalAmtLCY@1100010(CustLedgEntry4@1100001 : Record 21;CustLedgEntry3@1100002 : Record 21;CustLedgEntry2@1100000 : Record 21) : Decimal;
    BEGIN
    WITH CustLedgEntry4 DO BEGIN
    IF IsCustBillDoc(CustLedgEntry4) THEN
    EXIT(CustLedgEntry3."Original Amt. (LCY)");
    EXIT(CustLedgEntry2."Original Amt. (LCY)");
    END;
    END;

    LOCAL PROCEDURE GetVendSettledAmount@1100014(SettledAmt@1100000 : Decimal;VendLedgEntry4@1100003 : Record 25;VendLedgEntry3@1100002 : Record 25;VendLedgEntry2@1100001 : Record 25) : Decimal;
    BEGIN
    WITH VendLedgEntry4 DO BEGIN
    IF IsVendBillDoc(VendLedgEntry4) THEN
    EXIT(ROUND(SettledAmt / VendLedgEntry3.GetOriginalCurrencyFactor));
    EXIT(ROUND(SettledAmt / VendLedgEntry2.GetOriginalCurrencyFactor));
    END;
    END;

    LOCAL PROCEDURE GetCustSettledAmount@1100019(SettledAmt@1100003 : Decimal;CustLedgEntry4@1100002 : Record 21;CustLedgEntry3@1100001 : Record 21;CustLedgEntry2@1100000 : Record 21) : Decimal;
    BEGIN
    WITH CustLedgEntry4 DO BEGIN
    IF IsCustBillDoc(CustLedgEntry4) THEN
    EXIT(ROUND(SettledAmt / CustLedgEntry3.GetOriginalCurrencyFactor));
    EXIT(ROUND(SettledAmt / CustLedgEntry2.GetOriginalCurrencyFactor));
    END;
    END;

    LOCAL PROCEDURE IsVendBillDoc@1100015(VendLedgEntry4@1100000 : Record 25) : Boolean;
    BEGIN
    WITH VendLedgEntry4 DO
    EXIT("Document Type" = "Document Type"::Bill);
    END;

    LOCAL PROCEDURE IsCustBillDoc@1100016(CustLedgEntry4@1100000 : Record 21) : Boolean;
    BEGIN
    WITH CustLedgEntry4 DO
    EXIT("Document Type" = "Document Type"::Bill);
    END;

    LOCAL PROCEDURE CalcVendRealizedVATAmt@1100032(VAR VATBase@1100001 : Decimal;VAR VATAmount@1100000 : Decimal;VAR VATBaseAddCurr@1100005 : Decimal;VAR VATAmountAddCurr@1100006 : Decimal;VATEntry2@1100002 : Record 254;VendLedgEntry4@1100003 : Record 25;VATPart@1100004 : Decimal);
    BEGIN
    CalcRealizedVATAmt(
    VATBase,VATAmount,
    VATBaseAddCurr,VATAmountAddCurr,
    VATEntry2,
    IsVendBillDoc(VendLedgEntry4),
    VATPart);
    END;

    LOCAL PROCEDURE CalcCustRealizedVATAmt@1100029(VAR VATBase@1100001 : Decimal;VAR VATAmount@1100000 : Decimal;VAR VATBaseAddCurr@1100006 : Decimal;VAR VATAmountAddCurr@1100005 : Decimal;VATEntry2@1100002 : Record 254;CustLedgEntry4@1100003 : Record 21;VATPart@1100004 : Decimal);
    BEGIN
    CalcRealizedVATAmt(
    VATBase,VATAmount,
    VATBaseAddCurr,VATAmountAddCurr,
    VATEntry2,
    IsCustBillDoc(CustLedgEntry4),
    VATPart);
    END;

    LOCAL PROCEDURE CalcRealizedVATAmt@1100036(VAR VATBase@1100002 : Decimal;VAR VATAmount@1100001 : Decimal;VAR VATBaseAddCurr@1100008 : Decimal;VAR VATAmountAddCurr@1100007 : Decimal;VATEntry2@1100003 : Record 254;UseUnrealAmt@1100000 : Boolean;VATPart@1100004 : Decimal);
    VAR
    UnrealAmt@1100006 : Decimal;
    UnrealBase@1100005 : Decimal;
    UnrealAmtACY@1100009 : Decimal;
    UnrealBaseACY@1100010 : Decimal;
    BEGIN
    WITH VATEntry2 DO
    IF UseUnrealAmt THEN BEGIN
    UnrealAmt := "Unrealized Amount";
    UnrealBase := "Unrealized Base";
    UnrealAmtACY := "Add.-Currency Unrealized Amt.";
    UnrealBaseACY := "Add.-Currency Unrealized Base";
    END ELSE BEGIN
    UnrealAmt := "Remaining Unrealized Amount";
    UnrealBase := "Remaining Unrealized Base";
    UnrealAmtACY := "Add.-Curr. Rem. Unreal. Amount";
    UnrealBaseACY := "Add.-Curr. Rem. Unreal. Base";
    END;
    VATAmount := ROUND(UnrealAmt * VATPart);
    VATBase := ROUND(UnrealBase * VATPart);
    VATAmountAddCurr := ROUND(UnrealAmtACY * VATPart,AddCurrency."Amount Rounding Precision");
    VATBaseAddCurr := ROUND(UnrealBaseACY * VATPart,AddCurrency."Amount Rounding Precision");
    END;

Prerequisites

You must have one of the following products installed to apply this hotfix:
  • The Spanish version of Microsoft Dynamics NAV 2009 R2
  • The Spanish version of Microsoft Dynamics NAV 2009 SP1

Removal information

You cannot remove this hotfix.

↑ Back to the top


More Information

For more information about problems that are related to unrealized VAT in VAT entries, click the following article number to view the article in the Microsoft Knowledge Base:
2664615 The amount in the VAT entries is incorrect when you post an application in the Spanish version of Microsoft Dynamics NAV 2009

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

↑ Back to the top

Article Info
Article ID : 2739839
Revision : 1
Created on : 1/7/2017
Published on : 12/13/2012
Exists online : False
Views : 238