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.
0
Comments
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
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com
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.
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com
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
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;
:P