示例#1
0
def review(facility_name, year = None, month = None):
    # options for dropdowns
    select_years = util.get_last_x_years(5)
    select_months = util.get_months_dict()

    if not month or not year: #mostly we default to last_month
        # default to last month, get start and end dates
        last_month = util.get_last_month()
        year = last_month.year
        month = last_month.month

    from_date, to_date = util.start_and_end_month(year, month)

    # get line_items for month
    criteria = {
            ('line_item', 'date_created'): {'from': from_date, 'to': to_date},
            ('line_item', 'price_per_unit'): {'compare': 'greater than', 'value': 0}
    }
    tqc = TableQueryCollection('line_item', criteria)
    table_query = tqc.get_first()
    pt = PageTemplate(MODULE_NAME, 'review')
    return pt.page_template_context(
            year = year, month = month,
            select_years = select_years, select_months = select_months,
            table_name = 'line_item', table_query = table_query
    )
示例#2
0
def invoice_summary(facility_name, year, month):
    # options for dropdowns
    select_years = util.get_last_x_years(5)
    select_months = util.get_months_dict()
    from_date, to_date = util.start_and_end_month(year, month)

    criteria = {
            ('invoice', 'invoice_month'): {'from': from_date, 'to': to_date},
    }
    tqc = TableQueryCollection('invoice', criteria)
    hidden_fields = {'year': year, 'month': month}
    pt = PageTemplate(MODULE_NAME, 'invoice_summary')
    return pt.page_template_context(
            select_years = select_years, select_months = select_months,
            year = year, month = month, from_date = from_date, table_name = 'invoice', table_query = tqc.queries[0],
            hidden_fields = hidden_fields, facility_name = facility_name
    )
示例#3
0
def reports(facility_name, year = None, month = None):
    # options for dropdowns
    select_years = util.get_last_x_years(5)
    select_months = util.get_months_dict()

    if not month or not year: #mostly we default to last_month
        # default to last month, get start and end dates
        last_month = util.get_last_month()
        year = last_month.year
        month = last_month.month

    lc = LineItemCollection(year, month)
    lc.populate_report_data()
    pt = PageTemplate(MODULE_NAME, 'reports')
    return pt.page_template_context(
            lc = lc, year = year, month = month,
            select_years = select_years, select_months = select_months)