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:
Rucha Mahabal
2022-07-26 12:35:50 +05:30
committed by GitHub
parent 85802b0f97
commit bc7cfe6919
3 changed files with 24 additions and 1 deletions

View File

@@ -27,7 +27,7 @@ frappe.ui.form.on('Member', {
frappe.set_route('query-report', 'General Ledger', {party_type: 'Member', party: frm.doc.name});
}
});
if (frm.doc.customer) {
frm.add_custom_button(__('Accounts Receivable'), function() {
frappe.set_route('query-report', 'Accounts Receivable', {customer: frm.doc.customer});

View File

@@ -623,7 +623,14 @@ class SalarySlip(TransactionBase):
def add_structure_components(self, component_type):
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):
if self.salary_slip_based_on_timesheet and struct_row.salary_component == timesheet_component:
continue
amount = self.eval_condition_and_formula(struct_row, data)
if amount is not None and struct_row.statistical_component == 0:
self.update_component_row(struct_row, amount, component_type, data=data)

View File

@@ -20,6 +20,7 @@ class SalaryStructure(Document):
self.validate_max_benefits_with_flexi()
self.validate_component_based_on_tax_slab()
self.validate_payment_days_based_dependent_component()
self.validate_timesheet_component()
def set_missing_values(self):
overwritten_fields = [
@@ -89,6 +90,21 @@ class SalaryStructure(Document):
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):
# remove whitespaces from condition and formula fields
for row in self.earnings: