def get_period_date_ranges(period, fiscal_year=None, year_start_date=None): month_details= get_month_details(fiscal_year,period) period_date_ranges = [] period_date_ranges.append([month_details.get('first_day'),month_details.get('end_date1')]) return period_date_ranges
def get_period_list(filters,fiscal_year, month, from_beginning=False): import datetime """Get a list of dict {"to_date": to_date, "key": key, "label": label} Periodicity can be (Yearly, Quarterly, Monthly)""" month_details=get_month_details(fiscal_year,month) period_list=[] period_list_last_year =[] period_list.append(_dict({ "to_date": month_details.get('end_date1') })) period_list_last_year.append(_dict({ "to_date": month_details.get('last_year_to_date1') })) for opts in period_list: opts.update({ "key": month_details.get('current_fiscal_year'), "label": 'This Year', "year_start_date": month_details.get('start_date'), "year_end_date": month_details.get('end_date1') }) if from_beginning: # set start date as None for all fiscal periods, used in case of Balance Sheet opts["from_date"] = None else: opts["from_date"] = month_details.get('start_date') for optss in period_list_last_year: optss.update({ "key": month_details.get('last_fiscal_year'), "label": 'Last Year', "year_start_date": month_details.get('start_date_last_year'), "year_end_date": month_details.get('last_year_to_date1') }) if from_beginning: # set start date as None for all fiscal periods, used in case of Balance Sheet optss["from_date"] = None else: optss["from_date"] = month_details.get('start_date_last_year') return period_list ,period_list_last_year