mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
feat: Full and Final Settlement and Gratuity Fix (#26364)
* feat: Full and Final Settlement * removed option to pay via salary slip * feat: Create JV * test:fnf * fix: tracking asset movement * fix: sider and test * fix: changes Requested * fix: changes requested * fix: valication for Asset * fix: add filter for reference document only if relevant field is present * fix: doctype cleanup - add more fields to the list view and standard filter - set title field - incorrect field labels * feat: add list view settings for FNF * fix: incorrect reference type set in Journal Entry * fix: validation message * chore: add Full and Final Statement link to Workspace Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
This commit is contained in:
@@ -3,13 +3,6 @@
|
||||
|
||||
frappe.ui.form.on('Gratuity', {
|
||||
setup: function (frm) {
|
||||
frm.set_query('salary_component', function () {
|
||||
return {
|
||||
filters: {
|
||||
type: "Earning"
|
||||
}
|
||||
};
|
||||
});
|
||||
frm.set_query("expense_account", function () {
|
||||
return {
|
||||
filters: {
|
||||
@@ -31,7 +24,7 @@ frappe.ui.form.on('Gratuity', {
|
||||
});
|
||||
},
|
||||
refresh: function (frm) {
|
||||
if (frm.doc.docstatus === 1 && frm.doc.pay_via_salary_slip === 0 && frm.doc.status === "Unpaid") {
|
||||
if (frm.doc.docstatus == 1 && frm.doc.status == "Unpaid") {
|
||||
frm.add_custom_button(__("Create Payment Entry"), function () {
|
||||
return frappe.call({
|
||||
method: 'erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry',
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
"company",
|
||||
"gratuity_rule",
|
||||
"section_break_5",
|
||||
"pay_via_salary_slip",
|
||||
"payroll_date",
|
||||
"salary_component",
|
||||
"payable_account",
|
||||
"expense_account",
|
||||
"mode_of_payment",
|
||||
@@ -49,26 +46,12 @@
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"fieldname": "pay_via_salary_slip",
|
||||
"fieldtype": "Check",
|
||||
"label": "Pay via Salary Slip"
|
||||
},
|
||||
{
|
||||
"fieldname": "posting_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Posting date",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.pay_via_salary_slip == 1",
|
||||
"fieldname": "salary_component",
|
||||
"fieldtype": "Link",
|
||||
"label": "Salary Component",
|
||||
"mandatory_depends_on": "eval: doc.pay_via_salary_slip == 1",
|
||||
"options": "Salary Component"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "current_work_experience",
|
||||
@@ -95,20 +78,18 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Expense Account",
|
||||
"mandatory_depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"options": "Account"
|
||||
"options": "Account",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"fieldname": "mode_of_payment",
|
||||
"fieldtype": "Link",
|
||||
"label": "Mode of Payment",
|
||||
"mandatory_depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"options": "Mode of Payment"
|
||||
"options": "Mode of Payment",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "gratuity_rule",
|
||||
@@ -161,13 +142,6 @@
|
||||
"fieldname": "column_break_15",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.pay_via_salary_slip == 1",
|
||||
"fieldname": "payroll_date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Payroll Date",
|
||||
"mandatory_depends_on": "eval: doc.pay_via_salary_slip == 1"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:doc.pay_via_salary_slip == 0",
|
||||
@@ -177,26 +151,23 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"fieldname": "payable_account",
|
||||
"fieldtype": "Link",
|
||||
"label": "Payable Account",
|
||||
"mandatory_depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"options": "Account"
|
||||
"options": "Account",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"label": "Cost Center",
|
||||
"mandatory_depends_on": "eval: doc.pay_via_salary_slip == 0",
|
||||
"options": "Cost Center"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-11-02 18:21:11.971488",
|
||||
"modified": "2021-07-02 15:05:57.396398",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Payroll",
|
||||
"name": "Gratuity",
|
||||
|
||||
@@ -19,10 +19,7 @@ class Gratuity(AccountsController):
|
||||
self.status = "Unpaid"
|
||||
|
||||
def on_submit(self):
|
||||
if self.pay_via_salary_slip:
|
||||
self.create_additional_salary()
|
||||
else:
|
||||
self.create_gl_entries()
|
||||
self.create_gl_entries()
|
||||
|
||||
def on_cancel(self):
|
||||
self.ignore_linked_doctypes = ['GL Entry']
|
||||
@@ -65,19 +62,6 @@ class Gratuity(AccountsController):
|
||||
|
||||
return gl_entry
|
||||
|
||||
def create_additional_salary(self):
|
||||
if self.pay_via_salary_slip:
|
||||
additional_salary = frappe.new_doc('Additional Salary')
|
||||
additional_salary.employee = self.employee
|
||||
additional_salary.salary_component = self.salary_component
|
||||
additional_salary.overwrite_salary_structure_amount = 0
|
||||
additional_salary.amount = self.amount
|
||||
additional_salary.payroll_date = self.payroll_date
|
||||
additional_salary.company = self.company
|
||||
additional_salary.ref_doctype = self.doctype
|
||||
additional_salary.ref_docname = self.name
|
||||
additional_salary.submit()
|
||||
|
||||
def set_total_advance_paid(self):
|
||||
paid_amount = frappe.db.sql("""
|
||||
select ifnull(sum(debit_in_account_currency), 0) as paid_amount
|
||||
|
||||
@@ -11,10 +11,6 @@ def get_data():
|
||||
{
|
||||
'label': _('Payment'),
|
||||
'items': ['Payment Entry']
|
||||
},
|
||||
{
|
||||
'label': _('Additional Salary'),
|
||||
'items': ['Additional Salary']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -22,19 +22,18 @@ class TestGratuity(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
frappe.db.sql("DELETE FROM `tabGratuity`")
|
||||
frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'")
|
||||
|
||||
def test_get_last_salary_slip_should_return_none_for_new_employee(self):
|
||||
new_employee = make_employee("new_employee@salary.com", company='_Test Company')
|
||||
salary_slip = get_last_salary_slip(new_employee)
|
||||
assert salary_slip is None
|
||||
|
||||
def test_check_gratuity_amount_based_on_current_slab_and_additional_salary_creation(self):
|
||||
def test_check_gratuity_amount_based_on_current_slab(self):
|
||||
employee, sal_slip = create_employee_and_get_last_salary_slip()
|
||||
|
||||
rule = get_gratuity_rule("Rule Under Unlimited Contract on termination (UAE)")
|
||||
|
||||
gratuity = create_gratuity(pay_via_salary_slip = 1, employee=employee, rule=rule.name)
|
||||
gratuity = create_gratuity(employee=employee, rule=rule.name)
|
||||
|
||||
#work experience calculation
|
||||
date_of_joining, relieving_date = frappe.db.get_value('Employee', employee, ['date_of_joining', 'relieving_date'])
|
||||
@@ -62,9 +61,6 @@ class TestGratuity(unittest.TestCase):
|
||||
|
||||
self.assertEqual(flt(gratuity_amount, 2), flt(gratuity.amount, 2))
|
||||
|
||||
#additional salary creation (Pay via salary slip)
|
||||
self.assertTrue(frappe.db.exists("Additional Salary", {"ref_docname": gratuity.name}))
|
||||
|
||||
def test_check_gratuity_amount_based_on_all_previous_slabs(self):
|
||||
employee, sal_slip = create_employee_and_get_last_salary_slip()
|
||||
rule = get_gratuity_rule("Rule Under Limited Contract (UAE)")
|
||||
@@ -142,14 +138,9 @@ def create_gratuity(**args):
|
||||
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.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()
|
||||
|
||||
Reference in New Issue
Block a user