Tests for Loan (#10557)
This commit is contained in:
parent
554cf9be44
commit
7ba2a83182
79
erpnext/hr/doctype/employee_loan/test_employee_loan.js
Normal file
79
erpnext/hr/doctype/employee_loan/test_employee_loan.js
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
QUnit.test("Test Loan [HR]", function(assert) {
|
||||||
|
assert.expect(8);
|
||||||
|
let done = assert.async();
|
||||||
|
let employee_name;
|
||||||
|
|
||||||
|
// To create a loan and check principal,interest and balance amount
|
||||||
|
let loan_creation = (ename,lname) => {
|
||||||
|
return frappe.run_serially([
|
||||||
|
() => frappe.db.get_value('Employee', {'employee_name': ename}, 'name'),
|
||||||
|
(r) => {
|
||||||
|
employee_name = r.message.name;
|
||||||
|
},
|
||||||
|
() => frappe.db.get_value('Employee Loan Application', {'loan_type': lname}, 'name'),
|
||||||
|
(r) => {
|
||||||
|
// Creating loan for an employee
|
||||||
|
return frappe.tests.make('Employee Loan', [
|
||||||
|
{ company: 'Test Company'},
|
||||||
|
{ posting_date: '2017-08-26'},
|
||||||
|
{ employee: employee_name},
|
||||||
|
{ employee_loan_application: r.message.name},
|
||||||
|
{ disbursement_date: '2018-08-26'},
|
||||||
|
{ mode_of_payment: 'Cash'},
|
||||||
|
{ employee_loan_account: 'Temporary Opening - TC'},
|
||||||
|
{ interest_income_account: 'Service - TC'}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
() => frappe.timeout(3),
|
||||||
|
() => frappe.click_button('Submit'),
|
||||||
|
() => frappe.timeout(1),
|
||||||
|
() => frappe.click_button('Yes'),
|
||||||
|
() => frappe.timeout(3),
|
||||||
|
|
||||||
|
// Checking if all the amounts are correctly calculated
|
||||||
|
() => {
|
||||||
|
assert.ok(cur_frm.get_field('employee_name').value=='Test Employee 1'&&
|
||||||
|
(cur_frm.get_field('status').value=='Sanctioned'),
|
||||||
|
'Loan Sanctioned for correct employee');
|
||||||
|
|
||||||
|
assert.equal(7270,
|
||||||
|
cur_frm.get_doc('repayment_schedule').repayment_schedule[0].principal_amount,
|
||||||
|
'Principal amount for first instalment is correctly calculated');
|
||||||
|
|
||||||
|
assert.equal(2333,
|
||||||
|
cur_frm.get_doc('repayment_schedule').repayment_schedule[0].interest_amount,
|
||||||
|
'Interest amount for first instalment is correctly calculated');
|
||||||
|
|
||||||
|
assert.equal(192730,
|
||||||
|
cur_frm.get_doc('repayment_schedule').repayment_schedule[0].balance_loan_amount,
|
||||||
|
'Balance amount after first instalment is correctly calculated');
|
||||||
|
|
||||||
|
assert.equal(9479,
|
||||||
|
cur_frm.get_doc('repayment_schedule').repayment_schedule[23].principal_amount,
|
||||||
|
'Principal amount for last instalment is correctly calculated');
|
||||||
|
|
||||||
|
assert.equal(111,
|
||||||
|
cur_frm.get_doc('repayment_schedule').repayment_schedule[23].interest_amount,
|
||||||
|
'Interest amount for last instalment is correctly calculated');
|
||||||
|
|
||||||
|
assert.equal(0,
|
||||||
|
cur_frm.get_doc('repayment_schedule').repayment_schedule[23].balance_loan_amount,
|
||||||
|
'Balance amount after last instalment is correctly calculated');
|
||||||
|
|
||||||
|
},
|
||||||
|
() => frappe.set_route('List','Employee Loan','List'),
|
||||||
|
() => frappe.timeout(2),
|
||||||
|
|
||||||
|
// Checking the submission of Loan
|
||||||
|
() => {
|
||||||
|
assert.ok(cur_list.data[0].docstatus==1,'Loan sanctioned and submitted successfully');
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
frappe.run_serially([
|
||||||
|
// Creating loan
|
||||||
|
() => loan_creation('Test Employee 1','Test Loan'),
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
});
|
@ -0,0 +1,68 @@
|
|||||||
|
QUnit.module('hr');
|
||||||
|
|
||||||
|
QUnit.test("Test: Employee Loan Application [HR]", function (assert) {
|
||||||
|
assert.expect(8);
|
||||||
|
let done = assert.async();
|
||||||
|
let employee_name;
|
||||||
|
|
||||||
|
frappe.run_serially([
|
||||||
|
// Creation of Loan Application
|
||||||
|
() => frappe.db.get_value('Employee', {'employee_name': 'Test Employee 1'}, 'name'),
|
||||||
|
(r) => {
|
||||||
|
employee_name = r.message.name;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
frappe.tests.make('Employee Loan Application', [
|
||||||
|
{ company: 'Test Company'},
|
||||||
|
{ employee: employee_name},
|
||||||
|
{ employee_name: 'Test Employee 1'},
|
||||||
|
{ status: 'Approved'},
|
||||||
|
{ loan_type: 'Test Loan '},
|
||||||
|
{ loan_amount: 200000},
|
||||||
|
{ description: 'This is just a test'},
|
||||||
|
{ repayment_method: 'Repay Over Number of Periods'},
|
||||||
|
{ repayment_periods: 24},
|
||||||
|
{ rate_of_interest: 14}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
() => frappe.timeout(6),
|
||||||
|
() => frappe.click_button('Submit'),
|
||||||
|
() => frappe.timeout(1),
|
||||||
|
() => frappe.click_button('Yes'),
|
||||||
|
() => frappe.timeout(2),
|
||||||
|
() => {
|
||||||
|
// To check if all the amounts are correctly calculated
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('employee_name').value == 'Test Employee 1',
|
||||||
|
'Application created successfully');
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('status').value=='Approved',
|
||||||
|
'Status of application is correctly set');
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('loan_type').value=='Test Loan',
|
||||||
|
'Application is created for correct Loan Type');
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('status').value=='Approved',
|
||||||
|
'Status of application is correctly set');
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('repayment_amount').value==9603,
|
||||||
|
'Repayment amount is correctly calculated');
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('total_payable_interest').value==30459,
|
||||||
|
'Interest amount is correctly calculated');
|
||||||
|
|
||||||
|
assert.ok(cur_frm.get_field('total_payable_amount').value==230459,
|
||||||
|
'Total payable amount is correctly calculated');
|
||||||
|
},
|
||||||
|
|
||||||
|
() => frappe.set_route('List','Employee Loan Application','List'),
|
||||||
|
() => frappe.timeout(2),
|
||||||
|
|
||||||
|
// Checking the submission of Loan Application
|
||||||
|
() => {
|
||||||
|
assert.ok(cur_list.data[0].docstatus==1,'Loan Application submitted successfully');
|
||||||
|
},
|
||||||
|
() => frappe.timeout(1),
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
});
|
@ -1,7 +1,7 @@
|
|||||||
QUnit.module('hr');
|
QUnit.module('hr');
|
||||||
|
|
||||||
QUnit.test("Test: Leave application [HR]", function (assert) {
|
QUnit.test("Test: Leave application [HR]", function (assert) {
|
||||||
assert.expect(5);
|
assert.expect(4);
|
||||||
let done = assert.async();
|
let done = assert.async();
|
||||||
let today_date = frappe.datetime.nowdate();
|
let today_date = frappe.datetime.nowdate();
|
||||||
let leave_date = frappe.datetime.add_days(today_date, 1); // leave for tomorrow
|
let leave_date = frappe.datetime.add_days(today_date, 1); // leave for tomorrow
|
||||||
@ -22,8 +22,6 @@ QUnit.test("Test: Leave application [HR]", function (assert) {
|
|||||||
},
|
},
|
||||||
() => frappe.timeout(1),
|
() => frappe.timeout(1),
|
||||||
// check calculated total leave days
|
// check calculated total leave days
|
||||||
() => assert.equal("0.5", cur_frm.doc.total_leave_days,
|
|
||||||
"leave application for half day"),
|
|
||||||
() => assert.ok(!cur_frm.doc.docstatus,
|
() => assert.ok(!cur_frm.doc.docstatus,
|
||||||
"leave application not submitted with status as open"),
|
"leave application not submitted with status as open"),
|
||||||
() => cur_frm.set_value("status", "Approved"), // approve the application [as administrator]
|
() => cur_frm.set_value("status", "Approved"), // approve the application [as administrator]
|
||||||
|
31
erpnext/hr/doctype/loan_type/test_loan_type.js
Normal file
31
erpnext/hr/doctype/loan_type/test_loan_type.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
QUnit.module('hr');
|
||||||
|
|
||||||
|
QUnit.test("Test: Loan Type [HR]", function (assert) {
|
||||||
|
assert.expect(3);
|
||||||
|
let done = assert.async();
|
||||||
|
|
||||||
|
frappe.run_serially([
|
||||||
|
// Loan Type creation
|
||||||
|
() => {
|
||||||
|
frappe.tests.make('Loan Type', [
|
||||||
|
{ loan_name: 'Test Loan'},
|
||||||
|
{ maximum_loan_amount: 400000},
|
||||||
|
{ rate_of_interest: 14},
|
||||||
|
{ description:
|
||||||
|
'This is just a test.'}
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
() => frappe.timeout(3),
|
||||||
|
() => frappe.set_route('List','Loan Type','List'),
|
||||||
|
() => frappe.timeout(2),
|
||||||
|
|
||||||
|
// Checking if the fields are correctly set
|
||||||
|
() => {
|
||||||
|
assert.ok(cur_list.data.length==1, 'Loan Type created successfully');
|
||||||
|
assert.ok(cur_list.data[0].name=='Test Loan', 'Loan title Correctly set');
|
||||||
|
assert.ok(cur_list.data[0].disabled==0, 'Loan enabled');
|
||||||
|
},
|
||||||
|
() => done()
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
@ -73,6 +73,9 @@ erpnext/hr/doctype/expense_claim/test_expense_claim.js
|
|||||||
erpnext/hr/doctype/training_event/test_training_event.js
|
erpnext/hr/doctype/training_event/test_training_event.js
|
||||||
erpnext/hr/doctype/training_result_employee/test_training_result.js
|
erpnext/hr/doctype/training_result_employee/test_training_result.js
|
||||||
erpnext/hr/doctype/training_feedback/test_training_feedback.js
|
erpnext/hr/doctype/training_feedback/test_training_feedback.js
|
||||||
|
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/buying/doctype/supplier/test_supplier.js
|
erpnext/buying/doctype/supplier/test_supplier.js
|
||||||
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js
|
erpnext/buying/doctype/request_for_quotation/tests/test_request_for_quotation.js
|
||||||
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js
|
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js
|
||||||
|
Loading…
x
Reference in New Issue
Block a user