Symptoms

If you apply the prepayments update, the VAT entries sometimes have incorrect values in the Hungarian version of Microsoft Dynamics NAV 2009 R2. In addition, when you create an advance credit memo with a foreign currency, an incorrect currency rate is used. 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 Variables in the codeunit (26585) as follows:
    Existing code

    ... 
    TempDocDim@1470008 : TEMPORARY Record 357;
    TempDimBuf@1470007 : TEMPORARY Record 360;
    PrepmtInvBuffer@1470009 : TEMPORARY Record 461;
    SalesSetup@1470010 : Record 311;
    PrevLineNo@1470012 : Integer;
    LineNo@1470011 : Integer;
    ...

    Replacement code

    ...
    TempDocDim@1470008 : TEMPORARY Record 357;
    TempDimBuf@1470007 : TEMPORARY Record 360;
    PrepmtInvBuffer@1470009 : TEMPORARY Record 461;

    // Add the following line.
    VATClauseBuffer@1470085 : TEMPORARY Record 26511;
    // End of the added line.

    SalesSetup@1470010 : Record 311;
    PrevLineNo@1470012 : Integer;
    LineNo@1470011 : Integer;
    ...
  2. Change the code in PostLetter function in the codeunit (26585) as follows:
    Existing code 1

    ... 
    PostingDate@1470020 : Date;
    LineAmount@1470009 : Decimal;
    PostingDescription@1470021 : Text[50];
    BEGIN
    LetterHeader := LetterHeader2;
    WITH SalesHeader DO BEGIN
    ...

    Replacement code 1

    ...
    PostingDate@1470020 : Date;
    LineAmount@1470009 : Decimal;
    PostingDescription@1470021 : Text[50];

    // Add the following lines.
    CurrFactor@1360001 : Decimal;
    VATCurrFactor@1360000 : Decimal;
    // End of the added lines.

    BEGIN
    LetterHeader := LetterHeader2;
    WITH SalesHeader DO BEGIN...

    Existing code 2

    ...
    SalesInvHeader."Posting Date" := PostingDate;
    SalesInvHeader."Document Date" := PostingDate;
    SalesInvHeader."VAT Date" := PostingDate;

    // Delete the following lines.
    SalesInvHeader."Currency Factor" := LetterHeader."Currency Factor";
    SalesInvHeader."VAT Currency Factor" := LetterHeader."VAT Currency Factor";
    // End of the deleted lines.

    SalesInvHeader."Due Date" := LetterHeader."Advance Due Date";
    SalesInvHeader."Pmt. Discount Date" := "Prepmt. Pmt. Discount Date";
    SalesInvHeader."Payment Discount %" := "Prepmt. Payment Discount %";
    ...

    Replacement code 2

    ...
    SalesInvHeader."Posting Date" := PostingDate;
    SalesInvHeader."Document Date" := PostingDate;
    SalesInvHeader."VAT Date" := PostingDate;

    // Add the following lines.

    GetPrepaymentCurrFactors("No.",CurrFactor,VATCurrFactor);
    SalesInvHeader."Currency Factor" := CurrFactor;
    SalesInvHeader."VAT Currency Factor" := VATCurrFactor;

    // End of the added lines.

    SalesInvHeader."Due Date" := LetterHeader."Advance Due Date";
    SalesInvHeader."Pmt. Discount Date" := "Prepmt. Pmt. Discount Date";
    SalesInvHeader."Payment Discount %" := "Prepmt. Payment Discount %";
    ...

    Existing code 3

    ...
    SalesCrMemoHeader."Posting Date" := PostingDate;
    SalesCrMemoHeader."VAT Date" := PostingDate;
    SalesCrMemoHeader."Document Date" := PostingDate;

    // Delete the following lines.
    SalesCrMemoHeader."Currency Factor" :=
    CurrExchRate.ExchangeRate(PostingDate,"Currency Code");
    SalesCrMemoHeader."VAT Currency Factor" := LetterHeader."VAT Currency Factor";
    // End of the deleted lines.

    SalesCrMemoHeader."Due Date" := LetterHeader."Advance Due Date";
    SalesCrMemoHeader.Correction := GLSetup."Mark Cr. Memos as Corrections";
    SalesCrMemoHeader."Date Sent" := 0D;
    ...

    Replacement code 3

    ...
    SalesCrMemoHeader."Posting Date" := PostingDate;
    SalesCrMemoHeader."VAT Date" := PostingDate;
    SalesCrMemoHeader."Document Date" := PostingDate;

    // Add the following lines.
    SalesCrMemoHeader."Currency Factor" := SalesInvHeaderBuf."Currency Factor";
    SalesCrMemoHeader."VAT Currency Factor" := SalesInvHeaderBuf."VAT Currency Factor";
    // End of the added lines.

    SalesCrMemoHeader."Due Date" := LetterHeader."Advance Due Date";
    SalesCrMemoHeader.Correction := GLSetup."Mark Cr. Memos as Corrections";
    SalesCrMemoHeader."Date Sent" := 0D;
    ...

    Existing code 4

    ...
    SalesInvHeader."Reversed By Cr. Memo No." := SalesCrMemoHeader."No.";
    SalesInvHeader.MODIFY;

    GenJnlLineDocType := GenJnlLine."Document Type"::"Credit Memo";
    PostedDocTabNo := DATABASE::"Sales Cr.Memo Header";
    Window.UPDATE(1,STRSUBSTNO(Text005,"Document Type","No.",SalesCrMemoHeader."No."));
    ...

    Replacement code 4

    ...
    SalesInvHeader."Reversed By Cr. Memo No." := SalesCrMemoHeader."No.";
    SalesInvHeader.MODIFY;

    // Add the following lines.
    CurrFactor := SalesCrMemoHeader."Currency Factor";
    VATCurrFactor := SalesCrMemoHeader."VAT Currency Factor";
    // End of the added lines.

    GenJnlLineDocType := GenJnlLine."Document Type"::"Credit Memo";
    PostedDocTabNo := DATABASE::"Sales Cr.Memo Header";
    Window.UPDATE(1,STRSUBSTNO(Text005,"Document Type","No.",SalesCrMemoHeader."No."));
    ...

    Existing code 5

    ...
    // Create Lines
    LineCount := 0;
    PrepmtInvBuffer.DELETEALL;

    // Delete the following line.
    BuildInvLineBuffer(LetterHeader,DocumentType,PrepmtInvBuffer,TempDocDim);
    // End of the deleted line.

    TempDimBuf.INIT;
    IF PrepmtInvBuffer.FINDSET THEN
    REPEAT
    ...

    Replacement code 5

    ...
    // Create Lines
    LineCount := 0;
    PrepmtInvBuffer.DELETEALL;

    // Add the following line.
    BuildInvLineBuffer(LetterHeader,DocumentType,PrepmtInvBuffer,TempDocDim,VATCurrFactor);
    // End of the added line.

    TempDimBuf.INIT;
    IF PrepmtInvBuffer.FINDSET THEN
    REPEAT
    ...

    Existing code 6

    ...
    GenJnlLine."Posting No. Series" := "Posting No. Series";
    GenJnlLine."IC Partner Code" := "Bill-to IC Partner Code";
    GenJnlLine."Group VAT ID" := "Group VAT ID"; // PS50595

    // Delete the following lines.
    GenJnlLine.VALIDATE("Currency Factor",LetterHeader."Currency Factor");
    GenJnlLine.VALIDATE("VAT Currency Factor",LetterHeader."VAT Currency Factor");
    // End of the deleted lines.

    GenJnlLine."VAT Base Amt. to Report (LCY)" := PrepmtInvBuffer."VAT Base Amt. to Report (LCY)";
    GenJnlLine."VAT Amount to Report (LCY)" := PrepmtInvBuffer."VAT Amount to Report (LCY)";
    RunGenJnlPostLine(GenJnlLine,PrepmtInvBuffer."Dimension Entry No.");
    ...

    Replacement code 6

    ...
    GenJnlLine."Posting No. Series" := "Posting No. Series";
    GenJnlLine."IC Partner Code" := "Bill-to IC Partner Code";
    GenJnlLine."Group VAT ID" := "Group VAT ID"; // PS50595

    // Add the following lines.
    GenJnlLine.VALIDATE("Currency Factor",CurrFactor);
    GenJnlLine.VALIDATE("VAT Currency Factor",VATCurrFactor);

    // End of the added lines.

    GenJnlLine."VAT Base Amt. to Report (LCY)" := PrepmtInvBuffer."VAT Base Amt. to Report (LCY)";
    GenJnlLine."VAT Amount to Report (LCY)" := PrepmtInvBuffer."VAT Amount to Report (LCY)";
    RunGenJnlPostLine(GenJnlLine,PrepmtInvBuffer."Dimension Entry No.");
    ...

    Existing code 7

    ...
    END;
    LetterHeader2 := LetterHeader;

    CLEAR(GenJnlPostLine);
    Window.CLOSE;
    EXIT(TRUE);
    ...

    Replacement code 7

    ...
    END;
    LetterHeader2 := LetterHeader;

    // Add the following lines.
    SetVATClause(SalesInvHeader,SalesInvLine);
    FinalizeVATClause(SalesInvHeader,SalesInvLine);
    // End of the added lines.

    CLEAR(GenJnlPostLine);
    Window.CLOSE;
    EXIT(TRUE);
    ...
  3. Change the code in AddPrepmtSalesInvLine function in the codeunit (26585) as follows:
    Existing code 1

    ...
    LOCAL PROCEDURE AddPrepmtSalesInvLine@1470033(LetterLine@1470002 : Record 26586;SalesInvHeader@1470001 : Record 112;AmountInclVAT@1470005 : Decimal;VATAmount@1470000 : Decimal;VAR LastLetterNo@1470006 : Code[20]) : Boolean;
    VAR
    LetterHeader@1360000 : Record 26585;
    GenJnlLine@1360001 : Record 81;
    SalesInvLine@1470003 : Record 113;
    NextLineNo@1470004 : Integer;
    ...

    Replacement code 1

    ...
    LOCAL PROCEDURE AddPrepmtSalesInvLine@1470033(LetterLine@1470002 : Record 26586;SalesInvHeader@1470001 : Record 112;AmountInclVAT@1470005 : Decimal;VATAmount@1470000 : Decimal;VAR LastLetterNo@1470006 : Code[20]) : Boolean;
    VAR

    // Delete the following line.
    LetterHeader@1360000 : Record 26585;
    // End of the deleted line.

    GenJnlLine@1360001 : Record 81;
    SalesInvLine@1470003 : Record 113;
    NextLineNo@1470004 : Integer;
    ...

    Existing code 2

    ...
    SalesInvLine."VAT Base Amt. to Report (LCY)" := SalesInvLine."VAT Base Amount";
    SalesInvLine."VAT Amount to Report (LCY)" := -VATAmount;
    END ELSE BEGIN

    // Delete the following lines.
    LetterHeader.GET(LetterLine."Letter No.");
    GenJnlLine."Currency Code" := LetterLine."Currency Code";
    GenJnlLine."VAT Currency Factor" := LetterHeader."VAT Currency Factor";
    // End of the deleted lines.

    GenJnlLine."Posting Date" := SalesInvHeader."Posting Date";
    GenJnlLine.CalcVATToReport(SalesInvLine."VAT Base Amount",-VATAmount);
    SalesInvLine."VAT Base Amt. to Report (LCY)" := GenJnlLine."VAT Base Amt. to Report (LCY)";
    ...

    Replacement code 2

    ...
    SalesInvLine."VAT Base Amt. to Report (LCY)" := SalesInvLine."VAT Base Amount";
    SalesInvLine."VAT Amount to Report (LCY)" := -VATAmount;
    END ELSE BEGIN

    // Add the following lines.
    GenJnlLine."Currency Code" := LetterLine."Currency Code";
    GenJnlLine."VAT Currency Factor" := SalesInvHeader."VAT Currency Factor";
    // End of the added lines.

    GenJnlLine."Posting Date" := SalesInvHeader."Posting Date";
    GenJnlLine.CalcVATToReport(SalesInvLine."VAT Base Amount",-VATAmount);
    SalesInvLine."VAT Base Amt. to Report (LCY)" := GenJnlLine."VAT Base Amt. to Report (LCY)";
    ...
  4. Change the code in BuildInvLineBuffer function in the codeunit (26585) as follows:
    Existing code 1

    ...
    LetterLine2.TABLECAPTION,LetterLine2."Letter No.",LetterLine2."Line No.",DimMgt.GetDimValuePostingErr);
    END;

    // Delete the following line.
    LOCAL PROCEDURE BuildInvLineBuffer@1470020(LetterHeader@1470000 : Record 26585;DocumentType@1470005 : 'Invoice,Credit Memo';VAR PrepmtInvBuf@1470001 : Record 461;VAR TempDocDim@1470002 : Record 357);
    // End of the deleted line.

    VAR
    LetterLine@1470003 : Record 26586;
    PrepmtInvBuf2@1470004 : Record 461;
    ...

    Replacement code 1

    ...
    LetterLine2.TABLECAPTION,LetterLine2."Letter No.",LetterLine2."Line No.",DimMgt.GetDimValuePostingErr);
    END;

    // Add the following line.
    LOCAL PROCEDURE BuildInvLineBuffer@1470020(LetterHeader@1470000 : Record 26585;DocumentType@1470005 : 'Invoice,Credit Memo';VAR PrepmtInvBuf@1470001 : Record 461;VAR TempDocDim@1470002 : Record 357;VATCurrFactor@1360000 : Decimal);
    // End of the added line.

    VAR
    LetterLine@1470003 : Record 26586;
    PrepmtInvBuf2@1470004 : Record 461;
    ...

    Existing code 2

    ...
    LetterLine.SETRANGE("Letter No.",LetterHeader."No.");
    IF LetterLine.FINDSET THEN
    REPEAT

    // Delete the following line.
    FillInvLineBuffer(LetterLine,DocumentType,LetterHeader."VAT Currency Factor",PrepmtInvBuf2,TempDocDim);
    // End of the deleted line.

    IF PrepmtInvBuf2.Amount <> 0 THEN
    PrepmtInvBuf.InsertInvLineBuffer(PrepmtInvBuf2);
    UNTIL LetterLine.NEXT = 0;
    ...

    Replacement code 2

    ...
    LetterLine.SETRANGE("Letter No.",LetterHeader."No.");
    IF LetterLine.FINDSET THEN
    REPEAT

    // Add the following line.
    FillInvLineBuffer(LetterLine,DocumentType,VATCurrFactor,PrepmtInvBuf2,TempDocDim);
    // End of the added line.

    IF PrepmtInvBuf2.Amount <> 0 THEN
    PrepmtInvBuf.InsertInvLineBuffer(PrepmtInvBuf2);
    UNTIL LetterLine.NEXT = 0;
    ...
  5. Add the functions in the codeunit (26585) as follows:

    ...
    LOCAL PROCEDURE GetPrepaymentCurrFactors@1470049(SalesOrderNo@1470000 : Code[20];VAR CurrFactor@1360001 : Decimal;VAR VATCurrFactor@1360002 : Decimal);
    VAR
    LetterHeader@1470001 : Record 26585;
    CustLedgEntry@1470002 : Record 21;
    AdvanceLink@1470003 : Record 26590;
    BEGIN
    CurrFactor := 0;
    VATCurrFactor := 0;

    WITH AdvanceLink DO BEGIN
    LetterHeader.SETRANGE("Order No.",SalesOrderNo);
    IF LetterHeader.FINDLAST THEN BEGIN
    SETCURRENTKEY("Document No.","Line No.","Entry Type");
    SETRANGE("Entry Type","Entry Type"::"Link To Letter");
    SETRANGE("Document No.",LetterHeader."No.");
    IF FINDLAST THEN
    IF CustLedgEntry.GET("CV Ledger Entry No.") THEN
    IF CustLedgEntry."Currency Code" <> '' THEN BEGIN
    CurrFactor := CustLedgEntry."Original Currency Factor";
    VATCurrFactor := CustLedgEntry."VAT Currency Factor";
    END;
    END;
    END;
    END;

    LOCAL PROCEDURE SetVATClause@1470058(SalesInvHeader@1470001 : Record 112;SalesInvLine@1470002 : Record 113);
    BEGIN
    WITH VATClauseBuffer DO
    IF GET(SalesInvLine."VAT Bus. Posting Group",SalesInvLine."VAT Prod. Posting Group") THEN BEGIN
    "VAT Base" +=
    CurrExchRate.ExchangeAmtFCYToLCY(SalesInvHeader."Posting Date",
    SalesInvHeader."Currency Code",
    PrepmtInvBuffer.Amount,
    SalesInvHeader."Currency Factor");
    "VAT Amount" +=
    (CurrExchRate.ExchangeAmtFCYToLCY(SalesInvHeader."Posting Date",
    SalesInvHeader."Currency Code",
    PrepmtInvBuffer."Amount Incl. VAT",
    SalesInvHeader."Currency Factor") -
    CurrExchRate.ExchangeAmtFCYToLCY(SalesInvHeader."Posting Date",
    SalesInvHeader."Currency Code",
    SalesInvLine.Amount,
    SalesInvHeader."Currency Factor"));
    MODIFY;
    END ELSE BEGIN
    "VAT Bus. Posting Group" := SalesInvLine."VAT Bus. Posting Group";
    "VAT Prod. Posting Group" := SalesInvLine."VAT Prod. Posting Group";
    "VAT Base" :=
    CurrExchRate.ExchangeAmtFCYToLCY(SalesInvHeader."Posting Date",
    SalesInvHeader."Currency Code",
    PrepmtInvBuffer.Amount,
    SalesInvHeader."Currency Factor");
    "VAT Amount" :=
    CurrExchRate.ExchangeAmtFCYToLCY(SalesInvHeader."Posting Date",
    SalesInvHeader."Currency Code",
    PrepmtInvBuffer."Amount Incl. VAT",
    SalesInvHeader."Currency Factor") -
    "VAT Base";
    INSERT;
    END;
    END;

    LOCAL PROCEDURE FinalizeVATClause@1470064(SalesInvHeader@1470002 : Record 112;SalesInvLine@1470003 : Record 113);
    VAR
    TransferExtText@1470000 : Codeunit 378;
    VATClauseSetup@1470001 : Record 26512;
    BEGIN
    IF VATClauseBuffer.FINDSET THEN
    REPEAT
    VATClauseSetup.SETRANGE("VAT Bus. Posting Group",VATClauseBuffer."VAT Bus. Posting Group");
    VATClauseSetup.SETRANGE("VAT Prod. Posting Group",VATClauseBuffer."VAT Prod. Posting Group");
    IF VATClauseSetup.FINDSET THEN
    REPEAT
    VATClauseSetup.TESTFIELD("Standard Text Code");
    TransferExtText.VATCheckIfAnyExtText(SalesInvHeader,VATClauseSetup."Standard Text Code");
    TransferExtText.InsertVATExtText(SalesInvLine,VATClauseBuffer);
    UNTIL VATClauseSetup.NEXT = 0;
    UNTIL VATClauseBuffer.NEXT = 0;
    END;
    ...

Prerequisites

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

  • The Hungarian version of Microsoft Dynamics NAV 2009 R2

In addition, you must have MSDNAV2009R2Prepaymts_Hungary and MSDYN_VATExchangeRateAdvancesHungarianNAV2009R2 installed.

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?

What affected your experience?

Thank you for your feedback!

×