Which Navision code is posting sale & purchase values in GLs of GL Entry Table

Hello.

I am searching code in code unit 12, 21, 22 & 90 that is responsible for posting values in GL A/c No. in GL table at the time of Purchase and sale and i found function like InsertGLEntry() that is posting values from GLEntryTmp table type variable and this variable getting values from GLEntry table type variable and GLEntry variable getting values from GenJnlLine table type variable but unable to find actual codes that converting and assigning sale/purchase values according to GL Account nos.

So pls tell me where i can find it and share same codes …

Thanks.

You will have to create your own function to write it to Gen. Journal line table and post it right from this function, do not use standard NAV function as you don’t know where all it will be called from and keep in mind some functions use publisher and subscriber and by calling insertglentry function you might be posting additional line, if I were you I would create my own function and call this function to post any additional entries into G/L entry table.

Sbhatbng thanx for your reply,
Can you share same function coding and Where i need to call it

Or can you share existing function that posting values in GL accounts.

If you are using NAV 2016 then you would go to codeunit 90 and search for

// Balancing account
IF “Bal. Account No.” <> ‘’ THEN BEGIN
IF GUIALLOWED THEN

Right after this lines of code is executed, you will call your function, first create a function and you can use the same code as show in the above //Balancing account code. Make sure are putting a condition as to when this code should be called, I am not sure what you are trying to accomplish in purchase side but put a condition otherwise for every line in the purchase it will create a G/L account, also make sure you have the Account no. and Bal. Account no. populated, otherwise your posting will fail. In purchase & receivable setup create a field for G/L account no. and Bal. Account no. and populate them and use these fields in the posting routine in your function to post the additional line while posting. Also In the G/L entry table I would create a new boolean field to identify the transaction which would let you know that you posted this transaction.

PostExcise_Function.txt (10.9 KB)

Thanx for your reply and explanation

My purpose is posting of “Purchase Line”.“Column Value” and “Sale Line”.“Column Value” to G/L entry table against newly created GL.

So i created new column in “Excise Posting Setup” table to mention new GL No. and trying to create new below function as created in above attachment for “ADC VAT Account”.

WITH GenJnlLine DO BEGIN

IF “Excise Amount” <> 0 THEN BEGIN

IF “Gen. Posting Type” = “Gen. Posting Type”::Purchase THEN BEGIN

ExcisePostingSetup.SETRANGE(“Excise Bus. Posting Group”,“Excise Bus. Posting Group”);

ExcisePostingSetup.SETRANGE(“Excise Prod. Posting Group”,“Excise Prod. Posting Group”);

ExcisePostingSetup.SETRANGE(“From Date”,0D,GenJnlLine.“Posting Date”);

IF ExcisePostingSetup.FIND(’+’) THEN

IF ((“Account Type” = “Account Type”::“Fixed Asset”) OR

((“Account Type” = “Account Type”::“G/L Account”) AND (“Capital Item”)))

THEN BEGIN

ExcisePostingSetup.TESTFIELD(“Cenvat Cr. Receivable Account”);

InitGLEntry(ExcisePostingSetup.“Cenvat Cr. Receivable Account”,

ROUND(((“Excise Amount” - “BED Amount”)/2) + “BED Amount”),

ROUND(((“Source Curr. Excise Amount” - “Source Curr. BED Amount”)/2) + “Source Curr. BED Amount”),

TRUE,“System-Created Entry”);

InsertGLEntry(TRUE);

InsertExciseforCapitalItems(GenJnlLine,ExcisePostingSetup.“Cenvat Cr. Receivable Account”,FALSE);

ExcisePostingSetup.TESTFIELD(“Cenvat Cr. (Deferred) Account”);

InitGLEntry(ExcisePostingSetup.“Cenvat Cr. (Deferred) Account”,

(“Excise Amount” - ROUND(((“Excise Amount”-“BED Amount”)/ 2) + “BED Amount”)),

(“Source Curr. Excise Amount” - ROUND(((“Source Curr. Excise Amount” - “Source Curr. BED Amount”)/2) +

“Source Curr. BED Amount”)), TRUE,“System-Created Entry”);

InsertGLEntry(TRUE);

InsertExciseforCapitalItems(GenJnlLine,ExcisePostingSetup.“Cenvat Cr. (Deferred) Account”,TRUE);

END ELSE

IF “BED Amount” <> 0 THEN BEGIN

InitGLEntry(ExcisePostingSetup.“BED Account”,“BED Amount”

,“Source Curr. Excise Amount”,

TRUE,“System-Created Entry”);

InsertGLEntry(TRUE);

END; END;

IF “Excise Amount” <> 0 THEN BEGIN

IF “Gen. Posting Type” = “Gen. Posting Type”::Purchase THEN BEGIN

ExPostingGrp.SETRANGE(“Excise Bus. Posting Group”,“Excise Bus. Posting Group”);

ExPostingGrp.SETRANGE(“Excise Prod. Posting Group”,“Excise Prod. Posting Group”);

ExPostingGrp.SETRANGE(“From Date”,0D,GenJnlLine.“Posting Date”);

IF ExPostingGrp.FIND(’-’) THEN BEGIN

ExPostingGrp.TESTFIELD(“BED Account”);

IF GenJnlLine.“BED Amount” <> 0 THEN BEGIN

InitGLEntry(ExPostingGrp.“BED Account”,ABS(ROUND(“BED Amount”)),“Source Curr. Excise Amount”,

TRUE,“System-Created Entry”);

InsertGLEntry(TRUE);

END

END; END;END; END;