def execute(filters=None):
    if not filters: filters = {}

    columns = get_columns(filters)
    period_month_ranges = get_period_month_ranges(filters["period"],
                                                  filters["fiscal_year"])
    sim_map = get_salesperson_item_month_map(filters)

    data = []
    for salesperson, salesperson_items in sim_map.items():
        for item_group, monthwise_data in salesperson_items.items():
            row = [salesperson, item_group]
            totals = [0, 0, 0]
            for relevant_months in period_month_ranges:
                period_data = [0, 0, 0]
                for month in relevant_months:
                    month_data = monthwise_data.get(month, {})
                    for i, fieldname in enumerate(
                        ["target", "achieved", "variance"]):
                        value = flt(month_data.get(fieldname))
                        period_data[i] += value
                        totals[i] += value
                period_data[2] = period_data[0] - period_data[1]
                row += period_data
            totals[2] = totals[0] - totals[1]
            row += totals
            data.append(row)

    return columns, sorted(data, key=lambda x: (x[0], x[1]))
示例#2
0
def execute(filters=None):
	if not filters: filters = {}
	
	columns = get_columns(filters)
	period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
	cam_map = get_costcenter_account_month_map(filters)

	precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2

	data = []

	for cost_center, cost_center_items in cam_map.items():
		for account, monthwise_data in cost_center_items.items():
			row = [cost_center, account]
			totals = [0, 0, 0]
			for relevant_months in period_month_ranges:
				period_data = [0, 0, 0]
				for month in relevant_months:
					month_data = monthwise_data.get(month, {})
					for i, fieldname in enumerate(["target", "actual", "variance"]):
						value = flt(month_data.get(fieldname), precision)
						period_data[i] += value
						totals[i] += value
				period_data[2] = period_data[0] - period_data[1]
				row += period_data
			totals[2] = totals[0] - totals[1]
			row += totals
			data.append(row)

	return columns, sorted(data, key=lambda x: (x[0], x[1]))
def execute(filters=None):
    if not filters:
        filters = {}

    columns = get_columns(filters)
    period_month_ranges = get_period_month_ranges(filters["period"], filters["fiscal_year"])
    tim_map = get_territory_item_month_map(filters)

    data = []
    for territory, territory_items in tim_map.items():
        for item_group, monthwise_data in territory_items.items():
            row = [territory, item_group]
            totals = [0, 0, 0]
            for relevant_months in period_month_ranges:
                period_data = [0, 0, 0]
                for month in relevant_months:
                    month_data = monthwise_data.get(month, {})
                    for i, fieldname in enumerate(["target", "achieved", "variance"]):
                        value = flt(month_data.get(fieldname))
                        period_data[i] += value
                        totals[i] += value
                period_data[2] = period_data[0] - period_data[1]
                row += period_data
            totals[2] = totals[0] - totals[1]
            row += totals
            data.append(row)

    return columns, sorted(data, key=lambda x: (x[0], x[1]))
def execute(filters=None):
    if not filters: filters = {}

    columns = get_columns(filters)
    period_month_ranges = get_period_month_ranges(filters["period"],
                                                  filters["fiscal_year"])
    cam_map = get_costcenter_account_month_map(filters)

    precision = webnotes.conn.get_value("Global Defaults", None,
                                        "float_precision") or 2

    data = []

    for cost_center, cost_center_items in cam_map.items():
        for account, monthwise_data in cost_center_items.items():
            row = [cost_center, account]
            totals = [0, 0, 0]
            for relevant_months in period_month_ranges:
                period_data = [0, 0, 0]
                for month in relevant_months:
                    month_data = monthwise_data.get(month, {})
                    for i, fieldname in enumerate(
                        ["target", "actual", "variance"]):
                        value = flt(month_data.get(fieldname), precision)
                        period_data[i] += value
                        totals[i] += value
                period_data[2] = period_data[0] - period_data[1]
                row += period_data
            totals[2] = totals[0] - totals[1]
            row += totals
            data.append(row)

    return columns, sorted(data, key=lambda x: (x[0], x[1]))