[Fix]Salary Slip can be created without salary structure
This commit is contained in:
parent
1f53aaf093
commit
273c5e71fd
@ -13,6 +13,20 @@ frappe.ui.form.on("Salary Slip", {
|
||||
}
|
||||
}
|
||||
}
|
||||
frm.set_query("salary_component", "earnings", function() {
|
||||
return {
|
||||
filters: {
|
||||
type: "earning"
|
||||
}
|
||||
}
|
||||
})
|
||||
frm.set_query("salary_component", "deductions", function() {
|
||||
return {
|
||||
filters: {
|
||||
type: "deduction"
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
company: function(frm) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -40,14 +41,15 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "posting_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "posting Date",
|
||||
"label": "Posting Date",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
@ -65,6 +67,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -92,6 +95,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "employee_name",
|
||||
"fieldtype": "Read Only",
|
||||
"hidden": 0,
|
||||
@ -119,6 +123,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "department",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -146,6 +151,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "designation",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -173,6 +179,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "branch",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -200,6 +207,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -225,6 +233,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -250,6 +259,7 @@
|
||||
"allow_on_submit": 1,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "letter_head",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -275,6 +285,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "section_break_10",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -299,6 +310,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "salary_slip_based_on_timesheet",
|
||||
"fieldtype": "Check",
|
||||
@ -326,6 +338,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "fiscal_year",
|
||||
"fieldtype": "Link",
|
||||
@ -354,6 +367,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "month",
|
||||
"fieldtype": "Select",
|
||||
@ -383,6 +397,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "start_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@ -408,6 +423,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Today",
|
||||
"depends_on": "",
|
||||
"fieldname": "end_date",
|
||||
@ -435,6 +451,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_15",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -459,6 +476,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "salary_structure",
|
||||
"fieldtype": "Link",
|
||||
@ -486,6 +504,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "total_days_in_month",
|
||||
"fieldtype": "Float",
|
||||
@ -513,6 +532,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "leave_without_pay",
|
||||
"fieldtype": "Float",
|
||||
@ -540,6 +560,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "payment_days",
|
||||
"fieldtype": "Float",
|
||||
@ -567,6 +588,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "hourly_wages",
|
||||
"fieldtype": "Section Break",
|
||||
@ -593,6 +615,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "timesheets",
|
||||
"fieldtype": "Table",
|
||||
@ -620,6 +643,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_20",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -644,6 +668,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "total_working_hours",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@ -669,6 +694,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "hour_rate",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -694,6 +720,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "section_break_26",
|
||||
"fieldtype": "Section Break",
|
||||
@ -720,6 +747,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "bank_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@ -746,6 +774,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "bank_account_no",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@ -772,6 +801,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_01",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -796,6 +826,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -823,6 +854,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "earning_deduction",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -848,6 +880,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "earning",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -874,6 +907,8 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fieldname": "earnings",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@ -901,6 +936,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "deduction",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -927,6 +963,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "deductions",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@ -954,6 +991,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "totals",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@ -979,6 +1017,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "arrear_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -1006,6 +1045,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "leave_encashment_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -1033,6 +1073,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "gross_pay",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -1060,6 +1101,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_25",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@ -1083,6 +1125,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "total_deduction",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -1110,6 +1153,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Gross Pay + Arrear Amount +Encashment Amount - Total Deduction",
|
||||
"fieldname": "net_pay",
|
||||
"fieldtype": "Currency",
|
||||
@ -1138,6 +1182,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "rounded_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -1163,6 +1208,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Net Pay (in words) will be visible once you save the Salary Slip.",
|
||||
"fieldname": "total_in_words",
|
||||
"fieldtype": "Data",
|
||||
@ -1198,7 +1244,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2016-09-19 15:15:06.809508",
|
||||
"modified": "2016-09-24 05:16:54.102341",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Slip",
|
||||
|
@ -324,7 +324,8 @@ class SalarySlip(TransactionBase):
|
||||
self.set(total_field, self.get(total_field) + flt(d.amount))
|
||||
|
||||
def calculate_net_pay(self):
|
||||
self.calculate_component_amounts()
|
||||
if self.salary_structure:
|
||||
self.calculate_component_amounts()
|
||||
|
||||
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))
|
||||
|
||||
|
@ -41,12 +41,12 @@ class TestSalarySlip(unittest.TestCase):
|
||||
|
||||
self.assertEquals(ss.total_days_in_month, 31)
|
||||
self.assertEquals(ss.payment_days, 31)
|
||||
self.assertEquals(ss.earnings[0].amount, 0)
|
||||
self.assertEquals(ss.earnings[1].amount, 0)
|
||||
self.assertEquals(ss.deductions[0].amount, 0)
|
||||
self.assertEquals(ss.deductions[1].amount, 0)
|
||||
self.assertEquals(ss.gross_pay, 0)
|
||||
self.assertEquals(ss.net_pay, 0)
|
||||
self.assertEquals(ss.earnings[0].amount, 5000)
|
||||
self.assertEquals(ss.earnings[1].amount, 3000)
|
||||
self.assertEquals(ss.deductions[0].amount, 5000)
|
||||
self.assertEquals(ss.deductions[1].amount, 2500)
|
||||
self.assertEquals(ss.gross_pay, 10500)
|
||||
self.assertEquals(ss.net_pay, 3000)
|
||||
|
||||
def test_salary_slip_with_holidays_excluded(self):
|
||||
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
||||
@ -58,13 +58,13 @@ class TestSalarySlip(unittest.TestCase):
|
||||
|
||||
self.assertEquals(ss.total_days_in_month, 27)
|
||||
self.assertEquals(ss.payment_days, 27)
|
||||
self.assertEquals(ss.earnings[0].amount, 0)
|
||||
self.assertEquals(ss.earnings[0].amount, 5000)
|
||||
self.assertEquals(ss.earnings[0].default_amount, 5000)
|
||||
self.assertEquals(ss.earnings[1].amount, 0)
|
||||
self.assertEquals(ss.deductions[0].amount, 0)
|
||||
self.assertEquals(ss.deductions[1].amount, 0)
|
||||
self.assertEquals(ss.gross_pay, 0)
|
||||
self.assertEquals(ss.net_pay, 0)
|
||||
self.assertEquals(ss.earnings[1].amount, 3000)
|
||||
self.assertEquals(ss.deductions[0].amount, 5000)
|
||||
self.assertEquals(ss.deductions[1].amount, 2500)
|
||||
self.assertEquals(ss.gross_pay, 10500)
|
||||
self.assertEquals(ss.net_pay, 3000)
|
||||
|
||||
def test_payment_days(self):
|
||||
# Holidays not included in working days
|
||||
@ -179,6 +179,7 @@ class TestSalarySlip(unittest.TestCase):
|
||||
salary_slip.employee_name = frappe.get_value("Employee", {"name":frappe.db.get_value("Employee", {"user_id": user})}, "employee_name")
|
||||
salary_slip.month = "12"
|
||||
salary_slip.fiscal_year = "_Test Fiscal Year 2016"
|
||||
salary_slip.posting_date = nowdate()
|
||||
salary_slip.insert()
|
||||
# salary_slip.submit()
|
||||
salary_slip = salary_slip.name
|
||||
|
@ -98,6 +98,7 @@ def make_salary_slip_from_salary_structure(employee):
|
||||
sal_slip.employee_name = frappe.get_value("Employee", {"name":employee}, "employee_name")
|
||||
sal_slip.month = "11"
|
||||
sal_slip.fiscal_year = "_Test Fiscal Year 2016"
|
||||
sal_slip.posting_date = nowdate()
|
||||
sal_slip.insert()
|
||||
sal_slip.submit()
|
||||
return sal_slip
|
||||
|
@ -30,7 +30,7 @@ class TestTimesheet(unittest.TestCase):
|
||||
|
||||
self.assertEquals(salary_slip.total_working_hours, 2)
|
||||
self.assertEquals(salary_slip.hour_rate, 50)
|
||||
self.assertEquals(salary_slip.net_pay, 50)
|
||||
self.assertEquals(salary_slip.net_pay, 150)
|
||||
self.assertEquals(salary_slip.timesheets[0].time_sheet, timesheet.name)
|
||||
self.assertEquals(salary_slip.timesheets[0].working_hours, 2)
|
||||
|
||||
|
@ -345,6 +345,7 @@ def set_missing_values(time_sheet, target):
|
||||
target.salary_slip_based_on_timesheet = 1
|
||||
target.start_date = doc.start_date
|
||||
target.end_date = doc.end_date
|
||||
target.posting_date = doc.modified
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_activity_cost(employee=None, activity_type=None):
|
||||
|
Loading…
Reference in New Issue
Block a user