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:-
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.begin TempDeclarationLines.SETRANGE(Type,TempDeclarationLines.Type::Sale); // VSTF307397.end IF NOT TempDeclarationLines.ISEMPTY THEN EXIT; TempDeclarationLines.RESET; CreateFileHeader; WriteDeclarationLinesToText(TempDeclarationLines); END ELSE EXIT; // 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 THEN EXIT; TempDeclarationLines.RESET; CreateFileHeader; WriteDeclarationLinesToText(TempDeclarationLines); END ELSE EXIT; // End of the added lines. END; WriteAppliedPaymentsToText; IF FileHeaderCreated THEN BEGIN ... -
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.") <> '' THEN VendorDocumentNo := VATEntry."Document No." ELSE BEGIN UnrealizedVATEntry.GET(VATEntry."Unrealized VAT Entry No."); VendorDocumentNo := FindAppliedToDocumentNo(UnrealizedVATEntry); END; // End of the added lines. END; EXIT; END; ... -
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 %") THEN EXIT(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 BEGIN IF VATEntryRec."Unrealized VAT Entry No." <> 0 THEN EXIT(CheckVATOnUnrealVATEntries(VATEntryRec)); EXIT(TRUE); END; // End of the added lines. UNTIL VATEntries.NEXT = 0; END; ... -
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; VAR UnrealVATEntry@1100001 : Record 254; BEGIN UnrealVATEntry.GET(VATEntryRec."Unrealized VAT Entry No."); UnrealVATEntry.SETCURRENTKEY("Transaction No."); UnrealVATEntry.SETRANGE("Transaction No.",UnrealVATEntry."Transaction No."); IF UnrealVATEntry.FINDSET THEN REPEAT IF (UnrealVATEntry."VAT %" <> VATEntryRec."VAT %") OR (UnrealVATEntry."EC %" <> VATEntryRec."EC %") THEN EXIT(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; ... -
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]; VAR ClosedBillGroup@1100003 : Record 7000007; ClosedPmtOrder@1100002 : Record 7000022; PostedBillGroup@1100004 : Record 7000006; PostedPmtOrder@1100001 : Record 7000021; BEGIN CASE Type OF VATEntry.Type::Sale: BEGIN IF PostedBillGroup.GET(DocumentNo) THEN EXIT(PostedBillGroup."Bank Account No."); IF ClosedBillGroup.GET(DocumentNo) THEN EXIT(ClosedBillGroup."Bank Account No."); END; VATEntry.Type::Purchase: BEGIN IF PostedPmtOrder.GET(DocumentNo) THEN EXIT(PostedPmtOrder."Bank Account No."); IF ClosedPmtOrder.GET(DocumentNo) THEN EXIT(ClosedPmtOrder."Bank Account No."); END; END; EXIT(''); END; // End of the added lines. PROCEDURE RecordTypeSale@1100009(); VAR UnrealizedVATEntry@1100001 : Record 254; ... -
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 BEGIN AppliedToDocumentNo := 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, ... -
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 ELSE IF BankAccLE.GET(DeclarationLine."Bank Account Ledger Entry No.") THEN BEGIN CollectionPaymentMethodUsed := 'C'; BankAcc.GET(BankAccLE."Bank Account No."); BankAccountOrPaymentMethodUsed := BankAcc."CCC No."; IF BankAccountOrPaymentMethodUsed = '' THEN BankAccountOrPaymentMethodUsed := BankAcc."Bank Account No."; IF BankAccountOrPaymentMethodUsed = '' THEN BankAccountOrPaymentMethodUsed := 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 BEGIN IF BankAccLE.GET(DeclarationLine."Bank Account Ledger Entry No.") THEN BankAccNo := BankAccLE."Bank Account No." ELSE BankAccNo := FindPmtOrderBillGrBankAcc(DeclarationLine.Type,DeclarationLine."Document No."); BankAccountOrPaymentMethodUsed := GetBankAccountUsed(BankAccNo); IF BankAccountOrPaymentMethodUsed <> '' THEN CollectionPaymentMethodUsed := 'C'; END; // End of the added lines. IF BankAccountOrPaymentMethodUsed = '' THEN BEGIN CollectionPaymentMethodUsed := 'O'; IF DeclarationLine.Type = DeclarationLine.Type::Sale THEN ... -
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]; VAR BankAccount@1100000 : Record 270; BEGIN WITH BankAccount DO IF GET(BankAccNo) THEN BEGIN BankAccountUsed := "CCC No."; IF BankAccountUsed = '' THEN BankAccountUsed := "Bank Account No."; IF BankAccountUsed = '' THEN BankAccountUsed := 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.