Wrong total amount in a reminder if the reminder fee account is set up with VAT in the Microsoft Dynamics NAV 2009

Symptoms

The total amount in a reminder is wrong if the reminder fee account is set up with value-added tax (VAT) in the Microsoft Dynamics NAV 2009. This happens although the reminder fee is not registered and the customer is an EU customer. Follow the steps in the code changes section to solve this issue. This problem occurs in the following products:
  • Microsoft Dynamics NAV 2009 R2
  • Microsoft Dynamics NAV 2009 SP1

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. However, 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 Dynamics NAV client users are logged off the system. This includes Microsoft Dynamics NAV Application Server (NAS) services. 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 Properties in the Reminder Statistics Form (437) as follows:
    Existing code
    ...
    CALCFIELDS("Interest Amount","VAT Amount");
    ReminderTotal := "Remaining Amount" + "Additional Fee" + "Interest Amount" + "VAT Amount";
    CustPostingGr.GET("Customer Posting Group");
    VATInterest := 0;
    IF ReminderLevel.GET("Reminder Terms Code","Reminder Level") THEN

    // Delete the following lines.
    IF ReminderLevel."Calculate Interest" THEN BEGIN
    GLAcc.GET(CustPostingGr."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    END;

    IF GLAcc.GET(CustPostingGr."Additional Fee Account") THEN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");

    Interest := (ReminderTotal - "Remaining Amount" - "Additional Fee" * (VATPostingSetup."VAT %"/100 + 1))/
    (VATInterest/100 + 1);

    VatAmount := Interest * VATInterest/100 +
    "Additional Fee" * VATPostingSetup."VAT %"/100;

    // End of the deleted lines.

    IF Cust.GET("Customer No.") THEN
    Cust.CALCFIELDS("Balance (LCY)")
    ELSE
    CLEAR(Cust);
    IF Cust."Credit Limit (LCY)" = 0 THEN
    ...
    Replacement code
    ...
    CALCFIELDS("Interest Amount","VAT Amount");
    ReminderTotal := "Remaining Amount" + "Additional Fee" + "Interest Amount" + "VAT Amount";
    CustPostingGr.GET("Customer Posting Group");
    VATInterest := 0;
    IF ReminderLevel.GET("Reminder Terms Code","Reminder Level") THEN

    // Add the following lines.
    IF ReminderLevel."Calculate Interest" AND ("VAT Amount" <> 0) THEN BEGIN
    GLAcc.GET(CustPostingGr."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    IF GLAcc.GET(CustPostingGr."Additional Fee Account") THEN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    Interest :=
    (ReminderTotal -
    "Remaining Amount" - "Additional Fee" * (VATPostingSetup."VAT %"/ 100 + 1)) /(VATInterest / 100 + 1);
    VatAmount := Interest * VATInterest / 100 + "Additional Fee" * VATPostingSetup."VAT %" / 100;
    END ELSE
    Interest := "Interest Amount";
    // End of the added lines.

    IF Cust.GET("Customer No.") THEN
    Cust.CALCFIELDS("Balance (LCY)")
    ELSE
    CLEAR(Cust);
    IF Cust."Credit Limit (LCY)" = 0 THEN
    ...
  2. Change the code in the Properties in the Reminder Statistics Form (441) as follows:
    Existing code
    ...
    BEGIN
    SETRANGE("No.");
    CALCFIELDS("Interest Amount","VAT Amount");
    ReminderTotal := "Remaining Amount" + "Additional Fee" + "Interest Amount" + "VAT Amount";
    CustPostingGr.GET("Customer Posting Group");

    // Delete the following lines.
    ReminderLevel.GET("Reminder Terms Code","Reminder Level");
    IF ReminderLevel."Calculate Interest" THEN BEGIN
    GLAcc.GET(CustPostingGr."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    END ELSE
    VATInterest := 0;
    IF GLAcc.GET(CustPostingGr."Additional Fee Account") THEN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");

    Interest := (ReminderTotal - "Remaining Amount" - "Additional Fee" * (VATPostingSetup."VAT %"/100 + 1))/
    (VATInterest/100 + 1);

    VatAmount := Interest * VATInterest/100 +
    "Additional Fee" * VATPostingSetup."VAT %"/100;

    // End of the deleted lines.

    IF Cust.GET("Customer No.") THEN
    Cust.CALCFIELDS("Balance (LCY)")
    ELSE
    CLEAR(Cust);
    IF Cust."Credit Limit (LCY)" = 0 THEN
    ...
    Replacement code
    ...
    BEGIN
    SETRANGE("No.");
    CALCFIELDS("Interest Amount","VAT Amount");
    ReminderTotal := "Remaining Amount" + "Additional Fee" + "Interest Amount" + "VAT Amount";
    CustPostingGr.GET("Customer Posting Group");

    // Add the following lines.
    IF ReminderLevel.GET("Reminder Terms Code","Reminder Level") THEN
    IF ReminderLevel."Calculate Interest" AND ("VAT Amount" <> 0) THEN BEGIN
    GLAcc.GET(CustPostingGr."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    IF GLAcc.GET(CustPostingGr."Additional Fee Account") THEN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    Interest :=
    (ReminderTotal -
    "Remaining Amount" - "Additional Fee" * (VATPostingSetup."VAT %"/ 100 + 1)) /(VATInterest / 100 + 1);
    VatAmount := Interest * VATInterest / 100 + "Additional Fee" * VATPostingSetup."VAT %" / 100;
    END ELSE
    Interest := "Interest Amount";
    // End of the added lines.

    IF Cust.GET("Customer No.") THEN
    Cust.CALCFIELDS("Balance (LCY)")
    ELSE
    CLEAR(Cust);
    IF Cust."Credit Limit (LCY)" = 0 THEN
    ...
  3. Change the code in the Data Item Number 1 in the Reminder Statistics Report (117) as follows:
    Existing code
    ...
    IF GLAcc.GET(CustPostingGroup."Additional Fee Account") THEN BEGIN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    AddFeeInclVAT := "Additional Fee" * (1 + VATPostingSetup."VAT %"/100);
    END ELSE
    AddFeeInclVAT := "Additional Fee";

    // Delete the following lines.
    CALCFIELDS("Interest Amount");
    IF "Interest Amount" <> 0 THEN BEGIN
    GLAcc.GET(CustPostingGroup."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    END ELSE
    VATInterest := 0;
    // End of the deleted lines.

    IF ISSERVICETIER THEN BEGIN
    NNC_InterestAmountTotal := 0;
    NNC_RemainingAmountTotal := 0;
    NNC_VATAmountTotal := 0;
    ...
    Replacement code
    ...
    IF GLAcc.GET(CustPostingGroup."Additional Fee Account") THEN BEGIN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    AddFeeInclVAT := "Additional Fee" * (1 + VATPostingSetup."VAT %"/100);
    END ELSE
    AddFeeInclVAT := "Additional Fee";

    // Add the following lines.
    CALCFIELDS("Interest Amount","VAT Amount");
    IF ("Interest Amount" <> 0) AND ("VAT Amount" <> 0) THEN BEGIN
    GLAcc.GET(CustPostingGroup."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    Interest:=
    (ReminderInterestAmount +
    "VAT Amount" +"Issued Reminder Header"."Additional Fee" - AddFeeInclVAT) / (VATInterest / 100 + 1);
    END ELSE BEGIN
    Interest:= "Interest Amount";
    VATInterest := 0;
    END;
    // End of the added lines.

    IF ISSERVICETIER THEN BEGIN
    NNC_InterestAmountTotal := 0;
    NNC_RemainingAmountTotal := 0;
    NNC_VATAmountTotal := 0;
    ...
  4. Change the code in the Data Item Number 4 Sections in the Reminder Statistics Report (117) as follows:
    Existing code 1
    ...
    }
    CONTROLS
    {
    { 45 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    CaptionML=ENU=Interest Amount;

    // Delete the following line.
    SourceExpr=(ReminderInterestAmount + "VAT Amount" +"Issued Reminder Header"."Additional Fee" - AddFeeInclVAT)/(VATInterest/100 +1);
    // End of the deleted line.

    AutoFormatType=1;
    AutoFormatExpr="Issued Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=ReminderInterestAmount____VAT_Amount____Issued_Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100__1_ }
    { 47 ;Label ;6090 ;0 ;4200 ;423 ;ParentControl=45;
    FontSize=9;
    ...
    Replacement code 1
    ...
    }
    CONTROLS
    {
    { 45 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    CaptionML=ENU=Interest Amount;

    // Add the following line.
    SourceExpr=Interest;
    // End of the added line.

    AutoFormatType=1;
    AutoFormatExpr="Issued Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=ReminderInterestAmount____VAT_Amount____Issued_Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100__1_ }
    { 47 ;Label ;6090 ;0 ;4200 ;423 ;ParentControl=45;
    FontSize=9;
    ...
    Existing code 2
    ...
    CONTROLS
    {
    { 44 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    FontBold=Yes;
    CaptionML=ENU=Total;

    // Delete the following line.
    SourceExpr="Remaining Amount" + ReminderInterestAmount + "VAT Amount"-(ReminderInterestAmount + "VAT Amount" +"Issued Reminder Header"."Additional Fee" - AddFeeInclVAT)/(VATInterest/100+1)*VATInterest/100 + "Issued Reminder Header"."Additional Fee" - AddFeeInclVAT;
    // End of the deleted line.

    AutoFormatType=1;
    AutoFormatExpr="Issued Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=Remaining_Amount____ReminderInterestAmount____VAT_Amount___ReminderInterestAmount____VAT_Amount____Issued_Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100_1__VATInterest_100____Issued_Reminder_Header___Additional_Fee____AddFeeInclVAT }
    { 56 ;TextBox ;6090 ;0 ;4200 ;423 ;FontSize=9;
    FontBold=Yes;
    ...
    Replacement code 2
    ...
    CONTROLS
    {
    { 44 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    FontBold=Yes;
    CaptionML=ENU=Total;

    // Add the following line.
    SourceExpr="Remaining Amount" + ReminderInterestAmount;
    // End of the added line.

    AutoFormatType=1;
    AutoFormatExpr="Issued Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=Remaining_Amount____ReminderInterestAmount____VAT_Amount___ReminderInterestAmount____VAT_Amount____Issued_Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100_1__VATInterest_100____Issued_Reminder_Header___Additional_Fee____AddFeeInclVAT }
    { 56 ;TextBox ;6090 ;0 ;4200 ;423 ;FontSize=9;
    FontBold=Yes;
    ...
  5. Change the code in the Data Item Number 1 in the Reminder Statistics Report (122) as follows:
    Existing code
    ...
    IF GLAcc.GET(CustPostingGroup."Additional Fee Account") THEN BEGIN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    AddFeeInclVAT := "Additional Fee" * (1 + VATPostingSetup."VAT %"/100);
    END ELSE
    AddFeeInclVAT := "Additional Fee";

    // Delete the following lines.
    CALCFIELDS("Interest Amount");
    IF "Interest Amount" <> 0 THEN BEGIN
    GLAcc.GET(CustPostingGroup."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    END ELSE
    VATInterest := 0;

    // End of the deleted lines.

    IF ISSERVICETIER THEN BEGIN
    NNC_Interest := 0;
    NNC_TotalLCY := 0;
    NNC_VATAmount := 0;
    NNC_TotalLCYVATAmount := 0;
    ...
    Replacement code
    ...
    IF GLAcc.GET(CustPostingGroup."Additional Fee Account") THEN BEGIN
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    AddFeeInclVAT := "Additional Fee" * (1 + VATPostingSetup."VAT %"/100);
    END ELSE
    AddFeeInclVAT := "Additional Fee";

    // Add the following lines.
    CALCFIELDS("Interest Amount","VAT Amount");
    IF ("Interest Amount" <> 0) AND ("VAT Amount" <> 0) THEN BEGIN
    GLAcc.GET(CustPostingGroup."Interest Account");
    VATPostingSetup.GET("VAT Bus. Posting Group",GLAcc."VAT Prod. Posting Group");
    VATInterest := VATPostingSetup."VAT %";
    Interest:=
    (ReminderInterestAmount +
    "VAT Amount" +"Reminder Header"."Additional Fee" - AddFeeInclVAT) / (VATInterest / 100 + 1);
    END ELSE BEGIN
    Interest:= "Interest Amount";
    VATInterest := 0;
    END;
    IF VATInterest <> 0 THEN
    // End of the added lines.

    IF ISSERVICETIER THEN BEGIN
    NNC_Interest := 0;
    NNC_TotalLCY := 0;
    NNC_VATAmount := 0;
    NNC_TotalLCYVATAmount := 0;
    ...
  6. Change the code in the Data Item Number 2 in the Reminder Statistics Report (122) as follows:
    Existing code
    ...
    }
    { PROPERTIES
    {
    DataItemIndent=1;
    DataItemTable=Table2000000026;

    // Delete the following line.
    DataItemTableView=SORTING(Number) WHERE(Number=CONST(1));
    // End of the deleted line.

    DataItemVarName=PageCounter;
    }
    SECTIONS
    {
    { PROPERTIES
    ...
    Replacement code
    ...
    }
    { PROPERTIES
    {
    DataItemIndent=1;
    DataItemTable=Table2000000026;

    // Add the following lines.
    DataItemTableView=SORTING(Number)
    WHERE(Number=CONST(1));
    // End of the added lines.

    DataItemVarName=PageCounter;
    }
    SECTIONS
    {
    { PROPERTIES
    ...
  7. Change the code in the Data Item Number 3 in the Reminder Statistics Report (122) as follows:
    Existing code
    ...
    }
    { PROPERTIES
    {
    DataItemIndent=2;
    DataItemTable=Table2000000026;

    // Delete the following line.
    DataItemTableView=SORTING(Number) WHERE(Number=FILTER(1..));
    // End of the deleted line.

    DataItemVarName=DimensionLoop;
    OnPreDataItem=BEGIN
    IF NOT ShowDim THEN
    CurrReport.BREAK;
    DocDim.SETRANGE("Table ID",DATABASE::"Reminder Header");
    ...
    Replacement code
    ...
    }
    { PROPERTIES
    {
    DataItemIndent=2;
    DataItemTable=Table2000000026;

    // Add the following lines.
    DataItemTableView=SORTING(Number)
    WHERE(Number=FILTER(1..));
    // End of the added lines.

    DataItemVarName=DimensionLoop;
    OnPreDataItem=BEGIN
    IF NOT ShowDim THEN
    CurrReport.BREAK;
    DocDim.SETRANGE("Table ID",DATABASE::"Reminder Header");
    ...
  8. Change the code in the Data Item Number 5 in the Reminder Statistics Report (122) as follows:
    Existing code
    ...
    }
    { PROPERTIES
    {
    DataItemIndent=2;
    DataItemTable=Table296;

    // Delete the following line.
    DataItemTableView=SORTING(Reminder No.,Line No.) WHERE(Line Type=FILTER(<>Not Due));
    // End of the deleted line.

    OnPreDataItem=BEGIN
    IF ISSERVICETIER THEN
    TotalVATAmount := 0;

    IF FIND('+') THEN BEGIN
    ...
    Replacement code
    ...
    }
    { PROPERTIES
    {
    DataItemIndent=2;
    DataItemTable=Table296;

    // Add the following lines.
    DataItemTableView=SORTING(Reminder No.,Line No.)
    WHERE(Line Type=FILTER(<>Not Due));
    // End of the added lines.

    OnPreDataItem=BEGIN
    IF ISSERVICETIER THEN
    TotalVATAmount := 0;

    IF FIND('+') THEN BEGIN
    ...
  9. Change the code in the Data Item Number 5 Sections in the Reminder Statistics Report (122) as follows:
    Existing code 1
    ...
    }
    CONTROLS
    {
    { 17 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    CaptionML=ENU=Interest Amount;

    // Delete the following line.
    SourceExpr=(ReminderInterestAmount + "VAT Amount" +"Reminder Header"."Additional Fee" - AddFeeInclVAT)/(VATInterest/100 +1);
    // End of the deleted line.

    AutoFormatType=1;
    AutoFormatExpr="Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=ReminderInterestAmount____VAT_Amount____Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100__1_ }
    { 20 ;Label ;6090 ;0 ;4200 ;423 ;ParentControl=17;
    FontSize=9;
    ...
    Replacement code 1
    ...
    }
    CONTROLS
    {
    { 17 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    CaptionML=ENU=Interest Amount;

    // Add the following line.
    SourceExpr=Interest;
    // End of the added line.

    AutoFormatType=1;
    AutoFormatExpr="Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=ReminderInterestAmount____VAT_Amount____Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100__1_ }
    { 20 ;Label ;6090 ;0 ;4200 ;423 ;ParentControl=17;
    FontSize=9;
    ...
    Existing code 2
    ...
    }
    CONTROLS
    {
    { 29 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    FontBold=Yes;

    // Delete the following line.
    SourceExpr="Remaining Amount" + ReminderInterestAmount + "VAT Amount"-(ReminderInterestAmount + "VAT Amount" +"Reminder Header"."Additional Fee" - AddFeeInclVAT)/(VATInterest/100+1)*VATInterest/100 + "Reminder Header"."Additional Fee" - AddFeeInclVAT;
    // End of the deleted line.

    AutoFormatType=1;
    AutoFormatExpr="Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=Remaining_Amount____ReminderInterestAmount____VAT_Amount___ReminderInterestAmount____VAT_Amount____Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100_1__VATInterest_100____Reminder_Header___Additional_Fee____AddFeeInclVAT }
    { 43 ;TextBox ;6090 ;0 ;4200 ;423 ;FontSize=9;
    FontBold=Yes;
    ...
    Replacement code 2
    ...
    }
    CONTROLS
    {
    { 29 ;TextBox ;10710;0 ;2520 ;423 ;FontSize=9;
    FontBold=Yes;

    // Add the following line.
    SourceExpr="Remaining Amount" + ReminderInterestAmount;
    // End of the added line.

    AutoFormatType=1;
    AutoFormatExpr="Reminder Line".GetCurrencyCodeFromHeader;
    DataSetFieldName=Remaining_Amount____ReminderInterestAmount____VAT_Amount___ReminderInterestAmount____VAT_Amount____Reminder_Header___Additional_Fee____AddFeeInclVAT___VATInterest_100_1__VATInterest_100____Reminder_Header___Additional_Fee____AddFeeInclVAT }
    { 43 ;TextBox ;6090 ;0 ;4200 ;423 ;FontSize=9;
    FontBold=Yes;
    ...

Prerequisites

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

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.
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 Usefor other considerations.
คุณสมบัติ

รหัสบทความ: 3009492 - การตรวจสอบครั้งสุดท้าย: 5 ส.ค. 2015 - ฉบับแก้ไข: 1

คำติชม