Add ability to fetch Non stock items in Gross Profit report
This commit is contained in:
parent
1aea75261d
commit
9aa11d2ad7
@ -5,7 +5,7 @@
|
|||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"modified": "2014-06-03 07:18:17.077022",
|
"modified": "2014-09-18 19:00:50.263854",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Gross Profit",
|
"name": "Gross Profit",
|
||||||
|
@ -14,7 +14,7 @@ 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()
|
||||||
|
|
||||||
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",
|
||||||
_("Selling Amount") + ":Currency", _("Buying Amount") + ":Currency",
|
_("Selling Amount") + ":Currency", _("Buying Amount") + ":Currency",
|
||||||
@ -29,7 +29,7 @@ def execute(filters=None):
|
|||||||
buying_amount = get_sales_bom_buying_amount(row.item_code, row.warehouse,
|
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)
|
row.parenttype, row.name, row.item_row, stock_ledger_entries, item_sales_bom_map)
|
||||||
else:
|
else:
|
||||||
buying_amount = get_buying_amount(row.parenttype, row.name, row.item_row,
|
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), []))
|
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
|
||||||
@ -107,7 +107,6 @@ def get_source_data(filters):
|
|||||||
timestamp(si.posting_date, si.posting_time) as posting_datetime
|
timestamp(si.posting_date, si.posting_time) as posting_datetime
|
||||||
from `tabSales Invoice` si, `tabSales Invoice Item` item
|
from `tabSales Invoice` si, `tabSales Invoice Item` item
|
||||||
where item.parent = si.name and si.docstatus = 1 %s
|
where item.parent = si.name and si.docstatus = 1 %s
|
||||||
and si.update_stock = 1
|
|
||||||
order by si.posting_date desc, si.posting_time desc""" % (conditions,), filters, as_dict=1)
|
order by si.posting_date desc, si.posting_time desc""" % (conditions,), filters, as_dict=1)
|
||||||
|
|
||||||
source = delivery_note_items + sales_invoice_items
|
source = delivery_note_items + sales_invoice_items
|
||||||
|
@ -159,10 +159,11 @@ def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no,
|
|||||||
|
|
||||||
return buying_amount
|
return buying_amount
|
||||||
|
|
||||||
def get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries):
|
def get_buying_amount(item_code, item_qty, voucher_type, voucher_no, item_row, stock_ledger_entries):
|
||||||
# IMP NOTE
|
# IMP NOTE
|
||||||
# stock_ledger_entries should already be filtered by item_code and warehouse and
|
# stock_ledger_entries should already be filtered by item_code and warehouse and
|
||||||
# sorted by posting_date desc, posting_time desc
|
# sorted by posting_date desc, posting_time desc
|
||||||
|
if frappe.db.get_value("Item", item_code, "is_stock_item") == "Yes":
|
||||||
for i, sle in enumerate(stock_ledger_entries):
|
for i, sle in enumerate(stock_ledger_entries):
|
||||||
if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \
|
if sle.voucher_type == voucher_type and sle.voucher_no == voucher_no and \
|
||||||
sle.voucher_detail_no == item_row:
|
sle.voucher_detail_no == item_row:
|
||||||
@ -171,6 +172,14 @@ def get_buying_amount(voucher_type, voucher_no, item_row, stock_ledger_entries):
|
|||||||
buying_amount = previous_stock_value - flt(sle.stock_value)
|
buying_amount = previous_stock_value - flt(sle.stock_value)
|
||||||
|
|
||||||
return buying_amount
|
return buying_amount
|
||||||
|
else:
|
||||||
|
item_rate = frappe.db.sql("""select sum(base_amount) / sum(qty)
|
||||||
|
from `tabPurchase Invoice Item`
|
||||||
|
where item_code = %s and docstatus=1""" % ('%s'), item_code)
|
||||||
|
buying_amount = flt(item_qty) * flt(item_rate[0][0])
|
||||||
|
|
||||||
|
return buying_amount
|
||||||
|
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user