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

Error: Salary Slip creation failed for Payroll Entry due to added tax component from salary component #2145

Closed
1 task done
zulfi007 opened this issue Sep 3, 2024 · 2 comments · Fixed by #2147
Closed
1 task done
Labels
bug Something isn't working

Comments

@zulfi007
Copy link

zulfi007 commented Sep 3, 2024

Information about bug

Salary Slip creation failed for Payroll Entry due to error in "Added tax components from the Salary Component master as the salary structure didn't have any tax component".

Module

Payroll

Version

Frappe Version - 15.36.1
ErpNext Version - 15.34.0
Frappe HR Version - 15.28.0

Installation method

FrappeCloud

Relevant log output / Stack trace / Full Error Message.

Traceback with variables (most recent call last):
  File "apps/hrms/hrms/payroll/doctype/payroll_entry/payroll_entry.py", line 1411, in create_salary_slips_for_employees
    frappe.get_doc(args).insert()
      employees = ['HR-EMP-00026', 'HR-EMP-00010', 'HR-EMP-00014', 'HR-EMP-00018', 'HR-EMP-00015', 'HR-EMP-00022', 'HR-EMP-00007', 'HR-EMP-00016', 'HR-EMP-00011', 'HR-EMP-00008', 'HR-EMP-00005', 'HR-EMP-00009', 'HR-EMP-00012', 'HR-EMP-00017', 'HR-EMP-00024', 'HR-EMP-00002', 'HR-EMP-00003', 'HR-EMP-00006', 'HR-EMP-00013', 'HR-EMP-00020', 'HR-EMP-00004', 'HR-EMP-00023', 'HR-EMP-00029', 'HR-EMP-00028']
      args = {'salary_slip_based_on_timesheet': 0, 'payroll_frequency': 'Monthly', 'start_date': '2024-08-01', 'end_date': '2024-08-31', 'company': 'Alwahab Traders', 'posting_date': '2024-08-01', 'deduct_tax_for_unclaimed_employee_benefits': 0, 'deduct_tax_for_unsubmitted_tax_exemption_proof': 0, 'payroll_entry': 'HR-PRUN-2024-00009', 'exchange_rate': 1, 'currency': 'PKR', 'doctype': 'Salary Slip', 'employee': 'HR-EMP-00002'}
      publish_progress = False
      payroll_entry = <PayrollEntry: HR-PRUN-2024-00009 docstatus=1>
      salary_slips_exist_for = []
      count = 15
      emp = 'HR-EMP-00002'
      e = SyntaxError('invalid syntax', ('<unknown>', 0, 0, '', 0, 0))
  File "apps/frappe/frappe/model/document.py", line 291, in insert
    self.run_before_save_methods()
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
  File "apps/frappe/frappe/model/document.py", line 1091, in run_before_save_methods
    self.run_method("validate")
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      method = 'validate'
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x7fc6a4325c60>
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      args = ()
      kwargs = {}
      hooks = [<function apply at 0x7fc6a61742c0>, <function check_for_running_deletion_job at 0x7fc6a6175e40>]
      method = 'validate'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ['frappe.workflow.doctype.workflow_action.workflow_action.process_w...
      handler = 'erpnext.setup.doctype.transaction_deletion_record.transaction_deletion_record.check_for_running_deletion_job'
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x7fc6a4325760>
      compose = <function Document.hook.<locals>.compose at 0x7fc6a4326660>
      f = <function Document.run_method.<locals>.fn at 0x7fc6a4325c60>
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      method = 'validate'
      args = ()
      kwargs = {}
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x7fc6a4326ca0>
      fn = <function Document.run_method.<locals>.fn at 0x7fc6a4325c60>
      hooks = (<function apply at 0x7fc6a61742c0>, <function check_for_running_deletion_job at 0x7fc6a6175e40>)
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      args = ()
      kwargs = {}
      method_object = <bound method SalarySlip.validate of <SalarySlip: Sal Slip/HR-EMP-00002/00032>>
      method = 'validate'
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 147, in validate
    self.get_emp_and_working_day_details()
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
      args = (<SalarySlip: Sal Slip/HR-EMP-00002/00032>,)
      kwargs = {}
      apply_condition = <function whitelist.<locals>.innerfn.<locals>.<lambda> at 0x7fc6a3b076a0>
      func = <function SalarySlip.get_emp_and_working_day_details at 0x7fc6a3b07600>
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 337, in get_emp_and_working_day_details
    self.pull_sal_struct()
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      struct = 'Manager Salary Structure'
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 411, in pull_sal_struct
    make_salary_slip(self._salary_structure_doc.name, self)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      make_salary_slip = <function make_salary_slip at 0x7fc6a45cd300>
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
      args = ('Manager Salary Structure', <SalarySlip: Sal Slip/HR-EMP-00002/00032>)
      kwargs = {}
      apply_condition = <function whitelist.<locals>.innerfn.<locals>.<lambda> at 0x7fc6a45cc540>
      func = <function make_salary_slip at 0x7fc6a45cc860>
  File "apps/hrms/hrms/payroll/doctype/salary_structure/salary_structure.py", line 377, in make_salary_slip
    doc = get_mapped_doc(
      source_name = 'Manager Salary Structure'
      target_doc = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      employee = None
      posting_date = None
      as_print = False
      print_format = None
      for_preview = 0
      ignore_permissions = False
      postprocess = <function make_salary_slip.<locals>.postprocess at 0x7fc6a43256c0>
  File "apps/frappe/frappe/model/mapper.py", line 152, in get_mapped_doc
    postprocess(source_doc, target_doc)
      from_doctype = 'Salary Structure'
      from_docname = 'Manager Salary Structure'
      table_maps = {'Salary Structure': {'doctype': 'Salary Slip', 'field_map': {'total_earning': 'gross_pay', 'name': 'salary_structure', 'currency': 'currency'}}}
      target_doc = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      postprocess = <function make_salary_slip.<locals>.postprocess at 0x7fc6a43256c0>
      ignore_permissions = False
      ignore_child_tables = True
      cached = True
      apply_strict_user_permissions = 0
      source_doc = <SalaryStructure: Manager Salary Structure docstatus=1>
      row_exists_for_parentfield = {}
  File "apps/hrms/hrms/payroll/doctype/salary_structure/salary_structure.py", line 375, in postprocess
    target.run_method("process_salary_structure", for_preview=for_preview)
      source = <SalaryStructure: Manager Salary Structure docstatus=1>
      target = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      employee = None
      for_preview = 0
      posting_date = None
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      method = 'process_salary_structure'
      args = ()
      kwargs = {'for_preview': 0}
      fn = <function Document.run_method.<locals>.fn at 0x7fc6a4324f40>
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      args = ()
      kwargs = {'for_preview': 0}
      hooks = []
      method = 'process_salary_structure'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions'], 'on_update_after_submit': ['frappe.workflow.doctype.workflow_action.workflow_action.process_w...
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x7fc6a4327100>
      compose = <function Document.hook.<locals>.compose at 0x7fc6a43251c0>
      f = <function Document.run_method.<locals>.fn at 0x7fc6a4324f40>
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      method = 'process_salary_structure'
      args = ()
      kwargs = {'for_preview': 0}
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x7fc6a4325620>
      fn = <function Document.run_method.<locals>.fn at 0x7fc6a4324f40>
      hooks = ()
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      args = ()
      kwargs = {'for_preview': 0}
      method_object = <bound method SalarySlip.process_salary_structure of <SalarySlip: Sal Slip/HR-EMP-00002/00032>>
      method = 'process_salary_structure'
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 1929, in process_salary_structure
    self.calculate_net_pay()
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      for_preview = 0
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 796, in calculate_net_pay
    self.update_dependent_components_recursively("earnings", deduction_abbrs)
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      set_gross_pay_and_base_gross_pay = <function SalarySlip.calculate_net_pay.<locals>.set_gross_pay_and_base_gross_pay at 0x7fc6a4325a80>
      deduction_abbrs = []
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 818, in update_dependent_components_recursively
    for var in get_variables_from_formula(d.formula):
      self = <SalarySlip: Sal Slip/HR-EMP-00002/00032>
      component_type = 'earnings'
      updated_var = []
      is_var_updated = <function SalarySlip.update_dependent_components_recursively.<locals>.is_var_updated at 0x7fc6a43263e0>
      other_component_type = 'deductions'
      d = <SalaryDetail: 214f3a59e2 docstatus=1 parent=Manager Salary Structure>
      var = 'base'
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 2353, in get_variables_from_formula
    return [node.id for node in ast.walk(ast.parse(formula, mode="eval")) if isinstance(node, ast.Name)]
      formula = ''
  File "/usr/lib/python3.11/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
      source = ''
      filename = '<unknown>'
      mode = 'eval'
      type_comments = False
      feature_version = -1
      flags = 1024
builtins.SyntaxError: invalid syntax (<unknown>, line 0)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@zulfi007 zulfi007 added the bug Something isn't working label Sep 3, 2024
@ruchamahabal
Copy link
Member

@zulfi007 please share the salary structure Manager Salary Structure with all the formulae

@zulfi007
Copy link
Author

zulfi007 commented Sep 4, 2024

@zulfi007 please share the salary structure Manager Salary Structure with all the formulae

{
"name": "Manager_Salary_Structure",
"owner": "[email protected]",
"docstatus": 1,
"company": "Company XYZ",
"letter_head": "Company XYZ Letterhead",
"is_active": "Yes",
"is_default": "No",
"leave_encashment_amount_per_day": 0,
"max_benefits": 0,
"salary_slip_based_on_timesheet": 0,
"payroll_frequency": "Monthly",
"hour_rate": 0,
"total_earning": 5000,
"total_deduction": 0,
"net_pay": 5000,
"doctype": "Salary Structure",
"earnings": [
{
"name": "earning_1",
"salary_component": "Basic",
"abbr": "BASIC",
"amount": 0,
"year_to_date": 0,
"is_recurring_additional_salary": 0,
"statistical_component": 0,
"depends_on_payment_days": 1,
"exempted_from_income_tax": 0,
"is_tax_applicable": 0,
"is_flexible_benefit": 0,
"variable_based_on_taxable_salary": 0,
"do_not_include_in_total": 0,
"deduct_full_tax_on_selected_payroll_date": 0,
"condition": "",
"amount_based_on_formula": 1,
"formula": "base * 1",
"default_amount": 0,
"additional_amount": 0,
"tax_on_flexible_benefit": 0,
"tax_on_additional_salary": 0,
"parent": "Manager_Salary_Structure",
"parentfield": "earnings",
"parenttype": "Salary Structure",
"doctype": "Salary Detail"
},
{
"name": "earning_2",
"salary_component": "Conveyance Allowance",
"abbr": "CA",
"amount": 5000,
"year_to_date": 0,
"is_recurring_additional_salary": 0,
"statistical_component": 0,
"depends_on_payment_days": 1,
"exempted_from_income_tax": 0,
"is_tax_applicable": 0,
"is_flexible_benefit": 0,
"variable_based_on_taxable_salary": 0,
"do_not_include_in_total": 0,
"deduct_full_tax_on_selected_payroll_date": 0,
"condition": "",
"amount_based_on_formula": 1,
"formula": "",
"default_amount": 0,
"additional_amount": 0,
"tax_on_flexible_benefit": 0,
"tax_on_additional_salary": 0,
"parent": "Manager_Salary_Structure",
"parentfield": "earnings",
"parenttype": "Salary Structure",
"doctype": "Salary Detail"
}
],
"deductions": []
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants
@zulfi007 @ruchamahabal and others