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 "Inv. Discount Amount", "Unit price excl VAT" and "Line Amount excl VAT" values are incorrect in a sales order that has price inclusive tax enabled in the Indian version of Microsoft Dynamics NAV 2009


View products that this article applies to.

This article applies to Microsoft Dynamics NAV for the Indian (in) language locale.

↑ Back to the top


Symptoms

Assume that you have a sales order that has price inclusive tax enabled in the Indian version of Microsoft Dynamics NAV 2009. After you run the Calculate Structure Values function, the Inv. Discount Amount, Unit price excl VAT and Line Amount excl VAT values are incorrect. 
This problem occurs in the following products:
  • The Indian version of Microsoft Dynamics NAV 2009 R2
  • The Indian version of 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 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 Line Discount % - OnValidate trigger in the Sales Line table (37) as follows:
    Existing code
    ...
    "Line Discount %" := 100;

    // Delete the following line.
    IF NOT "Price Inclusive of Tax" THEN

    "Line Discount Amount" :=
    ROUND(ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") * "Line Discount %" / 100,
    Currency."Amount Rounding Precision")

    // Delete the following lines.
    ELSE
    "Line Discount Amount" := ROUND(ROUND(Quantity * "Unit Price Incl. of Tax",Currency."Amount Rounding Precision") *
    "Line Discount %" / 100,Currency."Amount Rounding Precision");
    // End of the lines.
    ...
    Replacement code
    ...

    "Line Discount %" := 100;

    "Line Discount Amount" :=
    ROUND(ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") * "Line Discount %" / 100,
    Currency."Amount Rounding Precision");
    ...
  2. Change the code in the Line Discount Amount - OnValidate trigger in the Sales Line table (37) as follows:
    Existing code
    ...
    TESTFIELD(Quantity);

    // Delete the following line.
    IF NOT "Price Inclusive of Tax" THEN

    IF ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") <> 0 THEN
    "Line Discount %" :=
    ROUND(
    "Line Discount Amount" / ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") * 100,
    0.00001)
    ELSE
    "Line Discount %" := 0

    // Delete the following lines.
    ELSE
    IF ROUND(Quantity * "Unit Price Incl. of Tax",Currency."Amount Rounding Precision") <> 0 THEN
    "Line Discount %" :=
    ROUND(
    "Line Discount Amount" / ROUND(Quantity * "Unit Price Incl. of Tax",Currency."Amount Rounding Precision") * 100,
    0.00001)
    ELSE
    "Line Discount %" := 0;
    // End of the lines.

    "Inv. Discount Amount" := 0;
    ...
    Replacement code
    ...
    TESTFIELD(Quantity);
    IF ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") <> 0 THEN
    "Line Discount %" :=
    ROUND(
    "Line Discount Amount" / ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") * 100,
    0.00001)
    ELSE
    "Line Discount %" := 0;
    "Inv. Discount Amount" := 0;
    ...
  3. Change the code in the GetSalesPriceExclusiveTaxes function in the Sales Line table (37) as follows:
    Existing code
    ...
    IF StrOrderDetails."Include Base" THEN
    BaseAmountVariable := BaseAmountVariable + Quantity;

    // Delete the following lines.
    IF StrOrderDetails."Include Line Discount" THEN
    BaseAmountFixed := BaseAmountFixed - "Line Discount Amount";
    IF StrOrderDetails."Include Invoice Discount" THEN BEGIN
    BaseAmountFixed := BaseAmountFixed + "Inv Discount Fixed";
    BaseAmountVariable := BaseAmountVariable - "Inv Discount Variable";
    END;
    // End of the lines.

    IF SalesHeader."Currency Factor" <> 0 THEN
    ...
    Replacement code
    ...
    IF StrOrderDetails."Include Base" THEN
    BaseAmountVariable := BaseAmountVariable + Quantity;

    IF SalesHeader."Currency Factor" <> 0 THEN
    ...
  4. Change the code in the CalculateStructuresPIT function in the Sales Line table (37) as follows:
    Existing code
    ...
    SalesLine.MODIFY;

    // Delete the following lines.
    IF i < 3 THEN BEGIN
    FixedAmt := 0;
    VariableAmt := 0;
    AdjustedAmt := 0;
    DiffAdjustmentAmt := 0;
    FixedAmt := SalesLine."Unit Price Incl. of Tax" * SalesLine.Quantity;
    VariableAmt := SalesLine.Quantity;
    StrOrderLineDetails.RESET;
    StrOrderLineDetails.SETCURRENTKEY(Type,"Document Type","Document No.","Structure Code","Item No.","Line No.");
    StrOrderLineDetails.SETRANGE(Type,StrOrderLineDetails.Type::Sale);
    StrOrderLineDetails.SETRANGE("Document Type",SalesLine."Document Type");
    StrOrderLineDetails.SETRANGE("Document No.",SalesLine."Document No.");
    StrOrderLineDetails.SETRANGE("Structure Code",SalesLine."PIT Structure");
    StrOrderLineDetails.SETRANGE("Item No.",SalesLine."No.");
    StrOrderLineDetails.SETRANGE("Line No.",SalesLine."Line No.");
    StrOrderLineDetails.SETRANGE("Include PIT Calculation",TRUE);
    IF StrOrderLineDetails.FIND('-') THEN
    REPEAT
    FixedAmt -= StrOrderLineDetails.Amount;
    AdjustedAmt := AdjustedAmt + StrOrderLineDetails.Amount;
    UNTIL StrOrderLineDetails.NEXT = 0;

    SalesLine."Unit Price" := 0;
    IF VariableAmt <> 0 THEN BEGIN
    SalesLine."Unit Price" := ROUND((FixedAmt / VariableAmt),GetRoundingPrecisionUnitPrice);
    IF SalesLine."Unit Price" < 0 THEN
    SalesLine.FIELDERROR("Unit Price");
    IF (i = 2) AND (FixedAmt <> 0) AND (SalesLine.Quantity <> 0) THEN BEGIN
    AdjustedAmt := AdjustedAmt + (SalesLine."Unit Price" * SalesLine.Quantity);
    FixedAmt := SalesLine."Unit Price Incl. of Tax" * SalesLine.Quantity;
    DiffAdjustmentAmt := ((FixedAmt - AdjustedAmt)/SalesLine.Quantity) *
    (SalesLine."Unit Price" * SalesLine.Quantity) / (FixedAmt );
    SalesLine."Unit Price" := ROUND(SalesLine."Unit Price" - DiffAdjustmentAmt,GetRoundingPrecisionUnitPrice);
    IF SalesLine."Unit Price" < 0 THEN
    SalesLine.FIELDERROR("Unit Price");
    END;
    SalesLine.ValidateUnitPrice;
    SalesLine.ChkQtyUpdatioAfterDDPLA;
    SalesLine.MODIFY;
    IF SalesHeader."Calc. Inv. Discount (%)" THEN
    CalcInvDis.CalculateWithSalesHeader(SalesHeader,SalesLine);
    SalesLine.GET(SalesLine."Document Type",SalesLine."Document No.",SalesLine."Line No.");
    END;
    END;
    // End of the lines.
    ...
    Replacement code
    ...
    SalesLine.MODIFY;
    ...
  5. Change the code in the UpdateSalesLinesPIT function in the Sales Line table (37) as follows:
    Existing code
    ...
    "Service Tax Amount" + "Service Tax eCess Amount" + "Service Tax SHE Cess Amount";
    MODIFY;
    ...
    Replacement code
    ...

    "Service Tax Amount" + "Service Tax eCess Amount" + "Service Tax SHE Cess Amount";

    // Add the following lines.
    "Amount To Customer UPIT" :=
    "Line Amount" - "Inv. Discount Amount" + "Excise Amount" + "Tax Amount" + "Charges To Customer";
    // End of the lines.

    MODIFY;
    ...
  6. Change the code in the ValidateUnitPrice function in the Sales Line table (37) as follows:
    Existing code
    ...
    "Line Discount %" := 100;

    // Delete the following line.
    IF NOT "Price Inclusive of Tax" THEN

    "Line Discount Amount" := ROUND(ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") * "Line Discount %" / 100,
    Currency."Amount Rounding Precision")

    // Delete the following lines.
    ELSE
    "Line Discount Amount" := ROUND(ROUND(Quantity * "Unit Price Incl. of Tax",Currency."Amount Rounding Precision") *
    "Line Discount %" / 100,Currency."Amount Rounding Precision");
    // End of the lines.

    "Inv. Discount Amount" := 0;
    ...
    Replacement code
    ...

    "Line Discount %" := 100;
    "Line Discount Amount" := ROUND(ROUND(Quantity * "Unit Price",Currency."Amount Rounding Precision") * "Line Discount %" / 100,
    Currency."Amount Rounding Precision");
    "Inv. Discount Amount" := 0;
    ...
  7. Change the code in the DivideAmount function in the Sales - Post codeunit (80) as follows: 
    Existing code 1
    ...
    IF SalesLineQty <> Quantity THEN

    // Delete the following lines.
    IF "Price Inclusive of Tax" THEN
    "Line Discount Amount" :=
    ROUND((SalesLineQty * "Unit Price Incl. of Tax") * "Line Discount %" / 100,Currency."Amount Rounding Precision")
    ELSE
    // End of the lines.

    "Line Discount Amount" :=
    ROUND("Line Amount" * "Line Discount %" / 100,Currency."Amount Rounding Precision");
    "Line Amount" := "Line Amount" - "Line Discount Amount";
    ...
    Replacement code 1
    ...
    IF SalesLineQty <> Quantity THEN
    "Line Discount Amount" :=
    ROUND("Line Amount" * "Line Discount %" / 100,Currency."Amount Rounding Precision");
    "Line Amount" := "Line Amount" - "Line Discount Amount";
    ...
    Existing code 2
    ...
    "Bal. TDS/TCS Including SHECESS",Currency."Amount Rounding Precision");

    // Delete the following lines.
    IF "Price Inclusive of Tax" THEN BEGIN
    "Amount To Customer UPIT" := SalesLineQty * "Unit Price";
    GLSetup.GET;
    StrOrdLineDetails2.RESET;
    StrOrdLineDetails2.SETRANGE(Type,StrOrdLineDetails2.Type::Sale);
    StrOrdLineDetails2.SETRANGE("Document Type","Document Type");
    StrOrdLineDetails2.SETRANGE("Document No.","Document No.");
    StrOrdLineDetails2.SETRANGE("Line No.","Line No.");
    StrOrdLineDetails2.SETRANGE("Include PIT Calculation",TRUE);
    IF StrOrdLineDetails2.FINDSET THEN
    REPEAT
    SalesLine2.GET("Document Type","Document No.","Line No.");
    IF StrOrdLineDetails2."Tax/Charge Type" = StrOrdLineDetails2."Tax/Charge Type"::Excise THEN
    "Amount To Customer UPIT" += "Excise Amount";
    IF StrOrdLineDetails2."Tax/Charge Type" = StrOrdLineDetails2."Tax/Charge Type"::"Sales Tax" THEN
    "Amount To Customer UPIT" += "Tax Amount";
    IF StrOrdLineDetails2."Tax/Charge Type" = StrOrdLineDetails2."Tax/Charge Type"::Charges THEN BEGIN
    IF QuantityType = QuantityType::General THEN
    "Amount To Customer UPIT" += ROUND(StrOrdLineDetails2.Amount * SalesLineQty / Quantity,
    Currency."Amount Rounding Precision");
    IF QuantityType = QuantityType::Invoicing THEN
    "Amount To Customer UPIT" += ROUND(StrOrdLineDetails2.Amount * SalesLine2."Qty. to Invoice" / SalesLine2.Quantity,
    Currency."Amount Rounding Precision");
    IF QuantityType = QuantityType::Shipping THEN
    "Amount To Customer UPIT" += ROUND(StrOrdLineDetails2.Amount * SalesLine2."Qty. to Ship" / SalesLine2.Quantity,
    Currency."Amount Rounding Precision");
    END;
    UNTIL StrOrdLineDetails2.NEXT = 0;
    "Total UPIT Amount" := ROUND("Total UPIT Amount" * SalesLineQty / Quantity,Currency."Amount Rounding Precision");
    END;
    // End of the lines.

    END;
    END;
    ...
    Replacement code 2
    ...
    "Bal. TDS/TCS Including SHECESS",Currency."Amount Rounding Precision");

    // Add the following lines.
    IF "Price Inclusive of Tax" THEN
    "Amount To Customer UPIT" :=
    ROUND("Line Amount" - "Inv. Discount Amount" + "Excise Amount" + "Tax Amount" +
    "Charges To Customer", Currency."Amount Rounding Precision");
    // End of the lines.

    END;
    END;
    ...
  8. Change the code in the RoundAmount function in the Sales - Post codeunit (80) as follows:
    Existing code
    ...
    TotalSalesLineLCY."Amount To Customer";
    "Charges To Customer" :=
    ...
    Replacement code
    ...
    TotalSalesLineLCY."Amount To Customer";

    // Add the following lines.
    "Amount To Customer UPIT" :=
    ROUND(
    CurrExchRate.ExchangeAmtFCYToLCY(
    UseDate,SalesHeader."Currency Code",
    TotalSalesLine."Amount To Customer UPIT",SalesHeader."Currency Factor")) -
    TotalSalesLineLCY."Amount To Customer UPIT";
    "Total UPIT Amount" :=
    ROUND(
    CurrExchRate.ExchangeAmtFCYToLCY(
    UseDate,SalesHeader."Currency Code",
    TotalSalesLine."Total UPIT Amount",SalesHeader."Currency Factor")) -
    TotalSalesLineLCY."Total UPIT Amount";
    // End of the lines.

    "Charges To Customer" :=
    ...
  9. Change the code in the ReverseAmount function in the Sales - Post codeunit (80) as follows:
    Existing code
    ...
    "Amount To Customer" := -"Amount To Customer";
    "Charges To Customer" := -"Charges To Customer";
    ...
    Replacement code
    ...
    "Amount To Customer" := -"Amount To Customer";

    // Add the following lines.
    Amount To Customer UPIT" := -"Amount To Customer UPIT";
    Total UPIT Amount" := -"Total UPIT Amount";
    // End of the lines.

    "Charges To Customer" := -"Charges To Customer";
    ...
  10. Change the code in the InvoiceUPITRounding function in the Sales - Post codeunit (80) as follows:
    Existing code 1
    ...
    EXIT;

    // Delete the following line.
    UPITRoundingAmount := TotalSalesLine."Total UPIT Amount" - ROUND(TotalSalesLine."Amount To Customer UPIT");

    IF UPITRoundingAmount <> 0 THEN BEGIN
    ...
    Replacement code 1
    ...
    EXIT;

    // Add the following line.
    UPITRoundingAmount := TotalSalesLine."Amount To Customer UPIT" - ROUND(TotalSalesLine."Amount To Customer UPIT");

    IF UPITRoundingAmount <> 0 THEN BEGIN
    ...
    Existing code 2
    ...
    "UPIT Rounding Inserted" := TRUE;

    // Delete the following line.
    IF SalesHeader."Prices Including VAT" THEN

    VALIDATE("Unit Price",UPITRoundingAmount)
    ...
    Replacement code 2
    ...
    "UPIT Rounding Inserted" := TRUE;

    // Add the following line.
    IF SalesHeader."Price Inclusive of Taxes" THEN

    VALIDATE("Unit Price",UPITRoundingAmount)
    ...

Prerequisites

You must have one of the following products installed to apply this hotfix:
  • The Indian version of Microsoft Dynamics NAV 2009 R2
  • The Indian version of Microsoft Dynamics NAV 2009 Service Pack 1 (SP1)

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

↑ Back to the top

Article Info
Article ID : 2633195
Revision : 1
Created on : 1/7/2017
Published on : 11/4/2011
Exists online : False
Views : 171