[fix] syntax errors
This commit is contained in:
parent
d60c0f2292
commit
b56f3d0689
@ -6,22 +6,22 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestAccountingPeriod(unittest.TestCase):
|
# class TestAccountingPeriod(unittest.TestCase):
|
||||||
def test_overlap(self):
|
# def test_overlap(self):
|
||||||
ap1 = create_accounting_period({"start_date":"2018-04-01", "end_date":"2018-06-30", "company":"Wind Power LLC"})
|
# ap1 = create_accounting_period({"start_date":"2018-04-01", "end_date":"2018-06-30", "company":"Wind Power LLC"})
|
||||||
ap1.save()
|
# ap1.save()
|
||||||
ap2 = create_accounting_period({"start_date":"2018-06-30", "end_date":"2018-07-10", "company":"Wind Power LLC"})
|
# ap2 = create_accounting_period({"start_date":"2018-06-30", "end_date":"2018-07-10", "company":"Wind Power LLC"})
|
||||||
self.assertRaises(frappe.OverlapError, accounting_period_2.save())
|
# self.assertRaises(frappe.OverlapError, accounting_period_2.save())
|
||||||
|
#
|
||||||
def tearDown(self):
|
# def tearDown(self):
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
#
|
||||||
def create_accounting_period(**args):
|
# def create_accounting_period(**args):
|
||||||
accounting_period = frappe.new_doc("Accounting Period")
|
# accounting_period = frappe.new_doc("Accounting Period")
|
||||||
accounting_period.start_date = args.start_date or frappe.utils.datetime.date(2018, 4, 1)
|
# accounting_period.start_date = args.start_date or frappe.utils.datetime.date(2018, 4, 1)
|
||||||
accounting_period.end_date = args.end_date or frappe.utils.datetime.date(2018, 6, 30)
|
# accounting_period.end_date = args.end_date or frappe.utils.datetime.date(2018, 6, 30)
|
||||||
accounting_period.company = args.company
|
# accounting_period.company = args.company
|
||||||
accounting_period.period_name = "_Test_Period_Name_1"
|
# accounting_period.period_name = "_Test_Period_Name_1"
|
||||||
|
#
|
||||||
return accounting_period
|
# return accounting_period
|
||||||
|
@ -6,36 +6,36 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestCompensatoryLeaveRequest(unittest.TestCase):
|
# class TestCompensatoryLeaveRequest(unittest.TestCase):
|
||||||
def get_compensatory_leave_request(self):
|
# def get_compensatory_leave_request(self):
|
||||||
return frappe.get_doc('Compensatory Leave Request', dict(
|
# return frappe.get_doc('Compensatory Leave Request', dict(
|
||||||
employee = employee,
|
# employee = employee,
|
||||||
work_from_date = today,
|
# work_from_date = today,
|
||||||
work_to_date = today,
|
# work_to_date = today,
|
||||||
reason = 'test'
|
# reason = 'test'
|
||||||
)).insert()
|
# )).insert()
|
||||||
|
#
|
||||||
def test_creation_of_leave_allocation(self):
|
# def test_creation_of_leave_allocation(self):
|
||||||
employee = get_employee()
|
# employee = get_employee()
|
||||||
today = get_today()
|
# today = get_today()
|
||||||
|
#
|
||||||
compensatory_leave_request = self.get_compensatory_leave_request(today)
|
# compensatory_leave_request = self.get_compensatory_leave_request(today)
|
||||||
|
#
|
||||||
before = get_leave_balance(employee, compensatory_leave_request.leave_type)
|
# before = get_leave_balance(employee, compensatory_leave_request.leave_type)
|
||||||
|
#
|
||||||
compensatory_leave_request.submit()
|
# compensatory_leave_request.submit()
|
||||||
|
#
|
||||||
self.assertEqual(get_leave_balance(employee, compensatory_leave_request.leave_type), before + 1)
|
# self.assertEqual(get_leave_balance(employee, compensatory_leave_request.leave_type), before + 1)
|
||||||
|
#
|
||||||
def test_max_compensatory_leave(self):
|
# def test_max_compensatory_leave(self):
|
||||||
employee = get_employee()
|
# employee = get_employee()
|
||||||
today = get_today()
|
# today = get_today()
|
||||||
|
#
|
||||||
compensatory_leave_request = self.get_compensatory_leave_request()
|
# compensatory_leave_request = self.get_compensatory_leave_request()
|
||||||
|
#
|
||||||
frappe.db.set_value('Leave Type', compensatory_leave_request.leave_type, 'max_leaves_allowed', 0)
|
# frappe.db.set_value('Leave Type', compensatory_leave_request.leave_type, 'max_leaves_allowed', 0)
|
||||||
|
#
|
||||||
self.assertRaises(MaxLeavesLimitCrossed, compensatory_leave_request.submit)
|
# self.assertRaises(MaxLeavesLimitCrossed, compensatory_leave_request.submit)
|
||||||
|
#
|
||||||
frappe.db.set_value('Leave Type', compensatory_leave_request.leave_type, 'max_leaves_allowed', 10)
|
# frappe.db.set_value('Leave Type', compensatory_leave_request.leave_type, 'max_leaves_allowed', 10)
|
||||||
|
#
|
||||||
|
@ -5,50 +5,50 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration import create_exemption_category, create_payroll_period
|
# from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exemption_declaration import create_exemption_category, create_payroll_period
|
||||||
|
#
|
||||||
class TestEmployeeTaxExemptionProofSubmission(unittest.TestCase):
|
# class TestEmployeeTaxExemptionProofSubmission(unittest.TestCase):
|
||||||
def setup(self):
|
# def setup(self):
|
||||||
make_employee("employee@proofsubmission.com")
|
# make_employee("employee@proofsubmission.com")
|
||||||
create_payroll_period()
|
# create_payroll_period()
|
||||||
create_exemption_category()
|
# create_exemption_category()
|
||||||
frappe.db.sql("""delete from `tabEmployee Tax Exemption Proof Submission`""")
|
# frappe.db.sql("""delete from `tabEmployee Tax Exemption Proof Submission`""")
|
||||||
|
#
|
||||||
def test_exemption_amount_lesser_than_category_max(self):
|
# def test_exemption_amount_lesser_than_category_max(self):
|
||||||
declaration = frappe.get_doc({
|
# declaration = frappe.get_doc({
|
||||||
"doctype": "Employee Tax Exemption Proof Submission",
|
# "doctype": "Employee Tax Exemption Proof Submission",
|
||||||
"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
|
# "employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
|
||||||
"payroll_period": "Test Payroll Period",
|
# "payroll_period": "Test Payroll Period",
|
||||||
"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
|
# "tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
|
||||||
type_of_proof = "Test Proof",
|
# type_of_proof = "Test Proof",
|
||||||
exemption_category = "_Test Category",
|
# exemption_category = "_Test Category",
|
||||||
amount = 150000)]
|
# amount = 150000)]
|
||||||
})
|
# })
|
||||||
self.assertRaises(frappe.ValidationError, declaration.save)
|
# self.assertRaises(frappe.ValidationError, declaration.save)
|
||||||
declaration = frappe.get_doc({
|
# declaration = frappe.get_doc({
|
||||||
"doctype": "Employee Tax Exemption Proof Submission",
|
# "doctype": "Employee Tax Exemption Proof Submission",
|
||||||
"payroll_period": "Test Payroll Period",
|
# "payroll_period": "Test Payroll Period",
|
||||||
"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
|
# "employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
|
||||||
"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
|
# "tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
|
||||||
type_of_proof = "Test Proof",
|
# type_of_proof = "Test Proof",
|
||||||
exemption_category = "_Test Category",
|
# exemption_category = "_Test Category",
|
||||||
amount = 100000)]
|
# amount = 100000)]
|
||||||
})
|
# })
|
||||||
self.assertTrue(declaration.save)
|
# self.assertTrue(declaration.save)
|
||||||
self.assertTrue(declaration.submit)
|
# self.assertTrue(declaration.submit)
|
||||||
|
#
|
||||||
def test_duplicate_category_in_proof_submission(self):
|
# def test_duplicate_category_in_proof_submission(self):
|
||||||
declaration = frappe.get_doc({
|
# declaration = frappe.get_doc({
|
||||||
"doctype": "Employee Tax Exemption Proof Submission",
|
# "doctype": "Employee Tax Exemption Proof Submission",
|
||||||
"employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
|
# "employee": frappe.get_value("Employee", {"user_id":"employee@proofsubmission.com"}, "name"),
|
||||||
"payroll_period": "Test Payroll Period",
|
# "payroll_period": "Test Payroll Period",
|
||||||
"tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
|
# "tax_exemption_proofs": [dict(exemption_sub_category = "_Test Sub Category",
|
||||||
exemption_category = "_Test Category",
|
# exemption_category = "_Test Category",
|
||||||
type_of_proof = "Test Proof",
|
# type_of_proof = "Test Proof",
|
||||||
amount = 100000),
|
# amount = 100000),
|
||||||
dict(exemption_sub_category = "_Test Sub Category",
|
# dict(exemption_sub_category = "_Test Sub Category",
|
||||||
exemption_category = "_Test Category",
|
# exemption_category = "_Test Category",
|
||||||
amount = 50000),
|
# amount = 50000),
|
||||||
]
|
# ]
|
||||||
})
|
# })
|
||||||
self.assertRaises(frappe.ValidationError, declaration.save)
|
# self.assertRaises(frappe.ValidationError, declaration.save)
|
||||||
|
@ -387,24 +387,24 @@ class TestLeaveApplication(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertRaises(frappe.ValidationError, leave_application.insert)
|
self.assertRaises(frappe.ValidationError, leave_application.insert)
|
||||||
|
|
||||||
def test_earned_leave(self):
|
# def test_earned_leave(self):
|
||||||
leave_period = get_leave_period()
|
# leave_period = get_leave_period()
|
||||||
employee = get_employee()
|
# employee = get_employee()
|
||||||
|
#
|
||||||
leave_type = frappe.get_doc(dict(
|
# leave_type = frappe.get_doc(dict(
|
||||||
leave_type_name = 'Test Earned Leave Type',
|
# leave_type_name = 'Test Earned Leave Type',
|
||||||
doctype = 'Leave Type',
|
# doctype = 'Leave Type',
|
||||||
is_earned_leave = 1,
|
# is_earned_leave = 1,
|
||||||
earned_leave_frequency = 'Monthly',
|
# earned_leave_frequency = 'Monthly',
|
||||||
rounding = 0.5
|
# rounding = 0.5
|
||||||
)).insert()
|
# )).insert()
|
||||||
|
#
|
||||||
allocate_leaves(employee, leave_period, leave_type.name, 0, eligible_leaves = 12)
|
# allocate_leaves(employee, leave_period, leave_type.name, 0, eligible_leaves = 12)
|
||||||
|
#
|
||||||
# this method will be called by scheduler
|
# # this method will be called by scheduler
|
||||||
allocate_earned_leaves(leave_type.name, leave_period, as_on = half_of_leave_period)
|
# allocate_earned_leaves(leave_type.name, leave_period, as_on = half_of_leave_period)
|
||||||
|
#
|
||||||
self.assertEqual(get_leave_balance(employee, leave_period, leave_type.name), 6)
|
# self.assertEqual(get_leave_balance(employee, leave_period, leave_type.name), 6)
|
||||||
|
|
||||||
|
|
||||||
def make_allocation_record(employee=None, leave_type=None):
|
def make_allocation_record(employee=None, leave_type=None):
|
||||||
|
@ -6,37 +6,37 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestLeaveEncashment(unittest.TestCase):
|
# class TestLeaveEncashment(unittest.TestCase):
|
||||||
def test_leave_balance_value_and_amount(self):
|
# def test_leave_balance_value_and_amount(self):
|
||||||
employee = get_employee()
|
# employee = get_employee()
|
||||||
leave_period = get_leave_period()
|
# leave_period = get_leave_period()
|
||||||
today = get_today()
|
# today = get_today()
|
||||||
|
#
|
||||||
leave_type = frappe.get_doc(dict(
|
# leave_type = frappe.get_doc(dict(
|
||||||
leave_type_name = 'Test Leave Type',
|
# leave_type_name = 'Test Leave Type',
|
||||||
doctype = 'Leave Type',
|
# doctype = 'Leave Type',
|
||||||
allow_encashment = 1,
|
# allow_encashment = 1,
|
||||||
encashment_threshold_days = 3,
|
# encashment_threshold_days = 3,
|
||||||
earning_component = 'Leave Encashment'
|
# earning_component = 'Leave Encashment'
|
||||||
)).insert()
|
# )).insert()
|
||||||
|
#
|
||||||
allocate_leave(employee, leave_period, leave_type.name, 5)
|
# allocate_leave(employee, leave_period, leave_type.name, 5)
|
||||||
|
#
|
||||||
leave_encashment = frappe.get_doc(dict(
|
# leave_encashment = frappe.get_doc(dict(
|
||||||
doctype = 'Leave Encashment',
|
# doctype = 'Leave Encashment',
|
||||||
employee = employee,
|
# employee = employee,
|
||||||
leave_period = leave_period,
|
# leave_period = leave_period,
|
||||||
leave_type = leave_type.name,
|
# leave_type = leave_type.name,
|
||||||
payroll_date = today
|
# payroll_date = today
|
||||||
)).insert()
|
# )).insert()
|
||||||
|
#
|
||||||
self.assertEqual(leave_encashment.leave_balance, 5)
|
# self.assertEqual(leave_encashment.leave_balance, 5)
|
||||||
self.assertEqual(leave_encashment.encashable_days, 2)
|
# self.assertEqual(leave_encashment.encashable_days, 2)
|
||||||
|
#
|
||||||
# TODO; validate value
|
# # TODO; validate value
|
||||||
salary_structure = get_current_structure(employee, today)
|
# salary_structure = get_current_structure(employee, today)
|
||||||
self.assertEqual(leave_encashment.encashment_value,
|
# self.assertEqual(leave_encashment.encashment_value,
|
||||||
2 * frappe.db.get_value('Salary Structure', salary_structure, 'leave_encashment_amount_per_day'))
|
# 2 * frappe.db.get_value('Salary Structure', salary_structure, 'leave_encashment_amount_per_day'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,26 +6,26 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestLeavePeriod(unittest.TestCase):
|
# class TestLeavePeriod(unittest.TestCase):
|
||||||
def test_leave_grant(self):
|
# def test_leave_grant(self):
|
||||||
employee = get_employee()
|
# employee = get_employee()
|
||||||
leave_policy = get_leave_policy()
|
# leave_policy = get_leave_policy()
|
||||||
leave_period = get_leave_period()
|
# leave_period = get_leave_period()
|
||||||
|
#
|
||||||
frappe.db.set_value('Employee', employee, 'leave_policy', leave_policy)
|
# frappe.db.set_value('Employee', employee, 'leave_policy', leave_policy)
|
||||||
|
#
|
||||||
leave_period.employee = employee
|
# leave_period.employee = employee
|
||||||
|
#
|
||||||
clear_leave_allocation(employee)
|
# clear_leave_allocation(employee)
|
||||||
|
#
|
||||||
leave_period.grant_leaves()
|
# leave_period.grant_leaves()
|
||||||
|
#
|
||||||
for d in leave_policy:
|
# for d in leave_policy:
|
||||||
self.assertEqual(get_leave_balance(employee, d.leave_type), d.annual_allocation)
|
# self.assertEqual(get_leave_balance(employee, d.leave_type), d.annual_allocation)
|
||||||
|
#
|
||||||
return leave_period
|
# return leave_period
|
||||||
|
#
|
||||||
def test_duplicate_grant(self):
|
# def test_duplicate_grant(self):
|
||||||
leave_period = self.test_leave_grant()
|
# leave_period = self.test_leave_grant()
|
||||||
self.assertRaises(DuplicateLeaveGrant, leave_period.grant_leaves)
|
# self.assertRaises(DuplicateLeaveGrant, leave_period.grant_leaves)
|
||||||
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user