G/L description to contain same text as Invoice Line

carlcarl Member Posts: 19
edited 2007-11-23 in NAV Tips & Tricks
I have a client that wants the following customization:
- When the user posts an Invoice he inputs a particular description in the Invoice line.
- When the invoice is posted and the user goes to 'Navigate' and chooses to see G/L entries, in the description field there is something like 'Invoice SIV07000010'.
- This client wants the description he first inputted in the invoice lines to be also shown in the G/L entries instead of the 'Invoice SIV07000010'.

Any ideas anyone?

Thanks and regards.

Comments

  • krikikriki Member, Moderator Posts: 9,094
    carl wrote:
    - This client wants the description he first inputted in the invoice lines to be also shown in the G/L entries instead of the 'Invoice SIV07000010'.
    And what does he want in case he has 2 invoice lines with different descriptions that arrive in the same G/L Account No.? Navision totals lines with the same characteristics into 1 G/L entry to avoid creating too many records.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • carlcarl Member Posts: 19
    In that case the client has agreed that the FIRST description is taken into consideration to avoid confusion.
  • krikikriki Member, Moderator Posts: 9,094
    You need to check codeunit 80 (for sales) or 90 (for purchase) where the temptable is filled to be used to post in G/L.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • MalajloMalajlo Member Posts: 294
    Show Posting Description field.
    Or you can use Posting Desc. Code
  • carlcarl Member Posts: 19
    I tried using TempSalesLine.Description. It works fine when I have just one invoice line. When i have more than 1 invoice line all the descriptions are set to the description of the LAST invoice line.

    What is needed is that if for example you have 2 invoice lines (2 seperate G/L accounts), the G/L Entries should hold both descriptions of Invoice Line 1(firs account) and Invoice Line 2(second account). Thanks all for your help and time!
  • Jonathan2708Jonathan2708 Member Posts: 552
    Hi,

    This is a very common modification request from customers and we always apply it. See code below :
    Custom Code To Replace G/L Entry Descriptions With The Sales/Purchase Invoice Line Description
    ==============================================================================================
    
    Table 49 - Invoice Post. Buffer
    ===============================
    
    New Fields
    ----------
    50000 Posting Description   (Text 50)
    50001 Line No.              (Integer)
    
    
    CodeUnit 90 - Purch.-Post
    =========================
    
    OnRun() Trigger
    ---------------
    ....
    
    GenJnlLine.INIT;
    GenJnlLine."Posting Date" := "Posting Date";
    GenJnlLine."Document Date" := "Document Date";
    // *************************************************************************************************
    // Following Field Assignment Modified By J.Wareham 21/09/2004 To Post Actual Line Description To GL
    IF InvPostingBuffer[1]."Posting Description" <> '' THEN
       GenJnlLine.Description := InvPostingBuffer[1]."Posting Description"
    ELSE
       GenJnlLine.Description := "Posting Description";
    // *************************************************************************************************
    GenJnlLine."Reason Code" := "Reason Code";
    GenJnlLine."Document Type" := GenJnlLineDocType;
    GenJnlLine."Document No." := GenJnlLineDocNo;
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    
    ....
    
    FillInvPostingBuffer() Trigger
    ------------------------------
    ...
      // *************************************************************************************************
      // Following Code Added By J.Wareham 21/09/2004 To Pass Actual Line Description Through To GL Entry
      IF (PurchLine.Type = PurchLine.Type::"G/L Account") OR (PurchLine.Type = PurchLine.Type::Item) THEN BEGIN
         InvPostingBuffer[1]."Posting Description" := PurchLine.Description;
         InvPostingBuffer[1]."Line No." := PurchLine."Line No.";
      END;
      // *************************************************************************************************
    
      TempDocDim.SETRANGE("Table ID",DATABASE::"Purchase Line");
      TempDocDim.SETRANGE("Line No.","Line No.");
      UpdInvPostingBuffer;
    END;
    
    
    CodeUnit 80 - Sales-Post
    =========================
    
    OnRun() Trigger
    ---------------
    ....
    
    GenJnlLine.INIT;
    GenJnlLine."Posting Date" := "Posting Date";
    GenJnlLine."Document Date" := "Document Date";
    // *************************************************************************************************
    // Following Field Assignment Modified By J.Wareham 21/09/2004 To Post Actual Line Description To GL
    IF InvPostingBuffer[1]."Posting Description" <> '' THEN
       GenJnlLine.Description := InvPostingBuffer[1]."Posting Description"
    ELSE
       GenJnlLine.Description := "Posting Description";
    // *************************************************************************************************
    GenJnlLine."Reason Code" := "Reason Code";
    GenJnlLine."Document Type" := GenJnlLineDocType;
    GenJnlLine."Document No." := GenJnlLineDocNo;
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    
    ....
    
    FillInvPostingBuffer() Trigger
    ------------------------------
    ...
      // *************************************************************************************************
      // Following Code Added By J.Wareham 21/09/2004 To Pass Actual Line Description Through To GL Entry
      IF SalesLine.Type = SalesLine.Type::"G/L Account" THEN BEGIN
         InvPostingBuffer[1]."Posting Description" := SalesLine.Description;
         InvPostingBuffer[1]."Line No." := SalesLine."Line No.";
      END;  
      // *************************************************************************************************
    
      TempDocDim.SETRANGE("Table ID",DATABASE::"Purchase Line");
      TempDocDim.SETRANGE("Line No.","Line No.");
      UpdInvPostingBuffer;
    END;
    
  • krikikriki Member, Moderator Posts: 9,094
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • carlcarl Member Posts: 19
    Solved as per Jonathan2708's code. Thanks all for your help and time.
  • MaWMaW Member Posts: 74
    Hi, just had a customer wanting this same solution.
    Is it possible by now, to do this functionality by hooking up on events instead of changing code inside CU 90?
  • mucamuca Member Posts: 42
    Easiest way is to put field "Posting Description" in sales/purchase header forms/pages and tell a customer that he can change it here as he wants.
  • JuhlJuhl Member Posts: 724
    I always make a factbox page for GL Entry, that shows related invoiced purchase/sales lines.
    No changing standard code and you see all descriptions.
    Follow me on my blog juhl.blog
  • MaWMaW Member Posts: 74
    Customer have multiple lines with type GL Account. So the posting description on header cannot help us. As that relation is 1 - n, one to many. We need a one to one relation.

    Factbox could be an idea if customer can se the direct line in factbox, and not just all the lines form sales/purch.
  • JuhlJuhl Member Posts: 724
    The direct line jo see on the main page. Factbox is for related info, like sales/purch lines!

    With the factbox approach you need to block deletion of posted documents for the period you need to look back.

    But remember it is a 1-N relationship, so dont dtry to solved it in the 1.

    Another way is to make sure all lines in a invoice have different dimensions, this will cause multiple entries. But then you would have to make a system for that.

    But anything else than changing the posting routines.

    I have big customers with alot of customizations, but Codeunit 80 is untouched. You just have to change your thinking, and find another way, than the straight forward one.
    AL/Extensions forces you down this path.
    Follow me on my blog juhl.blog
  • MuhammadArif_1234211MuhammadArif_1234211 Member Posts: 3
    edited 2020-07-08
    Hi @Jonathan2708 ,The above solution is not working on Nav 2018
Sign In or Register to comment.