minor ux fix

This commit is contained in:
Nabin Hait 2018-06-12 16:28:58 +05:30
parent 6c4fa1e917
commit 76c51b3068
5 changed files with 218 additions and 184 deletions

View File

@ -3,7 +3,7 @@
"allow_guest_to_view": 0, "allow_guest_to_view": 0,
"allow_import": 1, "allow_import": 1,
"allow_rename": 1, "allow_rename": 1,
"autoname": "Retention-Bonus-.####", "autoname": "RB-.####",
"beta": 0, "beta": 0,
"creation": "2018-05-13 14:59:42.038964", "creation": "2018-05-13 14:59:42.038964",
"custom": 0, "custom": 0,
@ -15,6 +15,7 @@
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -47,6 +48,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -79,6 +81,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -110,6 +113,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -141,6 +145,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -172,6 +177,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -202,6 +208,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -235,6 +242,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -268,6 +276,7 @@
}, },
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
@ -310,7 +319,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-05-17 10:36:01.865302", "modified": "2018-06-12 16:28:11.071680",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Retention Bonus", "name": "Retention Bonus",

View File

@ -30,9 +30,11 @@ frappe.ui.form.on('Salary Component', {
}, },
type: function(frm) { type: function(frm) {
if(frm.doc.type=="Earning"){ if(frm.doc.type=="Earning"){
frm.set_value("is_tax_applicable", 1);
frm.set_value("variable_based_on_taxable_salary", 0); frm.set_value("variable_based_on_taxable_salary", 0);
} }
if(frm.doc.type=="Deduction"){ if(frm.doc.type=="Deduction"){
frm.set_value("is_tax_applicable", 0);
frm.set_value("is_flexible_benefit", 0); frm.set_value("is_flexible_benefit", 0);
} }
}, },

View File

@ -151,6 +151,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "1",
"depends_on": "eval:doc.type == \"Earning\"", "depends_on": "eval:doc.type == \"Earning\"",
"fieldname": "is_tax_applicable", "fieldname": "is_tax_applicable",
"fieldtype": "Check", "fieldtype": "Check",
@ -1001,7 +1002,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-06-05 14:02:49.277515", "modified": "2018-06-12 14:52:28.688391",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "HR", "module": "HR",
"name": "Salary Component", "name": "Salary Component",
@ -1026,6 +1027,25 @@
"share": 1, "share": 1,
"submit": 0, "submit": 0,
"write": 1 "write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"delete": 0,
"email": 0,
"export": 0,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 0,
"read": 1,
"report": 0,
"role": "Employee",
"set_user_permissions": 0,
"share": 0,
"submit": 0,
"write": 0
} }
], ],
"quick_entry": 0, "quick_entry": 0,

View File

@ -6,6 +6,13 @@ cur_frm.add_fetch('time_sheet', 'total_hours', 'working_hours');
frappe.ui.form.on("Salary Slip", { frappe.ui.form.on("Salary Slip", {
setup: function(frm) { setup: function(frm) {
$.each(["earnings", "deductions"], function(i, table_fieldname) {
frm.get_field(table_fieldname).grid.editable_fields = [
{fieldname: 'salary_component', columns: 6},
{fieldname: 'amount', columns: 4}
];
})
frm.fields_dict["timesheets"].grid.get_field("time_sheet").get_query = function(){ frm.fields_dict["timesheets"].grid.get_field("time_sheet").get_query = function(){
return { return {
filters: { filters: {
@ -61,13 +68,10 @@ frappe.ui.form.on("Salary Slip", {
refresh: function(frm) { refresh: function(frm) {
frm.trigger("toggle_fields") frm.trigger("toggle_fields")
frm.trigger("toggle_reqd_fields") frm.trigger("toggle_reqd_fields")
var salary_detail_fields = ['formula', 'abbr', 'statistical_component'] var salary_detail_fields = ["formula", "abbr", "statistical_component", "is_tax_applicable",
"is_flexible_benefit", "variable_based_on_taxable_salary"]
cur_frm.fields_dict['earnings'].grid.set_column_disp(salary_detail_fields,false); cur_frm.fields_dict['earnings'].grid.set_column_disp(salary_detail_fields,false);
cur_frm.fields_dict['deductions'].grid.set_column_disp(salary_detail_fields,false); cur_frm.fields_dict['deductions'].grid.set_column_disp(salary_detail_fields,false);
let fields_read_only = ["is_tax_applicable", "is_flexible_benefit", "variable_based_on_taxable_salary"];
fields_read_only.forEach(function(field) {
frappe.meta.get_docfield("Salary Detail", field, frm.doc.name).read_only = 1;
});
}, },
salary_slip_based_on_timesheet: function(frm, dt, dn) { salary_slip_based_on_timesheet: function(frm, dt, dn) {

View File

@ -503,14 +503,13 @@ class SalarySlip(TransactionBase):
def calculate_variable_based_on_taxable_salary(self, tax_component): def calculate_variable_based_on_taxable_salary(self, tax_component):
payroll_period = get_payroll_period(self.start_date, self.end_date, self.company) payroll_period = get_payroll_period(self.start_date, self.end_date, self.company)
if not payroll_period: if not payroll_period:
frappe.msgprint(_("Start and end dates not in a valid Payroll Period, \ frappe.msgprint(_("Start and end dates not in a valid Payroll Period, cannot calculate {0}.")
cannot calculate {0}.").format(tax_component)) .format(tax_component))
return False, False return False, False
if payroll_period.end_date <= getdate(self.end_date): if payroll_period.end_date <= getdate(self.end_date):
if not self.deduct_tax_for_unsubmitted_tax_exemption_proof \ if not self.deduct_tax_for_unsubmitted_tax_exemption_proof \
or not self.deduct_tax_for_unclaimed_employee_benefits: or not self.deduct_tax_for_unclaimed_employee_benefits:
frappe.throw(_("You have to Deduct Tax for Unsubmitted Tax Exemption Proof \ frappe.throw(_("You have to Deduct Tax for Unsubmitted Tax Exemption Proof and Unclaimed Employee Benefits in the last Salary Slip of Payroll Period"))
and Unclaimed Employee Benefits in the last Salary Slip of Payroll Period"))
else: else:
return self.calculate_tax_for_payroll_period(tax_component, payroll_period) return self.calculate_tax_for_payroll_period(tax_component, payroll_period)