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

feat: Salary Withholding #1726

Draft
wants to merge 37 commits into
base: develop
Choose a base branch
from

Conversation

vinyselopal
Copy link
Contributor

Please provide enough information so that others can review your pull request:

Explain the details for making this change. What existing problem does the pull request solve?

Screenshots/GIFs

@ruchamahabal ruchamahabal changed the title Salary withhold feat: Salary Withholding May 1, 2024
Comment on lines 25 to 29
"date_of_joining": frappe.get_value("Employee", employee, "date_of_joining"),
"relieving_date": frappe.get_value("Employee", employee, "relieving_date"),
"employee_name": frappe.get_value("Employee", employee, "employee_name"),
"resignation_letter_date": frappe.get_value("Employee", employee, "resignation_letter_date"),
"notice_number_of_days": frappe.get_value("Employee", employee, "notice_number_of_days"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lead to 5 DB calls from a single table. All of this should be fetched in a single query. You can just set fetch from properties for these fields and eliminate this code completely

@@ -1158,6 +1158,7 @@ def get_filtered_employees(
query = set_fields_to_select(query, fields)
query = set_searchfield(query, searchfield, search_string, qb_object=Employee)
query = set_filter_conditions(query, filters, qb_object=Employee)
salary_withholding_documents = frappe.db.get_all("Salary Withholding")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date filtering for fetching salary withholding documents should happen here itself instead of fetching all records

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the date filtering should happen in this get_all query based on dates instead of looping and filtering in python later.

Not "join" in the main query since this won't be a widely used feature initially

Comment on lines 24 to 34
employee = frappe.db.get_all(
"Employee",
filters={"name": employee},
fields=[
"date_of_joining",
"relieving_date",
"employee_name",
"resignation_letter_date",
"notice_number_of_days",
],
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
employee = frappe.db.get_all(
"Employee",
filters={"name": employee},
fields=[
"date_of_joining",
"relieving_date",
"employee_name",
"resignation_letter_date",
"notice_number_of_days",
],
)
employee = frappe.db.get_value(
"Employee",
employee,
fields=[
"date_of_joining",
"relieving_date",
"employee_name",
"resignation_letter_date",
"notice_number_of_days",
],
as_dict=True,
)

get_all is for fetching multiple records. We just need a single record here and also know the name of the record so get_value is the correct way

This will eliminate employee[0].date_of_joining too because this will directly return the dictionary not a list of dictionaries

@@ -725,6 +725,7 @@
"oldfieldtype": "Section Break"
},
{
"default": "Released",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a status field in Salary Slip. Use the same?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants