Fixed salary structure tests
This commit is contained in:
parent
427172c941
commit
2f64f0f5fa
@ -1,18 +1,18 @@
|
||||
QUnit.test("test Salary Structure", function(assert) {
|
||||
assert.expect(6);
|
||||
assert.expect(12);
|
||||
let done = assert.async();
|
||||
let employee_name1;
|
||||
|
||||
let salary_structure = (ename1,ename2) => {
|
||||
frappe.run_serially([
|
||||
() => frappe.db.get_value('Employee', {'employee_name': ename1}, 'name'),
|
||||
frappe.run_serially([
|
||||
() => frappe.db.get_value('Employee', {'employee_name': "Test Employee 1"}, 'name',
|
||||
(r) => {
|
||||
employee_name1 = r.message.name;
|
||||
},
|
||||
() => frappe.db.get_value('Employee', {'employee_name': ename2}, 'name'),
|
||||
employee_name1 = r.name;
|
||||
}
|
||||
),
|
||||
() => frappe.db.get_value('Employee', {'employee_name': "Test Employee 3"}, 'name',
|
||||
(r) => {
|
||||
// Creating Salary Structure for employees);
|
||||
frappe.tests.make('Salary Structure', [
|
||||
return frappe.tests.make('Salary Structure', [
|
||||
{ company: 'For Testing'},
|
||||
{ payroll_frequency: 'Monthly'},
|
||||
{ employees: [
|
||||
@ -22,7 +22,7 @@ QUnit.test("test Salary Structure", function(assert) {
|
||||
{base: 25000}
|
||||
],
|
||||
[
|
||||
{employee: r.message.name},
|
||||
{employee: r.name},
|
||||
{from_date: '2017-07-01'},
|
||||
{base: 30000}
|
||||
]
|
||||
@ -45,37 +45,34 @@ QUnit.test("test Salary Structure", function(assert) {
|
||||
]},
|
||||
{ payment_account: 'CASH - FT'},
|
||||
]);
|
||||
},
|
||||
() => frappe.timeout(12),
|
||||
() => cur_dialog.set_value('value','Test Salary Structure'),
|
||||
() => frappe.timeout(2),
|
||||
() => frappe.click_button('Create'),
|
||||
() => {
|
||||
// To check if all the fields are correctly set
|
||||
assert.ok(cur_frm.doc.employees[0].employee_name.includes('Test Employee 1') &&
|
||||
cur_frm.doc.employees[1].employee_name.includes('Test Employee 3'),
|
||||
'Employee names are correctly set');
|
||||
}
|
||||
),
|
||||
() => frappe.timeout(18),
|
||||
() => cur_dialog.set_value('value','Test Salary Structure'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Create'),
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
// To check if all the fields are correctly set
|
||||
assert.ok(cur_frm.doc.employees[0].employee_name.includes('Test Employee 1') &&
|
||||
cur_frm.doc.employees[1].employee_name.includes('Test Employee 3'),
|
||||
'Employee names are correctly set');
|
||||
|
||||
assert.ok(cur_frm.doc.employees[0].base==25000,
|
||||
'Base value for first employee is correctly set');
|
||||
assert.ok(cur_frm.doc.employees[0].base==25000,
|
||||
'Base value for first employee is correctly set');
|
||||
|
||||
assert.ok(cur_frm.doc.employees[1].base==30000,
|
||||
'Base value for second employee is correctly set');
|
||||
assert.ok(cur_frm.doc.employees[1].base==30000,
|
||||
'Base value for second employee is correctly set');
|
||||
|
||||
assert.ok(cur_frm.doc.earnings[0].formula.includes('base * .80'),
|
||||
'Formula for earnings as Basic is correctly set');
|
||||
assert.ok(cur_frm.doc.earnings[0].formula.includes('base * .80'),
|
||||
'Formula for earnings as Basic is correctly set');
|
||||
|
||||
assert.ok(cur_frm.doc.earnings[1].formula.includes('B * .20'),
|
||||
'Formula for earnings as Leave Encashment is correctly set');
|
||||
assert.ok(cur_frm.doc.earnings[1].formula.includes('B * .20'),
|
||||
'Formula for earnings as Leave Encashment is correctly set');
|
||||
|
||||
assert.ok(cur_frm.doc.deductions[0].formula.includes('(B+LE) * .20'),
|
||||
'Formula for deductions as Income Tax is correctly set');
|
||||
},
|
||||
]);
|
||||
};
|
||||
frappe.run_serially([
|
||||
() => salary_structure('Test Employee 1','Test Employee 3'),
|
||||
() => frappe.timeout(16),
|
||||
assert.ok(cur_frm.doc.deductions[0].formula.includes('(B+LE) * .20'),
|
||||
'Formula for deductions as Income Tax is correctly set');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user