Incorrect unit price after Prices inc. VAT was changed in the Hungarian version of Microsoft Dynamics NAV 2009 R2

Symptoms

When you create a corrective invoice if the Prices inc. VAT field was changed, the unit price values are incorrect in the Hungarian version of Microsoft Dynamics NAV 2009 R2. Follow the steps in the code changes section to solve this issue. This problem occurs in the following products:

  • The Hungarian version of Microsoft Dynamics NAV 2009 R2

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 UpdateVATAmounts function in the Sales Correction Line table (14536) as follows:
    Existing code

    ...
    Amount * (1 - SalesHeader."VAT Base Discount %" / 100),
    Currency."Amount Rounding Precision");
    "Amount Including VAT" :=
    ROUND(
    Amount * (1 - SalesHeader."VAT Base Discount %" / 100) * "VAT %" / 100,
    Currency."Amount Rounding Precision",Currency.VATRoundingDirection);
    END;
    "VAT Calculation Type"::"Full VAT":
    BEGIN
    ...

    Replacement code

    ...
    Amount * (1 - SalesHeader."VAT Base Discount %" / 100),
    Currency."Amount Rounding Precision");
    "Amount Including VAT" :=

    // Add the following line.
    Amount +
    // End of the added line.

    ROUND(
    Amount * (1 - SalesHeader."VAT Base Discount %" / 100) * "VAT %" / 100,
    Currency."Amount Rounding Precision",Currency.VATRoundingDirection);
    END;
    "VAT Calculation Type"::"Full VAT":
    BEGIN
    ...
  2. Change the code in CheckLineAmount function in the Sales Correction Line table (14536) as follows:
    Existing code 1

    ...
    "Unit Price Incl. Discount" := "Unit Price" - "Unit Price" * "Line Discount %" / 100;
    END;

    // Delete the following line.
    PROCEDURE CheckLineAmount@1360000();
    // End of the deleted line.

    BEGIN
    // PS16433.begin
    IF "Before/ After correction" = "Before/ After correction"::After THEN BEGIN
    ...

    Replacement code 1

    ...
    "Unit Price Incl. Discount" := "Unit Price" - "Unit Price" * "Line Discount %" / 100;
    END;

    // Add the following lines.
    PROCEDURE CheckLineAmount@1170219();
    VAR
    SalesinvHeader@1170001 : Record 112;
    // End of the added lines.

    BEGIN
    // PS16433.begin
    IF "Before/ After correction" = "Before/ After correction"::After THEN BEGIN
    ...

    Existing code 2

    ...
    // PS16433.begin
    IF "Before/ After correction" = "Before/ After correction"::After THEN BEGIN
    SalesCorrLine.GET("Document Type","Document No.","Correction Line No.","Before/ After correction"::Before);
    GetCorrType;
    IF (SalesCorrLine."Line Amount" > "Line Amount") AND
    ("Document Type" = "Document Type"::Invoice) AND
    (SalesCorrectionType."Correction Type" = SalesCorrectionType."Correction Type"::"Quantity and Value")
    THEN
    ...

    Replacement code 2

    ...
    // PS16433.begin
    IF "Before/ After correction" = "Before/ After correction"::After THEN BEGIN
    SalesCorrLine.GET("Document Type","Document No.","Correction Line No.","Before/ After correction"::Before);

    // Add the following line.
    SalesinvHeader.GET(SalesHeader."Corr. Document No.");
    // End of the added line.

    GetCorrType;
    IF (SalesCorrLine."Line Amount" > "Line Amount") AND

    // Add the following line.
    (SalesHeader."Prices Including VAT" = SalesinvHeader."Prices Including VAT") AND
    // End of the added line.

    ("Document Type" = "Document Type"::Invoice) AND
    (SalesCorrectionType."Correction Type" = SalesCorrectionType."Correction Type"::"Quantity and Value")
    THEN
    ...
  3. Change the code in Data Item Number 5 in the Sales - Invoice (HU) report (14516) as follows:
    Existing code

    ...
    DataItemTable=Table14537;
    DataItemTableView=SORTING(Document No.,Correction Line No.,Before/ After correction,Document Type)
    WHERE(Before/ After correction=FILTER(Before),
    Document Type=CONST(Posted Invoice));
    DataItemVarName=PostedSalesCorrLineBefore;
    DataItemLinkReference=Sales Invoice Header;
    DataItemLink=Document No.=FIELD(No.);
    }
    SECTIONS
    {
    ...

    Replacement code

    ...
    DataItemTable=Table14537;
    DataItemTableView=SORTING(Document No.,Correction Line No.,Before/ After correction,Document Type)
    WHERE(Before/ After correction=FILTER(Before),
    Document Type=CONST(Posted Invoice));
    DataItemVarName=PostedSalesCorrLineBefore;

    // Add the following lines.
    OnAfterGetRecord=BEGIN
    IF SalesInvHeader.GET("Sales Invoice Header"."Corr. Document No.") THEN
    IF SalesInvHeader."Prices Including VAT" <> "Sales Invoice Header"."Prices Including VAT" THEN
    "Unit Price Incl. Discount" := "VAT Base Amount" / Quantity;
    END;

    // End of the added lines.

    DataItemLinkReference=Sales Invoice Header;
    DataItemLink=Document No.=FIELD(No.);
    }
    SECTIONS
    {
    ...
  4. Change the code in Data Item Number 6 in the Sales - Invoice (HU) report (14516) as follows:
    Existing code

    ...
    DataItemTable=Table14537;
    DataItemTableView=SORTING(Document No.,Correction Line No.,Before/ After correction,Document Type)
    WHERE(Before/ After correction=FILTER(After),
    Document Type=CONST(Posted Invoice));
    DataItemVarName=PostedSalesCorrLineAfter;
    DataItemLinkReference=PostedSalesCorrLineBefore;
    DataItemLink=Document No.=FIELD(Document No.),
    Correction Line No.=FIELD(Correction Line No.);
    }
    SECTIONS
    ...

    Replacement code

    ...
    DataItemTable=Table14537;
    DataItemTableView=SORTING(Document No.,Correction Line No.,Before/ After correction,Document Type)
    WHERE(Before/ After correction=FILTER(After),
    Document Type=CONST(Posted Invoice));
    DataItemVarName=PostedSalesCorrLineAfter;

    // Add the following lines.
    OnAfterGetRecord=BEGIN
    IF SalesInvHeader."Prices Including VAT" <> "Sales Invoice Header"."Prices Including VAT" THEN
    "Unit Price Incl. Discount" := "VAT Base Amount" / Quantity;
    END;

    // End of the added lines.

    DataItemLinkReference=PostedSalesCorrLineBefore;
    DataItemLink=Document No.=FIELD(Document No.),
    Correction Line No.=FIELD(Correction Line No.);
    }
    SECTIONS
    ...
  5. Change the code in Global Variables in the Sales - Invoice (HU) report (14516) as follows:
    Existing code

    ...
    VALExchRate@1360016 : Text[50];
    Text14530@1360017 : TextConst 'ENU=%1/%2;HUN=%1/%2';
    GroupVATText@13600018 : Text[30];
    CorrInvText@1360018 : TextConst 'ENU=C O R R E C T I V E I N V O I C E;HUN=H E L Y E S B Ö T Š S Z µ M L A';
    LogInteractionEnable@19003940 : Boolean INDATASET;

    PROCEDURE InitLogInteraction@1360000();
    BEGIN
    LogInteraction := SegManagement.FindInteractTmplCode(4) <> '';
    END;
    ...

    Replacement code

    ...
    VALExchRate@1360016 : Text[50];
    Text14530@1360017 : TextConst 'ENU=%1/%2;HUN=%1/%2';
    GroupVATText@13600018 : Text[30];
    CorrInvText@1360018 : TextConst 'ENU=C O R R E C T I V E I N V O I C E;HUN=H E L Y E S B Ö T Š S Z µ M L A';
    LogInteractionEnable@19003940 : Boolean INDATASET;

    // Add the following line.
    SalesInvHeader@13600019 : Record 112;
    // End of the added line.

    PROCEDURE InitLogInteraction@1360000();
    BEGIN
    LogInteraction := SegManagement.FindInteractTmplCode(4) <> '';
    END;
    ...
  6. Change the code in InitSalesLineOnCharge function in the VATCorrectionManagement codeunit (14535) as follows:
    Existing code 1

    ...
    SalesLine.INSERT;
    CopyDim(SalesLine,SalesCorrLine);
    END;

    PROCEDURE InitSalesLineOnCharge@1360001(VAR SalesLine@1360000 : Record 37;SalesCorrLine@1360001 : Record 14536;QtyOnSalesLine@1360002 : Decimal);
    BEGIN
    InitSalesLine(SalesCorrLine,SalesLine);
    SalesLine.Type := SalesLine.Type::"Charge (Item)";
    SalesLine."No." := SalesCorrType."Item Charge Code";
    SalesLine.VALIDATE("Unit of Measure Code",'');
    ...

    Replacement code 1

    ...
    SalesLine.INSERT;
    CopyDim(SalesLine,SalesCorrLine);
    END;

    PROCEDURE InitSalesLineOnCharge@1360001(VAR SalesLine@1360000 : Record 37;SalesCorrLine@1360001 : Record 14536;QtyOnSalesLine@1360002 : Decimal);

    // Add the following lines.
    VAR
    SalesInvHeader@1360003 : Record 112;
    // End of the added lines.

    BEGIN
    InitSalesLine(SalesCorrLine,SalesLine);
    SalesLine.Type := SalesLine.Type::"Charge (Item)";
    SalesLine."No." := SalesCorrType."Item Charge Code";
    SalesLine.VALIDATE("Unit of Measure Code",'');
    ...

    Existing code 2

    ...
    InitSalesLine(SalesCorrLine,SalesLine);
    SalesLine.Type := SalesLine.Type::"Charge (Item)";
    SalesLine."No." := SalesCorrType."Item Charge Code";
    SalesLine.VALIDATE("Unit of Measure Code",'');
    SalesLine.VALIDATE(Quantity,QtyOnSalesLine);
    SalesLine.VALIDATE("Unit Price",SalesCorrLine."Unit Price");
    IF SalesLine.Quantity <> 0 THEN
    SalesLine.VALIDATE("Line Discount %",SalesCorrLine."Line Discount %");
    SalesLine.UpdateAmounts;
    SalesLine.VALIDATE("Unit Cost (LCY)",0);
    ...

    Replacement code 2

    ...
    InitSalesLine(SalesCorrLine,SalesLine);
    SalesLine.Type := SalesLine.Type::"Charge (Item)";
    SalesLine."No." := SalesCorrType."Item Charge Code";
    SalesLine.VALIDATE("Unit of Measure Code",'');
    SalesLine.VALIDATE(Quantity,QtyOnSalesLine);

    // Add the following lines.
    IF (SalesCorrLine."Before/ After correction" = SalesCorrLine."Before/ After correction"::Before) AND
    (SalesInvHeader.GET(SalesCorrLine."Source Document No.")) AND
    (SalesHeader."Prices Including VAT" <> SalesInvHeader."Prices Including VAT")
    THEN BEGIN
    IF SalesHeader."Prices Including VAT" THEN
    SalesLine.VALIDATE("Unit Price",SalesCorrLine."Amount Including VAT" / SalesCorrLine.Quantity)
    ELSE
    SalesLine.VALIDATE("Unit Price",SalesCorrLine."VAT Base Amount" / SalesCorrLine.Quantity);
    END ELSE
    // End of the added lines.

    SalesLine.VALIDATE("Unit Price",SalesCorrLine."Unit Price");
    IF SalesLine.Quantity <> 0 THEN
    SalesLine.VALIDATE("Line Discount %",SalesCorrLine."Line Discount %");
    SalesLine.UpdateAmounts;
    SalesLine.VALIDATE("Unit Cost (LCY)",0);
    ...

Prerequisites

You must have one of the following products installed to apply this hotfix:

  • The Hungarian version of Microsoft Dynamics NAV 2009 R2

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.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×