fix: do not update component amount for timesheet components (#31696)
* fix: do not update component amount for timesheet components * fix: warn the user about overwriting timesheet component amount
This commit is contained in:
@@ -27,7 +27,7 @@ frappe.ui.form.on('Member', {
|
|||||||
frappe.set_route('query-report', 'General Ledger', {party_type: 'Member', party: frm.doc.name});
|
frappe.set_route('query-report', 'General Ledger', {party_type: 'Member', party: frm.doc.name});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (frm.doc.customer) {
|
if (frm.doc.customer) {
|
||||||
frm.add_custom_button(__('Accounts Receivable'), function() {
|
frm.add_custom_button(__('Accounts Receivable'), function() {
|
||||||
frappe.set_route('query-report', 'Accounts Receivable', {customer: frm.doc.customer});
|
frappe.set_route('query-report', 'Accounts Receivable', {customer: frm.doc.customer});
|
||||||
|
|||||||
@@ -623,7 +623,14 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
def add_structure_components(self, component_type):
|
def add_structure_components(self, component_type):
|
||||||
data = self.get_data_for_eval()
|
data = self.get_data_for_eval()
|
||||||
|
timesheet_component = frappe.db.get_value(
|
||||||
|
"Salary Structure", self.salary_structure, "salary_component"
|
||||||
|
)
|
||||||
|
|
||||||
for struct_row in self._salary_structure_doc.get(component_type):
|
for struct_row in self._salary_structure_doc.get(component_type):
|
||||||
|
if self.salary_slip_based_on_timesheet and struct_row.salary_component == timesheet_component:
|
||||||
|
continue
|
||||||
|
|
||||||
amount = self.eval_condition_and_formula(struct_row, data)
|
amount = self.eval_condition_and_formula(struct_row, data)
|
||||||
if amount is not None and struct_row.statistical_component == 0:
|
if amount is not None and struct_row.statistical_component == 0:
|
||||||
self.update_component_row(struct_row, amount, component_type, data=data)
|
self.update_component_row(struct_row, amount, component_type, data=data)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class SalaryStructure(Document):
|
|||||||
self.validate_max_benefits_with_flexi()
|
self.validate_max_benefits_with_flexi()
|
||||||
self.validate_component_based_on_tax_slab()
|
self.validate_component_based_on_tax_slab()
|
||||||
self.validate_payment_days_based_dependent_component()
|
self.validate_payment_days_based_dependent_component()
|
||||||
|
self.validate_timesheet_component()
|
||||||
|
|
||||||
def set_missing_values(self):
|
def set_missing_values(self):
|
||||||
overwritten_fields = [
|
overwritten_fields = [
|
||||||
@@ -89,6 +90,21 @@ class SalaryStructure(Document):
|
|||||||
|
|
||||||
return abbr
|
return abbr
|
||||||
|
|
||||||
|
def validate_timesheet_component(self):
|
||||||
|
if not self.salary_slip_based_on_timesheet:
|
||||||
|
return
|
||||||
|
|
||||||
|
for component in self.earnings:
|
||||||
|
if component.salary_component == self.salary_component:
|
||||||
|
frappe.msgprint(
|
||||||
|
_(
|
||||||
|
"Row #{0}: Timesheet amount will overwrite the Earning component amount for the Salary Component {1}"
|
||||||
|
).format(self.idx, frappe.bold(self.salary_component)),
|
||||||
|
title=_("Warning"),
|
||||||
|
indicator="orange",
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
def strip_condition_and_formula_fields(self):
|
def strip_condition_and_formula_fields(self):
|
||||||
# remove whitespaces from condition and formula fields
|
# remove whitespaces from condition and formula fields
|
||||||
for row in self.earnings:
|
for row in self.earnings:
|
||||||
|
|||||||
Reference in New Issue
Block a user