Pass a field to G/L Entry

aliennavaliennav Member Posts: 449
Hi All
Following is the scenerio:
I have made a new field onn Purchase Header & Purchase Inv. Line. (Lets say "XXX")
datatype: Decimal
Added a new account in G/L Account List By F3 )----say(YYY)
In General Posting Setup I have added another field "Account No. of XXX" with table relation to G/L Account table.

Now,
Suppose I have given 100 in Purchase Invoice field(I am posting invoice) and selected account "YYY" in GL setup for posting that amount.

I want that wen I post Purchase Invoice then that amount would get debited and credited from vendor and YYY respectively.

What & where the changes have to be made??


For any clarifications pl. revert.

Comments

  • ara3nara3n Member Posts: 9,256
    I suggest to get in contact with your senior developer who could help with development.
    If you don't know how to create a journal and post it during posting of document, I suggest to start learning nav with an easier mod. Like for example adding a field/table/ and studding CU 80/90/12/22
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • gvolkovgvolkov Member Posts: 196
    Excellet suggestion from ara3n
    Microsoft Certified Technology Specialist
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified Business Management Solutions Specialist

    http://www.navisiontech.com
  • mrsamrsa Member Posts: 35
    I looks to me like posting automatic payment to inovice. You can see paments method and how to automaticaly close invoice with automatic paymenth by posting to Vendor and G/L Account.


    Code is in codeunit 90, code section after:


    // Balancing account
    IF "Bal. Account No." <> '' THEN BEGIN
    IF GUIALLOWED THEN
    Window.UPDATE(5,1);
    VendLedgEntry.FINDLAST;
    GenJnlLine.INIT;
    ......
    ......

    This is a nice example of extra posting in Purch/Post codeunit.

    But if don't quite undertand how to work with temp GnlJnlLine, temp jnl dimensions table I would also suggest that you contact someone with more expirince esptially if you must do this on some producution enviroment.
  • gvolkovgvolkov Member Posts: 196
    If its an automatic payment to an invoice, all you need to do is set up balancing account on the payment method. Then all invoices will be "auto-paid" on invocing.
    Microsoft Certified Technology Specialist
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified Business Management Solutions Specialist

    http://www.navisiontech.com
  • aliennavaliennav Member Posts: 449
    ara3n wrote:
    I suggest to get in contact with your senior developer who could help with development.
    If you don't know how to create a journal and post it during posting of document, I suggest to start learning nav with an easier mod. Like for example adding a field/table/ and studding CU 80/90/12/22
    Thanks for your suggestion but either u didnt get my point or you have not read the query carefully.
    Also, things you mentioned are clear and what u din mention is not clear.
    So, I would request you to pl. give some valuable suggestion.
    Regards
  • aliennavaliennav Member Posts: 449
    aliennav wrote:
    Hi All
    Following is the scenerio:
    I have made a new field onn Purchase Header & Purchase Inv. Line. (Lets say "XXX")
    datatype: Decimal
    Added a new account in G/L Account List By F3 )----say(YYY)
    In General Posting Setup I have added another field "Account No. of XXX" with table relation to G/L Account table.

    Now,
    Suppose I have given 100 in Purchase Invoice field(I am posting invoice) and selected account "YYY" in GL setup for posting that amount.

    I want that wen I post Purchase Invoice then that amount would get debited and credited from vendor and YYY respectively.

    What & where the changes have to be made??


    I want that in G/L entry 2 lines for that amount would get reflected.

    For any clarifications pl. revert.
  • mrsamrsa Member Posts: 35
    You also did not read my post very carefully. You can put your code in codeunit 90 (for example after //Balancing account section). Code is same like //Balancing account section, you can reuse this code and rewrite it according to your needs.

    You must change code according to your needs:

    GenJnlLine.Amount := TotalPurchLine."Amount Including VAT" +
    VendLedgEntry."Remaining Pmt. Disc. Possible";

    replace with:
    GenJnlLine.Amount := yourAmount

    replace code:

    IF "Bal. Account Type" = "Bal. Account Type"::"Bank Account" THEN
    GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::"Bank Account";
    GenJnlLine."Bal. Account No." := "Bal. Account No.";

    with:

    GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::"G/L Account";
    GenJnlLine."Bal. Account No." := yourAccountFormSetupTable;
    .....


    Orginal code snipet in codeunit 80:


    // Balancing account
    IF "Bal. Account No." <> '' THEN BEGIN
    IF GUIALLOWED THEN
    Window.UPDATE(5,1);
    VendLedgEntry.FINDLAST;
    GenJnlLine.INIT;
    GenJnlLine."Internal Correction" := "Internal Correction";
    GenJnlLine."Posting Date" := "Posting Date";
    GenJnlLine."Document Date" := "Document Date";
    GenJnlLine."VAT Date" := "VAT Date";
    //ADV
    IF PurchHeader."Advance Document" = TRUE THEN BEGIN
    GenJnlLine.Prepayment := TRUE;
    GenJnlLine."Prepayment Type" := GenJnlLine."Prepayment Type"::Advance;
    END;
    //ADV
    GenJnlLine.Description := "Posting Description";
    GenJnlLine."Shortcut Dimension 1 Code" := "Shortcut Dimension 1 Code";
    GenJnlLine."Shortcut Dimension 2 Code" := "Shortcut Dimension 2 Code";
    GenJnlLine."Reason Code" := "Reason Code";
    GenJnlLine."Account Type" := GenJnlLine."Account Type"::Vendor;
    GenJnlLine."Account No." := "Pay-to Vendor No.";
    GenJnlLine."Posting Group" := "Vendor Posting Group";
    IF "Document Type" = "Document Type"::"Credit Memo" THEN
    GenJnlLine."Document Type" := GenJnlLine."Document Type"::Refund
    ELSE
    GenJnlLine."Document Type" := GenJnlLine."Document Type"::Payment;
    GenJnlLine."Document No." := GenJnlLineDocNo;
    GenJnlLine."External Document No." := GenJnlLineExtDocNo;
    GenJnlLine."SAD No." := GenJnlLineSADNo;
    GenJnlLine."Customs Procedure Code" :=PurchHeader."Customs Procedure Code";
    IF "Bal. Account Type" = "Bal. Account Type"::"Bank Account" THEN
    GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::"Bank Account";
    GenJnlLine."Bal. Account No." := "Bal. Account No.";
    GenJnlLine."Currency Code" := "Currency Code";
    GenJnlLine.Amount := TotalPurchLine."Amount Including VAT" +
    VendLedgEntry."Remaining Pmt. Disc. Possible";
    GenJnlLine.Correction := Correction;
    GenJnlLine."Source Currency Code" := "Currency Code";
    GenJnlLine."Source Currency Amount" := GenJnlLine.Amount;
    VendLedgEntry.CALCFIELDS(Amount);
    IF VendLedgEntry.Amount = 0 THEN
    GenJnlLine."Amount (LCY)" := TotalPurchLineLCY."Amount Including VAT"
    ELSE
    GenJnlLine."Amount (LCY)" :=
    TotalPurchLineLCY."Amount Including VAT" +
    ROUND(
    VendLedgEntry."Remaining Pmt. Disc. Possible" /
    VendLedgEntry."Adjusted Currency Factor");
    IF PurchHeader."Currency Code" = '' THEN
    GenJnlLine."Currency Factor" := 1
    ELSE
    GenJnlLine."Currency Factor" := PurchHeader."Currency Factor";
    GenJnlLine."Applies-to Doc. Type" := GenJnlLineDocType;
    GenJnlLine."Applies-to Doc. No." := GenJnlLineDocNo;
    GenJnlLine."Source Type" := GenJnlLine."Source Type"::Vendor;
    GenJnlLine."Source No." := "Pay-to Vendor No.";
    GenJnlLine."Source Code" := SrcCode;
    GenJnlLine."Posting No. Series" := "Posting No. Series";
    GenJnlLine."IC Partner Code" := "Pay-to IC Partner Code";
    GenJnlLine."Allow Zero-Amount Posting" := TRUE;
    GenJnlPostLine.RunWithCheck(GenJnlLine,TempJnlLineDim);
    END;
  • aliennavaliennav Member Posts: 449
    Thanks mrsa.
    :P
Sign In or Register to comment.