mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
Added test cased
This commit is contained in:
@@ -211,10 +211,9 @@ class SalarySlip(TransactionBase):
|
|||||||
def email_salary_slip(self):
|
def email_salary_slip(self):
|
||||||
receiver = frappe.db.get_value("Employee", self.employee, "company_email") or \
|
receiver = frappe.db.get_value("Employee", self.employee, "company_email") or \
|
||||||
frappe.db.get_value("Employee", self.employee, "personal_email")
|
frappe.db.get_value("Employee", self.employee, "personal_email")
|
||||||
|
|
||||||
if receiver:
|
if receiver:
|
||||||
subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
|
subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
|
||||||
frappe.sendmail([receiver], subject=subj, message = _("Please see attachment"),
|
frappe.sendmail([receiver], subject=subj, message = _("Please see attachment"),
|
||||||
attachments=[frappe.attach_print(self.doctype, self.name, file_name=self.name)])
|
attachments=[frappe.attach_print(self.doctype, self.name, file_name=self.name)], bulk=True)
|
||||||
else:
|
else:
|
||||||
msgprint(_("{0}: Employee email not found, hence email not sent").format(self.employee_name))
|
msgprint(_("{0}: Employee email not found, hence email not sent").format(self.employee_name))
|
||||||
|
|||||||
@@ -97,6 +97,19 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
frappe.set_user("test_employee@example.com")
|
frappe.set_user("test_employee@example.com")
|
||||||
self.assertTrue(salary_slip_test_employee.has_permission("read"))
|
self.assertTrue(salary_slip_test_employee.has_permission("read"))
|
||||||
|
|
||||||
|
def test_email_salary_slip(self):
|
||||||
|
frappe.db.sql("delete from `tabBulk Email`")
|
||||||
|
|
||||||
|
hr_settings = frappe.get_doc("HR Settings", "HR Settings")
|
||||||
|
hr_settings.email_salary_slip_to_employee = 1
|
||||||
|
hr_settings.save()
|
||||||
|
|
||||||
|
self.make_employee("test_employee@example.com")
|
||||||
|
self.make_employee_salary_slip("test_employee@example.com")
|
||||||
|
bulk_mails = frappe.db.sql("""select name from `tabBulk Email`""")
|
||||||
|
self.assertTrue(bulk_mails)
|
||||||
|
|
||||||
|
|
||||||
def make_employee(self, user):
|
def make_employee(self, user):
|
||||||
if not frappe.db.get_value("User", user):
|
if not frappe.db.get_value("User", user):
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
@@ -118,6 +131,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
"date_of_joining": "2013-01-01",
|
"date_of_joining": "2013-01-01",
|
||||||
"department": "_Test Department 1",
|
"department": "_Test Department 1",
|
||||||
"gender": "Female",
|
"gender": "Female",
|
||||||
|
"company_email": user,
|
||||||
"status": "Active"
|
"status": "Active"
|
||||||
}).insert()
|
}).insert()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user