fix: reverse linking
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.json b/erpnext/hr/doctype/additional_salary/additional_salary.json
index 91bcdc3..bf9d819 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.json
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.json
@@ -163,7 +163,7 @@
],
"is_submittable": 1,
"links": [],
- "modified": "2020-03-05 18:54:17.763244",
+ "modified": "2020-03-02 18:06:29.170878",
"modified_by": "Administrator",
"module": "HR",
"name": "Additional Salary",
diff --git a/erpnext/hr/doctype/additional_salary/additional_salary.py b/erpnext/hr/doctype/additional_salary/additional_salary.py
index d1b602d..d8f7444 100644
--- a/erpnext/hr/doctype/additional_salary/additional_salary.py
+++ b/erpnext/hr/doctype/additional_salary/additional_salary.py
@@ -50,7 +50,7 @@
@frappe.whitelist()
def get_additional_salary_component(employee, start_date, end_date, component_type):
additional_components = frappe.db.sql("""
- select salary_component, sum(amount) as amount, overwrite_salary_structure_amount, deduct_full_tax_on_selected_payroll_date
+ select name, salary_component, amount, overwrite_salary_structure_amount, deduct_full_tax_on_selected_payroll_date
from `tabAdditional Salary`
where employee=%(employee)s
and docstatus = 1
@@ -60,7 +60,6 @@
from_date <= %(to_date)s and to_date >= %(to_date)s
)
and type = %(component_type)s
- group by salary_component, overwrite_salary_structure_amount
order by salary_component, overwrite_salary_structure_amount
""", {
'employee': employee,
@@ -70,8 +69,11 @@
}, as_dict=1)
additional_components_list = []
+ existing_salary_components = []
component_fields = ["depends_on_payment_days", "salary_component_abbr", "is_tax_applicable", "variable_based_on_taxable_salary", 'type']
for d in additional_components:
+ if d.salary_component in existing_salary_components:
+ frappe.throw(_('Multiple additional Salary is created for Salary Component {0}'.format(d.salary_component)))
struct_row = frappe._dict({'salary_component': d.salary_component})
component = frappe.get_all("Salary Component", filters={'name': d.salary_component}, fields=component_fields)
if component:
@@ -79,6 +81,7 @@
struct_row['deduct_full_tax_on_selected_payroll_date'] = d.deduct_full_tax_on_selected_payroll_date
struct_row['is_additional_component'] = 1
+ struct_row['additional_salary'] = d.name
additional_components_list.append(frappe._dict({
'amount': d.amount,
@@ -86,4 +89,5 @@
'struct_row': struct_row,
'overwrite': d.overwrite_salary_structure_amount,
}))
+ existing_salary_components.append(d.salary_component)
return additional_components_list
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee/test_employee.py b/erpnext/hr/doctype/employee/test_employee.py
index 906386d..d3410de 100644
--- a/erpnext/hr/doctype/employee/test_employee.py
+++ b/erpnext/hr/doctype/employee/test_employee.py
@@ -51,7 +51,7 @@
"doctype": "User",
"email": user,
"first_name": user,
- "new_password": "qwerty123@12435",
+ "new_password": "password",
"roles": [{"doctype": "Has Role", "role": "Employee"}]
}).insert()
diff --git a/erpnext/hr/doctype/salary_detail/salary_detail.json b/erpnext/hr/doctype/salary_detail/salary_detail.json
index bde735d..5a55593 100644
--- a/erpnext/hr/doctype/salary_detail/salary_detail.json
+++ b/erpnext/hr/doctype/salary_detail/salary_detail.json
@@ -25,6 +25,7 @@
"tax_on_flexible_benefit",
"tax_on_additional_salary",
"section_break_11",
+ "additional_salary",
"condition_and_formula_help"
],
"fields": [
@@ -187,11 +188,18 @@
"fieldtype": "HTML",
"label": "Condition and Formula Help",
"options": "<h3>Condition and Formula Help</h3>\n\n<p>Notes:</p>\n\n<ol>\n<li>Use field <code>base</code> for using base salary of the Employee</li>\n<li>Use Salary Component abbreviations in conditions and formulas. <code>BS = Basic Salary</code></li>\n<li>Use field name for employee details in conditions and formulas. <code>Employment Type = employment_type</code><code>Branch = branch</code></li>\n<li>Use field name from Salary Slip in conditions and formulas. <code>Payment Days = payment_days</code><code>Leave without pay = leave_without_pay</code></li>\n<li>Direct Amount can also be entered based on Condtion. See example 3</li></ol>\n\n<h4>Examples</h4>\n<ol>\n<li>Calculating Basic Salary based on <code>base</code>\n<pre><code>Condition: base < 10000</code></pre>\n<pre><code>Formula: base * .2</code></pre></li>\n<li>Calculating HRA based on Basic Salary<code>BS</code> \n<pre><code>Condition: BS > 2000</code></pre>\n<pre><code>Formula: BS * .1</code></pre></li>\n<li>Calculating TDS based on Employment Type<code>employment_type</code> \n<pre><code>Condition: employment_type==\"Intern\"</code></pre>\n<pre><code>Amount: 1000</code></pre></li>\n</ol>"
+ },
+ {
+ "fieldname": "additional_salary",
+ "fieldtype": "Link",
+ "label": "Additional Salary ",
+ "options": "Additional Salary",
+ "read_only": 1
}
],
"istable": 1,
"links": [],
- "modified": "2019-12-31 17:15:25.646689",
+ "modified": "2020-03-02 18:16:38.571005",
"modified_by": "Administrator",
"module": "HR",
"name": "Salary Detail",
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index d03a3dd..ac55c67 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -442,6 +442,7 @@
if amount:
self.append(key, {
'amount': amount,
+ 'additional_salary': '' if not struct_row.get("additional_salary") else struct_row.get("additional_salary"),
'default_amount': amount if not struct_row.get("is_additional_component") else 0,
'depends_on_payment_days' : struct_row.depends_on_payment_days,
'salary_component' : struct_row.salary_component,
@@ -790,14 +791,6 @@
"repay_from_salary": 1,
})
-
- def update_salary_slip_in_additional_salary(self):
- salary_slip = self.name if self.docstatus==1 else None
- frappe.db.sql("""
- update `tabAdditional Salary` set salary_slip=%s
- where employee=%s and payroll_date between %s and %s and docstatus=1
- """, (salary_slip, self.employee, self.start_date, self.end_date))
-
def make_loan_repayment_entry(self):
for loan in self.loans:
repayment_entry = create_repayment_entry(loan.loan, self.employee,