Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

Symptoms

After you install KB3034441 in the Spanish version of Microsoft Dynamics NAV 2009, when you apply a normal payment and a bill from customer or vendor ledger entries, the posted G/L entries refer both to the same account, which is incorrect. 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 PostDtldCustLedgEntries function in the Gen. Jnl.-Post Line codeunit (12) as follows:
    Existing code 1

    ...
    LOCAL PROCEDURE PostDtldCustLedgEntries@46(GenJnlLine2@1000 : Record 81;VAR DtldCVLedgEntryBuf@1001 : Record 383;CustPostingGr@1002 : Record 92;GLSetup@1003 : Record 98;NextTransactionNo@1004 : Integer;CustLedgEntryInserted@1012 : Boolean);
    VAR
    DtldCustLedgEntry@1005 : Record 379;
    Currency@1007 : Record 4;
    GenPostingSetup@1008 : Record 252;
    TotalAmountLCY@1009 : Decimal;
    TotalAmountAddCurr@1010 : Decimal;
    PaymentDiscAcc@1011 : Code[20];
    DtldCustLedgEntryNoOffset@1006 : Integer;
    PaymentTolAcc@1013 : Code[20];
    ...

    Replacement code 1

    ...
    LOCAL PROCEDURE PostDtldCustLedgEntries@46(GenJnlLine2@1000 : Record 81;VAR DtldCVLedgEntryBuf@1001 : Record 383;CustPostingGr@1002 : Record 92;GLSetup@1003 : Record 98;NextTransactionNo@1004 : Integer;CustLedgEntryInserted@1012 : Boolean);
    VAR
    DtldCustLedgEntry@1005 : Record 379;
    Currency@1007 : Record 4;
    GenPostingSetup@1008 : Record 252;

    // Add the following line.
    DtldCustLedgEntry3@1100044 : Record 379;
    // End of the added line.

    TotalAmountLCY@1009 : Decimal;
    TotalAmountAddCurr@1010 : Decimal;
    PaymentDiscAcc@1011 : Code[20];
    DtldCustLedgEntryNoOffset@1006 : Integer;
    PaymentTolAcc@1013 : Code[20];
    ...

    Existing code 2

    ...
    ReceivableAccAmtLCY@1100001 : Decimal;
    ReceivableAccAmtAddCurr@1100000 : Decimal;
    DtldCustLedgEntry2@1100003 : TEMPORARY Record 379;
    ExistDtldCVLedgEntryBuf@1000003 : Boolean;
    FindBill@1100004 : Boolean;
    BEGIN
    TotalAmountLCY := 0;
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    ...

    Replacement code 2

    ...
    ReceivableAccAmtLCY@1100001 : Decimal;
    ReceivableAccAmtAddCurr@1100000 : Decimal;
    DtldCustLedgEntry2@1100003 : TEMPORARY Record 379;
    ExistDtldCVLedgEntryBuf@1000003 : Boolean;
    FindBill@1100004 : Boolean;

    // Add the following line.
    EntryUnapplied@1100051 : Boolean;
    // End of the added line.

    BEGIN
    TotalAmountLCY := 0;
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    ...

    Existing code 3

    ...
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    NegativeLCYAppAmt := 0;
    NegativeACYAppAmt := 0;

    IF GenJnlLine2."Account Type" = GenJnlLine2."Account Type"::Customer THEN BEGIN
    IF DtldCustLedgEntry.FINDLAST THEN
    DtldCustLedgEntryNoOffset := DtldCustLedgEntry."Entry No."
    ELSE
    ...

    Replacement code 3

    ...
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    NegativeLCYAppAmt := 0;
    NegativeACYAppAmt := 0;

    // Add the following line.
    EntryUnapplied := FALSE;
    // End of the added line.

    IF GenJnlLine2."Account Type" = GenJnlLine2."Account Type"::Customer THEN BEGIN
    IF DtldCustLedgEntry.FINDLAST THEN
    DtldCustLedgEntryNoOffset := DtldCustLedgEntry."Entry No."
    ELSE
    ...

    Existing code 4

    ...
    END;
    InsertGLEntry(TRUE);
    GenJnlLine."Posting Date" := OriginalPostingDate;
    END;

    // Delete the following line.
    PostReceivableDocs(GenJnlLine);
    // End of the deleted line.

    IF NOT GLEntryTmp.FINDFIRST AND ExistDtldCVLedgEntryBuf THEN BEGIN
    InitGLEntry(CustPostingGr."Receivables Account",PositiveLCYAppAmt,PositiveACYAppAmt,FALSE,TRUE);
    InsertGLEntry(FALSE);
    InitGLEntry(CustPostingGr."Receivables Account",NegativeLCYAppAmt,NegativeACYAppAmt,FALSE,TRUE);
    ...

    Replacement code 4

    ...
    END;
    InsertGLEntry(TRUE);
    GenJnlLine."Posting Date" := OriginalPostingDate;
    END;

    // Add the following lines.
    WITH DtldCustLedgEntry3 DO BEGIN
    SETCURRENTKEY("Cust. Ledger Entry No.");
    SETRANGE("Cust. Ledger Entry No.",DtldCustLedgEntry."Cust. Ledger Entry No.");
    SETFILTER("Applies-to Bill No.",'<>%1','');
    SETRANGE(Unapplied,TRUE);
    EntryUnapplied := NOT ISEMPTY;
    END;

    PostReceivableDocs(EntryUnapplied);
    // End of the added lines.

    IF NOT GLEntryTmp.FINDFIRST AND ExistDtldCVLedgEntryBuf THEN BEGIN
    InitGLEntry(CustPostingGr."Receivables Account",PositiveLCYAppAmt,PositiveACYAppAmt,FALSE,TRUE);
    InsertGLEntry(FALSE);
    InitGLEntry(CustPostingGr."Receivables Account",NegativeLCYAppAmt,NegativeACYAppAmt,FALSE,TRUE);
    ...
  2. Change the code in PostDtldVendLedgEntries function in the Gen. Jnl.-Post Line codeunit (12) as follows:
    Existing code 1

    ...  
    PROCEDURE PostDtldVendLedgEntries@32(GenJnlLine2@1000 : Record 81;VAR DtldCVLedgEntryBuf@1001 : Record 383;VendPostingGr@1002 : Record 93;NextTransactionNo@1003 : Integer;VendLedgEntryInserted@1011 : Boolean);
    VAR
    DtldVendLedgEntry@1004 : Record 380;
    Currency@1006 : Record 4;
    GenPostingSetup@1007 : Record 252;
    TotalAmountLCY@1008 : Decimal;
    TotalAmountAddCurr@1009 : Decimal;
    PaymentDiscAcc@1010 : Code[20];
    DtldVendLedgEntryNoOffset@1005 : Integer;
    PaymentTolAcc@1012 : Code[20];
    ...

    Replacement code 1

    ...
    PROCEDURE PostDtldVendLedgEntries@32(GenJnlLine2@1000 : Record 81;VAR DtldCVLedgEntryBuf@1001 : Record 383;VendPostingGr@1002 : Record 93;NextTransactionNo@1003 : Integer;VendLedgEntryInserted@1011 : Boolean);
    VAR
    DtldVendLedgEntry@1004 : Record 380;
    Currency@1006 : Record 4;
    GenPostingSetup@1007 : Record 252;

    // Add the following line.
    DtldVendLedgEntry3@1100055 : Record 380;
    // End of the added line.

    TotalAmountLCY@1008 : Decimal;
    TotalAmountAddCurr@1009 : Decimal;
    PaymentDiscAcc@1010 : Code[20];
    DtldVendLedgEntryNoOffset@1005 : Integer;
    PaymentTolAcc@1012 : Code[20];
    ...

    Existing code 2

    ...
    PayableAccAmtLCY@1100002 : Decimal;
    PayableAccAmtAddCurr@1100010 : Decimal;
    DtldVendLedgEntry2@1100003 : Record 380;
    ExistDtldCVLedgEntryBuf@1100004 : Boolean;
    FindBill@1100005 : Boolean;
    BEGIN
    TotalAmountLCY := 0;
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    ...

    Replacement code 2

    ...
    PayableAccAmtLCY@1100002 : Decimal;
    PayableAccAmtAddCurr@1100010 : Decimal;
    DtldVendLedgEntry2@1100003 : Record 380;
    ExistDtldCVLedgEntryBuf@1100004 : Boolean;
    FindBill@1100005 : Boolean;

    // Add the following line.
    EntryUnapplied@1100051 : Boolean;
    // End of the added line.

    BEGIN
    TotalAmountLCY := 0;
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    ...

    Existing code 3

    ...
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    NegativeLCYAppAmt := 0;
    NegativeACYAppAmt := 0;

    IF GenJnlLine2."Account Type" = GenJnlLine2."Account Type"::Vendor THEN BEGIN
    IF DtldVendLedgEntry.FINDLAST THEN
    DtldVendLedgEntryNoOffset := DtldVendLedgEntry."Entry No."
    ELSE
    ...

    Replacement code 3

    ...
    TotalAmountAddCurr := 0;
    PositiveLCYAppAmt := 0;
    PositiveACYAppAmt := 0;
    NegativeLCYAppAmt := 0;
    NegativeACYAppAmt := 0;

    // Add the following line.
    EntryUnapplied := FALSE;
    // End of the added line.

    IF GenJnlLine2."Account Type" = GenJnlLine2."Account Type"::Vendor THEN BEGIN
    IF DtldVendLedgEntry.FINDLAST THEN
    DtldVendLedgEntryNoOffset := DtldVendLedgEntry."Entry No."
    ELSE
    ...

    Existing code 4

    ...
    END;
    InsertGLEntry(TRUE);
    GenJnlLine."Posting Date" := OriginalPostingDate;
    END;

    // Delete the following line.
    PostPayableDocs(GenJnlLine);
    // End of the deleted line.

    IF NOT GLEntryTmp.FINDFIRST AND ExistDtldCVLedgEntryBuf THEN BEGIN
    InitGLEntry(VendPostingGr."Payables Account",PositiveLCYAppAmt,PositiveACYAppAmt,FALSE,TRUE);
    InsertGLEntry(FALSE);
    InitGLEntry(VendPostingGr."Payables Account",NegativeLCYAppAmt,NegativeACYAppAmt,FALSE,TRUE);
    ...

    Replacement code 4

    ...
    END;
    InsertGLEntry(TRUE);
    GenJnlLine."Posting Date" := OriginalPostingDate;
    END;

    // Add the following lines.
    WITH DtldVendLedgEntry3 DO BEGIN
    SETCURRENTKEY("Vendor Ledger Entry No.");
    SETRANGE("Vendor Ledger Entry No.",DtldVendLedgEntry."Vendor Ledger Entry No.");
    SETFILTER("Applies-to Bill No.",'<>%1','');
    SETRANGE(Unapplied,TRUE);
    EntryUnapplied := NOT ISEMPTY;
    END;

    PostPayableDocs(EntryUnapplied);
    // End of the added lines.

    IF NOT GLEntryTmp.FINDFIRST AND ExistDtldCVLedgEntryBuf THEN BEGIN
    InitGLEntry(VendPostingGr."Payables Account",PositiveLCYAppAmt,PositiveACYAppAmt,FALSE,TRUE);
    InsertGLEntry(FALSE);
    InitGLEntry(VendPostingGr."Payables Account",NegativeLCYAppAmt,NegativeACYAppAmt,FALSE,TRUE);
    ...
  3. Change the code in PostPayableDocs function in the Gen. Jnl.-Post Line codeunit (12) as follows:
    Existing code 1

    ...
    ELSE
    VATEntry."Bill-to/Pay-to No." := GenJnlLine2."Account No.";
    END;
    END;

    // Delete the following line.
    LOCAL PROCEDURE PostPayableDocs@1100009(VAR GenJnlLine@1100000 : Record 81);
    // End of the deleted line.

    BEGIN
    IF (DocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    IF DocAmountLCY <> 0 THEN BEGIN
    ...

    Replacement code 1

    ...
    ELSE
    VATEntry."Bill-to/Pay-to No." := GenJnlLine2."Account No.";
    END;
    END;

    // Add the following line.
    LOCAL PROCEDURE PostPayableDocs@1100009(EntryUnapplied@1100001 : Boolean);
    // End of the added line.

    BEGIN
    IF (DocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    IF DocAmountLCY <> 0 THEN BEGIN
    ...

    Existing code 2

    ...
    BEGIN
    IF (DocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    IF DocAmountLCY <> 0 THEN BEGIN

    // Delete the following lines.
    // VSTF330588.begin
    //IF (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::Invoice) THEN BEGIN
    IF (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::Invoice) OR
    (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::" ")
    THEN BEGIN
    // VSTF330588.end
    // End of the deleted lines.

    VendPostingGr.TESTFIELD("Payables Account");
    InitGLEntry(VendPostingGr."Payables Account",DocAmountLCY,DocAmtCalcAddCurrency(DocAmountLCY),TRUE,TRUE);
    GLEntry."Bal. Account Type" := GenJnlLine."Bal. Account Type";
    GLEntry."Bal. Account No." := GenJnlLine."Bal. Account No.";
    InsertGLEntry(TRUE);
    ...

    Replacement code 2

    ...
    BEGIN
    IF (DocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    IF DocAmountLCY <> 0 THEN BEGIN

    // Add the following lines.
    IF (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::Invoice) OR
    EntryUnapplied
    THEN BEGIN
    // End of the added lines.

    VendPostingGr.TESTFIELD("Payables Account");
    InitGLEntry(VendPostingGr."Payables Account",DocAmountLCY,DocAmtCalcAddCurrency(DocAmountLCY),TRUE,TRUE);
    GLEntry."Bal. Account Type" := GenJnlLine."Bal. Account Type";
    GLEntry."Bal. Account No." := GenJnlLine."Bal. Account No.";
    InsertGLEntry(TRUE);
    ...
  4. Change the code in PostReceivableDocs function in the Gen. Jnl.-Post Line codeunit (12) as follows:
    Existing code 1

    ...
    GLEntry."Bal. Account No." := GenJnlLine."Bal. Account No.";
    InsertGLEntry(TRUE);
    END;
    END;

    // Delete the following line.
    LOCAL PROCEDURE PostReceivableDocs@1100003(VAR GenJnlLine@1100000 : Record 81);
    // End of the deleted line.

    BEGIN
    IF (DocAmountLCY <> 0) OR (DiscDocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) OR (RejDocAmountLCY <> 0) OR
    (DiscRiskFactAmountLCY <> 0) OR (DiscUnriskFactAmountLCY <> 0) OR (CollFactAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    ...

    Replacement code 1

    ...
    GLEntry."Bal. Account No." := GenJnlLine."Bal. Account No.";
    InsertGLEntry(TRUE);
    END;
    END;

    // Add the following line.
    LOCAL PROCEDURE PostReceivableDocs@1100003(EntryUnapplied@1100001 : Boolean);
    // End of the added line.

    BEGIN
    IF (DocAmountLCY <> 0) OR (DiscDocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) OR (RejDocAmountLCY <> 0) OR
    (DiscRiskFactAmountLCY <> 0) OR (DiscUnriskFactAmountLCY <> 0) OR (CollFactAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    ...

    Existing code 2

    ...
    IF (DocAmountLCY <> 0) OR (DiscDocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) OR (RejDocAmountLCY <> 0) OR
    (DiscRiskFactAmountLCY <> 0) OR (DiscUnriskFactAmountLCY <> 0) OR (CollFactAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    IF DocAmountLCY <> 0 THEN BEGIN

    // Delete the following lines.
    // VSTF330588.begin
    //IF (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::Invoice) THEN BEGIN
    IF (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::Invoice) OR
    (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::" ")
    THEN BEGIN
    // VSTF330588.end
    // End of the deleted lines.

    CustPostingGr.TESTFIELD("Receivables Account");
    InitGLEntry(CustPostingGr."Receivables Account",DocAmountLCY,DocAmtCalcAddCurrency(DocAmountLCY),TRUE,TRUE);
    GLEntry."Bal. Account Type" := GenJnlLine."Bal. Account Type";
    GLEntry."Bal. Account No." := GenJnlLine."Bal. Account No.";
    InsertGLEntry(TRUE);
    ...

    Replacement code 2

    ...
    IF (DocAmountLCY <> 0) OR (DiscDocAmountLCY <> 0) OR (CollDocAmountLCY <> 0) OR (RejDocAmountLCY <> 0) OR
    (DiscRiskFactAmountLCY <> 0) OR (DiscUnriskFactAmountLCY <> 0) OR (CollFactAmountLCY <> 0) THEN
    IF NextEntryNo2 = NextEntryNo THEN
    NextEntryNo := NextEntryNo - 1;
    IF DocAmountLCY <> 0 THEN BEGIN

    // Add the following lines.
    IF (GenJnlLine."Applies-to Doc. Type" = GenJnlLine."Applies-to Doc. Type"::Invoice) OR
    EntryUnapplied
    THEN BEGIN
    // End of the added lines.

    CustPostingGr.TESTFIELD("Receivables Account");
    InitGLEntry(CustPostingGr."Receivables Account",DocAmountLCY,DocAmtCalcAddCurrency(DocAmountLCY),TRUE,TRUE);
    GLEntry."Bal. Account Type" := GenJnlLine."Bal. Account Type";
    GLEntry."Bal. Account No." := GenJnlLine."Bal. Account No.";
    InsertGLEntry(TRUE);
    ...

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

In addition, you must have KB3034441 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?

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.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×