Assign GL Accounts to Cost Centers / Accounting Dimensions

Our client, a food beverage factory, has many cost centers and accounting dimensions.
In ERPNext, you cannot assign a GL account (Income/Expense) to a cost center or to an Accounting Dimension as default.
Upon creation of JV, the accountant has to select the proper Accounting Dimension for each row in the JV, which is tedious work especially if there are 100s of daily transactions. The error rate will be higher for omitting the assignment of Accounting Dimension or selecting the wrong one.
If it is possible to assign the Accounting Dimensions / Cost Center directly to the GL Account as default, while still selecting the Accounting Dimensions in voucher entry for other non-default GL accounts, or for fine-tuning (as 1st priority).
Any suggestions?

Try Session Defaults: Session Defaults


Maybe you can check this.

I guess it will helps you.

1 Like

Hi Melvin,
Applying Account Dimension Filters will be great if there was assigned as default value. Like if I want to restrict certain Income / Expense accounts to a specific branch, and link that in the proper Accounting Dimensions filter for that branch name. Whenever a transaction (JV, sales invoice,…) is made to that account, it should pickup the assigned accounting dimension branch name by default.

Hi Melvin,
I think if possible to add - in addition to Allow and Restrict option of Accounting Dimension for an account - an option like “default” to automatically populate the proper Accounting Dimension value in the voucher automatically whenever the said account is selected

Hi Abdufaiz.
Apparently the default option is not possible, but at last the system prevent mistakes posting a menssage if the user didn’t change the account dimension to the one allowed.
I am not developer, maybe someone else can help you with a custom script to do that. I am sorry.

Abdufaiz, I am thinking on another idea to avoid writing code that could be tried but I am not sure if it will works and it would require some commits to verify that it doesn’t affect other settings.
I describe it to you in case you want to try it.
On Customize doctype: Account add a custom field: “account dimensions by default”, of type: Link to Account Dimensions so you can link an account to the best one just when is nedeed.
Later go to the related child table of a doctype involved (test first just on one) as Jornal Entry (Journal Entry Account), Sales Invoice (Sale Invocie Item) , Purchase Invoice (Purchase Invoice Item) and so on and go to the field row of Account dimensions.
This row has “:Company” as value by Defaut so now this is where you have to start testing if it works by changing some configuration
In this row fill the field Fetch From: account.account_dimensions_by_default
Test with a case if it works. If not try cleaning “:Company” from de Default field and try again.
You the check Fetch If Empty to apply if needed.
If the expected result is achieved in the tests of some configuration, the format could continue to be replicated for the rest of the doctypes.
The last step is to test other scenarios that are not affected by this configuration change.

1 Like

Hi Melvin,
Many thanks for your great helpful hints.
What I tried so far:

  1. DocType: Account - Customize Form
    Add Row
    Label: Account Cost Center by Default
    Type: Link
    Name: account_cost_center_by_default
    Options: Cost Center
  2. DocType: Journal Entry Account- Customize Form
    Select Field: Cost Center
    Edit Row
    Fetch From: account.account_cost_center_by_default


  1. Go to Chart of Account - Edit an account and then go to the new field: Account Cost Center by Default and select one of the Cost Center options
  2. In Journal Entry - Create an entry by selecting this account in one of the rows, edit the row and you will find the default Cost Center entry is auto-selected.

I need to test with other Accounting Dimension Entries, and then apply to other DocType (vouchers)

I had another issue related to this.
If the company has a default Cost Center, then it will not show in Journal Entry if the Fetch From is there.

  1. Default value and Fetch From From (account has value) and Fetch if Empty - False— > Fetch From value
  2. Default value and Fetch From (account has value) and Fetch if Empty - True— > Default value
  3. Default Empty and Fetch From From (account has value) and Fetch if Empty - False— > Fetch From value
  4. Default value and Fetch From From (account has No value - empty ) and Fetch if Empty - False— >Empty | Here I want it to revert back to Default value if the value obtained from Fetch From field is empty

I want to have the following priority

  1. Use Fetch From value available - use it regardless of the Default Value available or not
  2. Use Default value - If Fetch From - value is Not available (or empty) -