Try ERPNext Buy Support Partners Foundation

Error when submitting expense claim

After the recent update to v12.9.2, we have problem submitting the expense claim. The system prompts us the following:

From browser console I saw it is because of pl_must_have_cost_center in gl_entry.py.

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 56, in handle
return frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 61, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1055, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/workflow.py”, line 105, in apply_workflow
doc.submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 867, in submit
self._submit()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 856, in _submit
self.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 273, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 326, in _save
self.run_post_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 930, in run_post_save_methods
self.run_method(“on_submit”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 797, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1067, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1050, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 791, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/expense_claim/expense_claim.py”, line 69, in on_submit
self.make_gl_entries()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/hr/doctype/expense_claim/expense_claim.py”, line 101, in make_gl_entries
make_gl_entries(gl_entries, cancel)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py”, line 24, in make_gl_entries
save_entries(gl_map, adv_adj, update_outstanding, from_repost)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py”, line 128, in save_entries
make_entry(entry, adv_adj, update_outstanding, from_repost)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py”, line 143, in make_entry
gle.validate()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 30, in validate
self.pl_must_have_cost_center()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py”, line 77, in pl_must_have_cost_center
.format(self.voucher_type, self.voucher_no, self.account))
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 377, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 356, in msgprint
_raise_exception()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 316, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.ValidationError: Expense Claim EXP00674: Cost Center is required for ‘Profit and Loss’ account Telephone Expenses - IB. Please set up a default Cost Center for the Company.

This wasn’t happening before the upgrade. And I have checked some discussions in the forum and I have confirmed the Default Expense Claim Payable Account is already set to Creditors in the company but it won’t help.

The only way to to get rid of this error is to select Cost Center for every items in the expense claim form (which we did not need to do that before the upgrade).

Does it become the norm now, or have I missed something?

Thanks.

I don’t have this in front of me to test right now, but did you try setting a default cost center in your company page?

I always have the default cost center in company setting.

I can confirm that we are also experiencing the exact same issue today as well. We upgraded last week to v12.9.3 and had the same error message when trying to post expense reports this morning.

“Expense Claim EXP00096: Cost Center is required for ‘Profit and Loss’ account 5160 - Expensed Job Costs - AV8. Please set up a default Cost Center for the Company.”

We also went to the company list and confirmed that the Default Cost Center is still set to Main-AV8. All other default account settings are still there as well.

I would like to point out that if I open the drop down for the individual line in the expense claim that there are now TWO cost centers I can select. Until now there has only been the Main-AV8 cost center. Now there is one called Av8 Technologies-AV81 I do not recall setting up a second cost center ever. This was created on it’s own.

I went to the Cost Center Tree and see that there is no cost center called AV8 Technologies-AV81, but it is offered up as one in the dialog box in the expense report. I think this bug needs to be addressed.

Hi @peterg,

Any update? However can we fix this?

Thanks.

Hi,

For now manually select the child node of the cost center in each record (row). That should work. We will get the filters fixed.

Thank you for reporting.

Unfortunately, I don’t have any instance of v12.9.2 running to check.

I’m not able to reproduce the issue on 13-beta, which is good news I think though not something that helps you immediately. Until a fix comes in, in addition to just setting it manually (which is tedious), you could always set the default value for the Expense Claim Detail doctype via the Customize Form tool. Would that help as a short-term fix?

Yes, the issue is fixed in the develop branch. We will release a fix for v12 soon.

1 Like

@peterg Yes. I have set the default value for the Expense Claim Detail doctype via the Customize Form tool since after I discovered the problem. So I just reported it to see whether it is the new behavior now or bug :slight_smile:

I will wait patiently for the fix in v12. Thanks @michelle

2 Likes

The issue had been fixed.
Pull request: https://github.com/frappe/erpnext/pull/22219