set salary components
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.js b/erpnext/hr/doctype/payroll_entry/payroll_entry.js
index cc10d70..7f4769c 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.js
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.js
@@ -104,9 +104,9 @@
frm.set_value('end_date', r.message.end_date);
}
}
- })
+ });
},
-})
+});
// Create salary slips
@@ -119,7 +119,7 @@
let submit_salary_slip = function (frm) {
var doc = frm.doc;
return $c('runserverobj', { 'method': 'submit_salary_slips', 'docs': doc });
-}
+};
let make_bank_entry = function (frm) {
var doc = frm.doc;
@@ -136,4 +136,4 @@
} else {
frappe.msgprint(__("Company, From Date and To Date is mandatory"));
}
-}
+};
diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py
index a77df95..b36afa3 100644
--- a/erpnext/hr/doctype/payroll_entry/payroll_entry.py
+++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py
@@ -47,9 +47,6 @@
and t1.name = t2.employee
%s """% cond, {"sal_struct": sal_struct})
return emp_list
- else:
- frappe.msgprint(_("No active or default Salary Structure found for employee {0} for the given dates")
- .format(self .employee), title=_('Salary Structure Missing'))
def get_filter_condition(self):
self.check_mandatory()
@@ -107,14 +104,9 @@
ss_dict = {}
ss_dict["Employee Name"] = ss.employee_name
ss_dict["Total Pay"] = fmt_money(ss.rounded_total,currency = frappe.defaults.get_global_default("currency"))
- ss_dict["Salary Slip"] = self.format_as_links(ss.name)[0]
+ ss_dict["Salary Slip"] = format_as_links(ss.name)[0]
ss_list.append(ss_dict)
- return self.create_log(ss_list)
-
- def create_log(self, ss_list):
- if not ss_list or len(ss_list) < 1:
- frappe.throw(_("No employee for the above selected criteria OR salary slip already created"))
- return
+ return create_log(ss_list)
def get_sal_slip_list(self, ss_status, as_dict=False):
"""
@@ -146,8 +138,8 @@
ss_dict = {}
ss_dict["Employee Name"] = ss_obj.employee_name
ss_dict["Total Pay"] = fmt_money(ss_obj.net_pay,
- currency = frappe.defaults.get_global_default("currency"))
- ss_dict["Salary Slip"] = self.format_as_links(ss_obj.name)[0]
+ currency = frappe.defaults.get_global_default("currency"))
+ ss_dict["Salary Slip"] = format_as_links(ss_obj.name)[0]
if ss_obj.net_pay<0:
not_submitted_ss.append(ss_dict)
@@ -162,21 +154,7 @@
jv_name = self.make_accural_jv_entry()
frappe.msgprint(_("Salary Slip submitted from {0} to {1}").format(ss_obj.start_date, ss_obj.end_date))
- return self.create_submit_log(submitted_ss, not_submitted_ss, jv_name)
-
- def create_submit_log(self, submitted_ss, not_submitted_ss, jv_name):
-
- if not submitted_ss and not not_submitted_ss:
- frappe.msgprint("No salary slip found to submit for the above selected criteria OR salary slip already submitted")
-
- if not_submitted_ss:
- frappe.msgprint("Not submitted Salary Slip <br>\
- Possible reasons: <br>\
- 1. Net pay is less than 0. <br>\
- 2. Company Email Address specified in employee master is not valid. <br>")
- return
- def format_as_links(self, salary_slip):
- return ['<a href="#Form/Salary Slip/{0}">{0}</a>'.format(salary_slip)]
+ return create_submit_log(submitted_ss, not_submitted_ss, jv_name)
def get_total_salary_and_loan_amounts(self):
"""
@@ -229,7 +207,7 @@
account = self.get_salary_component_account(s)
account_dict[account] = account_dict.get(account, 0) + a
return account_dict
-
+
def get_default_payroll_payable_account(self):
payroll_payable_account = frappe.db.get_value("Company",
{"company_name": self.company}, "default_payroll_payable_account")
@@ -433,4 +411,22 @@
'month_days': month_days
})
else:
- frappe.throw(_("Fiscal Year {0} not found").format(year))
\ No newline at end of file
+ frappe.throw(_("Fiscal Year {0} not found").format(year))
+
+def create_log(ss_list):
+ if not ss_list or len(ss_list) < 1:
+ frappe.throw(_("No employee for the above selected criteria OR salary slip already created"))
+
+def format_as_links(salary_slip):
+ return ['<a href="#Form/Salary Slip/{0}">{0}</a>'.format(salary_slip)]
+
+def create_submit_log(submitted_ss, not_submitted_ss, jv_name):
+
+ if not submitted_ss and not not_submitted_ss:
+ frappe.msgprint("No salary slip found to submit for the above selected criteria OR salary slip already submitted")
+
+ if not_submitted_ss:
+ frappe.msgprint("Not submitted Salary Slip <br>\
+ Possible reasons: <br>\
+ 1. Net pay is less than 0. <br>\
+ 2. Company Email Address specified in employee master is not valid. <br>")
\ No newline at end of file
diff --git a/erpnext/hr/doctype/payroll_entry/test_set_salary_components.js b/erpnext/hr/doctype/payroll_entry/test_set_salary_components.js
new file mode 100644
index 0000000..8ff5515
--- /dev/null
+++ b/erpnext/hr/doctype/payroll_entry/test_set_salary_components.js
@@ -0,0 +1,61 @@
+QUnit.module('HR');
+
+QUnit.test("test: Set Salary Components", function (assert) {
+ assert.expect(5);
+ let done = assert.async();
+
+ frappe.run_serially([
+ () => frappe.set_route('Form', 'Salary Component', 'Leave Encashment'),
+ () => {
+ var row = frappe.model.add_child(cur_frm.doc, "Salary Component Account", "accounts");
+ row.company = 'For Testing';
+ row.default_account = 'Salary - FT';
+ },
+
+ () => cur_frm.save(),
+ () => frappe.timeout(2),
+ () => assert.equal(cur_frm.doc.accounts[0].default_account, 'Salary - FT'),
+
+ () => frappe.set_route('Form', 'Salary Component', 'Basic'),
+ () => {
+ var row = frappe.model.add_child(cur_frm.doc, "Salary Component Account", "accounts");
+ row.company = 'For Testing';
+ row.default_account = 'Salary - FT';
+ },
+
+ () => cur_frm.save(),
+ () => frappe.timeout(2),
+ () => assert.equal(cur_frm.doc.accounts[0].default_account, 'Salary - FT'),
+
+ () => frappe.set_route('Form', 'Salary Component', 'Income Tax'),
+ () => {
+ var row = frappe.model.add_child(cur_frm.doc, "Salary Component Account", "accounts");
+ row.company = 'For Testing';
+ row.default_account = 'Salary - FT';
+ },
+
+ () => cur_frm.save(),
+ () => frappe.timeout(2),
+ () => assert.equal(cur_frm.doc.accounts[0].default_account, 'Salary - FT'),
+
+ () => frappe.set_route('Form', 'Salary Component', 'Arrear'),
+ () => {
+ var row = frappe.model.add_child(cur_frm.doc, "Salary Component Account", "accounts");
+ row.company = 'For Testing';
+ row.default_account = 'Salary - FT';
+ },
+
+ () => cur_frm.save(),
+ () => frappe.timeout(2),
+ () => assert.equal(cur_frm.doc.accounts[0].default_account, 'Salary - FT'),
+
+ () => frappe.set_route('Form', 'Company', 'For Testing'),
+ () => cur_frm.set_value('default_payroll_payable_account', 'Payroll Payable - FT'),
+ () => cur_frm.save(),
+ () => frappe.timeout(2),
+ () => assert.equal(cur_frm.doc.default_payroll_payable_account, 'Payroll Payable - FT'),
+
+ () => done()
+
+ ]);
+});
diff --git a/erpnext/tests/ui/tests.txt b/erpnext/tests/ui/tests.txt
index a5dcbcb..08fc9c3 100644
--- a/erpnext/tests/ui/tests.txt
+++ b/erpnext/tests/ui/tests.txt
@@ -78,6 +78,7 @@
erpnext/hr/doctype/loan_type/test_loan_type.js
erpnext/hr/doctype/employee_loan_application/test_employee_loan_application.js
erpnext/hr/doctype/employee_loan/test_employee_loan.js
+erpnext/hr/doctype/payroll_entry/test_set_salary_components.js
erpnext/hr/doctype/payroll_entry/test_payroll_entry.js
erpnext/buying/doctype/supplier/test_supplier.js
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js