Merge pull request #52 from nabinhait/master

Salary Manager Launched
diff --git a/accounts/doctype/loan/__init__.py b/accounts/doctype/loan/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/accounts/doctype/loan/__init__.py
+++ /dev/null
diff --git a/accounts/doctype/loan/loan.js b/accounts/doctype/loan/loan.js
deleted file mode 100644
index 5a45362..0000000
--- a/accounts/doctype/loan/loan.js
+++ /dev/null
@@ -1,54 +0,0 @@
-$.extend(cur_frm.cscript, {
-	Generate: function(doc, dt, dn) {
-		cur_frm.cscript.clear_installments(doc);
-		for(var i=0; i< doc.no_of_installments; i++) {
-			d = LocalDB.add_child(doc, 'Loan Installment', 'installments');
-			d.amount = doc.loan_amount / doc.no_of_installments;
-			d.due_date = dateutil.add_months(doc.start_date, i+1);
-		}
-		cur_frm.refresh();
-	},
-/*	submit:function(doc){
-		data=doc.get_values();
-
-		data['']=
-		$c_obj(make_doclist(dt,dn),'loan_post',data,function(){});
-	},*/
-	refresh: function(doc) {
-		cur_frm.cscript.hide_show_buttons(doc);
-	},
-	hide_show_buttons: function(doc) {
-		if(doc.docstatus==0) {
-			hide_field('Installment Reciept'); unhide_field('Generate');
-		} else if (doc.docstatus==1) {
-			unhide_field('Installment Reciept');hide_field('Generate');
-		}
-	},
-	clear_installments: function(doc) {
-		$.each(getchildren('Loan Installment', doc.name, 'installments', 'Loan'),
-			function(i, d) {
-				LocalDB.delete_doc('Loan Installment', d.name);
-			}
-		)
-	},
-	'Installment Reciept': function(doc, dt, dn) {
-		var d = new wn.widgets.Dialog({
-			width: 500,
-			title: 'Add a new payment installment',
-			fields: [
-				{fieldtype:'Data', label:'Cheque Number', fieldname:'cheque_number', reqd:1},
-				{fieldtype:'Date', label:'Cheque Date', fieldname:'cheque_date', reqd:1},
-				{fieldtype:'Link', label:'Bank Account', fieldname:'bank_account', reqd:1, options:'Account'},
-				{fieldtype:'Button', label:'Update',fieldname:'update'}
-			]
-		})
-		d.show();
-		d.fields_dict.update.input.onclick = function() {
-			var data = d.get_values();
-
-			if(data) {
-				$c_obj(make_doclist(dt,dn),'loan_installment_post',data,function(){cur_frm.refresh(); d.hide();});
-			}
-		}
-	}
-})
diff --git a/accounts/doctype/loan/loan.py b/accounts/doctype/loan/loan.py
deleted file mode 100644
index 9f0bcb5..0000000
--- a/accounts/doctype/loan/loan.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import webnotes
-from webnotes.model.doc import make_autoname, Document, addchild
-from webnotes import msgprint
-from webnotes.utils import get_defaults
-import json
-from accounts.utils import post_jv
-sql = webnotes.conn.sql
-
-class DocType:
-	def __init__(self, doc, doclist):
-		self.doc, self.doclist = doc, doclist
-
-	def autoname(self):
-		"""
-			Create Loan Id using naming_series pattern
-		"""
-		self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
-
-	def loan_post(self):
-		data['voucher_type']='Loan Issue'
-		data['naming_series']='JV'
-		data['fiscal_year'] = get_defaults()['fiscal_year'] # To be modified to take care
-		data['company'] = get_defaults()['company']
-		data['debit_account'] = self.doc['receivable_account']
-		data['credit_account'] = self.doc['account']
-		data['amount'] = self.doc.loan_amount
-		jv_name=post_jv(data)
-
-	def loan_installment_post(self, args):
-		"""
-			Posts the loan receipt into Journal Voucher
-		"""
-		next_inst = sql("select amount,name from `tabLoan Installment` where parent=%s and ifnull(cheque_number,'')='' order by due_date limit 1",self.doc.name)
-
-		data = json.loads(args)
-		data['voucher_type']='Loan Receipt'
-		data['naming_series']='JV'
-		data['amount']=next_inst[0][0]
-		data['debit_account']=data.get('bank_account')
-		data['credit_account']=self.doc.account
-		data['fiscal_year']=get_defaults()['fiscal_year']
-		data['company']=get_defaults()['company']
-		jv_name=post_jv(data)
-
-		sql("update `tabLoan Installment` set cheque_number=%s, cheque_date=%s, jv_number=%s where name=%s",(data.get('cheque_number'),data.get('cheque_date'),jv_name,next_inst[0][1]))
-
-		self.doclist = [Document(d.doctype, d.name) for d in self.doclist]
-
diff --git a/accounts/doctype/loan/loan.txt b/accounts/doctype/loan/loan.txt
deleted file mode 100644
index 001e1d3..0000000
--- a/accounts/doctype/loan/loan.txt
+++ /dev/null
@@ -1,172 +0,0 @@
-# DocType, Loan
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2011-07-15 10:35:26',
-		'docstatus': 0,
-		'modified': '2011-07-18 12:12:19',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'_last_update': '1310963215',
-		'colour': 'White:FFF',
-		'doctype': 'DocType',
-		'module': 'Accounts',
-		'name': '__common__',
-		'section_style': 'Simple',
-		'show_in_menu': 0,
-		'version': 15
-	},
-
-	# These values are common for all DocField
-	{
-		'doctype': 'DocField',
-		'name': '__common__',
-		'parent': 'Loan',
-		'parentfield': 'fields',
-		'parenttype': 'DocType',
-		'permlevel': 0
-	},
-
-	# These values are common for all DocPerm
-	{
-		'doctype': 'DocPerm',
-		'name': '__common__',
-		'parent': 'Loan',
-		'parentfield': 'permissions',
-		'parenttype': 'DocType',
-		'read': 1,
-		'role': 'Accounts User'
-	},
-
-	# DocType, Loan
-	{
-		'doctype': 'DocType',
-		'name': 'Loan'
-	},
-
-	# DocPerm
-	{
-		'cancel': 1,
-		'create': 1,
-		'doctype': 'DocPerm',
-		'idx': 1,
-		'permlevel': 0,
-		'submit': 1,
-		'write': 1
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 2,
-		'permlevel': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'naming_series',
-		'fieldtype': 'Select',
-		'idx': 1,
-		'label': 'Naming Series',
-		'options': '\nLOAN',
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'account',
-		'fieldtype': 'Link',
-		'idx': 2,
-		'label': 'Account',
-		'options': 'Account',
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'receivable_account',
-		'fieldtype': 'Link',
-		'idx': 3,
-		'label': 'Receivable Account',
-		'options': 'Account'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'invoice',
-		'fieldtype': 'Link',
-		'idx': 4,
-		'label': 'Invoice',
-		'options': 'Receivable Voucher',
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'loan_amount',
-		'fieldtype': 'Currency',
-		'idx': 5,
-		'label': 'Loan Amount',
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'start_date',
-		'fieldtype': 'Date',
-		'idx': 6,
-		'label': 'Start Date',
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'no_of_installments',
-		'fieldtype': 'Int',
-		'idx': 7,
-		'label': 'No of Installments',
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 8,
-		'label': 'Generate',
-		'trigger': 'Client'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'installments',
-		'fieldtype': 'Table',
-		'idx': 9,
-		'label': 'Installments',
-		'options': 'Loan Installment'
-	},
-
-	# DocField
-	{
-		'allow_on_submit': 1,
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 10,
-		'label': 'Installment Reciept'
-	}
-]
\ No newline at end of file
diff --git a/accounts/doctype/loan/test_loan.py b/accounts/doctype/loan/test_loan.py
deleted file mode 100644
index 4e72559..0000000
--- a/accounts/doctype/loan/test_loan.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import unittest
-import webnotes
-from webnotes.model.code import get_obj
-
-class TestScheduleGeneartion(unittest.TestCase):
-	def setUp(self):
-		webnotes.conn.begin()
-		# create a mock loan
-		self.loan = get_obj('Loan', 'LOAN00001')
-		
-	def test_generation(self):
-		"test the genaration of loan installments"
-		self.loan.generate()
-		self.assertEqual(self.loan.get_installment_total(), self.loan.doc.loan_amount)
-		
-	def tearDown(self):
-		webnotes.conn.rollback()
diff --git a/accounts/doctype/loan_installment/__init__.py b/accounts/doctype/loan_installment/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/accounts/doctype/loan_installment/__init__.py
+++ /dev/null
diff --git a/accounts/doctype/loan_installment/loan_installment.txt b/accounts/doctype/loan_installment/loan_installment.txt
deleted file mode 100644
index f729e34..0000000
--- a/accounts/doctype/loan_installment/loan_installment.txt
+++ /dev/null
@@ -1,111 +0,0 @@
-# DocType, Loan Installment
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2011-07-15 10:36:42',
-		'docstatus': 0,
-		'modified': '2011-07-15 15:48:34',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocType',
-		'istable': 1,
-		'module': 'Accounts',
-		'name': '__common__',
-		'section_style': 'Simple',
-		'show_in_menu': 0,
-		'version': 4
-	},
-
-	# These values are common for all DocField
-	{
-		'doctype': 'DocField',
-		'name': '__common__',
-		'parent': 'Loan Installment',
-		'parentfield': 'fields',
-		'parenttype': 'DocType'
-	},
-
-	# DocType, Loan Installment
-	{
-		'doctype': 'DocType',
-		'name': 'Loan Installment'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'amount',
-		'fieldtype': 'Currency',
-		'idx': 1,
-		'label': 'Amount',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'due_date',
-		'fieldtype': 'Date',
-		'idx': 2,
-		'label': 'Due Date',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'cheque_number',
-		'fieldtype': 'Data',
-		'idx': 3,
-		'label': 'Cheque Number',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'cheque_date',
-		'fieldtype': 'Date',
-		'idx': 4,
-		'label': 'Cheque Date',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'deposit_date',
-		'fieldtype': 'Date',
-		'idx': 5,
-		'label': 'Deposit Date',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'realized_date',
-		'fieldtype': 'Date',
-		'idx': 6,
-		'label': 'Realized Date',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'jv_number',
-		'fieldtype': 'Link',
-		'hidden': 0,
-		'idx': 7,
-		'label': 'JV Number',
-		'options': 'Journal Voucher',
-		'permlevel': 1
-	}
-]
\ No newline at end of file
diff --git a/hr/Module Def/HR/HR.txt b/hr/Module Def/HR/HR.txt
index 5ad5e54..212d689 100644
--- a/hr/Module Def/HR/HR.txt
+++ b/hr/Module Def/HR/HR.txt
@@ -1,603 +1,318 @@
+# Module Def, HR
 [
+
+	# These values are common in all dictionaries
 	{
-		'_last_update': None,
-		'creation': '2011-06-30 15:51:33',
-		'disabled': 'No',
+		'creation': '2011-07-01 17:41:43',
 		'docstatus': 0,
-		'doctype': u'Module Def',
-		'doctype_list': None,
-		'file_list': None,
-		'idx': None,
-		'is_hidden': 'No',
-		'last_updated_date': None,
-		'modified': '2011-06-30 15:51:33',
+		'modified': '2011-08-25 13:54:43',
 		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all Module Def Role
+	{
+		'doctype': 'Module Def Role',
+		'name': '__common__',
+		'parent': 'HR',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def'
+	},
+
+	# These values are common for all Module Def Item
+	{
+		'doctype': 'Module Def Item',
+		'name': '__common__',
+		'parent': 'HR',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+
+	# These values are common for all Module Def
+	{
+		'disabled': 'No',
+		'doctype': u'Module Def',
+		'is_hidden': 'No',
 		'module_desc': 'Human Resource Management - Employee Database, Salaries etc.',
 		'module_icon': 'HR.gif',
 		'module_label': 'HR',
 		'module_name': 'HR',
-		'module_page': None,
 		'module_seq': 9,
-		'name': 'HR',
-		'owner': 'Administrator',
-		'parent': None,
-		'parentfield': None,
-		'parenttype': None,
-		'trash_reason': None,
-		'widget_code': None
+		'name': '__common__'
 	},
+
+	# Module Def, HR
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
+		'doctype': u'Module Def',
+		'name': 'HR'
+	},
+
+	# Module Def Item
+	{
 		'description': 'Your Employee Database',
 		'display_name': 'Employee',
 		'doc_name': 'Employee',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'employee_name\nemployment_type\nstatus\nbranch\ndesignation\ndepartment\ngrade\nreports_to',
-		'hide': None,
-		'icon': None,
-		'idx': 1,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01335',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 1
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Employees Daily Attendance Tracking Form',
 		'display_name': 'Attendance',
 		'doc_name': 'Attendance',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'employee\nemployee_name\nstatus\natt_date\nfiscal_year\ncompany',
-		'hide': None,
-		'icon': None,
-		'idx': 2,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01336',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 2
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Upload Attendance data',
 		'display_name': 'Attendance Control Panel',
 		'doc_name': 'Attendance Control Panel',
 		'doc_type': 'Single DocType',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 3,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01337',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 3
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Leave allocation for selected employees at a time',
 		'display_name': 'Leave Control Panel',
 		'doc_name': 'Leave Control Panel',
 		'doc_type': 'Single DocType',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 4,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01338',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 4
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Allocate leave for fiscal year',
 		'display_name': 'Leave Allocation',
 		'doc_name': 'Leave Allocation',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'employee\nleave_type\nfiscal_year\ntotal_leaves_allocated\nposting_date',
-		'hide': None,
-		'icon': None,
-		'idx': 5,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01339',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 5
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Apply Leave',
 		'display_name': 'Leave Application',
 		'doc_name': 'Leave Application',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'employee\nleave_type\nfiscal_year\nfrom_date\nto_date\ntotal_leave_days',
-		'hide': None,
-		'icon': None,
-		'idx': 6,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01340',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 6
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Submit Employees Expenses',
 		'display_name': 'Expense Voucher',
 		'doc_name': 'Expense Voucher',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'status\nemployee\nemployee_name\nposting_date\ntotal_claimed_amount\ntotal_sanctioned_amount\nexp_approver',
-		'hide': None,
-		'icon': None,
-		'idx': 7,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01341',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 7
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Assign Responsibilities to employee and evaluate',
 		'display_name': 'Appraisal',
 		'doc_name': 'Appraisal',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'status\nemployee\nemployee_name\nstart_date\nend_date\ntotal_score\nkra_approver',
-		'hide': None,
-		'icon': None,
-		'idx': 8,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01342',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 8
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Generate Salary Structure heads for an employee',
 		'display_name': 'Salary Structure',
 		'doc_name': 'Salary Structure',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'employee\nis_active\nfiscal_year\nfrom_date\nctc\ntotal_earning\ntotal_deduction\ntotal',
-		'hide': None,
-		'icon': None,
-		'idx': 9,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01343',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 9
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Generate Salary Slip for an employee',
 		'display_name': 'Salary Slip',
 		'doc_name': 'Salary Slip',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'month\nyear\nemployee\nemployee_name\npayment_days\narrear_amount\nencashment_amount\ngross_pay\ntotal_deduction\nnet_pay',
-		'hide': None,
-		'icon': None,
-		'idx': 10,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01344',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 10
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
-		'description': 'Generate Salary Slip for all employee at a time',
-		'display_name': 'Salary Slip Control Panel',
-		'doc_name': 'Salary Slip Control Panel',
+		'description': 'Generate Salary Slip for multiple employee at a time based on selected criteria',
+		'display_name': 'Salary Manager',
+		'doc_name': 'Salary Manager',
 		'doc_type': 'Single DocType',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 11,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01345',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 11
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
 		'description': 'Job Applications received for various positions',
 		'display_name': 'Job Application',
 		'doc_name': 'Job Application',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
 		'fields': 'applicant_name\nemail\nposition',
-		'hide': None,
-		'icon': None,
-		'idx': 12,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01346',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 12
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
-		'description': None,
 		'display_name': 'Employee Information',
 		'doc_name': 'Employee',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 13,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01347',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 13
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
-		'description': None,
 		'display_name': "Employee's Birthday",
 		'doc_name': 'Employee',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 14,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01348',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 14
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
-		'description': None,
 		'display_name': 'New or left employees for a month',
 		'doc_name': 'Employee',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 15,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01349',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 15
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
-		'description': None,
 		'display_name': 'Monthly Attendance Details',
 		'doc_name': 'Attendance',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 16,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01350',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 16
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:33',
-		'description': None,
 		'display_name': 'Leave Application Details',
 		'doc_name': 'Leave Application',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 17,
-		'modified': '2011-06-30 15:51:33',
-		'modified_by': 'Administrator',
-		'name': 'MDI01351',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 17
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Leave Allocation Details',
 		'doc_name': 'Leave Allocation',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 18,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01352',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 18
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Employee Leave Balance Report',
 		'doc_name': 'Employee',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 19,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01353',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 19
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Salary Structure Details',
 		'doc_name': 'Salary Structure',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 20,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01354',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 20
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Salary Register',
 		'doc_name': 'Salary Slip',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 21,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01355',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 21
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Salary Slips',
 		'doc_name': 'Salary Slip',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 22,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01356',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 22
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Pending Appraisals',
 		'doc_name': 'Appraisal',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 23,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01357',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 23
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Employee Appraisals',
 		'doc_name': 'Appraisal',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 24,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01358',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 24
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Pending Expense Vouchers',
 		'doc_name': 'Expense Voucher',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 25,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01359',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 25
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:51:34',
-		'description': None,
 		'display_name': 'Expense Vouchers',
 		'doc_name': 'Expense Voucher',
 		'doc_type': 'Reports',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 26,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDI01360',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'idx': 26
 	},
+
+	# Module Def Role
 	{
-		'creation': '2011-06-30 15:51:34',
-		'docstatus': 0,
 		'doctype': 'Module Def Role',
 		'idx': 1,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDR00340',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'roles',
-		'parenttype': 'Module Def',
 		'role': 'HR Manager'
 	},
+
+	# Module Def Role
 	{
-		'creation': '2011-06-30 15:51:34',
-		'docstatus': 0,
 		'doctype': 'Module Def Role',
 		'idx': 2,
-		'modified': '2011-06-30 15:51:34',
-		'modified_by': 'Administrator',
-		'name': 'MDR00341',
-		'owner': 'Administrator',
-		'parent': 'HR',
-		'parentfield': 'roles',
-		'parenttype': 'Module Def',
 		'role': 'HR User'
 	}
 ]
\ No newline at end of file
diff --git a/hr/doctype/salary_manager/__init__.py b/hr/doctype/salary_manager/__init__.py
new file mode 100644
index 0000000..cb6c600
--- /dev/null
+++ b/hr/doctype/salary_manager/__init__.py
@@ -0,0 +1,4 @@
+from webnotes import ValidationError
+
+class SalarySlipExistsError(ValidationError): pass
+
diff --git a/hr/doctype/salary_manager/salary_manager.js b/hr/doctype/salary_manager/salary_manager.js
new file mode 100644
index 0000000..cf470be
--- /dev/null
+++ b/hr/doctype/salary_manager/salary_manager.js
@@ -0,0 +1,67 @@
+var display_activity_log = function(msg) {
+	if(!pscript.ss_html)
+		pscript.ss_html = $a(cur_frm.fields_dict['Activity Log'].wrapper,'div','',{border:'1px solid #CCC', backgroundColor:'#CCC'});
+	pscript.ss_html.innerHTML = '<div style="color:#EEE; background-color:#555;"><b><i>Activity Log:</i><br></b></div>';
+	pscript.ss_html.innerHTML += '<div style="color:#666; padding: 5px">'+ msg + '</div>';
+}
+
+//Create salary slip
+//-----------------------
+cur_frm.cscript['Create Salary Slip'] = function(doc, cdt, cdn) {
+	var callback = function(r, rt){
+		if (r.message)
+			display_activity_log(r.message);
+	}
+	$c('runserverobj', args={'method':'create_sal_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback);
+}
+
+
+
+//Submit salary slip
+//-----------------------
+cur_frm.cscript['Submit Salary Slip'] = function(doc, cdt, cdn) {
+	var check = confirm("Do you really want to Submit all Salary Slip for month : " + doc.month+" and fiscal year : "+doc.fiscal_year);
+	if(check){
+		var callback = function(r, rt){
+			if (r.message)
+				display_activity_log(r.message);
+		}
+		$c('runserverobj', args={'method':'submit_salary_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback);
+	}
+}
+
+// Make Bank Voucher
+//-----------------------
+cur_frm.cscript['Make Bank Voucher'] = function(doc,cdt,cdn){
+  if(doc.month && doc.fiscal_year){
+  	cur_frm.cscript.make_jv(doc, cdt, cdn);
+  }
+}
+
+
+// Make JV
+//-----------------------
+cur_frm.cscript.make_jv = function(doc, dt, dn) {
+	var call_back = function(r,rt){
+		var jv = LocalDB.create('Journal Voucher');
+		jv = locals['Journal Voucher'][jv];
+		jv.voucher_type = 'Bank Voucher';
+		jv.user_remark = 'Payment of salary for the month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year;
+		jv.fiscal_year = doc.fiscal_year;
+		jv.company = doc.company;
+		jv.posting_date = dateutil.obj_to_str(new Date());
+
+		// credit to bank
+		var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
+		d1.account = r.message['default_bank_account'];
+		d1.credit = r.message['amount']
+
+		// debit to salary account
+		var d2 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
+		d2.account = r.message['default_salary_account'];
+		d2.debit = r.message['amount']
+
+		loaddoc('Journal Voucher', jv.name);
+	}
+	$c_obj(make_doclist(dt,dn),'get_acc_details','',call_back);
+}
diff --git a/hr/doctype/salary_manager/salary_manager.py b/hr/doctype/salary_manager/salary_manager.py
new file mode 100644
index 0000000..ec8fba2
--- /dev/null
+++ b/hr/doctype/salary_manager/salary_manager.py
@@ -0,0 +1,164 @@
+# Please edit this list and import only required elements
+import webnotes
+
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
+
+set = webnotes.conn.set
+sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+in_transaction = webnotes.conn.in_transaction
+convert_to_lists = webnotes.conn.convert_to_lists
+	
+# -----------------------------------------------------------------------------------------
+
+
+class DocType:
+	def __init__(self, doc, doclist):
+		self.doc = doc
+		self.doclist = doclist
+		
+		
+	def get_emp_list(self):
+		"""
+			Returns list of active employees based on selected criteria 
+			and for which salary structure exists		
+		"""
+		
+		cond = self.get_filter_condition()
+		
+		emp_list = sql("""
+			select t1.name
+			from `tabEmployee` t1, `tabSalary Structure` t2 
+			where t1.docstatus!=2 and t2.docstatus != 2 
+			and ifnull(t1.status, 'Left') = 'Active' and ifnull(t2.is_active, 'No') = 'Yes' 
+			and t1.name = t2.employee
+		%s """% cond)
+
+		return emp_list
+		
+		
+	def get_filter_condition(self):
+		self.check_mandatory()
+		
+		cond = ''
+		for f in ['company', 'branch', 'department', 'designation', 'grade', 'employment_type']:
+			if self.doc.fields.get(f):
+				cond += " and t1." + f + " = '" + self.doc.fields.get(f) + "'"
+				
+		return cond
+		
+		
+	def check_mandatory(self):
+		for f in ['company', 'month', 'fiscal_year']:
+			if not self.doc.fields[f]:
+				msgprint("Please select %s to proceed" % f, raise_exception=1)
+		
+		
+	def create_sal_slip(self):
+		"""
+			Creates salary slip for selected employees if already not created
+		
+		"""
+		
+		emp_list = self.get_emp_list()
+		log = ""
+		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>"
+		else:
+			log = "<table><tr><td>No employee found for the above selected criteria</td></tr>"
+			
+		for emp in emp_list:
+			if not sql("""select name from `tabSalary Slip` 
+					where docstatus!= 2 and employee = %s and month = %s and fiscal_year = %s and company = %s
+					""", (emp[0], self.doc.month, self.doc.fiscal_year, self.doc.company)):
+				ss = Document('Salary Slip')
+				ss.fiscal_year = self.doc.fiscal_year
+				ss.employee = emp[0]
+				ss.month = self.doc.month
+				ss.email_check = self.doc.send_email
+				ss.company = self.doc.company
+				ss.save(1)
+			
+				ss_obj = get_obj('Salary Slip', ss.name, with_children=1)
+				ss_obj.get_emp_and_leave_details()
+				ss_obj.calculate_net_pay()
+				ss_obj.validate()
+				ss_obj.doc.save()
+			
+				for d in getlist(ss_obj.doclist, 'earning_details'):
+					d.save()
+				for d in getlist(ss_obj.doclist, 'deduction_details'):
+					d.save()
+					
+				log += '<tr><td>' + ss.name + '</td><td>' + ss_obj.doc.employee_name + '</td></tr>'
+		log += '</table>'
+		return log	
+				
+	def get_sal_slip_list(self):
+		"""
+			Returns list of salary slips based on selected criteria
+			which are not submitted
+		"""
+		cond = self.get_filter_condition()
+		ss_list = sql("""
+			select t1.name from `tabSalary Slip` t1 
+			where t1.docstatus = 0 and month = '%s' and fiscal_year = '%s' %s
+		""" % (self.doc.month, self.doc.fiscal_year, cond))
+		return ss_list
+			
+				
+	def submit_salary_slip(self):
+		"""
+			Submit all salary slips based on selected criteria
+		"""
+		ss_list = self.get_sal_slip_list()
+		log = ""
+		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>"
+		else:
+			log = "<table><tr><td>No salary slip found to submit for the above selected criteria</td></tr>"
+			
+		for ss in ss_list:
+			ss_obj = get_obj("Salary Slip",ss[0],with_children=1)
+			set(ss_obj.doc, 'docstatus', 1)
+			ss_obj.on_submit()
+			
+			log += '<tr><td>' + ss[0] + '</td><td>' + ss_obj.doc.employee_name + '</td></tr>'
+		log += '</table>'	
+		return log	
+			
+			
+	def get_total_salary(self):
+		"""
+			Get total salary amount from submitted salary slip based on selected criteria
+		"""
+		cond = self.get_filter_condition()
+		tot = sql("""
+			select sum(rounded_total) from `tabSalary Slip` t1 
+			where t1.docstatus = 1 and month = '%s' and fiscal_year = '%s' %s
+		""" % (self.doc.month, self.doc.fiscal_year, cond))
+		
+		return flt(tot[0][0])
+		
+		
+	def get_acc_details(self):
+		"""
+			get default bank account,default salary acount from company
+		"""
+		amt = self.get_total_salary()
+		com = sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company)
+		
+		if not com[0][0] or not com[0][1]:
+			msgprint("You can set Default Bank Account in Company master.")
+
+		ret = {
+			'def_bank_acc' : com and com[0][0] or '',
+			'def_sal_acc' : com and com[0][1] or '',
+			'amount' : amt
+		}
+		return ret
diff --git a/hr/doctype/salary_manager/salary_manager.txt b/hr/doctype/salary_manager/salary_manager.txt
new file mode 100644
index 0000000..66a7282
--- /dev/null
+++ b/hr/doctype/salary_manager/salary_manager.txt
@@ -0,0 +1,287 @@
+# DocType, Salary Manager
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2011-08-11 16:40:04',
+		'docstatus': 0,
+		'modified': '2011-08-25 12:02:57',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'_last_update': '1314179318',
+		'allow_copy': 1,
+		'allow_email': 1,
+		'allow_print': 1,
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'document_type': 'Other',
+		'issingle': 1,
+		'module': 'HR',
+		'name': '__common__',
+		'section_style': 'Simple',
+		'show_in_menu': 1,
+		'version': 29
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'name': '__common__',
+		'parent': 'Salary Manager',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# These values are common for all DocPerm
+	{
+		'create': 1,
+		'doctype': 'DocPerm',
+		'name': '__common__',
+		'parent': 'Salary Manager',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'write': 1
+	},
+
+	# DocType, Salary Manager
+	{
+		'doctype': 'DocType',
+		'name': 'Salary Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'role': 'System Manager'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 2,
+		'role': 'HR User'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm',
+		'idx': 3,
+		'role': 'HR Manager'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 1,
+		'label': 'Document Description',
+		'options': '<div class="field_description">You can generate multiple salary slips based on the selected criteria, submit and mail those to the employee directly from here</div>'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 2
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 3,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'company',
+		'fieldtype': 'Select',
+		'idx': 4,
+		'label': 'Company',
+		'options': 'link:Company',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'branch',
+		'fieldtype': 'Link',
+		'idx': 5,
+		'label': 'Branch',
+		'options': 'Branch'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'department',
+		'fieldtype': 'Link',
+		'idx': 6,
+		'label': 'Department',
+		'options': 'Department'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'designation',
+		'fieldtype': 'Link',
+		'idx': 7,
+		'label': 'Designation',
+		'options': 'Designation'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 8,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'grade',
+		'fieldtype': 'Select',
+		'idx': 9,
+		'label': 'Grade',
+		'options': 'link:Grade'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'employment_type',
+		'fieldtype': 'Select',
+		'idx': 10,
+		'label': 'Employment Type',
+		'options': 'link:Employment Type'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'fiscal_year',
+		'fieldtype': 'Select',
+		'idx': 11,
+		'label': 'Fiscal Year',
+		'options': 'link:Fiscal Year',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'month',
+		'fieldtype': 'Select',
+		'idx': 12,
+		'label': 'Month',
+		'options': '\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Check if you want to send salary slip in mail to each employee while submitting salary slip',
+		'doctype': 'DocField',
+		'fieldname': 'send_email',
+		'fieldtype': 'Check',
+		'idx': 13,
+		'label': 'Send Email'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 14
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 15,
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Creates salary slip for above mentioned criteria.',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 16,
+		'label': 'Create Salary Slip',
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 17,
+		'width': '25%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Submit all salary slips for the above selected criteria',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 18,
+		'label': 'Submit Salary Slip',
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'idx': 19,
+		'width': '25%'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Create Bank Voucher for the total salary paid for the above selected criteria',
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'idx': 20,
+		'label': 'Make Bank Voucher',
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
+		'idx': 21
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'HTML',
+		'idx': 22,
+		'label': 'Activity Log'
+	}
+]
\ No newline at end of file
diff --git a/hr/doctype/salary_manager/test_salary_manager.py b/hr/doctype/salary_manager/test_salary_manager.py
new file mode 100644
index 0000000..1a0b48a
--- /dev/null
+++ b/hr/doctype/salary_manager/test_salary_manager.py
@@ -0,0 +1,197 @@
+import unittest
+import webnotes
+
+from webnotes.model.doc import Document
+from webnotes.model.code import get_obj
+sql = webnotes.conn.sql
+
+class TestSalarySlip(unittest.TestCase):
+	def setUp(self):
+		webnotes.conn.begin()
+		for rec in [des1, dep1, branch1, grade1, comp1, emp1, emp2]:
+			rec.save(1)
+					
+		ss1[0].employee = emp1.name
+		for s in ss1: s.save(1)
+		for s in ss1[1:]:
+			sql("update `tabEarning Detail` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
+			sql("update `tabDeduction Detail` set parent = '%s' where name = '%s'" % (ss1[0].name, s.name))
+			
+		
+		ss2[0].employee = emp2.name
+		for s in ss2: s.save(1)		
+		for s in ss2[1:]:
+			sql("update `tabEarning Detail` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
+			sql("update `tabDeduction Detail` set parent = '%s' where name = '%s'" % (ss2[0].name, s.name))
+			
+		sman.save()
+		self.sm = get_obj('Salary Manager')	
+		leave.save(1)
+		self.sm.create_sal_slip()
+		
+	def test_creation(self):
+		ssid = sql("""
+			select name, department 
+			from `tabSalary Slip` 
+			where month = '08' and fiscal_year='2011-2012'""")
+
+		self.assertTrue(len(ssid)==1)
+		self.assertTrue(ssid[0][1] == 'dep1')
+		
+		
+	def test_lwp_calc(self):
+		ss = sql("""
+			select payment_days
+			from `tabSalary Slip` 
+			where month = '08' and fiscal_year='2011-2012' and employee = '%s'
+		""" % emp1.name)
+		
+		self.assertTrue(ss[0][0]==27)
+		
+	def test_net_pay(self):
+		ss = webnotes.conn.sql("""
+			select rounded_total 
+			from `tabSalary Slip` 
+			where month = '08'
+			and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name)
+		self.assertTrue(ss[0][0]==67)
+
+	def test_submit(self):
+		self.sm.submit_sal_slip()
+		ss = webnotes.conn.sql("""
+			select docstatus 
+			from `tabSalary Slip` 
+			where month = '08'
+			and fiscal_year='2011-2012' and employee = '%s'""" % emp1.name)
+		self.assertTrue(ss[0][0]==1)
+		
+	def tearDown(self):
+		webnotes.conn.rollback()
+		
+#--------------------------------------------
+# test data
+#--------------------------------------------
+des1 = Document(fielddata={
+	'name':'des1',
+	'doctype':'Designation',
+	'designation_name':'des1'
+})
+
+dep1 = Document(fielddata={
+	'name':'dep1',
+	'doctype':'Department',
+	'department_name' : 'dep1'
+})
+
+branch1 = Document(fielddata={
+	'name':'branch1',
+	'doctype':'Branch',
+	'branch' : 'branch1'
+})
+
+comp1 = Document(fielddata={
+	'name':'comp1',
+	'doctype':'Company',
+	'abbr':'c1',
+	'company_name' : 'comp1'
+})
+
+grade1 = Document(fielddata={
+	'name':'grade1',
+	'doctype':'Grade',
+	'grade_name' : 'grade1'	
+})
+	
+emp1 = Document(fielddata={
+	'doctype':'Employee',
+	'employee_number':'emp1',
+	'department':'dep1',
+	'designation':'des1',
+	'branch' : 'branch1',
+	'company':'comp1',
+	'grade':'grade1',
+	'naming_series':'EMP/',
+	'status':'Active',
+	'docstatus':0
+})
+
+emp2 = Document(fielddata={
+	'doctype':'Employee',
+	'employee_number':'emp2',
+	'department':'dep1',
+	'designation':'des2',
+	'branch' : 'branch1',
+	'company':'comp1',
+	'naming_series':'EMP/',
+	'grade':'grade1',
+	'status':'Active',
+
+})
+
+ss1 = [
+	Document(fielddata={
+		'doctype':'Salary Structure',
+		'docstatus':0,
+		'employee':'emp1',
+		'is_active':'Yes',
+		'department': 'dep1',
+		'designation' : 'des1'
+	}),
+	Document(fielddata={
+		'parenttype':'Salary Structure',
+		'parentfield':'earning_details',
+		'doctype':'Earning Detail',
+		'e_type' : 'Basic',
+		'depend_on_lwp':1,
+		'modified_value':100
+	}),
+	Document(fielddata={
+		'parenttype':'Salary Structure',
+		'parentfield':'earning_details',
+		'doctype':'Deduction Detail',
+		'd_type':'TDS',
+		'd_modified_amt':20
+	})
+]
+
+ss2 = [
+	Document(fielddata={
+		'doctype':'Salary Structure',
+		'is_active':'Yes',
+		'docstatus':0,
+	}),
+	Document(fielddata={
+		'parenttype':'Salary Structure',
+		'parentfield':'deduction_details',
+		'doctype':'Earning Detail',
+		'e_type' : 'Basic',
+		'modified_value':100
+	}),
+	Document(fielddata={
+		'parenttype':'Salary Structure',
+		'parentfield':'deduction_details',
+		'doctype':'Deduction Detail',
+		'd_type':'TDS',
+		'd_modified_amt':20
+	})
+]
+
+sman = Document(fielddata={
+		'name':'Salary Manager',
+		'doctype':'Salary Manager',
+		'company': 'comp1',
+		'department':'dep1',
+		'designation':'des1',
+		'month': '08',
+		'fiscal_year':'2011-2012'
+	})
+	
+leave = Document(fielddata = {
+		'doctype':'Leave Application',
+		'employee':'emp1',
+		'from_date':'2011-08-12',
+		'to_date':'2011-08-15',
+		'total_leave_days':'4',
+		'leave_type':'Leave Without Pay',
+		'docstatus':1
+	})
diff --git a/hr/doctype/salary_slip/salary_slip.js b/hr/doctype/salary_slip/salary_slip.js
index 8f953e6..c6ae27b 100644
--- a/hr/doctype/salary_slip/salary_slip.js
+++ b/hr/doctype/salary_slip/salary_slip.js
@@ -3,25 +3,25 @@
 // On load
 // -------------------------------------------------------------------
 cur_frm.cscript.onload = function(doc,dt,dn){
-  if((cint(doc.__islocal) == 1) && !doc.amended_from){
-    var today=new Date();
-    month = (today.getMonth()+01).toString();
-    if(month.length>1) doc.month = month;
-    else doc.month = '0'+month;
+	if((cint(doc.__islocal) == 1) && !doc.amended_from){
+		var today=new Date();
+		month = (today.getMonth()+01).toString();
+		if(month.length>1) doc.month = month;
+		else doc.month = '0'+month;
 		doc.fiscal_year = sys_defaults['fiscal_year'];
-    refresh_many(['month', 'fiscal_year']);
-    cur_frm.cscript.fiscal_year(doc, dt, dn);
-  }
+		refresh_many(['month', 'fiscal_year']);
+		cur_frm.cscript.fiscal_year(doc, dt, dn);
+	}
 }
 
 // Get leave details
 //---------------------------------------------------------------------
 cur_frm.cscript.fiscal_year = function(doc,dt,dn){
-    $c_obj(make_doclist(doc.doctype,doc.name), 'get_emp_and_leave_details','',function(r, rt) {
-      var doc = locals[dt][dn];
-      cur_frm.refresh();
-      calculate_all(doc, dt, dn);
-    });
+		$c_obj(make_doclist(doc.doctype,doc.name), 'get_emp_and_leave_details','',function(r, rt) {
+			var doc = locals[dt][dn];
+			cur_frm.refresh();
+			calculate_all(doc, dt, dn);
+		});
 }
 
 cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year;
@@ -29,24 +29,24 @@
 // Calculate total if lwp exists
 // ------------------------------------------------------------------------
 cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
-  doc.payment_days = flt(doc.total_days_in_month) - flt(doc.leave_without_pay);
-  refresh_field('payment_days');
-  calculate_all(doc, dt, dn);
+	doc.payment_days = flt(doc.total_days_in_month) - flt(doc.leave_without_pay);
+	refresh_field('payment_days');
+	calculate_all(doc, dt, dn);
 }
 
 // Calculate all
 // ------------------------------------------------------------------------
 var calculate_all = function(doc, dt, dn) {
-  calculate_earning_total(doc, dt, dn);
-  calculate_ded_total(doc, dt, dn);
-  calculate_net_pay(doc, dt, dn);
+	calculate_earning_total(doc, dt, dn);
+	calculate_ded_total(doc, dt, dn);
+	calculate_net_pay(doc, dt, dn);
 }
 
 // Trigger on earning modified amount and depends on lwp
 // ------------------------------------------------------------------------
 cur_frm.cscript.e_modified_amount = function(doc,dt,dn){
-  calculate_earning_total(doc, dt, dn);
-  calculate_net_pay(doc, dt, dn);
+	calculate_earning_total(doc, dt, dn);
+	calculate_net_pay(doc, dt, dn);
 }
 
 cur_frm.cscript.e_depends_on_lwp = cur_frm.cscript.e_modified_amount;
@@ -54,8 +54,8 @@
 // Trigger on earning modified amount and depends on lwp
 // ------------------------------------------------------------------------
 cur_frm.cscript.d_modified_amount = function(doc,dt,dn){
-  calculate_ded_total(doc, dt, dn);
-  calculate_net_pay(doc, dt, dn);
+	calculate_ded_total(doc, dt, dn);
+	calculate_net_pay(doc, dt, dn);
 }
 
 cur_frm.cscript.d_depends_on_lwp = cur_frm.cscript.d_modified_amount;
@@ -63,50 +63,50 @@
 // Calculate earning total
 // ------------------------------------------------------------------------
 var calculate_earning_total = function(doc, dt, dn) {
-  var tbl = getchildren('SS Earning Detail', doc.name, 'earning_details', doc.doctype);
+	var tbl = getchildren('SS Earning Detail', doc.name, 'earning_details', doc.doctype);
 
-  var total_earn = 0;
-  for(var i = 0; i < tbl.length; i++){
-    if(cint(tbl[i].e_depends_on_lwp) == 1) {
-      tbl[i].e_modified_amount = flt(tbl[i].e_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month));      
-      refresh_field('e_modified_amount', tbl[i].name, 'earning_details');
-    }
-    total_earn += flt(tbl[i].e_modified_amount);
-  }
-  doc.gross_pay = total_earn + flt(doc.arrear_amount) + flt(doc.leave_encashment_amount);
-  refresh_many(['e_modified_amount', 'gross_pay']);
+	var total_earn = 0;
+	for(var i = 0; i < tbl.length; i++){
+		if(cint(tbl[i].e_depends_on_lwp) == 1) {
+			tbl[i].e_modified_amount = Math.round(tbl[i].e_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)*100)/100;			
+			refresh_field('e_modified_amount', tbl[i].name, 'earning_details');
+		}
+		total_earn += flt(tbl[i].e_modified_amount);
+	}
+	doc.gross_pay = total_earn + flt(doc.arrear_amount) + flt(doc.leave_encashment_amount);
+	refresh_many(['e_modified_amount', 'gross_pay']);
 }
 
 // Calculate deduction total
 // ------------------------------------------------------------------------
 var calculate_ded_total = function(doc, dt, dn) {
-  var tbl = getchildren('SS Deduction Detail', doc.name, 'deduction_details', doc.doctype);
+	var tbl = getchildren('SS Deduction Detail', doc.name, 'deduction_details', doc.doctype);
 
-  var total_ded = 0;
-  for(var i = 0; i < tbl.length; i++){
-    if(cint(tbl[i].d_depends_on_lwp) == 1) {
-      tbl[i].d_modified_amount = flt(tbl[i].d_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month));
+	var total_ded = 0;
+	for(var i = 0; i < tbl.length; i++){
+		if(cint(tbl[i].d_depends_on_lwp) == 1) {
+			tbl[i].d_modified_amount = Math.round(tbl[i].d_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)*100)/100;
 			refresh_field('d_modified_amount', tbl[i].name, 'deduction_details');
-    }
-    total_ded += flt(tbl[i].d_modified_amount);
-  }
-  doc.total_deduction = total_ded;
-  refresh_field('total_deduction');  
+		}
+		total_ded += flt(tbl[i].d_modified_amount);
+	}
+	doc.total_deduction = total_ded;
+	refresh_field('total_deduction');	
 }
 
 // Calculate net payable amount
 // ------------------------------------------------------------------------
 var calculate_net_pay = function(doc, dt, dn) {
-  doc.net_pay = flt(doc.gross_pay) - flt(doc.total_deduction);
+	doc.net_pay = flt(doc.gross_pay) - flt(doc.total_deduction);
 	doc.rounded_total = Math.round(doc.net_pay);
-  refresh_many(['net_pay', 'rounded_total']);
+	refresh_many(['net_pay', 'rounded_total']);
 }
 
 // trigger on arrear
 // ------------------------------------------------------------------------
 cur_frm.cscript.arrear_amount = function(doc,dt,dn){
-  calculate_earning_total(doc, dt, dn);
-  calculate_net_pay(doc, dt, dn);
+	calculate_earning_total(doc, dt, dn);
+	calculate_net_pay(doc, dt, dn);
 }
 
 // trigger on encashed amount
@@ -116,5 +116,5 @@
 // validate
 // ------------------------------------------------------------------------
 cur_frm.cscript.validate = function(doc, dt, dn) {
-  calculate_all(doc, dt, dn);
+	calculate_all(doc, dt, dn);
 }
diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py
index af55956..0cdc898 100644
--- a/hr/doctype/salary_slip/salary_slip.py
+++ b/hr/doctype/salary_slip/salary_slip.py
@@ -68,7 +68,7 @@
 	# Get leave details
 	#=======================================================
 	def get_leave_details(self):
-		m = self.get_month_details()		
+		m = self.get_month_details()
 		lwp = self.calculate_lwp(m)
 		self.doc.total_days_in_month = m[3]
 		self.doc.leave_without_pay = lwp
@@ -129,12 +129,45 @@
 		self.check_existing()
 		dcc = TransactionBase().get_company_currency(self.doc.company)
 		self.doc.total_in_words	= get_obj('Sales Common').get_total_in_words(dcc, self.doc.rounded_total)
+
+
+	def calculate_earning_total(self):
+		"""
+			Calculates total earnings considering lwp
+		"""
+		self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount)
+		for d in getlist(self.doclist, 'earning_details'):
+			if cint(d.e_depends_on_lwp) == 1:
+				d.e_modified_amount = round(flt(d.e_amount)*flt(self.doc.payment_days)/cint(self.doc.total_days_in_month), 2)
+			self.doc.gross_pay += d.e_modified_amount
+	
+	def calculate_ded_total(self):
+		"""
+			Calculates total deduction considering lwp
+		"""
+		self.doc.total_deduction = 0
+		for d in getlist(self.doclist, 'deduction_details'):
+			if cint(d.d_depends_on_lwp) == 1:
+				d.d_modified_amount = round(flt(d.d_amount)*flt(self.doc.payment_days)/cint(self.doc.total_days_in_month), 2)
+			self.doc.total_deduction += d.d_modified_amount
+				
+	def calculate_net_pay(self):
+		"""
+			Calculate net payment
+		"""
+		self.calculate_earning_total()
+		self.calculate_ded_total()
+		self.doc.net_pay = flt(self.doc.gross_pay) - flt(self.doc.total_deduction)
+		self.doc.rounded_total = round(self.doc.net_pay)
 		
 	# ON SUBMIT
 	#=======================================================
 	def on_submit(self):
 		if(self.doc.email_check == 1):			
 			self.send_mail_funct()
+			
+	
+
 
 	# Send mail
 	#=======================================================
@@ -148,8 +181,7 @@
 		 
 			earn_table = ''
 			ded_table = ''
-			if earn_ret:
-			
+			if earn_ret:			
 				earn_table += "<table cellspacing= '5' cellpadding='5' >"
 				
 				for e in earn_ret:
diff --git a/hr/doctype/salary_slip_control_panel/__init__.py b/hr/doctype/salary_slip_control_panel/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/hr/doctype/salary_slip_control_panel/__init__.py
+++ /dev/null
diff --git a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js b/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js
deleted file mode 100644
index 5fd80cb..0000000
--- a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.js
+++ /dev/null
@@ -1,71 +0,0 @@
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-  alert("Salary Slip Control Panel is currently under re-development. It will take around a week time.");
-  hide_field(['Process Payroll', 'Submit Salary Slip', 'Make Bank Voucher']);
-}
-
-cur_frm.cscript['Process Payroll'] = function(doc,cdt,cdn){
-  $c('runserverobj', args={'method':'process_payroll','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},function(r,rt){
-    
-      if(!pscript.ss_html)
-        pscript.ss_html = $a(cur_frm.fields_dict['Salary Slip HTML'].wrapper,'span','',{border:'1px solid #CCC', backgroundColor:'#DDD'});
-      pscript.ss_html.innerHTML = '';
-      pscript.ss_html.innerHTML = r.message;
-      
-    
-    });
-
-}
-
-cur_frm.cscript['Submit Salary Slip'] = function(doc,cdt,cdn){
-  if(doc.month && doc.fiscal_year && doc.year){
-    var check = confirm("DO you really want to Submit all Salary Slip for month : " + doc.month+" and year : "+doc.year);
-    if(check){
-      $c('runserverobj', args={'method':'submit_sal_slip','docs':compress_doclist (make_doclist (doc.doctype,doc.name))},function(r,rt){
-      
-        if(!pscript.ss_html)
-          pscript.ss_html = $a(cur_frm.fields_dict['Salary Slip HTML'].wrapper,'span','',{border:'1px solid #CCC', backgroundColor:'#DDD'});
-        pscript.ss_html.innerHTML = '';
-        pscript.ss_html.innerHTML = r.message;
-        
-      
-      });
-    }
-  }
-  else
-    alert("Please select month, fiscal year and year");
-}
-
-// Make JV
-// --------
-cur_frm.cscript.make_jv = function(doc, dt, dn) {
-  var call_back = function(r,rt){
-    var jv = LocalDB.create('Journal Voucher');
-    jv = locals['Journal Voucher'][jv];
-    jv.voucher_type = 'Bank Voucher';
-    jv.remark = 'Salary - Bank Voucher';
-    jv.fiscal_year = doc.fiscal_year;
-    jv.company = doc.company;
-    
-    // credit to bank
-    var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
-    d1.account = r.message['default_bank_account'];
-
-    // debit to salary account
-    var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
-    d1.account = r.message['default_salary_account'];
-    if(!r.message['default_salary_account'] && !r.message['default_bank_account']) alert("To debit salary amount in salary head and credit amount from bank, you need to specify default salary account and default bank account in Global Defaults.\nGo to Setup, click on Company. Select a company.\nSelect Default Salary Account, Default Bank Account from Accounting tab.");
-    else if(!r.message['default_salary_account']) alert("To debit salary amount you need to specify default salary account in Global Defaults.\nGo to Setup, click on Company. Select a company.\nSelect Default Salary Account from Accounting tab.");
-    else if(!r.message['default_bank_account']) alert("To credit salary amount you need to specify default bank account in Global Defaults.\nGo to Setup, click on Company. Select a company.\nSelect Default Bank Account from Accounting tab.");
-    loaddoc('Journal Voucher', jv.name);
-  }
-  $c_obj(make_doclist(dt,dn),'get_acct_dtl','',call_back);
-
-}
-
-
-
-// Make Journal Voucher
-// --------------------
-cur_frm.cscript['Make Bank Voucher'] = function(doc, dt, dn) {
-  cur_frm.cscript.make_jv(doc,dt,dn);
-}
diff --git a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py b/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py
deleted file mode 100644
index 3a4fadf..0000000
--- a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.py
+++ /dev/null
@@ -1,137 +0,0 @@
-# Please edit this list and import only required elements
-import webnotes
-
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
-from webnotes.model.doclist import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, is_testing, msgprint, errprint
-
-set = webnotes.conn.set
-sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
-convert_to_lists = webnotes.conn.convert_to_lists
-	
-# -----------------------------------------------------------------------------------------
-
-
-class DocType:
-  def __init__(self, doc, doclist):
-    self.doc = doc
-    self.doclist = doclist   
-  
-  # Get Employees
-  # ********************************************************************** 
-  def get_employee(self):    
-    e1 = self.emp_fr_memp()  #get employee list from employee where employee is active
-    e2 = self.emp_fr_salstr(e1)  #get employee list from salary structure whose salary structure is created and is active 
-    e3 = self.emp_fr_salslip(e2)  #get employee list from salary slip whose salary slip not yet created for this month and year
-    return e3
-
-  # ********************************************************************** 
-  def emp_fr_memp(self):
-    lst1 = [[self.doc.employee_type,"employment_type"],[self.doc.branch,"branch"],[self.doc.designation,"designation"],[self.doc.department, "department"],[self.doc.grade,"grade"]]
-    
-    condition = ""
-    #flag = 0
-    for l in lst1:
-      
-      if(l[0]):
-        #if flag == 0:
-        #  condition += l[1] + "= '" + l[0] +"'"
-        #else:
-        condition += " and " + l[1]+ "= '" +l[0] +"'"
-        #flag = 1
-
-    emp_query = "select name from `tabEmployee` where status = 'Active'"
-    #if flag == 1:
-    emp_query += condition
-            
-    e = sql(emp_query)
-    return e
-
-  # ********************************************************************** 
-  def emp_fr_salstr(self,e1):
-    lst = []
-    for r in e1:
-      lst.append(r[0])
-    
-    
-    e_lst = "%s"%lst
-    e_lst=e_lst.replace("[","(")
-    e_lst=e_lst.replace("]",")")
-    cond = ''
-
-    if e1:
-      cond = " and employee in %s"%e_lst
-    
-    el=sql("select employee from `tabSalary Structure` where is_active = 'Yes'"+cond)
-
-    return el
-
-  # ********************************************************************** 
-  def emp_fr_salslip(self,e2):
-    e3 = []
-    for i in e2:
-      ret = sql("select name from `tabSalary Slip` where month = '%s' and year = '%s' and employee = '%s' and docstatus !=2 "%(self.doc.month,self.doc.year,i[0]))
-
-      if not ret:
-        e3.append(i[0])
-    return e3
-    
-  # ********************************************************************** 
-  def process_payroll(self):
-    sal_slip_str = ''
-    if self.doc.month and self.doc.fiscal_year and self.doc.year:
-      e = self.get_employee()
-      if e:
-        self.doc.emp_lst=e
-        sal_slip_str += 'Sucessfully created following salary slips:'
-      for i in e:
-      	ss = Document('Salary Slip')
-        ss.fiscal_year = self.doc.fiscal_year
-        ss.employee = i
-        ss.month = self.doc.month
-        ss.year= self.doc.year
-        ss.arrear_amount = self.doc.arrear_amount    
-        ss.email_check = self.doc.email_check
-        ss.save(1)
-        salary_obj=get_obj("Salary Slip",ss.name,with_children=1)   
-        salary_obj.process_payroll_all()
-        sal_slip_str += "<br/>"+ss.name 
-        
-    else:
-    
-      msgprint("For Process Payroll Fiscal Year, Month, Year fields are mandatory.")
-    if not sal_slip_str: 
-     
-      sal_slip_str = "No record found."
-    return cstr(sal_slip_str)
-
-  # ********************************************************************** 
-  def submit_sal_slip(self):
-  
-    sal_slip_str = ''
-    r = sql("select name from `tabSalary Slip` where month='%s' and year = '%s' and fiscal_year = '%s' and docstatus = 0"%(self.doc.month,self.doc.year,self.doc.fiscal_year))
-
-  
-    ret = sql("update `tabSalary Slip` set docstatus = 1 where month='%s' and year = '%s' and fiscal_year = '%s' and docstatus = 0"%(self.doc.month,self.doc.year,self.doc.fiscal_year))
-    if r:
-      sal_slip_str += 'Sucessfully updated following salary slips:'
-    for i in r:
-      
-      salary_obj=get_obj("Salary Slip",i[0],with_children=1)   
-      salary_obj.on_submit()
-      sal_slip_str += "<br/>"+cstr(i[0]) 
-    if not sal_slip_str: 
-     
-      sal_slip_str = "No record found."
-    return cstr(sal_slip_str)
-  
-  # ********************************************************************** 
-  #get default bank account,default salary acount from company.
-  def get_acct_dtl(self):
-    res = sql("select default_bank_account,default_salary_acount from `tabCompany` where name = '%s'"%get_defaults()['company'], as_dict=1)
-    return res[0]
diff --git a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.txt b/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.txt
deleted file mode 100644
index b83e0c7..0000000
--- a/hr/doctype/salary_slip_control_panel/salary_slip_control_panel.txt
+++ /dev/null
@@ -1,286 +0,0 @@
-# DocType, Salary Slip Control Panel
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2010-08-08 17:09:20',
-		'docstatus': 0,
-		'modified': '2010-12-29 18:02:38',
-		'modified_by': 'umair@iwebnotes.com',
-		'owner': 'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'_last_update': '1294312182',
-		'allow_copy': 1,
-		'allow_email': 1,
-		'allow_print': 1,
-		'colour': 'White:FFF',
-		'doctype': 'DocType',
-		'hide_heading': 0,
-		'hide_toolbar': 0,
-		'in_create': 0,
-		'issingle': 1,
-		'module': 'HR',
-		'name': '__common__',
-		'read_only': 1,
-		'section_style': 'Simple',
-		'server_code_error': ' ',
-		'show_in_menu': 0,
-		'use_template': 0,
-		'version': 113
-	},
-
-	# These values are common for all DocField
-	{
-		'doctype': 'DocField',
-		'name': '__common__',
-		'parent': 'Salary Slip Control Panel',
-		'parentfield': 'fields',
-		'parenttype': 'DocType',
-		'permlevel': 0
-	},
-
-	# These values are common for all DocPerm
-	{
-		'create': 1,
-		'doctype': 'DocPerm',
-		'name': '__common__',
-		'parent': 'Salary Slip Control Panel',
-		'parentfield': 'permissions',
-		'parenttype': 'DocType',
-		'permlevel': 0,
-		'read': 1,
-		'write': 1
-	},
-
-	# DocType, Salary Slip Control Panel
-	{
-		'doctype': 'DocType',
-		'name': 'Salary Slip Control Panel'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 1,
-		'role': 'System Manager'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 2,
-		'role': 'HR User'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 3,
-		'role': 'HR Manager'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 1,
-		'label': 'Salary Slip Control Panel'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'employee_type',
-		'fieldtype': 'Select',
-		'idx': 2,
-		'label': 'Employment Type',
-		'oldfieldname': 'employee_type',
-		'oldfieldtype': 'Select',
-		'options': 'link:Employment Type'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'grade',
-		'fieldtype': 'Select',
-		'idx': 3,
-		'label': 'Grade',
-		'oldfieldname': 'grade',
-		'oldfieldtype': 'Select',
-		'options': 'link:Grade'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'branch',
-		'fieldtype': 'Select',
-		'idx': 4,
-		'label': 'Branch',
-		'oldfieldname': 'branch',
-		'oldfieldtype': 'Select',
-		'options': 'link:Branch'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'department',
-		'fieldtype': 'Select',
-		'idx': 5,
-		'label': 'Department',
-		'oldfieldname': 'department',
-		'oldfieldtype': 'Select',
-		'options': 'link:Department'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'designation',
-		'fieldtype': 'Select',
-		'idx': 6,
-		'label': 'Designation',
-		'oldfieldname': 'designation',
-		'oldfieldtype': 'Select',
-		'options': 'link:Designation'
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'idx': 7,
-		'oldfieldtype': 'Column Break'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'fiscal_year',
-		'fieldtype': 'Select',
-		'idx': 8,
-		'in_filter': 1,
-		'label': 'Fiscal Year',
-		'oldfieldname': 'fiscal_year',
-		'oldfieldtype': 'Select',
-		'options': 'link:Fiscal Year'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'month',
-		'fieldtype': 'Select',
-		'idx': 9,
-		'label': 'Month',
-		'oldfieldname': 'month',
-		'oldfieldtype': 'Select',
-		'options': '\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'year',
-		'fieldtype': 'Select',
-		'idx': 10,
-		'label': 'Year',
-		'oldfieldname': 'year',
-		'oldfieldtype': 'Select',
-		'options': '\n2009\n2010\n2011\n2012'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'week_off',
-		'fieldtype': 'Currency',
-		'idx': 11,
-		'label': 'Week Off',
-		'oldfieldname': 'week_off',
-		'oldfieldtype': 'Currency'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'arrear_amount',
-		'fieldtype': 'Currency',
-		'idx': 12,
-		'label': 'Arrear Amount',
-		'oldfieldname': 'arrear_amount',
-		'oldfieldtype': 'Currency'
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'email_check',
-		'fieldtype': 'Check',
-		'idx': 13,
-		'label': 'Email',
-		'oldfieldname': 'email_check',
-		'oldfieldtype': 'Check'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 14,
-		'oldfieldtype': 'Section Break'
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 15,
-		'label': 'Process Payroll',
-		'oldfieldtype': 'Button',
-		'trigger': 'Client'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'HTML',
-		'idx': 16,
-		'label': 'Salary Slip HTML'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'idx': 17
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 18,
-		'label': 'Submit Salary Slip',
-		'oldfieldtype': 'Button',
-		'trigger': 'Client'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 19,
-		'label': 'Make Bank Voucher',
-		'trigger': 'Client'
-	}
-]
\ No newline at end of file
diff --git a/hr/doctype/salary_structure/salary_structure.txt b/hr/doctype/salary_structure/salary_structure.txt
index 3dcb8f9..d9a9acd 100644
--- a/hr/doctype/salary_structure/salary_structure.txt
+++ b/hr/doctype/salary_structure/salary_structure.txt
@@ -5,14 +5,14 @@
 	{
 		'creation': '2010-12-14 16:50:05',
 		'docstatus': 0,
-		'modified': '2011-06-27 14:39:11',
+		'modified': '2011-08-11 16:56:38',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1308808105',
+		'_last_update': '1311621379',
 		'colour': 'White:FFF',
 		'doctype': 'DocType',
 		'module': 'HR',
@@ -21,7 +21,7 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'subject': 'For %(employee_name)s',
-		'version': 586
+		'version': 587
 	},
 
 	# These values are common for all DocField
@@ -39,7 +39,8 @@
 		'name': '__common__',
 		'parent': 'Salary Structure',
 		'parentfield': 'permissions',
-		'parenttype': 'DocType'
+		'parenttype': 'DocType',
+		'read': 1
 	},
 
 	# DocType, Salary Structure
@@ -54,9 +55,9 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'match': 'owner',
+		'idx': 1,
 		'permlevel': 0,
-		'read': 1,
+		'role': 'Employee',
 		'submit': 0,
 		'write': 0
 	},
@@ -67,96 +68,39 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'match': 'owner',
-		'permlevel': 0,
-		'read': 1,
-		'submit': 0,
-		'write': 0
-	},
-
-	# DocPerm
-	{
-		'amend': 0,
-		'cancel': 0,
-		'create': 0,
-		'doctype': 'DocPerm',
-		'match': 'owner',
-		'permlevel': 0,
-		'read': 1,
-		'submit': 0,
-		'write': 0
-	},
-
-	# DocPerm
-	{
-		'amend': 0,
-		'cancel': 0,
-		'create': 0,
-		'doctype': 'DocPerm',
-		'match': 'owner',
-		'permlevel': 0,
-		'read': 1,
-		'submit': 0,
-		'write': 0
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'permlevel': 0,
-		'role': 'Sales User'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
 		'idx': 2,
 		'permlevel': 1,
-		'read': 1,
 		'role': 'All',
+		'submit': 0,
 		'write': 0
 	},
 
 	# DocPerm
 	{
-		'create': 1,
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
 		'doctype': 'DocPerm',
 		'idx': 3,
 		'permlevel': 0,
-		'read': 1,
 		'role': 'HR User',
-		'write': 1
+		'submit': 0,
+		'write': 0
 	},
 
 	# DocPerm
 	{
+		'amend': 1,
+		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
 		'idx': 4,
 		'permlevel': 0,
-		'read': 1,
 		'role': 'HR Manager',
+		'submit': 1,
 		'write': 1
 	},
 
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 5,
-		'permlevel': 1,
-		'read': 1,
-		'role': 'HR Manager'
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 6,
-		'permlevel': 1,
-		'read': 1,
-		'role': 'HR User'
-	},
-
 	# DocField
 	{
 		'doctype': 'DocField',
diff --git a/patches/patch.py b/patches/patch.py
index 482a276..92ded48 100644
--- a/patches/patch.py
+++ b/patches/patch.py
@@ -1,7 +1,7 @@
 # REMEMBER to update this
 # ========================
 
-last_patch = 343
+last_patch = 344
 
 #-------------------------------------------
 
@@ -1425,3 +1425,6 @@
 		sql("update `tabDocField` set permlevel = 0 where parent = 'Stock Entry Detail' and fieldname in ('s_warehouse', 't_warehouse', 'fg_item')")
 	elif patch_no == 343:
 		reload_doc('stock','doctype','item_customer_detail')
+	elif patch_no == 344:
+		sql("delete from `tabModule Def Item` where display_name = 'Salary Slip Control Panel' and parent = 'HR'")
+		reload_doc('hr','Module Def','HR')