2013-11-20 07:29:58 +00:00
|
|
|
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
2013-08-05 09:29:54 +00:00
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
2013-02-25 12:47:51 +00:00
|
|
|
from __future__ import unicode_literals
|
2014-02-14 10:17:51 +00:00
|
|
|
import frappe
|
2014-09-11 08:15:27 +00:00
|
|
|
from frappe import _
|
2014-11-21 07:07:30 +00:00
|
|
|
from erpnext.accounts.report.gross_profit_common import GrossProfitGenerator
|
2013-02-25 12:47:51 +00:00
|
|
|
|
|
|
|
def execute(filters=None):
|
|
|
|
if not filters: filters = {}
|
2014-11-21 07:07:30 +00:00
|
|
|
filters.update({"group_by": "name"})
|
|
|
|
source_data = GrossProfitGenerator(filters)
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
print source_data.retr()
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
return None, None
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# columns = get_columns(filters.group_by)
|
|
|
|
|
|
|
|
# data = []
|
|
|
|
# for row in source_data:
|
|
|
|
# print row
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# return columns, data
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# def get_columns(group_by):
|
|
|
|
# pass
|
2013-03-28 11:10:30 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# def get_data(group_by, source_data):
|
|
|
|
# pass
|
2014-11-10 06:59:29 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# def execute(filters=None):
|
|
|
|
# if not filters: filters = {}
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# stock_ledger_entries = get_stock_ledger_entries(filters)
|
|
|
|
# source = get_source_data(filters)
|
|
|
|
# item_sales_bom = get_item_sales_bom()
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# columns = [_("Sales Invoice") + "::120", _("Link") + "::30", _("Posting Date") + ":Date", _("Posting Time"),
|
|
|
|
# _("Item Code") + ":Link/Item", _("Item Name"), _("Description"), _("Warehouse") + ":Link/Warehouse",
|
|
|
|
# _("Qty") + ":Float", _("Selling Rate") + ":Currency", _("Avg. Buying Rate") + ":Currency",
|
|
|
|
# _("Selling Amount") + ":Currency", _("Buying Amount") + ":Currency",
|
|
|
|
# _("Gross Profit") + ":Currency", _("Gross Profit %") + ":Percent", _("Project") + ":Link/Project"]
|
|
|
|
# data = []
|
|
|
|
# for row in source:
|
|
|
|
# selling_amount = flt(row.base_amount)
|
|
|
|
# total_selling_amount += flt(row.base_amount)
|
2014-11-10 06:59:29 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# item_sales_bom_map = item_sales_bom.get(row.parenttype, {}).get(row.name, frappe._dict())
|
2014-11-10 06:59:29 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# if item_sales_bom_map.get(row.item_code):
|
|
|
|
# buying_amount = get_sales_bom_buying_amount(row.item_code, row.warehouse,
|
|
|
|
# row.parenttype, row.name, row.item_row, stock_ledger_entries, item_sales_bom_map)
|
|
|
|
# else:
|
|
|
|
# buying_amount = get_buying_amount(row.item_code, row.qty, row.parenttype, row.name, row.item_row,
|
|
|
|
# stock_ledger_entries.get((row.item_code, row.warehouse), []))
|
2014-09-17 06:43:31 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# buying_amount = buying_amount > 0 and buying_amount or 0
|
|
|
|
# total_buying_amount += buying_amount
|
2014-11-21 06:36:00 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# gross_profit = selling_amount - buying_amount
|
|
|
|
# total_gross_profit += gross_profit
|
2014-11-21 06:36:00 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# if selling_amount:
|
|
|
|
# gross_profit_percent = (gross_profit / selling_amount) * 100.0
|
|
|
|
# else:
|
|
|
|
# gross_profit_percent = 0.0
|
2014-11-21 06:36:00 +00:00
|
|
|
|
2014-11-21 07:07:30 +00:00
|
|
|
# icon = """<a href="%s"><i class="icon icon-share" style="cursor: pointer;"></i></a>""" \
|
|
|
|
# % ("/".join(["#Form", row.parenttype, row.name]),)
|
|
|
|
# data.append([row.name, icon, row.posting_date, row.posting_time, row.item_code, row.item_name,
|
|
|
|
# row.description, row.warehouse, row.qty, row.base_rate,
|
|
|
|
# row.qty and (buying_amount / row.qty) or 0, row.base_amount, buying_amount,
|
|
|
|
# gross_profit, gross_profit_percent, row.project])
|
|
|
|
|
|
|
|
# if total_selling_amount:
|
|
|
|
# total_gross_profit_percent = (total_gross_profit / total_selling_amount) * 100.0
|
|
|
|
# else:
|
|
|
|
# total_gross_profit_percent = 0.0
|
|
|
|
|
|
|
|
# data.append(["Total", None, None, None, None, None, None, None, None, None, None, total_selling_amount,
|
|
|
|
# total_buying_amount, total_gross_profit, total_gross_profit_percent, None])
|
|
|
|
|
|
|
|
# return columns, data
|