Example #1
0
def get_data(filters):
	data = []
	items = get_items(filters)
	sle = get_stock_ledger_entries(filters, items)
	item_details = get_item_details(items, sle, filters)
	periodic_data = get_periodic_data(sle, filters)
	ranges = get_period_date_ranges(filters)

	for dummy, item_data in iteritems(item_details):
		row = {
			"name": item_data.name,
			"item_name": item_data.item_name,
			"item_group": item_data.item_group,
			"uom": item_data.stock_uom,
			"brand": item_data.brand,
		}
		total = 0
		for dummy, end_date in ranges:
			period = get_period(end_date, filters)
			amount = flt(periodic_data.get(item_data.name, {}).get(period))
			row[scrub(period)] = amount
			total += amount
		row["total"] = total
		data.append(row)

	return data
Example #2
0
def get_data(filters):
    data = []
    items = get_items(filters)
    sle = get_stock_ledger_entries(filters, items)
    item_details = get_item_details(items, sle, filters)
    periodic_data = get_periodic_data(sle, filters)
    ranges = get_period_date_ranges(filters)

    for dummy, item_data in item_details.items():
        row = {
            "name": item_data.name,
            "item_name": item_data.item_name,
            "item_group": item_data.item_group,
            "uom": item_data.stock_uom,
            "brand": item_data.brand,
        }
        total = 0
        for dummy, end_date in ranges:
            period = get_period(end_date, filters)
            period_data = periodic_data.get(item_data.name, {}).get(period)
            amount = sum(period_data.values()) if period_data else 0
            row[scrub(period)] = amount
            total += amount
        row["total"] = total
        data.append(row)

    return data
Example #3
0
def execute(filters=None):
	if not filters: filters = {}

	validate_filters(filters)

	columns = get_columns(filters)

	items = get_items(filters)
	sle = get_stock_ledger_entries(filters, items)

	item_map = get_item_details(items, sle, filters)
	iwb_map = get_item_warehouse_map(filters, sle)
	warehouse_list = get_warehouse_list(filters)
	item_ageing = get_fifo_queue(filters)
	data = []
	item_balance = {}
	item_value = {}

	for (company, item, warehouse) in sorted(iwb_map):
		if not item_map.get(item):  continue

		row = []
		qty_dict = iwb_map[(company, item, warehouse)]
		item_balance.setdefault((item, item_map[item]["item_group"]), [])
		total_stock_value = 0.00
		for wh in warehouse_list:
			row += [qty_dict.bal_qty] if wh.name in warehouse else [0.00]
			total_stock_value += qty_dict.bal_val if wh.name in warehouse else 0.00

		item_balance[(item, item_map[item]["item_group"])].append(row)
		item_value.setdefault((item, item_map[item]["item_group"]),[])
		item_value[(item, item_map[item]["item_group"])].append(total_stock_value)


	# sum bal_qty by item
	for (item, item_group), wh_balance in iteritems(item_balance):
		if not item_ageing.get(item):  continue

		total_stock_value = sum(item_value[(item, item_group)])
		row = [item, item_group, total_stock_value]

		fifo_queue = item_ageing[item]["fifo_queue"]
		average_age = 0.00
		if fifo_queue:
			average_age = get_average_age(fifo_queue, filters["to_date"])

		row += [average_age]

		bal_qty = [sum(bal_qty) for bal_qty in zip(*wh_balance)]
		total_qty = sum(bal_qty)
		if len(warehouse_list) > 1:
			row += [total_qty]
		row += bal_qty

		if total_qty > 0:
			data.append(row)
		elif not filters.get("filter_total_zero_qty"):
			data.append(row)
	add_warehouse_column(columns, warehouse_list)
	return columns, data
Example #4
0
def get_data(filters):
    data = []
    items = get_items(filters)
    sle = get_stock_ledger_entries(filters, items)
    item_details = get_item_details(items, sle, filters)
    periodic_data = get_periodic_data(sle, filters)
    ranges = get_period_date_ranges(filters)

    today = getdate()

    for dummy, item_data in item_details.items():
        row = {
            "name": item_data.name,
            "item_name": item_data.item_name,
            "item_group": item_data.item_group,
            "uom": item_data.stock_uom,
            "brand": item_data.brand,
        }
        previous_period_value = 0.0
        for start_date, end_date in ranges:
            period = get_period(end_date, filters)
            period_data = periodic_data.get(item_data.name, {}).get(period)
            if period_data:
                row[scrub(period)] = previous_period_value = sum(
                    period_data.values())
            else:
                row[scrub(
                    period
                )] = previous_period_value if today >= start_date else None

        data.append(row)

    return data