test case
This commit is contained in:
parent
7b2870431e
commit
d73dd056d6
@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
var in_progress = false;
|
||||
|
||||
frappe.ui.form.on('Payroll Entry', {
|
||||
onload: function (frm) {
|
||||
frm.doc.posting_date = frappe.datetime.nowdate();
|
||||
@ -35,23 +37,23 @@ frappe.ui.form.on('Payroll Entry', {
|
||||
"is_group": 0,
|
||||
"company": frm.doc.company
|
||||
}
|
||||
}
|
||||
};
|
||||
}),
|
||||
frm.set_query("cost_center", function () {
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
company: frm.doc.company
|
||||
}
|
||||
frm.set_query("cost_center", function () {
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 0,
|
||||
company: frm.doc.company
|
||||
}
|
||||
}),
|
||||
frm.set_query("project", function () {
|
||||
return {
|
||||
filters: {
|
||||
company: frm.doc.company
|
||||
}
|
||||
};
|
||||
}),
|
||||
frm.set_query("project", function () {
|
||||
return {
|
||||
filters: {
|
||||
company: frm.doc.company
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
payroll_frequency: function (frm) {
|
||||
@ -63,7 +65,7 @@ frappe.ui.form.on('Payroll Entry', {
|
||||
frm.trigger("set_end_date");
|
||||
}else{
|
||||
// reset flag
|
||||
in_progress = false
|
||||
in_progress = false;
|
||||
}
|
||||
},
|
||||
|
||||
@ -71,7 +73,6 @@ frappe.ui.form.on('Payroll Entry', {
|
||||
frm.toggle_reqd(['payroll_frequency'], !frm.doc.salary_slip_based_on_timesheet);
|
||||
},
|
||||
|
||||
|
||||
set_start_end_dates: function (frm) {
|
||||
if (!frm.doc.salary_slip_based_on_timesheet) {
|
||||
frappe.call({
|
||||
@ -87,7 +88,7 @@ frappe.ui.form.on('Payroll Entry', {
|
||||
frm.set_value('end_date', r.message.end_date);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@ -109,19 +110,19 @@ frappe.ui.form.on('Payroll Entry', {
|
||||
|
||||
// Create salary slips
|
||||
|
||||
cur_frm.cscript.custom_before_submit = function (doc, cdt, cdn) {
|
||||
cur_frm.cscript.custom_before_submit = function (doc) {
|
||||
return $c('runserverobj', { 'method': 'create_salary_slips', 'docs': doc });
|
||||
}
|
||||
};
|
||||
|
||||
// Submit salary slips
|
||||
|
||||
submit_salary_slip = function (frm, cdt, cdn) {
|
||||
doc = frm.doc;
|
||||
let submit_salary_slip = function (frm) {
|
||||
var doc = frm.doc;
|
||||
return $c('runserverobj', { 'method': 'submit_salary_slips', 'docs': doc });
|
||||
}
|
||||
|
||||
make_bank_entry = function (frm, cdt, cdn) {
|
||||
doc = frm.doc;
|
||||
let make_bank_entry = function (frm) {
|
||||
var doc = frm.doc;
|
||||
if (doc.company && doc.start_date && doc.end_date) {
|
||||
return frappe.call({
|
||||
doc: cur_frm.doc,
|
||||
|
@ -112,8 +112,9 @@ class PayrollEntry(Document):
|
||||
return self.create_log(ss_list)
|
||||
|
||||
def create_log(self, ss_list):
|
||||
if not ss_list or len(ss_list) < 1:
|
||||
if not ss_list or len(ss_list) < 1:
|
||||
frappe.throw(_("No employee for the above selected criteria OR salary slip already created"))
|
||||
return
|
||||
|
||||
def get_sal_slip_list(self, ss_status, as_dict=False):
|
||||
"""
|
||||
@ -147,7 +148,7 @@ class PayrollEntry(Document):
|
||||
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]
|
||||
|
||||
|
||||
if ss_obj.net_pay<0:
|
||||
not_submitted_ss.append(ss_dict)
|
||||
else:
|
||||
@ -173,7 +174,7 @@ class PayrollEntry(Document):
|
||||
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)]
|
||||
|
||||
@ -188,9 +189,9 @@ class PayrollEntry(Document):
|
||||
where t1.docstatus = 1 and start_date >= %s and end_date <= %s %s
|
||||
""" % ('%s', '%s', cond), (self.start_date, self.end_date), as_dict=True)
|
||||
return totals[0]
|
||||
|
||||
|
||||
def get_loan_accounts(self):
|
||||
loan_accounts = frappe.get_all("Employee Loan", fields=["employee_loan_account", "interest_income_account"],
|
||||
loan_accounts = frappe.get_all("Employee Loan", fields=["employee_loan_account", "interest_income_account"],
|
||||
filters = {"company": self.company, "docstatus":1})
|
||||
if loan_accounts:
|
||||
return loan_accounts[0]
|
||||
@ -237,7 +238,7 @@ class PayrollEntry(Document):
|
||||
frappe.throw(_("Please set Default Payroll Payable Account in Company {0}")
|
||||
.format(self.company))
|
||||
|
||||
return payroll_payable_account
|
||||
return payroll_payable_account
|
||||
|
||||
def make_accural_jv_entry(self):
|
||||
self.check_permission('write')
|
||||
@ -353,7 +354,7 @@ class PayrollEntry(Document):
|
||||
frappe.db.set_value("Salary Slip", ss_obj.name, "journal_entry", jv_name)
|
||||
|
||||
def set_start_end_dates(self):
|
||||
self.update(get_start_end_dates(self.payroll_frequency,
|
||||
self.update(get_start_end_dates(self.payroll_frequency,
|
||||
self.start_date or self.posting_date, self.company))
|
||||
|
||||
@frappe.whitelist()
|
||||
@ -414,9 +415,7 @@ def get_end_date(start_date, frequency):
|
||||
def get_month_details(year, month):
|
||||
ysd = frappe.db.get_value("Fiscal Year", year, "year_start_date")
|
||||
if ysd:
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import calendar, datetime
|
||||
frappe.msgprint
|
||||
diff_mnt = cint(month)-cint(ysd.month)
|
||||
if diff_mnt<0:
|
||||
diff_mnt = 12-int(ysd.month)+cint(month)
|
||||
|
@ -1,38 +1,38 @@
|
||||
QUnit.module('HR')
|
||||
QUnit.module('HR');
|
||||
|
||||
QUnit.test("test: Payroll Entry", function (assert) {
|
||||
assert.expect(5);
|
||||
let done = assert.async();
|
||||
|
||||
frappe.run_serially([
|
||||
() => {
|
||||
() => {
|
||||
return frappe.tests.make('Payroll Entry', [
|
||||
{company: 'For Testing'},
|
||||
{posting_date: frappe.datetime.add_days(frappe.datetime.nowdate(), 0)},
|
||||
{payroll_frequency: 'Monthly'},
|
||||
// {start_date: },
|
||||
{cost_center: 'Main - '+frappe.get_abbr(frappe.defaults.get_default("Company"))}
|
||||
]);
|
||||
},
|
||||
|
||||
() => frappe.timeout(1),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.company, 'For Testing');
|
||||
assert.equal(cur_frm.doc.posting_date, frappe.datetime.add_days(frappe.datetime.nowdate(), 0));
|
||||
assert.equal(cur_frm.doc.cost_center, 'Main - FT');
|
||||
},
|
||||
|
||||
() => frappe.click_button('Submit'),
|
||||
() => frappe.timeout(1),
|
||||
() => frappe.click_button('Yes'),
|
||||
() => frappe.timeout(2),
|
||||
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.company, 'For Testing');
|
||||
assert.equal(cur_frm.doc.posting_date, frappe.datetime.add_days(frappe.datetime.nowdate(), 0));
|
||||
assert.equal(cur_frm.doc.cost_center, 'Main - FT');
|
||||
},
|
||||
|
||||
() => frappe.click_button('View Salary Slip'),
|
||||
() => frappe.timeout(2),
|
||||
() => assert.equal(cur_list.data[0].docstatus, 0),
|
||||
|
||||
() => frappe.set_route('Form', 'Payroll Entry', 'Payroll 0041'),
|
||||
() => frappe.set_route('Form', 'Payroll Entry', 'Payroll 0001'),
|
||||
() => frappe.click_button('Submit Salary Slip'),
|
||||
() => frappe.timeout(2),
|
||||
() => frappe.timeout(3),
|
||||
|
||||
() => frappe.click_button('Close'),
|
||||
() => frappe.timeout(1),
|
||||
@ -40,7 +40,7 @@ QUnit.test("test: Payroll Entry", function (assert) {
|
||||
() => frappe.click_button('View Salary Slip'),
|
||||
() => frappe.timeout(2),
|
||||
() => {
|
||||
assert.ok(cur_list.data[0].docstatus == 1, "Salary slip submitted");
|
||||
assert.ok(cur_list.data[0].docstatus == 1, "Salary slip submitted");
|
||||
},
|
||||
|
||||
() => done()
|
||||
|
@ -3,7 +3,6 @@
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
class TestPayrollEntry(unittest.TestCase):
|
||||
|
@ -78,6 +78,7 @@ 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/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
|
||||
erpnext/buying/doctype/supplier_quotation/tests/test_supplier_quotation.js
|
||||
|
Loading…
x
Reference in New Issue
Block a user