Merge pull request #4103 from nabinhait/monthly_attendance_sheet
[fix] Month issue fixed in Monthly Attendance Sheet
This commit is contained in:
commit
0353569e8b
@ -5,6 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, cint
|
from frappe.utils import cstr, cint
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
|
from calendar import monthrange
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters: filters = {}
|
if not filters: filters = {}
|
||||||
@ -73,23 +74,17 @@ def get_conditions(filters):
|
|||||||
msgprint(_("Please select month and year"), raise_exception=1)
|
msgprint(_("Please select month and year"), raise_exception=1)
|
||||||
|
|
||||||
filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
filters["month"] = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
|
||||||
"Dec"].index(filters["month"]) + 1
|
"Dec"].index(filters.month) + 1
|
||||||
|
|
||||||
from frappe.model.document import Document
|
year_start_date, year_end_date = frappe.db.get_value("Fiscal Year", filters.fiscal_year,
|
||||||
fiscal_years = frappe.get_doc("Fiscal Year",filters["fiscal_year"])
|
["year_start_date", "year_end_date"])
|
||||||
import datetime
|
|
||||||
year_start = fiscal_years.year_start_date.strftime("%Y")
|
if filters.month >= year_start_date.strftime("%m"):
|
||||||
year_end = fiscal_years.year_end_date.strftime("%Y")
|
year = year_start_date.strftime("%Y")
|
||||||
dt_test = datetime.datetime.strptime(year_end + "-" + str(100+int(filters["month"]))[2:3] + "-01", "%Y-%m-%d")
|
|
||||||
date_test = datetime.date(dt_test.year, dt_test.month, dt_test.day)
|
|
||||||
if date_test > fiscal_years.year_end_date:
|
|
||||||
year_target = year_start
|
|
||||||
else:
|
else:
|
||||||
year_target = year_end
|
year = year_end_date.strftime("%Y")
|
||||||
|
|
||||||
from calendar import monthrange
|
filters["total_days_in_month"] = monthrange(cint(year), filters.month)[1]
|
||||||
filters["total_days_in_month"] = monthrange(cint(year_target),
|
|
||||||
filters["month"])[1]
|
|
||||||
|
|
||||||
conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s"
|
conditions = " and month(att_date) = %(month)s and fiscal_year = %(fiscal_year)s"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user