Symptoms

The bases and amounts are incorrectly grouped for the same VAT percentage and period in the 340 Declaration with VAT cash involved in the Spanish version of Microsoft Dynamics NAV 2009.
The same scenario with normal VAT works as expected, separating each invoice regardless of whether they have the same VAT percentage. Follow the steps in theĀ code changes section to solve this issue. This problem occurs in the following products:

  • The Spanish version of Microsoft Dynamics NAV 2009 R2

  • The Spanish version of 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 Make 340 Declaration report (10743) as follows:
    Existing code 1

    ...   
    END;
    END;

    // Delete the following line.
    OnAfterGetRecord=BEGIN
    // End of the deleted line.

    OperationCode := GetOperationCode(VATEntry2);

    VATBuffer."VAT %" := "VAT %";
    ...

    Replacement code 1

    ... 
    END;
    END;

    // Add the following lines.
    OnAfterGetRecord=VAR
    VendLedgEntryAppl@1100000 : Record 25;
    NewEntry@1100001 : Boolean;
    BEGIN
    // End of the added lines.

    OperationCode := GetOperationCode(VATEntry2);

    VATBuffer."VAT %" := "VAT %";
    ...

    Existing code 2

    ... 
    VATBuffer.Amount := Amount;
    END;
    VATBuffer.INSERT;

    // Delete the following lines.

    IF Type = VATEntry.Type::Purchase THEN BEGIN
    VATEntryTemporary := VATEntry2;
    VATEntryTemporary.INSERT;
    END;
    END;
    // End of the deleted lines.

    END;

    TotalFields=Base,Amount;
    ...

    Replacement code 2

    ...
    VATBuffer.Amount := Amount;
    END;
    VATBuffer.INSERT;

    // Add the following lines.
    END;

    IF Type = VATEntry.Type::Purchase THEN
    IF HasBeenRealized("Entry No.") OR ("Unrealized VAT Entry No." <> 0) THEN BEGIN
    NewEntry := CheckVLEApplication(VATEntry2);

    VATEntryTemporary.SETRANGE("Posting Date","Posting Date");
    VATEntryTemporary.SETRANGE("Document No.","Document No.");
    VATEntryTemporary.SETRANGE("Document Type","Document Type");
    VATEntryTemporary.SETRANGE(Type,Type);
    VATEntryTemporary.SETRANGE("VAT %","VAT %");
    VATEntryTemporary.SETRANGE("Transaction No.","Transaction No.");
    IF VATEntryTemporary.FINDFIRST AND NOT NewEntry THEN BEGIN
    VATEntryTemporary.Base += Base;
    VATEntryTemporary.Amount += Amount;
    VATEntryTemporary.MODIFY;
    END ELSE BEGIN
    VATEntryTemporary := VATEntry2;
    VATEntryTemporary.INSERT;
    END;

    END ELSE BEGIN
    VATEntryTemporary := VATEntry2;
    VATEntryTemporary.INSERT;
    END;
    // End of the added lines.

    END;

    TotalFields=Base,Amount;
    ...

    Existing code 3

    ...  
    DataItemVarName=<Integer2>;
    OnPreDataItem=BEGIN
    VATBuffer.FIND('-');
    VATEntryTemporary.SETCURRENTKEY("VAT %","EC %");
    IF VATEntryTemporary.FINDFIRST THEN;
    CurrReport.CREATETOTALS(VATBuffer2.Base,VATBuffer2.Amount);
    Fin := FALSE;
    ...

    Replacement code 3

    ...  
    DataItemVarName=<Integer2>;
    OnPreDataItem=BEGIN
    VATBuffer.FIND('-');

    // Delete the following line.
    VATEntryTemporary.SETCURRENTKEY("VAT %","EC %");
    // End of the deleted line.

    IF VATEntryTemporary.FINDFIRST THEN;
    CurrReport.CREATETOTALS(VATBuffer2.Base,VATBuffer2.Amount);
    Fin := FALSE;
    ...

    Existing code 4

    ...
    IF VATEntry.Type = VATEntry.Type::Purchase THEN BEGIN
    VATEntryTemporary.Amount := VATBuffer.Amount;
    VATDeductAmt := CheckDeductibleVAT(VATEntryTemporary);

    // Delete the following lines.
    VATEntryTemporary.NEXT;
    RecordTypePurchase(VATEntry2);
    // End of the deleted lines.

    END;
    Fin := VATBuffer.NEXT = 0;
    END;
    ...

    Replacement code 4

    ...
    IF VATEntry.Type = VATEntry.Type::Purchase THEN BEGIN
    VATEntryTemporary.Amount := VATBuffer.Amount;
    VATDeductAmt := CheckDeductibleVAT(VATEntryTemporary);

    // Add the following lines.

    VATEntryTemporary.SETCURRENTKEY("VAT %","EC %");
    VATEntryTemporary.SETRANGE("VAT %",VATBuffer."VAT %");
    VATEntryTemporary.SETRANGE("EC %",VATBuffer."EC %");
    VATEntryTemporary.FINDSET;
    REPEAT
    RecordTypePurchase(VATEntryTemporary);
    UNTIL VATEntryTemporary.NEXT = 0;
    // End of the added lines.

    END;
    Fin := VATBuffer.NEXT = 0;
    END;
    ...
  2. Change the code in Global Variables in the Make 340 Declaration report (10743) as follows:
    Existing code

    ...
    VATEntryTemporary@1100078 : TEMPORARY Record 254;
    TempDeclarationLines@1100149 : TEMPORARY Record 10744;
    TempVATEntry@1100007 : TEMPORARY Record 254;
    CommonDialogMgt@1100015 : Codeunit 412;
    OutFile@1100016 : File;
    DeclarationNum@1100017 : Text[4];
    ...

    Replacement code

    ...  
    VATEntryTemporary@1100078 : TEMPORARY Record 254;
    TempDeclarationLines@1100149 : TEMPORARY Record 10744;
    TempVATEntry@1100007 : TEMPORARY Record 254;

    // Add the following line.
    TempDtldVendLedgerEntry@1100115 : TEMPORARY Record 380;
    // End of the added line.

    CommonDialogMgt@1100015 : Codeunit 412;
    OutFile@1100016 : File;
    DeclarationNum@1100017 : Text[4];
    ...
  3. Change the code in RecordTypePurchase function in the Make 340 Declaration report (10743) as follows:
    Existing code

    ...
    END ELSE
    OperationDateText := FormatDate(VATEntryRec."Posting Date");

    // Delete the following lines.
    IF VATEntryRec."Document Type" IN [VATEntryRec."Document Type"::Payment,VATEntryRec."Document Type"::Refund] THEN BEGIN
    UnrealizedVATEntryNo := VATEntryRec."Unrealized VAT Entry No.";
    DocumentDate := VATEntryRec."Posting Date";
    IF UnrealizedVATEntryNo <> 0 THEN BEGIN
    UnrealizedVATEntry.GET(UnrealizedVATEntryNo);
    OperationDateText := FormatDate(UnrealizedVATEntry."Posting Date");
    DocumentDate := UnrealizedVATEntry."Document Date";
    // End of the deleted lines.

    END;
    END ELSE
    UnrealizedVATEntryNo := 0;
    ...

    Replacement code

    ...
    END ELSE
    OperationDateText := FormatDate(VATEntryRec."Posting Date");

    // Add the following lines.
    VATBuffer2.Base := VATBuffer.Base;
    VATBuffer2.Amount := VATBuffer.Amount;

    IF VATEntryRec."Document Type" IN [VATEntryRec."Document Type"::Payment,VATEntryRec."Document Type"::Refund] THEN BEGIN
    UnrealizedVATEntryNo := VATEntryTemporary."Unrealized VAT Entry No.";
    DocumentDate := VATEntryTemporary."Posting Date";
    IF UnrealizedVATEntryNo <> 0 THEN BEGIN
    UnrealizedVATEntry.GET(UnrealizedVATEntryNo);
    OperationDateText := FormatDate(UnrealizedVATEntry."Posting Date");
    DocumentDate := UnrealizedVATEntry."Document Date";
    IF FindPmtOrderBillGrBankAcc(VATEntry.Type,VATEntry."Document No.") = '' THEN BEGIN
    VendorDocumentNo := UnrealizedVATEntry."External Document No.";
    VATBuffer2.Base := VATEntryTemporary.Base;
    VATBuffer2.Amount := VATEntryTemporary.Amount;
    END;
    // End of the added lines.

    END;
    END ELSE
    UnrealizedVATEntryNo := 0;
    ...
  4. Change the code in CheckVLEApplication function in the Make 340 Declaration report (10743) as follows:
    Existing code

    ...
    PrevDeclarationNumEnable := ReplaceDeclaration;
    END;

    BEGIN
    END.
    }
    ...

    Replacement code

    ...
    PrevDeclarationNumEnable := ReplaceDeclaration;
    END;

    // Add the following lines.
    LOCAL PROCEDURE CheckVLEApplication@1100074(VATEntry@1100000 : Record 254) : Boolean;
    VAR
    VendorLedgerEntry@1100001 : Record 25;
    DtldVendLedgEntry@1100002 : Record 380;
    CheckVendLedgEntry@1100003 : Record 25;
    UnrealizedVendLedgEntry@1100004 : Integer;
    BEGIN
    FilterVendLedgerEntryByVATEntry(VendorLedgerEntry,VATEntry);
    UnrealizedVendLedgEntry := GetUnrealizedInvoiceVLENo(VATEntry."Unrealized VAT Entry No.");

    IF VendorLedgerEntry.FINDSET THEN
    REPEAT
    DtldVendLedgEntry.RESET;
    DtldVendLedgEntry.SETRANGE(Unapplied,FALSE);
    DtldVendLedgEntry.SETRANGE("Entry Type",DtldVendLedgEntry."Entry Type"::Application);
    DtldVendLedgEntry.SETRANGE("Applied Vend. Ledger Entry No.",VendorLedgerEntry."Entry No.");
    IF UnrealizedVendLedgEntry <> 0 THEN
    DtldVendLedgEntry.SETRANGE("Vendor Ledger Entry No.",UnrealizedVendLedgEntry);

    IF DtldVendLedgEntry.FINDSET THEN
    REPEAT
    IF (DtldVendLedgEntry."Vendor Ledger Entry No." <> DtldVendLedgEntry."Applied Vend. Ledger Entry No.") AND
    CheckVendLedgEntry.GET(DtldVendLedgEntry."Vendor Ledger Entry No.")
    THEN BEGIN
    IF ExistDtldVLE(DtldVendLedgEntry."Vendor Ledger Entry No.",DtldVendLedgEntry."Applied Vend. Ledger Entry No.") THEN
    EXIT(FALSE);
    InsertTempDtldVLE(DtldVendLedgEntry."Vendor Ledger Entry No.",DtldVendLedgEntry."Applied Vend. Ledger Entry No.");
    EXIT(TRUE);
    END;
    UNTIL DtldVendLedgEntry.NEXT = 0
    ELSE BEGIN
    DtldVendLedgEntry.SETRANGE("Applied Vend. Ledger Entry No.");
    DtldVendLedgEntry.SETRANGE("Vendor Ledger Entry No.",VendorLedgerEntry."Entry No.");
    IF UnrealizedVendLedgEntry <> 0 THEN
    DtldVendLedgEntry.SETRANGE("Applied Vend. Ledger Entry No.",UnrealizedVendLedgEntry);

    IF DtldVendLedgEntry.FINDSET THEN
    REPEAT
    IF CheckVendLedgEntry.GET(DtldVendLedgEntry."Applied Vend. Ledger Entry No.") THEN BEGIN
    IF ExistDtldVLE(DtldVendLedgEntry."Applied Vend. Ledger Entry No.",DtldVendLedgEntry."Vendor Ledger Entry No.") THEN
    EXIT(FALSE);
    InsertTempDtldVLE(DtldVendLedgEntry."Applied Vend. Ledger Entry No.",DtldVendLedgEntry."Vendor Ledger Entry No.");
    EXIT(TRUE);
    END;
    UNTIL DtldVendLedgEntry.NEXT = 0;
    END;
    UNTIL VendorLedgerEntry.NEXT = 0;

    EXIT(TRUE);
    END;

    LOCAL PROCEDURE GetUnrealizedInvoiceVLENo@1100075(VATEntryNo@1100000 : Integer) : Integer;
    VAR
    VATEntry@1100002 : Record 254;
    VendLedgEntry@1100001 : Record 25;
    BEGIN
    IF NOT VATEntry.GET(VATEntryNo) THEN
    EXIT(0);
    FilterVendLedgerEntryByVATEntry(VendLedgEntry,VATEntry);
    IF VendLedgEntry.FINDFIRST THEN
    EXIT(VendLedgEntry."Entry No.");
    EXIT(0);
    END;

    LOCAL PROCEDURE FilterVendLedgerEntryByVATEntry@1100087(VAR VendLedgEntry@1100001 : Record 25;VATEntry@1100000 : Record 254);
    BEGIN
    VendLedgEntry.SETRANGE("Vendor No.",VATEntry."Bill-to/Pay-to No.");
    VendLedgEntry.SETRANGE("Posting Date",VATEntry."Posting Date");
    VendLedgEntry.SETRANGE("Document Type",VATEntry."Document Type");
    VendLedgEntry.SETRANGE("Document No.",VATEntry."Document No.");
    VendLedgEntry.SETRANGE("Transaction No.",VATEntry."Transaction No.");
    END;

    LOCAL PROCEDURE HasBeenRealized@1100064(VATEntryNo@1100000 : Integer) : Boolean;
    VAR
    UnrealizedVATEntry@1100001 : Record 254;
    BEGIN
    UnrealizedVATEntry.SETRANGE("Unrealized VAT Entry No.",VATEntryNo);
    EXIT(NOT UnrealizedVATEntry.ISEMPTY);
    END;

    LOCAL PROCEDURE ExistDtldVLE@1100195(VLENo@1100001 : Integer;AppliedVLENo@1100000 : Integer) : Boolean;
    BEGIN
    TempDtldVendLedgerEntry.SETRANGE("Vendor Ledger Entry No.",VLENo);
    TempDtldVendLedgerEntry.SETRANGE("Applied Vend. Ledger Entry No.",AppliedVLENo);
    EXIT(NOT TempDtldVendLedgerEntry.ISEMPTY);
    END;

    LOCAL PROCEDURE InsertTempDtldVLE@1100191(VLENo@1100000 : Integer;AppliedVLENo@1100001 : Integer);
    BEGIN
    TempDtldVendLedgerEntry.INIT;
    IF TempDtldVendLedgerEntry.FINDLAST THEN;
    TempDtldVendLedgerEntry."Entry No." += 1;
    TempDtldVendLedgerEntry."Vendor Ledger Entry No." := VLENo;
    TempDtldVendLedgerEntry."Applied Vend. Ledger Entry No." := AppliedVLENo;
    TempDtldVendLedgerEntry.INSERT;
    END;

    // End of the added lines.

    BEGIN
    END.
    }
    ...

Prerequisites

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

  • The Spanish version of Microsoft Dynamics NAV 2009 R2

  • The Spanish version of 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.

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!

×