Changes to Salary Register

This commit is contained in:
Kanchan Chauhan 2017-01-11 19:43:16 +05:30
parent d40e661ebd
commit 2f3ae914a6
7 changed files with 40 additions and 49 deletions

View File

@ -232,7 +232,7 @@ def get_data():
{
"type": "report",
"is_query_report": True,
"name": "Monthly Salary Register",
"name": "Salary Register",
"doctype": "Salary Slip"
},
{

View File

@ -1,34 +0,0 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.query_reports["Monthly Salary Register"] = {
"filters": [
{
"fieldname":"from_date",
"label": __("From"),
"fieldtype": "Date",
"default": frappe.datetime.add_months(frappe.datetime.get_today(), -1),
"reqd": 1
},
{
"fieldname":"to_date",
"label": __("To"),
"fieldtype": "Date",
"default": frappe.datetime.get_today(),
"reqd": 1
},
{
"fieldname":"employee",
"label": __("Employee"),
"fieldtype": "Link",
"options": "Employee"
},
{
"fieldname":"company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
}
]
}

View File

@ -2,8 +2,7 @@
{%= frappe.boot.letter_heads[filters.letter_head || frappe.defaults.get_default("letter_head")] %}
</div>
<h2 class="text-center">{%= __(report.report_name) %}</h2>
<h5 class="text-center">Fiscal Year: {%= filters.fiscal_year %}</h5>
<h5 class="text-center">Month: {%= filters.month %}</h5>
<h5 class="text-center">From {%= filters.date_range[0] %} to {%= filters.date_range[1] %}</h5>
<hr>
<table class="table table-bordered">
<thead>
@ -36,4 +35,3 @@
</tbody>
</table>
<p class="text-right text-muted">Printed On {%= dateutil.str_to_user(dateutil.get_datetime_as_string()) %}</p>

View File

@ -0,0 +1,27 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.query_reports["Salary Register"] = {
"filters": [
{
"fieldname":"date_range",
"label": __("Date Range"),
"fieldtype": "DateRange",
"default": [frappe.datetime.add_months(get_today(),-1), frappe.datetime.get_today()],
"reqd": 1
},
{
"fieldname":"employee",
"label": __("Employee"),
"fieldtype": "Link",
"options": "Employee"
},
{
"fieldname":"company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
}
]
}

View File

@ -1,17 +1,18 @@
{
"add_total_row": 1,
"apply_user_permissions": 1,
"creation": "2013-05-07 18:09:42",
"creation": "2017-01-10 17:36:58.153863",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 1,
"idx": 0,
"is_standard": "Yes",
"modified": "2014-06-03 07:18:17.187018",
"modified": "2017-01-10 17:38:00.832224",
"modified_by": "Administrator",
"module": "HR",
"name": "Monthly Salary Register",
"name": "Salary Register",
"owner": "Administrator",
"ref_doctype": "Salary Slip",
"report_name": "Monthly Salary Register",
"report_name": "Salary Register",
"report_type": "Script Report"
}

View File

@ -3,12 +3,11 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import flt, cstr
from frappe import msgprint, _
from frappe.utils import flt
from frappe import _
def execute(filters=None):
if not filters: filters = {}
salary_slips = get_salary_slips(filters)
columns, earning_types, ded_types = get_columns(salary_slips)
ss_earning_map = get_ss_earning_map(salary_slips)
@ -58,6 +57,7 @@ def get_columns(salary_slips):
return columns, salary_components[_("Earning")], salary_components[_("Deduction")]
def get_salary_slips(filters):
filters.update({"from_date": filters.get("date_range")[0], "to_date":filters.get("date_range")[1]})
conditions, filters = get_conditions(filters)
salary_slips = frappe.db.sql("""select * from `tabSalary Slip` where docstatus = 1 %s
order by employee""" % conditions, filters, as_dict=1)
@ -65,13 +65,12 @@ def get_salary_slips(filters):
if not salary_slips:
frappe.throw(_("No salary slip found between {0} and {1}").format(
filters.get("from_date"), filters.get("to_date")))
return salary_slips
def get_conditions(filters):
conditions = ""
if filters.get("from_date"): conditions += " and start_date >= %(from_date)s"
if filters.get("to_date"): conditions += " and end_date <= %(to_date)s"
if filters.get("date_range"): conditions += " and start_date >= %(from_date)s"
if filters.get("date_range"): conditions += " and end_date <= %(to_date)s"
if filters.get("company"): conditions += " and company = %(company)s"
if filters.get("employee"): conditions += " and employee = %(employee)s"