mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
fix: test
This commit is contained in:
@@ -26,15 +26,7 @@ class TestGratuity(unittest.TestCase):
|
|||||||
|
|
||||||
rule = get_gratuity_rule("Rule Under Unlimited Contract on termination (UAE)")
|
rule = get_gratuity_rule("Rule Under Unlimited Contract on termination (UAE)")
|
||||||
|
|
||||||
gratuity = frappe.new_doc("Gratuity")
|
gratuity = create_gratuity(pay_via_salary_slip = 1, employee=employee, rule=rule.name)
|
||||||
gratuity.employee = employee
|
|
||||||
gratuity.posting_date = getdate()
|
|
||||||
gratuity.gratuity_rule = rule.name
|
|
||||||
gratuity.pay_via_salary_slip = 1
|
|
||||||
gratuity.salary_component = "Performance Bonus"
|
|
||||||
gratuity.payroll_date = getdate()
|
|
||||||
gratuity.save()
|
|
||||||
gratuity.submit()
|
|
||||||
|
|
||||||
#work experience calculation
|
#work experience calculation
|
||||||
date_of_joining, relieving_date = frappe.db.get_value('Employee', employee, ['date_of_joining', 'relieving_date'])
|
date_of_joining, relieving_date = frappe.db.get_value('Employee', employee, ['date_of_joining', 'relieving_date'])
|
||||||
@@ -69,20 +61,8 @@ class TestGratuity(unittest.TestCase):
|
|||||||
employee, sal_slip = create_employee_and_get_last_salary_slip()
|
employee, sal_slip = create_employee_and_get_last_salary_slip()
|
||||||
rule = get_gratuity_rule("Rule Under Limited Contract (UAE)")
|
rule = get_gratuity_rule("Rule Under Limited Contract (UAE)")
|
||||||
set_mode_of_payment_account()
|
set_mode_of_payment_account()
|
||||||
payable_account = get_payable_account("_Test Company")
|
|
||||||
|
|
||||||
gratuity = frappe.new_doc("Gratuity")
|
gratuity = create_gratuity(expense_account = 'Payment Account - _TC', mode_of_payment='Cash', employee=employee)
|
||||||
gratuity.employee = employee
|
|
||||||
gratuity.posting_date = getdate()
|
|
||||||
gratuity.gratuity_rule = rule.name
|
|
||||||
gratuity.pay_via_salary_slip = 0
|
|
||||||
gratuity.payroll_date = getdate()
|
|
||||||
gratuity.expense_account = "Payment Account - _TC"
|
|
||||||
gratuity.payable_account = payable_account
|
|
||||||
gratuity.mode_of_payment = "Cash"
|
|
||||||
|
|
||||||
gratuity.save()
|
|
||||||
gratuity.submit()
|
|
||||||
|
|
||||||
#work experience calculation
|
#work experience calculation
|
||||||
date_of_joining, relieving_date = frappe.db.get_value('Employee', employee, ['date_of_joining', 'relieving_date'])
|
date_of_joining, relieving_date = frappe.db.get_value('Employee', employee, ['date_of_joining', 'relieving_date'])
|
||||||
@@ -127,7 +107,7 @@ class TestGratuity(unittest.TestCase):
|
|||||||
gratuity.reload()
|
gratuity.reload()
|
||||||
|
|
||||||
self.assertEqual(gratuity.status, "Paid")
|
self.assertEqual(gratuity.status, "Paid")
|
||||||
self.assertEqual(gratuity.paid_amount, flt(gratuity.amount, 2))
|
self.assertEqual(flt(gratuity.paid_amount,2), flt(gratuity.amount, 2))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.db.sql("DELETE FROM `tabGratuity`")
|
frappe.db.sql("DELETE FROM `tabGratuity`")
|
||||||
@@ -147,11 +127,32 @@ def get_gratuity_rule(name):
|
|||||||
|
|
||||||
return rule
|
return rule
|
||||||
|
|
||||||
|
def create_gratuity(**args):
|
||||||
|
if args:
|
||||||
|
args = frappe._dict(args)
|
||||||
|
gratuity = frappe.new_doc("Gratuity")
|
||||||
|
gratuity.employee = args.employee
|
||||||
|
gratuity.posting_date = getdate()
|
||||||
|
gratuity.gratuity_rule = args.rule or "Rule Under Limited Contract (UAE)"
|
||||||
|
gratuity.pay_via_salary_slip = args.pay_via_salary_slip or 0
|
||||||
|
if gratuity.pay_via_salary_slip:
|
||||||
|
gratuity.payroll_date = getdate()
|
||||||
|
gratuity.salary_component = "Performance Bonus"
|
||||||
|
else:
|
||||||
|
gratuity.expense_account = args.expense_account or 'Payment Account - _TC'
|
||||||
|
gratuity.payable_account = args.payable_account or get_payable_account("_Test Company")
|
||||||
|
gratuity.mode_of_payment = args.mode_of_payment or 'Cash'
|
||||||
|
|
||||||
|
gratuity.save()
|
||||||
|
gratuity.submit()
|
||||||
|
|
||||||
|
return gratuity
|
||||||
|
|
||||||
def set_mode_of_payment_account():
|
def set_mode_of_payment_account():
|
||||||
if not frappe.db.exists("Account", "Payment Account - _TC"):
|
if not frappe.db.exists("Account", "Payment Account - _TC"):
|
||||||
mode_of_payment = create_account()
|
mode_of_payment = create_account()
|
||||||
else:
|
|
||||||
mode_of_payment = frappe.get_doc("Mode of Payment", "Cash")
|
mode_of_payment = frappe.get_doc("Mode of Payment", "Cash")
|
||||||
|
|
||||||
mode_of_payment.accounts = []
|
mode_of_payment.accounts = []
|
||||||
mode_of_payment.append("accounts", {
|
mode_of_payment.append("accounts", {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
"fieldname": "calculate_gratuity_amount_based_on",
|
"fieldname": "calculate_gratuity_amount_based_on",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Calculate Gratuity Amount Based on",
|
"label": "Calculate Gratuity Amount Based On",
|
||||||
"options": "Current Slab\nSum of all previous slabs",
|
"options": "Current Slab\nSum of all previous slabs",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
"default": "365",
|
"default": "365",
|
||||||
"fieldname": "total_working_days_per_year",
|
"fieldname": "total_working_days_per_year",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Total Working Days Per Year"
|
"label": "Total working Days Per Year"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "minimum_year_for_gratuity",
|
"fieldname": "minimum_year_for_gratuity",
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-10-27 14:04:31.617621",
|
"modified": "2020-12-03 17:08:27.891535",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Payroll",
|
"module": "Payroll",
|
||||||
"name": "Gratuity Rule",
|
"name": "Gratuity Rule",
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ def create_salary_slips_for_employees(employees, args, publish_progress=True):
|
|||||||
title = _("Creating Salary Slips..."))
|
title = _("Creating Salary Slips..."))
|
||||||
else:
|
else:
|
||||||
salary_slip_name = frappe.db.sql(
|
salary_slip_name = frappe.db.sql(
|
||||||
'''SELECT
|
'''SELECT
|
||||||
name
|
name
|
||||||
FROM `tabSalary Slip`
|
FROM `tabSalary Slip`
|
||||||
WHERE company=%s
|
WHERE company=%s
|
||||||
|
|||||||
Reference in New Issue
Block a user