Applies ToDynamics NAV 2009

Symptoms

In the Spanish version of Microsoft Dynamics NAV 2009, assume that you have two different individual invoices (same customer or vendor or different one). Each of the two invoices uses only one line but different VAT% (one invoice 21% and the other 10% for example). You post these invoices by sending documents to Cartera (bills or invoices to Cartera) and add these two individual invoices into a bill group or payment order. If you settle only one of the lines individually, the payment is exported as "Z" in the 340 Declaration. However, when you settle both of the documents, the two payments are exported as "2", which is wrong, because the initial invoices were not type "C" (different lines with different VAT%), but individual ones (Normal Operation is set to "Blank"). 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 Properties in the Make 340 Declaration report (10743) as follows:Existing code

    ...IF FORM.RUNMODAL(10744,TempDeclarationLines) = ACTION::LookupOK THEN BEGIN                       TempDeclarationLines.SETRANGE("Operation Code",'R');                       TempDeclarationLines.SETRANGE("Property Location",TempDeclarationLines."Property Location"::" ");// Delete the following lines.// VSTf307397.beginTempDeclarationLines.SETRANGE(Type,TempDeclarationLines.Type::Sale);// VSTF307397.endIF NOT TempDeclarationLines.ISEMPTY THENEXIT;TempDeclarationLines.RESET;CreateFileHeader;WriteDeclarationLinesToText(TempDeclarationLines);END ELSEEXIT;// End of the deleted lines.                   END;                   WriteAppliedPaymentsToText;                   IF FileHeaderCreated THEN BEGIN...

    Replacement code

    ... IF FORM.RUNMODAL(10744,TempDeclarationLines) = ACTION::LookupOK THEN BEGIN                       TempDeclarationLines.SETRANGE("Operation Code",'R');                       TempDeclarationLines.SETRANGE("Property Location",TempDeclarationLines."Property Location"::" ");// Add the following lines.TempDeclarationLines.SETRANGE(Type,TempDeclarationLines.Type::Sale);IF NOT TempDeclarationLines.ISEMPTY THENEXIT;TempDeclarationLines.RESET;CreateFileHeader;WriteDeclarationLinesToText(TempDeclarationLines);END ELSEEXIT;// End of the added lines.                   END;                   WriteAppliedPaymentsToText;                   IF FileHeaderCreated THEN BEGIN...
  2. Change the code in the Make 340 Declaration report (10743) as follows:Existing code

    ... VATEntry."Document Type"::Refund:                                  BEGIN                                    IF VATEntry."Unrealized VAT Entry No." <> 0 THEN BEGIN// Delete the following lines.UnrealizedVATEntry.GET(VATEntry."Unrealized VAT Entry No.");VendorDocumentNo := FindAppliedToDocumentNo(UnrealizedVATEntry);// End of the deleted lines.                                    END;                                    EXIT;                                  END;...

    Replacement code

    ...VATEntry."Document Type"::Refund:                                  BEGIN                                    IF VATEntry."Unrealized VAT Entry No." <> 0 THEN BEGIN// Add the following lines.IF FindPmtOrderBillGrBankAcc(VATEntry.Type,VATEntry."Document No.") <> '' THENVendorDocumentNo := VATEntry."Document No."ELSE BEGINUnrealizedVATEntry.GET(VATEntry."Unrealized VAT Entry No.");VendorDocumentNo := FindAppliedToDocumentNo(UnrealizedVATEntry);END;// End of the added lines.                                    END;                                    EXIT;                                  END;...
  3. Change the code in CheckVATType function in the Make 340 Declaration report (10743) as follows:Existing code

    ...  IF VATEntries.FINDFIRST THEN        REPEAT          IF (VATEntries."VAT %" <> VATEntryRec."VAT %") OR// Delete the following lines.(VATEntries."EC %" <> VATEntryRec."EC %") THENEXIT(TRUE);// End of the deleted lines.        UNTIL VATEntries.NEXT = 0;    END;...

    Replacement code

    ... IF VATEntries.FINDFIRST THEN        REPEAT          IF (VATEntries."VAT %" <> VATEntryRec."VAT %") OR// Add the following lines.(VATEntries."EC %" <> VATEntryRec."EC %")THEN BEGINIF VATEntryRec."Unrealized VAT Entry No." <> 0 THENEXIT(CheckVATOnUnrealVATEntries(VATEntryRec));EXIT(TRUE);END;// End of the added lines.        UNTIL VATEntries.NEXT = 0;    END;...
  4. Change the code in CheckVATOnUnrealVATEntries function in the Make 340 Declaration report (10743) as follows:Existing code

    ...UNTIL VATEntries.NEXT = 0;    END;    PROCEDURE CalcECAmount@1100002(VATEntryRec@1100000 : Record 254;VAR VATBuffer3@1100001 : TEMPORARY Record 10704);    VAR      Currency@1100004 : Record 4;...

    Replacement code

    ...UNTIL VATEntries.NEXT = 0;    END;// Add the following lines.LOCAL PROCEDURE CheckVATOnUnrealVATEntries@1100044(VATEntryRec@1100000 : Record 254) : Boolean;VARUnrealVATEntry@1100001 : Record 254;BEGINUnrealVATEntry.GET(VATEntryRec."Unrealized VAT Entry No.");UnrealVATEntry.SETCURRENTKEY("Transaction No.");UnrealVATEntry.SETRANGE("Transaction No.",UnrealVATEntry."Transaction No.");IF UnrealVATEntry.FINDSET THENREPEATIF (UnrealVATEntry."VAT %" <> VATEntryRec."VAT %") OR(UnrealVATEntry."EC %" <> VATEntryRec."EC %")THENEXIT(TRUE);UNTIL UnrealVATEntry.NEXT = 0;EXIT(FALSE);END;// End of the added lines.PROCEDURE CalcECAmount@1100002(VATEntryRec@1100000 : Record 254;VAR VATBuffer3@1100001 : TEMPORARY Record 10704);    VAR      Currency@1100004 : Record 4;...
  5. Change the code in FindPmtOrderBillGrBankAcc function in the Make 340 Declaration report (10743) as follows:Existing code

    ...EXIT(FormatNumber(NoOfRegs,2));    END;    PROCEDURE RecordTypeSale@1100009();    VAR      UnrealizedVATEntry@1100001 : Record 254;...

    Replacement code

    ...EXIT(FormatNumber(NoOfRegs,2));    END;// Add the following lines.LOCAL PROCEDURE FindPmtOrderBillGrBankAcc@1100058(Type@1100005 : Option;DocumentNo@1100000 : Code[20]) : Code[20];VARClosedBillGroup@1100003 : Record 7000007;ClosedPmtOrder@1100002 : Record 7000022;PostedBillGroup@1100004 : Record 7000006;PostedPmtOrder@1100001 : Record 7000021;BEGINCASE Type OFVATEntry.Type::Sale:BEGINIF PostedBillGroup.GET(DocumentNo) THENEXIT(PostedBillGroup."Bank Account No.");IF ClosedBillGroup.GET(DocumentNo) THENEXIT(ClosedBillGroup."Bank Account No.");END;VATEntry.Type::Purchase:BEGINIF PostedPmtOrder.GET(DocumentNo) THENEXIT(PostedPmtOrder."Bank Account No.");IF ClosedPmtOrder.GET(DocumentNo) THENEXIT(ClosedPmtOrder."Bank Account No.");END;END;EXIT('');END;// End of the added lines.PROCEDURE RecordTypeSale@1100009();    VAR      UnrealizedVATEntry@1100001 : Record 254;...
  6. Change the code in RecordTypeSale function in the Make 340 Declaration report (10743) as follows:Existing code 1

    ...END ELSE          OperationDateText := FormatDate(VATEntry."Posting Date");      IF VATEntry."Document Type" IN [VATEntry."Document Type"::Payment,VATEntry."Document Type"::Refund] THEN BEGIN        UnrealizedVATEntryNo := VATEntry."Unrealized VAT Entry No.";        DocumentDate := VATEntry."Posting Date";...

    Replacement code 1

    ... END ELSE          OperationDateText := FormatDate(VATEntry."Posting Date");// Add the following lines.AppliedToDocumentNo := VATEntry."Document No.";UnrealizedVATEntryNo := 0;// End of the added lines.      IF VATEntry."Document Type" IN [VATEntry."Document Type"::Payment,VATEntry."Document Type"::Refund] THEN BEGIN        UnrealizedVATEntryNo := VATEntry."Unrealized VAT Entry No.";        DocumentDate := VATEntry."Posting Date";...

    Existing code 2

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

    Replacement code 2

    ...IF VATEntry."Document Type" IN [VATEntry."Document Type"::Payment,VATEntry."Document Type"::Refund] THEN BEGIN        UnrealizedVATEntryNo := VATEntry."Unrealized VAT Entry No.";        DocumentDate := VATEntry."Posting Date";// Add the following lines.IF (UnrealizedVATEntryNo <> 0) AND(FindPmtOrderBillGrBankAcc(VATEntry.Type,VATEntry."Document No.") = '')THEN BEGIN// End of the added lines.          UnrealizedVATEntry.GET(UnrealizedVATEntryNo);          AppliedToDocumentNo := FindAppliedToDocumentNo(UnrealizedVATEntry);          OperationDateText := FormatDate(UnrealizedVATEntry."Posting Date");...

    Existing code 3

    ... OperationDateText := FormatDate(UnrealizedVATEntry."Posting Date");          DocumentDate := UnrealizedVATEntry."Document Date";        END;// Delete the following lines.END ELSE BEGINAppliedToDocumentNo := VATEntry."Document No.";UnrealizedVATEntryNo := 0;// End of the deleted lines.      END;      CreateTempDeclarationLines(PADSTR(CustVATNumber,9,' '),Customer."No.",Customer.Name,DocumentDate,...

    Replacement code 3

    ...OperationDateText := FormatDate(UnrealizedVATEntry."Posting Date");          DocumentDate := UnrealizedVATEntry."Document Date";        END;      END;      CreateTempDeclarationLines(PADSTR(CustVATNumber,9,' '),Customer."No.",Customer.Name,DocumentDate,...
  7. Change the code in AddCollectionBankAcc function in the Make 340 Declaration report (10743) as follows:Existing code 1

    ...VATEntryForPmnt@1100008 : Record 254;      BankAccLE@1100002 : Record 271;      CheckLE@1100004 : Record 272;// Delete the following line.BankAcc@1100006 : Record 270;// End of the deleted line.      CollectionPaymentMethodUsed@1100005 : Text[1];      BankAccountOrPaymentMethodUsed@1100003 : Text[34];      InsertPosition@1100007 : Integer;...

    Replacement code 1

    ...VATEntryForPmnt@1100008 : Record 254;      BankAccLE@1100002 : Record 271;      CheckLE@1100004 : Record 272;// Add the following line.BankAccNo@1100009 : Code[20];// End of the added line.      CollectionPaymentMethodUsed@1100005 : Text[1];      BankAccountOrPaymentMethodUsed@1100003 : Text[34];      InsertPosition@1100007 : Integer;...

    Existing code 2

    ... IF CheckLE.FINDFIRST THEN BEGIN          BankAccountOrPaymentMethodUsed := CheckLE."Check No.";          CollectionPaymentMethodUsed := 'T';// Delete the following lines.END ELSEIF BankAccLE.GET(DeclarationLine."Bank Account Ledger Entry No.") THEN BEGINCollectionPaymentMethodUsed := 'C';BankAcc.GET(BankAccLE."Bank Account No.");BankAccountOrPaymentMethodUsed := BankAcc."CCC No.";IF BankAccountOrPaymentMethodUsed = '' THENBankAccountOrPaymentMethodUsed := BankAcc."Bank Account No.";IF BankAccountOrPaymentMethodUsed = '' THENBankAccountOrPaymentMethodUsed :=COPYSTR(BankAcc.IBAN,1,MAXSTRLEN(BankAccountOrPaymentMethodUsed));END;// End of the deleted lines.IF BankAccountOrPaymentMethodUsed = '' THEN BEGIN          CollectionPaymentMethodUsed := 'O';          IF DeclarationLine.Type = DeclarationLine.Type::Sale THEN...

    Replacement code 2

    ...IF CheckLE.FINDFIRST THEN BEGIN          BankAccountOrPaymentMethodUsed := CheckLE."Check No.";          CollectionPaymentMethodUsed := 'T';// Add the following lines.END ELSE BEGINIF BankAccLE.GET(DeclarationLine."Bank Account Ledger Entry No.") THENBankAccNo := BankAccLE."Bank Account No."ELSEBankAccNo := FindPmtOrderBillGrBankAcc(DeclarationLine.Type,DeclarationLine."Document No.");BankAccountOrPaymentMethodUsed := GetBankAccountUsed(BankAccNo);IF BankAccountOrPaymentMethodUsed <> '' THENCollectionPaymentMethodUsed := 'C';END;// End of the added lines.        IF BankAccountOrPaymentMethodUsed = '' THEN BEGIN          CollectionPaymentMethodUsed := 'O';          IF DeclarationLine.Type = DeclarationLine.Type::Sale THEN...
  8. Change the code in GetBankAccountUsed function in the Make 340 Declaration report (10743) as follows:Existing code

    ...  txt := InsertTextWithReplace(txt,BankAccountOrPaymentMethodUsed,InsertPosition);    END;    LOCAL PROCEDURE AreDatesInSamePeriod@1100035(Date1@1100000 : Date;Date2@1100001 : Date) : Boolean;    BEGIN      EXIT(CALCDATE('<CM>',Date1) = CALCDATE('<CM>',Date2));...

    Replacement code

    ...txt := InsertTextWithReplace(txt,BankAccountOrPaymentMethodUsed,InsertPosition);    END;// Add the following lines.LOCAL PROCEDURE GetBankAccountUsed@1100059(BankAccNo@1100001 : Code[20]) BankAccountUsed : Text[34];VARBankAccount@1100000 : Record 270;BEGINWITH BankAccount DOIF GET(BankAccNo) THEN BEGINBankAccountUsed := "CCC No.";IF BankAccountUsed = '' THENBankAccountUsed := "Bank Account No.";IF BankAccountUsed = '' THENBankAccountUsed := COPYSTR(IBAN,1,MAXSTRLEN(BankAccountUsed));END;END;// End of the added lines.LOCAL PROCEDURE AreDatesInSamePeriod@1100035(Date1@1100000 : Date;Date2@1100001 : Date) : Boolean;    BEGIN      EXIT(CALCDATE('<CM>',Date1) = CALCDATE('<CM>',Date2));...

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?

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.