Applies ToMicrosoft Dynamics NAV 2009 R2

This article applies to Microsoft Dynamics NAV for the Hungarian (hu) language locale.

Symptoms

Assume that you use the payment method with the Invoice Rounding Precision parameter set in the Hungarian version of Microsoft Dynamics NAV 2009 R2. Additionally, the rounding type is set to Nearest. In this situation, the rounding is incorrect and the final amount is incorrect.

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 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. Add a new PrepmtAmtToDeduct( PricesIncludingVAT: Boolean; PrepaymentPct: Decimal) : Decimal function in the Sales Line table (37). To do this, follow these steps:

    1. Add a local variable, and then specify the variable as follows:

      • Name: VATFactor

      • DataType: Decimal

    2. Add the code as follows:

      IF PricesIncludingVAT THENVATFactor := (1 + "VAT %" / 100)ELSEVATFactor := 1;EXIT(ROUND(ROUND(ROUND(ROUND("Unit Price" * "Qty. to Invoice",Currency."Amount Rounding Precision") *(1 - ("Line Discount %" / 100)),Currency."Amount Rounding Precision") *(PrepaymentPct / 100) / VATFactor,Currency."Amount Rounding Precision") * VATFactor,Currency."Amount Rounding Precision"));
  2. Change the CalcPrepaymentToDeduct function in the Sales Line table (37). To do this, follow these steps:

    1. Delete the following local variables:

      PrepmtPct: Decimal;AbsoluteAdvCorrection: Boolean;
    2. Add the following local variables:

      TotalPrepmtAmtToDeduct: Decimal;HundredPct: Decimal;
    3. Replace the code as follows:

      IF (Quantity - "Quantity Invoiced") <> 0 THEN BEGINTotalPrepmtAmtToDeduct := "Prepmt. Amt. Inv." - "Prepmt Amt Deducted";GetSalesHeader;IF SalesHeader."Prepayment Type" = SalesHeader."Prepayment Type"::Advance THEN BEGINVATPostingSetup.GET("VAT Bus. Posting Group","VAT Prod. Posting Group");CASE VATPostingSetup."Adv. Invoice Correction Type" OFVATPostingSetup."Adv. Invoice Correction Type"::Percentage:"Prepmt Amt to Deduct" :=ROUND("Qty. to Invoice" / (Quantity - "Quantity Invoiced") *TotalPrepmtAmtToDeduct,Currency."Amount Rounding Precision");VATPostingSetup."Adv. Invoice Correction Type"::Absolute:BEGINHundredPct := 100;"Prepmt Amt to Deduct" := PrepmtAmtToDeduct(SalesHeader."Prices Including VAT",HundredPct);IF "Prepmt Amt to Deduct" > TotalPrepmtAmtToDeduct THEN"Prepmt Amt to Deduct" := TotalPrepmtAmtToDeduct;END;VATPostingSetup."Adv. Invoice Correction Type"::"Fully Invoiced":IF "Qty. to Invoice" = Quantity - "Quantity Invoiced" THEN"Prepmt Amt to Deduct" := TotalPrepmtAmtToDeductELSE"Prepmt Amt to Deduct" := 0;END;END ELSE"Prepmt Amt to Deduct" := PrepmtAmtToDeduct(SalesHeader."Prices Including VAT","Prepayment %");END ELSE"Prepmt Amt to Deduct" := 0
  3. Add a new PrepmtAmtToDeduct( PricesIncludingVAT: Boolean; PrepaymentPct: Decimal) : Decimal function in the Purchase Line table (39). To do this, follow these steps:

    1. Add a local variable, and then specify the variable as follows:

      • Name: VATFactor

      • DataType: Decimal

    2. Add the code as follows:

      IF PricesIncludingVAT THENVATFactor := (1 + "VAT %" / 100)ELSEVATFactor := 1;EXIT(ROUND(ROUND(ROUND(ROUND("Unit Cost" * "Qty. to Invoice",Currency."Amount Rounding Precision") *(1 - ("Line Discount %" / 100)),Currency."Amount Rounding Precision") *(PrepaymentPct / 100) / VATFactor,Currency."Amount Rounding Precision") * VATFactor,Currency."Amount Rounding Precision"));
  4. Change the CalcPrepaymentToDeduct function in the Sales Line table (37). To do this, follow these steps:

    1. Delete the following local variables:

      PrepmtPct: Decimal;AbsoluteAdvCorrection: Boolean;
    2. Add the following local variables:

      TotalPrepmtAmtToDeduct: Decimal;HundredPct: Decimal;
    3. Replace the code as follows:

      IF (Quantity - "Quantity Invoiced") <> 0 THEN BEGINTotalPrepmtAmtToDeduct := "Prepmt. Amt. Inv." - "Prepmt Amt Deducted";GetPurchHeader;IF PurchHeader."Prepayment Type" = PurchHeader."Prepayment Type"::Advance THEN BEGINVATPostingSetup.GET("VAT Bus. Posting Group","VAT Prod. Posting Group");CASE VATPostingSetup."Adv. Invoice Correction Type" OFVATPostingSetup."Adv. Invoice Correction Type"::Percentage:"Prepmt Amt to Deduct" :=ROUND("Qty. to Invoice" / (Quantity - "Quantity Invoiced") *TotalPrepmtAmtToDeduct,Currency."Amount Rounding Precision");VATPostingSetup."Adv. Invoice Correction Type"::Absolute:BEGINHundredPct := 100;"Prepmt Amt to Deduct" := PrepmtAmtToDeduct(PurchHeader."Prices Including VAT",HundredPct);IF "Prepmt Amt to Deduct" > TotalPrepmtAmtToDeduct THEN"Prepmt Amt to Deduct" := TotalPrepmtAmtToDeduct;END;VATPostingSetup."Adv. Invoice Correction Type"::"Fully Invoiced":IF "Qty. to Invoice" = Quantity - "Quantity Invoiced" THEN"Prepmt Amt to Deduct" := TotalPrepmtAmtToDeductELSE"Prepmt Amt to Deduct" := 0;END;END ELSE"Prepmt Amt to Deduct" := PrepmtAmtToDeduct(PurchHeader."Prices Including VAT","Prepayment %");END ELSE"Prepmt Amt to Deduct" := 0
  5. Change the code in the InitInvoiceRoundingLine function in the Sales-Post Prepayments codeunit (442) as follows:Existing code

    ...IF SalesHeader."Currency Code" = '' THENCurrency.InitRoundingPrecisionELSECurrency.GET(SalesHeader."Currency Code");...

    Replacement code

    ...IF SalesHeader."Currency Code" = '' THEN BEGINCurrency.SetDocumentType(SalesHeader."Document Type");Currency.SetPaymentMethod(SalesHeader."Payment Method Code");Currency.InitRoundingPrecision;END ELSECurrency.GET(SalesHeader."Currency Code");...
  6. Change the code in the InsertLineRelation function in the Sales-Post Prepayments codeunit (442) as follows:Existing code

    ...IF SalesHeader."Currency Code" = '' THENCurrency.InitRoundingPrecisionELSECurrency.GET(SalesHeader."Currency Code");...

    Replacement code

    ...IF SalesHeader."Currency Code" = '' THEN BEGINCurrency.SetDocumentType(SalesHeader."Document Type");Currency.SetPaymentMethod(SalesHeader."Payment Method Code");Currency.InitRoundingPrecision;END ELSECurrency.GET(SalesHeader."Currency Code");...
  7. Change the code in the InsertInvoiceRounding function in the Sales-Post Prepayments codeunit (442) as follows:Existing code

    ..."G/L Account No." := SalesLine."No.";"Dimension Entry No." := InsertInDimBuffer(TempDocDim,SalesLine);...

    Replacement code

    ..."G/L Account No." := SalesLine."No.";// Add the following lineDescription := SalesLine.Description;"Dimension Entry No." := InsertInDimBuffer(TempDocDim,SalesLine);...
  8. Change the code in the InsertInvoiceRounding function in the Purchase-Post Prepayments codeunit (444) as follows:Existing code

    ..."G/L Account No." := PurchLine."No.";"Dimension Entry No." := InsertInDimBuffer(TempDocDim,PurchLine);...

    Replacement code

    ..."G/L Account No." := PurchLine."No.";// Add the following line.Description := PurchLine.Description;"Dimension Entry No." := InsertInDimBuffer(TempDocDim,PurchLine);...
  9. Change the code in the InitInvoiceRoundingLine function in the Purchase-Post Prepayments codeunit (444) as follows:Existing code

    ...IF PurchHeader."Currency Code" = '' THENCurrency.InitRoundingPrecisionELSECurrency.GET(PurchHeader."Currency Code");...

    Replacement code

    ...IF PurchHeader."Currency Code" = '' THEN BEGINCurrency.SetDocumentType(PurchHeader."Document Type");Currency.SetPaymentMethod(PurchHeader."Payment Method Code");Currency.InitRoundingPrecision;ENDELSECurrency.GET(PurchHeader."Currency Code");...
  10. Change the code in the InsertLineRelation function in the Purchase-Post Prepayments codeunit (444) as follows:Existing code

    ...IF PurchHeader."Currency Code" = '' THENCurrency.InitRoundingPrecisionELSECurrency.GET(PurchHeader."Currency Code");...

    Replacement code

    ...IF PurchHeader."Currency Code" = '' THEN BEGINCurrency.SetDocumentType(PurchHeader."Document Type");Currency.SetPaymentMethod(PurchHeader."Payment Method Code");Currency.InitRoundingPrecision;ENDELSECurrency.GET(PurchHeader."Currency Code");...
  11. Add a new LineRelationExists( LetterLine: Record 26586) : Boolean function in the Sales-Post Advances codeunit (26585). To do this, follow these steps:

    1. Add a local variable, and then specify the variable as follows:

      • Name: LineRelation

      • DataType: Record 26592

    2. Add the code as follows:

      WITH LineRelation DO BEGINSETRANGE(Type,Type::Sale);SETRANGE("Letter No.",LetterLine."Letter No.");SETRANGE("Letter Line No.",LetterLine."Line No.");EXIT(NOT ISEMPTY);END;
  12. Add a new UpdateAmountToApply( LetterLine: Record 26592; VAT LinkedAdvanceEntry: Record 21) function in the Sales-Post Advances codeunit (26585). To do this, follow these steps:

    1. Add a local variable, and then specify the variable as follows:

      • Name: Link

      • DataType: Record 26590

    2. Add a local variable, and then specify the variable as follows:

      • Name: CustLedgEntry

      • DataType: Record 21

    3. Add the code as follows:

      WITH Link DO BEGINSETRANGE("Entry Type","Entry Type"::"Link To Letter");SETRANGE("Document No.",LetterLine."Letter No.");SETRANGE("Line No.",LetterLine."Line No.");IF FINDSET THENREPEATIF CustLedgEntry.GET("CV Ledger Entry No.") THEN BEGINCustLedgEntry.CALCFIELDS("Remaining Amount");IF CustLedgEntry."Remaining Amount" <> -LinkedAdvanceEntry."Amount to Apply" THENIF LinkedAdvanceEntry.GET(CustLedgEntry."Entry No.") THEN BEGINLinkedAdvanceEntry."Amount to Apply" := LinkedAdvanceEntry."Amount to Apply" + Amount;LinkedAdvanceEntry.MODIFY;END ELSE BEGINLinkedAdvanceEntry := CustLedgEntry;LinkedAdvanceEntry."Amount to Apply" := Amount;LinkedAdvanceEntry."Currency Code" := "Currency Code";LinkedAdvanceEntry.INSERT;END;END;UNTIL NEXT = 0;END;
  13. Add a new AddRoundingLine( LetterLine: Record 26586; SalesInvHeader: Record 112; VAR LinkedAdvanceEntry: Record 21; LastLetterNo: Code [20]) : DeductedAmount: Decimal function in the Sales-Post Advances codeunit (26585) as follows:

    LetterLine.SETRANGE("Letter No.",LetterLine."Letter No.");LetterLine.SETFILTER("Line No.",'>%1',LetterLine."Line No.");LetterLine.SETFILTER("Amount To Deduct",'<>0');IF LetterLine.FINDSET(TRUE) THENREPEATIF NOT LineRelationExists(LetterLine) THEN BEGINDeductedAmount := DeductedAmount + LetterLine."Amount To Deduct";LetterLine."Amount Deducted" := LetterLine."Amount Deducted" + LetterLine."Amount To Deduct";LetterLine."Amount To Deduct" := 0;LetterLine.MODIFY(TRUE);UpdateAmountToApply(LetterLine,LinkedAdvanceEntry);AddPrepmtSalesInvLine(LetterLine,SalesInvHeader,LetterLine."Amount Deducted",LetterLine."VAT Amount",LastLetterNo);END;UNTIL LetterLine.NEXT = 0;
  14. Change the code in the PostInvoiceCorrection function in the Sales-Post Advances codeunit (26585) as follows:Existing code

    ...FullyDeducted := FullyDeductedCustPrepmt(SalesLine);// Delete the following lines.IF FullyDeducted THENDeductRndLetterLines(SalesHeader."No.");// End of thelines....

    Replacement code

    ...FullyDeducted := FullyDeductedCustPrepmt(SalesLine);...
  15. Change the code in the DeductRndLetterLines function in the Sales-Post Advances codeunit (26585) as follows:Existing code

    ...AddPrepmtSalesInvLine(LetterLine,SalesInvHeader,AmountToDeduct,VATAmount,LastLetterNo);END;UNTIL LineRelation.NEXT = 0;

    Replacement code

    ...AddPrepmtSalesInvLine(LetterLine,SalesInvHeader,AmountToDeduct,VATAmount,LastLetterNo);// Add the following lines.IF SalesLine."Prepmt Amt to Deduct" + SalesLine."Prepmt Amt Deducted" = SalesLine."Prepmt. Amt. Inv." THENInvoicedAmount := InvoicedAmount + AddRoundingLine(LetterLine,SalesInvHeader,LinkedAdvanceEntry,LastLetterNo);// End of the lines.END;UNTIL LineRelation.NEXT = 0;...
  16. Add a new LineRelationExists( LetterLine: Record 26588) function in the Purchase-Post Advances codeunit (26586). To do this, follow these steps:

    1. Add a local variable, and then specify the variable as follows:

      • Name: LineRelation

      • DataType: Record 26592

    2. Add the code as follows:

      WITH LineRelation DO BEGINSETRANGE(Type,Type::Purchase);SETRANGE("Letter No.",LetterLine."Letter No.");SETRANGE("Letter Line No.",LetterLine."Line No.");EXIT(NOT ISEMPTY);END;
  17. Add a new UpdateAmountToApply( LetterLine: Record 26588; VAR LinkedAdvanceEntry: Record 25) function in the Purchase-Post Advances codeunit (26586). To do this, follow these steps:

    1. Add a local variable, and then specify the variable as follows:

      • Name: LetterLine

      • DataType: Record 26588

    2. Add a local variable, and then specify the variable as follows:

      • Name: VendorLedgEntry

      • DataType: Record 25

    3. Add the code as follows:

      WITH Link DO BEGINSETRANGE("Entry Type","Entry Type"::"Link To Letter");SETRANGE("Document No.",LetterLine."Letter No.");SETRANGE("Line No.",LetterLine."Line No.");IF FINDSET THENREPEATIF VendorLedgEntry.GET("CV Ledger Entry No.") THEN BEGINVendorLedgEntry.CALCFIELDS("Remaining Amount");IF VendorLedgEntry."Remaining Amount" <> -LinkedAdvanceEntry."Amount to Apply" THENIF LinkedAdvanceEntry.GET(VendorLedgEntry."Entry No.") THEN BEGINLinkedAdvanceEntry."Amount to Apply" := LinkedAdvanceEntry."Amount to Apply" + Amount;LinkedAdvanceEntry.MODIFY;END ELSE BEGINLinkedAdvanceEntry := VendorLedgEntry;LinkedAdvanceEntry."Amount to Apply" := Amount;LinkedAdvanceEntry."Currency Code" := "Currency Code";LinkedAdvanceEntry.INSERT;END;END;UNTIL NEXT = 0;END;
  18. Add a new AddRoundingLine( LetterLine: Record 26588; PurchInvHeader: Record 122; VAR LinkedAdvanceEntry: Record 25; LastLetterNo: Code [20]) : DeductedAmount : Decimal function in the Purchase-Post Advances codeunit (26586) as follows:

    LetterLine.SETRANGE("Letter No.",LetterLine."Letter No.");LetterLine.SETFILTER("Line No.",'>%1',LetterLine."Line No.");LetterLine.SETFILTER("Amount To Deduct",'<>0');IF LetterLine.FINDSET(TRUE) THENREPEATIF NOT LineRelationExists(LetterLine) THEN BEGINDeductedAmount := DeductedAmount + LetterLine."Amount To Deduct";LetterLine."Amount Deducted" := LetterLine."Amount Deducted" + LetterLine."Amount To Deduct";LetterLine."Amount To Deduct" := 0;LetterLine.MODIFY(TRUE);UpdateAmountToApply(LetterLine,LinkedAdvanceEntry);AddPrepmtPurchInvLine(LetterLine,PurchInvHeader,LetterLine."Amount Deducted",LetterLine."VAT Amount",LastLetterNo);END;UNTIL LetterLine.NEXT = 0;
  19. Change the code in the PostInvoiceCorrection function in the Purchase-Post Advances codeunit (26586) as follows:Existing code

    ...FullyDeducted := FullyDeductedVendPrepmt(PurchLine);// Delete the following lines.IF FullyDeducted THENDeductRndLetterLines(PurchHeader."No.");// End of the lines.PurchLine.SETFILTER("Prepmt Amt to Deduct",'<>0');...

    Replacement code

    ...FullyDeducted := FullyDeductedVendPrepmt(PurchLine);PurchLine.SETFILTER("Prepmt Amt to Deduct",'<>0');...
  20. Delete the DeductRndLetterLines function in the Purchase-Post Advances codeunit (26586).

  21. Change the code in the PostInvLineCorrection function in the Purchase-Post Advances codeunit (26586) as follows:Existing code

    ...AddPrepmtPurchInvLine(LetterLine,PurchInvHeader,AmountToDeduct,VATAmount,LastLetterNo);END;UNTIL LineRelation.NEXT = 0;...

    Replacement code

    ...AddPrepmtPurchInvLine(LetterLine,PurchInvHeader,AmountToDeduct,VATAmount,LastLetterNo);// Add the following lines.IF PurchLine."Prepmt Amt to Deduct" + PurchLine."Prepmt Amt Deducted" = PurchLine."Prepmt. Amt. Inv." THENInvoicedAmount := InvoicedAmount + AddRoundingLine(LetterLine,PurchInvHeader,LinkedAdvanceEntry,LastLetterNo);// End of the lines.END;UNTIL LineRelation.NEXT = 0;...

Prerequisites

You must have the Hungarian version of Microsoft Dynamics NAV 2009 R2 installed to apply this hotfix.

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 Use for other considerations.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.