fix: requested changes and sider

This commit is contained in:
Anurag Mishra 2020-11-24 18:36:26 +05:30
parent 66b697cd05
commit af9f172be8
5 changed files with 23 additions and 32 deletions

View File

@ -2,15 +2,15 @@
// For license information, please see license.txt // For license information, please see license.txt
frappe.ui.form.on('Gratuity', { frappe.ui.form.on('Gratuity', {
setup: function(frm){ setup: function (frm) {
frm.set_query('salary_component', function() { frm.set_query('salary_component', function () {
return { return {
filters: { filters: {
type: "Earning" type: "Earning"
} }
}; };
}); });
frm.set_query("expense_account", function() { frm.set_query("expense_account", function () {
return { return {
filters: { filters: {
"root_type": "Expense", "root_type": "Expense",
@ -20,7 +20,7 @@ frappe.ui.form.on('Gratuity', {
}; };
}); });
frm.set_query("payable_account", function() { frm.set_query("payable_account", function () {
return { return {
filters: { filters: {
"root_type": "Liability", "root_type": "Liability",
@ -30,16 +30,16 @@ frappe.ui.form.on('Gratuity', {
}; };
}); });
}, },
refresh: function(frm){ 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.pay_via_salary_slip === 0 && frm.doc.status === "Unpaid") {
frm.add_custom_button(__("Create Payment Entry"), function() { frm.add_custom_button(__("Create Payment Entry"), function () {
return frappe.call({ return frappe.call({
method: 'erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry', method: 'erpnext.accounts.doctype.payment_entry.payment_entry.get_payment_entry',
args: { args: {
"dt": frm.doc.doctype, "dt": frm.doc.doctype,
"dn": frm.doc.name "dn": frm.doc.name
}, },
callback: function(r) { callback: function (r) {
var doclist = frappe.model.sync(r.message); var doclist = frappe.model.sync(r.message);
frappe.set_route("Form", doclist[0].doctype, doclist[0].name); frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
} }
@ -47,18 +47,18 @@ frappe.ui.form.on('Gratuity', {
}); });
} }
}, },
employee: function(frm) { employee: function (frm) {
frm.events.calculate_work_experience_and_amount(frm); frm.events.calculate_work_experience_and_amount(frm);
}, },
gratuity_rule: function(frm){ gratuity_rule: function (frm) {
frm.events.calculate_work_experience_and_amount(frm); frm.events.calculate_work_experience_and_amount(frm);
}, },
calculate_work_experience_and_amount: function(frm) { calculate_work_experience_and_amount: function (frm) {
if(frm.doc.employee && frm.doc.gratuity_rule){ if (frm.doc.employee && frm.doc.gratuity_rule) {
frappe.call({ frappe.call({
method:"erpnext.payroll.doctype.gratuity.gratuity.calculate_work_experience_and_amount", method: "erpnext.payroll.doctype.gratuity.gratuity.calculate_work_experience_and_amount",
args:{ args: {
employee: frm.doc.employee, employee: frm.doc.employee,
gratuity_rule: frm.doc.gratuity_rule gratuity_rule: frm.doc.gratuity_rule
} }

View File

@ -6,15 +6,16 @@ from __future__ import unicode_literals
import frappe import frappe
import unittest import unittest
from erpnext.hr.doctype.employee.test_employee import make_employee from erpnext.hr.doctype.employee.test_employee import make_employee
from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_employee_salary_slip from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_employee_salary_slip, make_earning_salary_component
from erpnext.payroll.doctype.gratuity.gratuity import get_last_salary_slip from erpnext.payroll.doctype.gratuity.gratuity import get_last_salary_slip
from erpnext.regional.united_arab_emirates.setup import create_gratuity_rule from erpnext.regional.united_arab_emirates.setup import create_gratuity_rule
from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account
from frappe.utils import getdate, add_days, get_datetime, flt from frappe.utils import getdate, add_days, get_datetime, flt
test_dependencies = ["Salary Component", "Salary Slip"]
class TestGratuity(unittest.TestCase): class TestGratuity(unittest.TestCase):
def setUp(self): def setUp(self):
make_earning_salary_component()
frappe.db.sql("DELETE FROM `tabGratuity`") frappe.db.sql("DELETE FROM `tabGratuity`")
frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'") frappe.db.sql("DELETE FROM `tabAdditional Salary` WHERE ref_doctype = 'Gratuity'")
@ -168,15 +169,9 @@ def create_employee_and_get_last_salary_slip():
else: else:
salary_slip = get_last_salary_slip(employee) salary_slip = get_last_salary_slip(employee)
#just to see what going on travis will remove this
print(frappe.db.get_value("Employee", "test_employee@salary.com", "company"))
print(frappe.db.get_value("Employee", "test_employee@salary.com", "holiday_list"))
if not frappe.db.get_value("Employee", "test_employee@salary.com", "holiday_list"): if not frappe.db.get_value("Employee", "test_employee@salary.com", "holiday_list"):
from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list
make_holiday_list() make_holiday_list()
frappe.db.set_value("Company", '_Test Company', "default_holiday_list", "Salary Slip Test Holiday List") frappe.db.set_value("Company", '_Test Company', "default_holiday_list", "Salary Slip Test Holiday List")
print(frappe.db.get_value("Employee", "test_employee@salary.com", "holiday_list"))
return employee, salary_slip return employee, salary_slip

View File

@ -25,17 +25,16 @@ frappe.ui.form.on('Gratuity Rule Slab', {
gratuity_rule_slabs_add(frm, cdt, cdn) { gratuity_rule_slabs_add(frm, cdt, cdn) {
let row = locals[cdt][cdn]; let row = locals[cdt][cdn];
let array_idx = row.idx - 1; let array_idx = row.idx - 1;
if(array_idx > 0){ if (array_idx > 0) {
row.from_year = cur_frm.doc.gratuity_rule_slabs[array_idx-1].to_year; row.from_year = cur_frm.doc.gratuity_rule_slabs[array_idx - 1].to_year;
frm.refresh(); frm.refresh();
} }
}, },
to_year(frm, cdt, cdn) { to_year(frm, cdt, cdn) {
let row = locals[cdt][cdn]; let row = locals[cdt][cdn];
if (row.to_year <= row.from_year && row.to_year === 0){ if (row.to_year <= row.from_year && row.to_year === 0) {
frappe.throw(__("To(Year) year can not be less than From(year) ")); frappe.throw(__("To(Year) year can not be less than From(year) "));
} }
} }
}); });

View File

@ -21,6 +21,7 @@ from erpnext.payroll.doctype.employee_tax_exemption_declaration.test_employee_ta
class TestSalarySlip(unittest.TestCase): class TestSalarySlip(unittest.TestCase):
def setUp(self): def setUp(self):
setup_test() setup_test()
def tearDown(self): def tearDown(self):
frappe.db.set_value("Payroll Settings", None, "include_holidays_in_total_working_days", 0) frappe.db.set_value("Payroll Settings", None, "include_holidays_in_total_working_days", 0)
frappe.set_user("Administrator") frappe.set_user("Administrator")

View File

@ -12,13 +12,9 @@ from erpnext.payroll.doctype.gratuity_rule.gratuity_rule import get_gratuity_rul
def setup(company=None, patch=True): def setup(company=None, patch=True):
make_custom_fields() make_custom_fields()
add_print_formats() add_print_formats()
<<<<<<< HEAD
add_custom_roles_for_reports() add_custom_roles_for_reports()
add_permissions() add_permissions()
create_standard_documents()
=======
create_gratuity_rule() create_gratuity_rule()
>>>>>>> test: gratuity
if company: if company:
create_sales_tax(company) create_sales_tax(company)