Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accounting Dimensions not fitched when "Round Off" added to the GL_Entry #22295

Closed
m4mousa opened this issue Jun 17, 2020 · 6 comments
Closed
Assignees
Labels
bug to-validate Old issues pending validation

Comments

@m4mousa
Copy link

m4mousa commented Jun 17, 2020

Description of the issue

when I submit sales invoice I got a message asks me to set accounting dimension which I already set in the invoice.

Context information (for bug reports)

Output of bench version

erpnext 12.9.4
frappe 12.6.2

Steps to reproduce the issue

  1. make "Branch" as accounting dimension
  2. add more than one branches
  3. make sales tax as 5% with type "On Net Total" and check on "Is this Tax included in Basic Rate?"
  4. add items to the invoice as:

Item Quantity Rate
item01 1 12
item02 1 36

  1. select branch in accounting dimension
  2. save
  3. submit

Observed result

Accounting Dimension Branch is required for 'Profit and Loss' account 52012208 - Round Off - NCT.

Expected result

Normal Submit

Stacktrace / full error message

16:54:50 web.1            | Traceback (most recent call last):
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
16:54:50 web.1            |     response = frappe.api.handle()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/api.py", line 56, in handle
16:54:50 web.1            |     return frappe.handler.handle()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
16:54:50 web.1            |     data = execute_cmd(cmd)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/handler.py", line 61, in execute_cmd
16:54:50 web.1            |     return frappe.call(method, **frappe.form_dict)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/__init__.py", line 1055, in call
16:54:50 web.1            |     return fn(*args, **newargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 19, in savedocs
16:54:50 web.1            |     doc.submit()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 867, in submit
16:54:50 web.1            |     self._submit()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 856, in _submit
16:54:50 web.1            |     self.save()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 273, in save
16:54:50 web.1            |     return self._save(*args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 326, in _save
16:54:50 web.1            |     self.run_post_save_methods()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 930, in run_post_save_methods
16:54:50 web.1            |     self.run_method("on_submit")
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 797, in run_method
16:54:50 web.1            |     out = Document.hook(fn)(self, *args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 1067, in composer
16:54:50 web.1            |     return composed(self, method, *args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 1050, in runner
16:54:50 web.1            |     add_to_return_value(self, fn(self, *args, **kwargs))
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 791, in <lambda>
16:54:50 web.1            |     fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 177, in on_submit
16:54:50 web.1            |     self.make_gl_entries()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 733, in make_gl_entries
16:54:50 web.1            |     make_gl_entries(gl_entries, cancel=(self.docstatus == 2),
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 24, in make_gl_entries
16:54:50 web.1            |     save_entries(gl_map, adv_adj, update_outstanding, from_repost)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 128, in save_entries
16:54:50 web.1            |     make_entry(entry, adv_adj, update_outstanding, from_repost)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py", line 145, in make_entry
16:54:50 web.1            |     gle.run_method("on_update_with_args", adv_adj, update_outstanding, from_repost)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 797, in run_method
16:54:50 web.1            |     out = Document.hook(fn)(self, *args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 1067, in composer
16:54:50 web.1            |     return composed(self, method, *args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 1050, in runner
16:54:50 web.1            |     add_to_return_value(self, fn(self, *args, **kwargs))
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/model/document.py", line 791, in <lambda>
16:54:50 web.1            |     fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py", line 41, in on_update_with_args
16:54:50 web.1            |     self.validate_dimensions_for_pl_and_bs()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/erpnext/erpnext/accounts/doctype/gl_entry/gl_entry.py", line 94, in validate_dimensions_for_pl_and_bs
16:54:50 web.1            |     frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Profit and Loss' account {1}.")
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/__init__.py", line 377, in throw
16:54:50 web.1            |     msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable)
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/__init__.py", line 356, in msgprint
16:54:50 web.1            |     _raise_exception()
16:54:50 web.1            |   File "/home/mohammed/frappe-bench/apps/frappe/frappe/__init__.py", line 316, in _raise_exception
16:54:50 web.1            |     raise raise_exception(msg)
16:54:50 web.1            | frappe.exceptions.ValidationError: Accounting Dimension <b>Branch</b> is required for 'Profit and Loss' account 52012208 - Round Off - NCT.

Additional information

I fixed this issue by editing file: frappe-bench/apps/erpnext/erpnext/accounts/general_ledger.py
in the function "make_round_off_gle" I made some modifications as:
Original:
for k in ["voucher_type", "voucher_no", "company",
"posting_date", "remarks", "is_opening"]:

My Modification:
for k in ["voucher_type", "voucher_no", "company",
"posting_date", "remarks", "is_opening", "branch"]:

@m4mousa m4mousa added the bug label Jun 17, 2020
@deepeshgarg007 deepeshgarg007 self-assigned this Jun 17, 2020
@deepeshgarg007
Copy link
Member

@m4mousa this issue should have been fixed by https://github.com/frappe/erpnext/pull/21691/files#diff-05872d9fe8d480b03ddb3e7509b2048bR984 and this was released in v12.9.0 Can you please check your version once again and confirm

@m4mousa
Copy link
Author

m4mousa commented Jun 17, 2020

I have already checked this but it does not fix the issue
also I have v12.9.4

@m4mousa
Copy link
Author

m4mousa commented Jun 28, 2020

any update on this

@aakvatech
Copy link
Contributor

Would it work if the cost center and project are two special checkboxs under company record to be checked as consider as dimensions. Then the get_accounting_dimensions() will add them to the list based on the check on those two special (legacy) dimensions.

The mandatory for P&L and BS can also be managed with such a special setup. Alternatively, allow those two special dimensions to be created as accounting dimensions and let the system work the way it does right now.

@mro-admin
Copy link

This is still happening on v12.13.0 . My fix was basically the same thing as above but ensure that all dimensions are added instead.

general_ledger.py Line 253

	if not round_off_gle:
		dimensions = get_accounting_dimensions()
		key_list = ["voucher_type", "voucher_no", "company",
			"posting_date", "remarks", "is_opening"]

		for dimension in dimensions:
			key_list.append(dimension)
		for k in key_list:
				round_off_gle[k] = gl_map[0][k]

@ankush ankush added the to-validate Old issues pending validation label Dec 10, 2021
@deepeshgarg007
Copy link
Member

Should be fixed via #30754

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug to-validate Old issues pending validation
Projects
None yet
Development

No branches or pull requests

5 participants