Tax Declaration, Proof Submission tests
diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
index 48f561a..84970d8 100644
--- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
+++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py
@@ -5,6 +5,110 @@
 
 import frappe
 import unittest
+from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee
 
 class TestEmployeeTaxExemptionDeclaration(unittest.TestCase):
-	pass
+	def setup(self):
+		make_employee("employee@taxexepmtion.com")
+		make_employee("employee1@taxexepmtion.com")
+		create_payroll_period()
+		create_exemption_category()
+		frappe.db.sql("""delete from `tabEmployee Tax Exemption Declaration`""")
+
+	def test_exemption_amount_greater_than_category_max(self):
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Declaration",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
+			"payroll_period": "Test Payroll Period",
+			"declarations": [dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 150000)]
+		})
+		self.assertRaises(frappe.ValidationError, declaration.save)
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Declaration",
+			"payroll_period": "Test Payroll Period",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
+			"declarations": [dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 90000)]
+		})
+		self.assertTrue(declaration.save)
+
+	def test_duplicate_category_in_declaration(self):
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Declaration",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
+			"payroll_period": "Test Payroll Period",
+			"declarations": [dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 100000),
+							dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 50000),
+							]
+		})
+		self.assertRaises(frappe.ValidationError, declaration.save)
+
+	def test_duplicate_submission_for_payroll_period(self):
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Declaration",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
+			"payroll_period": "Test Payroll Period",
+			"declarations": [dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 100000),
+							dict(exemption_sub_category = "_Test1 Sub Category",
+							exemption_category = "_Test Category",
+							amount = 50000),
+							]
+		})
+		self.assertTrue(declaration.submit)
+		duplicate_declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Declaration",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"),
+			"payroll_period": "Test Payroll Period",
+			"declarations": [dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 100000)
+							]
+		})
+		self.assertRaises(frappe.DocstatusTransitionError, duplicate_declaration.submit)
+		duplicate_declaration.employee = frappe.get_value("Employee", {"user_id":"employee1@taxexepmtion.com"}, "name")
+		self.assertTrue(duplicate_declaration.submit)
+
+def create_payroll_period():
+	if not frappe.db.exists("Payroll Period", "_Test Payroll Period"):
+		from datetime import date
+		payroll_period = frappe.get_doc(dict(
+			doctype = 'Payroll Period',
+			name = "_Test Payroll Period",
+			company = "_Test Company",
+			periods = [
+				dict(start_date = date(date.today().year, 1, 1),
+				end_date = date(date.today().year, 12, 31))
+			]
+		)).insert()
+
+def create_exemption_category():
+	if not frappe.db.exists("Employee Tax Exemption Category", "_Test Category"):
+		category = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Category",
+			"name": "_Test Category",
+			"deduction_component": "_Test Tax",
+			"max_amount": 100000
+		}).insert()
+	if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Category"):
+		frappe.get_doc({
+			"doctype": "Employee Tax Exemption Sub Category",
+			"name": "_Test Sub Category",
+			"exemption_category": "_Test Category",
+			"max_amount": 100000
+		}).insert()
+	if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Category"):
+		frappe.get_doc({
+			"doctype": "Employee Tax Exemption Sub Category",
+			"name": "_Test1 Sub Category",
+			"exemption_category": "_Test Category",
+			"max_amount": 50000
+		}).insert()
diff --git a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/test_employee_tax_exemption_proof_submission.py b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/test_employee_tax_exemption_proof_submission.py
index 1dc090f..4b5777b 100644
--- a/erpnext/hr/doctype/employee_tax_exemption_proof_submission/test_employee_tax_exemption_proof_submission.py
+++ b/erpnext/hr/doctype/employee_tax_exemption_proof_submission/test_employee_tax_exemption_proof_submission.py
@@ -5,6 +5,50 @@
 
 import frappe
 import unittest
+from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration import create_exemption_category, create_payroll_period
 
 class TestEmployeeTaxExemptionProofSubmission(unittest.TestCase):
-	pass
+	def setup(self):
+		make_employee("employee@proofsubmission.com")
+		create_payroll_period()
+		create_exemption_category()
+		frappe.db.sql("""delete from `tabEmployee Tax Exemption Proof Submission`""")
+
+	def test_exemption_amount_lesser_than_category_max(self):
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Proof Submission",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
+			"payroll_period": "Test Payroll Period",
+			"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
+							type_of_proof = "Test Proof",
+							exemption_category = "_Test Category",
+							amount = 150000)]
+		})
+		self.assertRaises(frappe.ValidationError, declaration.save)
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Proof Submission",
+			"payroll_period": "Test Payroll Period",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
+			"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
+							type_of_proof = "Test Proof",
+							exemption_category = "_Test Category",
+							amount = 100000)]
+		})
+		self.assertTrue(declaration.save)
+		self.assertTrue(declaration.submit)
+
+	def test_duplicate_category_in_proof_submission(self):
+		declaration = frappe.get_doc({
+			"doctype": "Employee Tax Exemption Proof Submission",
+			"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
+			"payroll_period": "Test Payroll Period",
+			"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							type_of_proof = "Test Proof",
+							amount = 100000),
+							dict(exemption_sub_category = "_Test Sub Category",
+							exemption_category = "_Test Category",
+							amount = 50000),
+							]
+		})
+		self.assertRaises(frappe.ValidationError, declaration.save)