Merge pull request #2395 from ankitjavalkarwork/fix2230
[#2230] Add Totals row to Gross Profit report
This commit is contained in:
commit
40c47b2236
@ -14,6 +14,10 @@ def execute(filters=None):
|
|||||||
source = get_source_data(filters)
|
source = get_source_data(filters)
|
||||||
item_sales_bom = get_item_sales_bom()
|
item_sales_bom = get_item_sales_bom()
|
||||||
|
|
||||||
|
total_gross_profit = 0.0
|
||||||
|
total_selling_amount = 0.0
|
||||||
|
total_buying_amount = 0.0
|
||||||
|
|
||||||
columns = [_("Delivery Note/Sales Invoice") + "::120", _("Link") + "::30", _("Posting Date") + ":Date", _("Posting Time"),
|
columns = [_("Delivery Note/Sales Invoice") + "::120", _("Link") + "::30", _("Posting Date") + ":Date", _("Posting Time"),
|
||||||
_("Item Code") + ":Link/Item", _("Item Name"), _("Description"), _("Warehouse") + ":Link/Warehouse",
|
_("Item Code") + ":Link/Item", _("Item Name"), _("Description"), _("Warehouse") + ":Link/Warehouse",
|
||||||
_("Qty") + ":Float", _("Selling Rate") + ":Currency", _("Avg. Buying Rate") + ":Currency",
|
_("Qty") + ":Float", _("Selling Rate") + ":Currency", _("Avg. Buying Rate") + ":Currency",
|
||||||
@ -22,6 +26,7 @@ def execute(filters=None):
|
|||||||
data = []
|
data = []
|
||||||
for row in source:
|
for row in source:
|
||||||
selling_amount = flt(row.base_amount)
|
selling_amount = flt(row.base_amount)
|
||||||
|
total_selling_amount += flt(row.base_amount)
|
||||||
|
|
||||||
item_sales_bom_map = item_sales_bom.get(row.parenttype, {}).get(row.name, frappe._dict())
|
item_sales_bom_map = item_sales_bom.get(row.parenttype, {}).get(row.name, frappe._dict())
|
||||||
|
|
||||||
@ -33,8 +38,11 @@ def execute(filters=None):
|
|||||||
stock_ledger_entries.get((row.item_code, row.warehouse), []))
|
stock_ledger_entries.get((row.item_code, row.warehouse), []))
|
||||||
|
|
||||||
buying_amount = buying_amount > 0 and buying_amount or 0
|
buying_amount = buying_amount > 0 and buying_amount or 0
|
||||||
|
total_buying_amount += buying_amount
|
||||||
|
|
||||||
gross_profit = selling_amount - buying_amount
|
gross_profit = selling_amount - buying_amount
|
||||||
|
total_gross_profit += gross_profit
|
||||||
|
|
||||||
if selling_amount:
|
if selling_amount:
|
||||||
gross_profit_percent = (gross_profit / selling_amount) * 100.0
|
gross_profit_percent = (gross_profit / selling_amount) * 100.0
|
||||||
else:
|
else:
|
||||||
@ -47,6 +55,14 @@ def execute(filters=None):
|
|||||||
row.qty and (buying_amount / row.qty) or 0, row.base_amount, buying_amount,
|
row.qty and (buying_amount / row.qty) or 0, row.base_amount, buying_amount,
|
||||||
gross_profit, gross_profit_percent, row.project])
|
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
|
return columns, data
|
||||||
|
|
||||||
def get_stock_ledger_entries(filters):
|
def get_stock_ledger_entries(filters):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user