Skip to content

Commit

Permalink
feat: status field in salary withholding based on withholding status …
Browse files Browse the repository at this point in the history
…for all cycles

(cherry picked from commit b2c3636)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Jul 23, 2024
1 parent ac968ac commit 4a3f912
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
45 changes: 37 additions & 8 deletions hrms/payroll/doctype/salary_withholding/salary_withholding.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
"employee_name",
"company",
"column_break_hbju",
"posting_date",
"payroll_frequency",
"number_of_withholding_cycles",
"column_break_rhlv",
"posting_date",
"status",
"from_date",
"to_date",
"exit_details_section",
Expand Down Expand Up @@ -101,7 +102,6 @@
"reqd": 1
},
{
"depends_on": "relieving_date",
"fieldname": "exit_details_section",
"fieldtype": "Section Break",
"label": "Exit Details"
Expand All @@ -125,10 +125,6 @@
"label": "Relieving Date",
"read_only": 1
},
{
"fieldname": "reason_section",
"fieldtype": "Section Break"
},
{
"fieldname": "reason_for_withholding_salary",
"fieldtype": "Small Text",
Expand All @@ -153,12 +149,28 @@
"print_hide": 1,
"read_only": 1,
"search_index": 1
},
{
"default": "Draft",
"fieldname": "status",
"fieldtype": "Select",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Status",
"options": "\nDraft\nWithheld\nReleased\nCancelled",
"read_only": 1
},
{
"collapsible": 1,
"fieldname": "reason_section",
"fieldtype": "Section Break",
"label": "Reason"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-07-01 11:36:47.960586",
"modified": "2024-07-02 13:31:47.510265",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Salary Withholding",
Expand Down Expand Up @@ -203,6 +215,23 @@
],
"sort_field": "creation",
"sort_order": "DESC",
"states": [],
"states": [
{
"color": "Red",
"title": "Draft"
},
{
"color": "Yellow",
"title": "Withheld"
},
{
"color": "Green",
"title": "Released"
},
{
"color": "Red",
"title": "Cancelled"
}
],
"title_field": "employee_name"
}
19 changes: 19 additions & 0 deletions hrms/payroll/doctype/salary_withholding/salary_withholding.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@


class SalaryWithholding(Document):
def validate(self):
self.set_status()

def set_status(self, update=False):
if self.docstatus == 0:
status = "Draft"
elif self.docstatus == 1:
if all(cycle.is_salary_released for cycle in self.cycles):
status = "Released"
else:
status = "Withheld"
elif self.docstatus == 2:
status = "Cancelled"

if update:
self.db_set("status", status)
else:
self.status = status

@frappe.whitelist()
def set_withholding_cycles_and_to_date(self):
self.to_date = self.get_to_date()
Expand Down

0 comments on commit 4a3f912

Please sign in to comment.