Merge pull request #53 from nabinhait/master

Sal manager email integration
This commit is contained in:
Nabin Hait 2011-08-25 04:00:07 -07:00
commit d04d7faf65
3 changed files with 72 additions and 64 deletions

View File

@ -68,9 +68,9 @@ class DocType:
emp_list = self.get_emp_list() emp_list = self.get_emp_list()
log = "" log = ""
if emp_list: if emp_list:
log = "<table><tr><td>Following Salary Slip has been created: </td></tr><tr><td><u>SAL SLIP ID</u></td><td><u>EMPLOYEE NAME</u></td></tr>" log = "<table><tr><td colspan = 2>Following Salary Slip has been created: </td></tr><tr><td><u>SAL SLIP ID</u></td><td><u>EMPLOYEE NAME</u></td></tr>"
else: else:
log = "<table><tr><td>No employee found for the above selected criteria</td></tr>" log = "<table><tr><td colspan = 2>No employee found for the above selected criteria</td></tr>"
for emp in emp_list: for emp in emp_list:
if not sql("""select name from `tabSalary Slip` if not sql("""select name from `tabSalary Slip`
@ -119,9 +119,17 @@ class DocType:
ss_list = self.get_sal_slip_list() ss_list = self.get_sal_slip_list()
log = "" log = ""
if ss_list: if ss_list:
log = "<table><tr><td>Following Salary Slip has been submitted: </td></tr><tr><td><u>SAL SLIP ID</u></td><td><u>EMPLOYEE NAME</u></td></tr>" log = """<table>
<tr>
<td colspan = 2>Following Salary Slip has been submitted: </td>
</tr>
<tr>
<td><u>SAL SLIP ID</u></td>
<td><u>EMPLOYEE NAME</u></td>
</tr>
"""
else: else:
log = "<table><tr><td>No salary slip found to submit for the above selected criteria</td></tr>" log = "<table><tr><td colspan = 2>No salary slip found to submit for the above selected criteria</td></tr>"
for ss in ss_list: for ss in ss_list:
ss_obj = get_obj("Salary Slip",ss[0],with_children=1) ss_obj = get_obj("Salary Slip",ss[0],with_children=1)

View File

@ -57,7 +57,7 @@ class TestSalarySlip(unittest.TestCase):
self.assertTrue(ss[0][0]==67) self.assertTrue(ss[0][0]==67)
def test_submit(self): def test_submit(self):
self.sm.submit_sal_slip() self.sm.submit_salary_slip()
ss = webnotes.conn.sql(""" ss = webnotes.conn.sql("""
select docstatus select docstatus
from `tabSalary Slip` from `tabSalary Slip`
@ -112,7 +112,8 @@ emp1 = Document(fielddata={
'grade':'grade1', 'grade':'grade1',
'naming_series':'EMP/', 'naming_series':'EMP/',
'status':'Active', 'status':'Active',
'docstatus':0 'docstatus':0,
'employee_name':'emp1'
}) })
emp2 = Document(fielddata={ emp2 = Document(fielddata={
@ -135,7 +136,8 @@ ss1 = [
'employee':'emp1', 'employee':'emp1',
'is_active':'Yes', 'is_active':'Yes',
'department': 'dep1', 'department': 'dep1',
'designation' : 'des1' 'designation' : 'des1',
'employee_name': 'emp1'
}), }),
Document(fielddata={ Document(fielddata={
'parenttype':'Salary Structure', 'parenttype':'Salary Structure',

View File

@ -175,9 +175,9 @@ class DocType(TransactionBase):
emailid_ret=sql("select company_email from `tabEmployee` where name = '%s'"%self.doc.employee) emailid_ret=sql("select company_email from `tabEmployee` where name = '%s'"%self.doc.employee)
if emailid_ret: if emailid_ret:
receiver = cstr(emailid_ret[0][0]) receiver = cstr(emailid_ret[0][0])
subj = 'Salary Slip ' + cstr(self.doc.month) +' '+cstr(self.doc.year) subj = 'Salary Slip - ' + cstr(self.doc.month) +'/'+cstr(self.doc.fiscal_year)
earn_ret=sql("select e_type,e_amount from `tabSS Earning Detail` where parent = '%s'"%self.doc.name) earn_ret=sql("select e_type,e_modified_amount from `tabSS Earning Detail` where parent = '%s'"%self.doc.name)
ded_ret=sql("select d_type,d_amount from `tabSS Deduction Detail` where parent = '%s'"%self.doc.name) ded_ret=sql("select d_type,d_modified_amount from `tabSS Deduction Detail` where parent = '%s'"%self.doc.name)
earn_table = '' earn_table = ''
ded_table = '' ded_table = ''
@ -207,62 +207,60 @@ class DocType(TransactionBase):
if not letter_head: if not letter_head:
letter_head = '' letter_head = ''
msg = ''' %s <br> msg = '''<div> %s <br>
<table cellspacing= "5" cellpadding="5" width = "100%%">
<tr>
<td colspan = 4 width = "100%%"><h4>Salary Slip</h4></td>
</tr>
<tr>
<td colspan = 2 width = "50%%"><b>Employee Code : %s</b></td>
<td colspan = 2 width = "50%%"><b>Employee Name : %s</b></td>
</tr>
<tr>
<td colspan = 2 width = "50%%">Month : %s</td>
<td colspan = 2 width = "50%%">Fiscal Year : %s</td>
</tr>
</table>
<table cellspacing= "5" cellpadding="5" > <table cellspacing= "5" cellpadding="5" >
<tr> <tr>
<td colspan = 4><h4>Salary Slip</h4></td> <td>Department : %s</td>
</tr> <td>Branch : %s</td>
<tr> <td colspan = 2>Designation : %s</td>
<td colspan = 2><b>Employee Code : %s</b></td> </tr>
<td colspan = 2><b>Employee Name : %s</b></td> <tr>
</tr> <td>Grade : %s</td>
<tr> <td>Bank Account No. : %s</td>
<td>Month : %s</td> <td colspan = 2>Bank Name : %s</td>
<td>Year : %s</td>
<td colspan = 2>Fiscal Year : %s</td>
</tr>
<tr>
<td>Department : %s</td>
<td>Branch : %s</td>
<td colspan = 2>Designation : %s</td>
</tr> </tr>
<tr> <tr>
<td>Grade : %s</td> <td colspan = 2>Arrear Amount : <b>%s</b></td>
<td>Bank Account No. : %s</td> <td colspan = 2>Payment days : %s</td>
<td colspan = 2>Bank Name : %s</td>
</tr> </tr>
<tr> </table>
<td>PF No. : %s</td> <table border="1px solid #CCC" width="100%%" cellpadding="0" cellspacing= "0" >
<td>ESIC No. : %s</td> <tr>
<td colspan = 2>Arrear Amount : <b>%s</b></td> <td colspan = 2 width = "50%%"><b>Earning</b></td>
</tr> <td colspan = 2 width = "50%%"><b>Deduction</b></td>
<tr> </tr>
<td>Total days in month : %s</td> <tr>
<td>Leave Without Pay : %s</td> <td colspan = 2 width = "50%%">%s</td>
<td colspan = 2>Payment days : %s</td> <td colspan = 2 width = "50%%">%s</td>
</tr>
</tr> </table>
<br><br> <table cellspacing= "5" cellpadding="5">
<tr> <tr>
<td colspan = 2><b>Earning</b></td> <td colspan = 2><b>Gross Pay :</b> %s</td>
<td colspan = 2><b>Deduction</b></td> <td colspan = 2><b>Total Deduction :</b> %s</td>
</tr> </tr>
<tr> <tr>
<td colspan = 2>%s</td> <td><b>Net Pay : %s</b></td>
<td colspan = 2>%s</td> </tr>
</tr> <tr>
<br> <td><b>Net Pay(in words) : %s</b></td>
<tr> </tr>
<td colspan = 2><b>Gross Pay :</b> %s</td> </table></div>'''%(cstr(letter_head[0][0]),cstr(self.doc.employee), cstr(self.doc.employee_name), cstr(self.doc.month), cstr(self.doc.fiscal_year), cstr(self.doc.department), cstr(self.doc.branch), cstr(self.doc.designation), cstr(self.doc.grade), cstr(self.doc.bank_account_no), cstr(self.doc.bank_name), cstr(self.doc.arrear_amount), cstr(self.doc.payment_days), earn_table, ded_table, cstr(self.doc.gross_pay), cstr(self.doc.total_deduction), cstr(self.doc.net_pay), cstr(self.doc.total_in_words))
<td colspan = 2><b>Total Deduction :</b> %s</td> sendmail([receiver], sender='automail@erpnext.com', subject=subj, parts=[['text/plain', msg]])
</tr>
<tr>
<td><b>Net Pay : %s</b></td>
<td colspan = 3><b>Net Pay (in words) : %s</b></td>
</tr>
</table>'''%(cstr(letter_head[0][0]),cstr(self.doc.employee),self.doc.employee_name,cstr(self.doc.month),cstr(self.doc.year),cstr(self.doc.fiscal_year),self.doc.department,self.doc.branch,self.doc.designation,self.doc.grade,cstr(self.doc.bank_account_no),self.doc.bank_name,cstr(self.doc.pf_no),cstr(self.doc.esic_no),cstr(self.doc.arrear_amount),cstr(self.doc.total_days_in_month),cstr(self.doc.leave_without_pay),cstr(self.doc.payment_days),earn_table,ded_table,cstr(self.doc.gross_pay),cstr(self.doc.total_deduction),cstr(self.doc.net_pay),cstr(self.doc.net_pay_in_words))
sendmail([receiver], sender='automail@webnotestech.com', subject=subj, parts=[['text/plain', msg]])
else: else:
msgprint("Company Email ID not found.") msgprint("Company Email ID not found.")