feat: Recurring Addtional Salary
This commit is contained in:
parent
943457abd3
commit
2d7fcab2c9
@ -13,5 +13,5 @@ frappe.ui.form.on('Additional Salary', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -17,8 +17,10 @@
|
|||||||
"ref_docname",
|
"ref_docname",
|
||||||
"column_break_5",
|
"column_break_5",
|
||||||
"company",
|
"company",
|
||||||
|
"is_recurring",
|
||||||
|
"from_date",
|
||||||
|
"to_date",
|
||||||
"payroll_date",
|
"payroll_date",
|
||||||
"salary_slip",
|
|
||||||
"type",
|
"type",
|
||||||
"department",
|
"department",
|
||||||
"amount",
|
"amount",
|
||||||
@ -76,12 +78,13 @@
|
|||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:(doc.is_recurring==0)",
|
||||||
"description": "Date on which this component is applied",
|
"description": "Date on which this component is applied",
|
||||||
"fieldname": "payroll_date",
|
"fieldname": "payroll_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Payroll Date",
|
"label": "Payroll Date",
|
||||||
"reqd": 1,
|
"mandatory_depends_on": "eval:(doc.is_recurring==0)",
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -107,13 +110,6 @@
|
|||||||
"options": "Company",
|
"options": "Company",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "salary_slip",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Salary Slip",
|
|
||||||
"options": "Salary Slip",
|
|
||||||
"read_only": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fetch_from": "salary_component.type",
|
"fetch_from": "salary_component.type",
|
||||||
"fieldname": "type",
|
"fieldname": "type",
|
||||||
@ -131,6 +127,26 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_recurring",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Recurring"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:(doc.is_recurring==1)",
|
||||||
|
"fieldname": "from_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "From Date",
|
||||||
|
"mandatory_depends_on": "eval:(doc.is_recurring==1)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "eval:(doc.is_recurring==1)",
|
||||||
|
"fieldname": "to_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"label": "To Date",
|
||||||
|
"mandatory_depends_on": "eval:(doc.is_recurring==1)"
|
||||||
|
},
|
||||||
|
{
|
||||||
"fieldname": "ref_doctype",
|
"fieldname": "ref_doctype",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Reference Document Type",
|
"label": "Reference Document Type",
|
||||||
|
|||||||
@ -21,10 +21,23 @@ class AdditionalSalary(Document):
|
|||||||
frappe.throw(_("Amount should not be less than zero."))
|
frappe.throw(_("Amount should not be less than zero."))
|
||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
date_of_joining, relieving_date = frappe.db.get_value("Employee", self.employee,
|
date_of_joining, relieving_date = frappe.db.get_value("Employee", self.employee,
|
||||||
["date_of_joining", "relieving_date"])
|
["date_of_joining", "relieving_date"])
|
||||||
if date_of_joining and getdate(self.payroll_date) < getdate(date_of_joining):
|
|
||||||
frappe.throw(_("Payroll date can not be less than employee's joining date"))
|
if not self.is_recurring and not self.payroll_date:
|
||||||
|
frappe.msgprint(_("Please enter Payroll Date."), indicator='blue', raise_exception=1)
|
||||||
|
if self.is_recurring and not self.from_date and not self.to_date:
|
||||||
|
frappe.msgprint(_("Please enter From Date and To Date."), indicator='blue', raise_exception=1)
|
||||||
|
if getdate(self.from_date) > getdate(self.to_date):
|
||||||
|
frappe.throw(_("From Date can not be greater than To Date."))
|
||||||
|
|
||||||
|
if date_of_joining:
|
||||||
|
if getdate(self.payroll_date) < getdate(date_of_joining):
|
||||||
|
frappe.throw(_("Payroll date can not be less than employee's joining date."))
|
||||||
|
elif getdate(self.from_date) < getdate(date_of_joining):
|
||||||
|
frappe.throw(_("From date can not be less than employee's joining date."))
|
||||||
|
elif getdate(self.to_date) > getdate(relieving_date):
|
||||||
|
frappe.throw(_("To date can not be greater than employee's relieving date."))
|
||||||
|
|
||||||
def get_amount(self, sal_start_date, sal_end_date):
|
def get_amount(self, sal_start_date, sal_end_date):
|
||||||
start_date = getdate(sal_start_date)
|
start_date = getdate(sal_start_date)
|
||||||
@ -45,8 +58,12 @@ def get_additional_salary_component(employee, start_date, end_date, component_ty
|
|||||||
from `tabAdditional Salary`
|
from `tabAdditional Salary`
|
||||||
where employee=%(employee)s
|
where employee=%(employee)s
|
||||||
and docstatus = 1
|
and docstatus = 1
|
||||||
and payroll_date between %(from_date)s and %(to_date)s
|
and (payroll_date between %(from_date)s and %(to_date)s)
|
||||||
and type = %(component_type)s
|
or (
|
||||||
|
(from_date between %(from_date)s and %(to_date)s)
|
||||||
|
or(to_date between %(from_date)s and %(to_date)s)
|
||||||
|
)
|
||||||
|
and type = %(component_type)s
|
||||||
group by salary_component, overwrite_salary_structure_amount
|
group by salary_component, overwrite_salary_structure_amount
|
||||||
order by salary_component, overwrite_salary_structure_amount
|
order by salary_component, overwrite_salary_structure_amount
|
||||||
""", {
|
""", {
|
||||||
|
|||||||
@ -410,6 +410,7 @@ class SalarySlip(TransactionBase):
|
|||||||
if additional_components:
|
if additional_components:
|
||||||
for additional_component in additional_components:
|
for additional_component in additional_components:
|
||||||
amount = additional_component.amount
|
amount = additional_component.amount
|
||||||
|
print("-------------[>>>]", amount)
|
||||||
overwrite = additional_component.overwrite
|
overwrite = additional_component.overwrite
|
||||||
self.update_component_row(frappe._dict(additional_component.struct_row), amount,
|
self.update_component_row(frappe._dict(additional_component.struct_row), amount,
|
||||||
component_type, overwrite=overwrite)
|
component_type, overwrite=overwrite)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user