frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
20.24k stars 7.07k forks source link

Error when creating Bank Entry from Process Payroll #10215

Closed umairsy closed 7 years ago

umairsy commented 7 years ago

payroll

Traceback (most recent call last): File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/app.py", line 56, in application response = frappe.handler.handle() File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/handler.py", line 21, in handle data = execute_cmd(cmd) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/handler.py", line 52, in execute_cmd return frappe.call(method, **frappe.form_dict) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/__init__.py", line 922, in call return fn(*args, **newargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/handler.py", line 80, in runserverobj frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/desk/form/run_method.py", line 35, in runserverobj r = doc.run_method(method) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 666, in run_method out = Document.hook(fn)(self, *args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 887, in composer return composed(self, method, *args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 870, in runner add_to_return_value(self, fn(self, *args, **kwargs)) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 660, in <lambda> fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/erpnext/erpnext/hr/doctype/process_payroll/process_payroll.py", line 342, in make_payment_entry return journal_entry.as_dict() UnboundLocalError: local variable 'journal_entry' referenced before assignment

tundebabzy commented 7 years ago

@umairsy "Submit Salary Slip" must have failed. Check the created Salary Slips to see if they successfully submitted. If not we have to find out why it did not and still did not show any errors.

In the meantime, I will add a fix so that instead of throwing an error, a useful message be will displayed.

umairsy commented 7 years ago

Correct. Salary Slips not submitted due to error "Party Type and Party is required for Receivable / Payable account Salary Payable - BS".

Following is the Salary Payable Account selected in the Company master. Anything missing?

screen shot 2017-08-02 at 10 53 43 am

Complete error message when Salary Slip submission (from Process Payroll) fails.

Traceback (most recent call last): File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/app.py", line 56, in application response = frappe.handler.handle() File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/handler.py", line 21, in handle data = execute_cmd(cmd) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/handler.py", line 52, in execute_cmd return frappe.call(method, **frappe.form_dict) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/__init__.py", line 922, in call return fn(*args, **newargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/handler.py", line 80, in runserverobj frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/desk/form/run_method.py", line 35, in runserverobj r = doc.run_method(method) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 666, in run_method out = Document.hook(fn)(self, *args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 887, in composer return composed(self, method, *args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 870, in runner add_to_return_value(self, fn(self, *args, **kwargs)) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 660, in <lambda> fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/erpnext/erpnext/hr/doctype/process_payroll/process_payroll.py", line 160, in submit_salary_slips jv_name = self.make_accural_jv_entry() File "/home/frappe/benches/bench-2017-07-31/apps/erpnext/erpnext/hr/doctype/process_payroll/process_payroll.py", line 309, in make_accural_jv_entry journal_entry.save() File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 230, in save return self._save(*args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 253, in _save self.insert() File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 192, in insert self.run_before_save_methods() File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 772, in run_before_save_methods self.run_method("validate") File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 666, in run_method out = Document.hook(fn)(self, *args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 887, in composer return composed(self, method, *args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 870, in runner add_to_return_value(self, fn(self, *args, **kwargs)) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/model/document.py", line 660, in <lambda> fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs) File "/home/frappe/benches/bench-2017-07-31/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 26, in validate self.validate_party() File "/home/frappe/benches/bench-2017-07-31/apps/erpnext/erpnext/accounts/doctype/journal_entry/journal_entry.py", line 103, in validate_party frappe.throw(_("Row {0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account)) File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/__init__.py", line 319, in throw msgprint(msg, raise_exception=exc, title=title, indicator='red') File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/__init__.py", line 309, in msgprint _raise_exception() File "/home/frappe/benches/bench-2017-07-31/apps/frappe/frappe/__init__.py", line 282, in _raise_exception raise raise_exception(encode(msg)) ValidationError: Row 7: Party Type and Party is required for Receivable / Payable account Salary Payable - BS

nabinhait commented 7 years ago

The account type for "Salary Payable - BS" should not be payable. If you leave it blank, it will not give any error.

nabinhait commented 7 years ago

still we need to fix the first error message, it should not give any error. Should be handled by if/else or validate for correct scenario.

tundebabzy commented 7 years ago

Set the account type to blank. When account type is Payable, Journal Entry looks for a party during validation.

tundebabzy commented 7 years ago

still we need to fix the first error message, it should not give any error. Should be handled by if/else or validate for correct scenario.

The error comes up if it cannot find Salary Slips with docstatus =1. I was thinking of showing a message in such a condition but I now think a better fix will be to make sure the payment entry section is not available if submit salary slip fails

tundebabzy commented 7 years ago

Fixed in #10255. Helpful message will now be shown instead of exception.