Merge pull request #39384 from deepeshgarg007/income_account_filter
feat: Income account filter in item-wise reports
This commit is contained in:
commit
a36b6cb102
@ -59,7 +59,21 @@ frappe.query_reports["Item-wise Sales Register"] = {
|
|||||||
"fieldname": "group_by",
|
"fieldname": "group_by",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"options": ["Customer Group", "Customer", "Item Group", "Item", "Territory", "Invoice"]
|
"options": ["Customer Group", "Customer", "Item Group", "Item", "Territory", "Invoice"]
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "income_account",
|
||||||
|
"label": __("Income Account"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Account",
|
||||||
|
get_query: () => {
|
||||||
|
let company = frappe.query_report.get_filter_value('company');
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
'company': company,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"formatter": function(value, row, column, data, default_formatter) {
|
"formatter": function(value, row, column, data, default_formatter) {
|
||||||
value = default_formatter(value, row, column, data);
|
value = default_formatter(value, row, column, data);
|
||||||
|
@ -83,9 +83,7 @@ def _execute(filters=None, additional_table_columns=None, additional_conditions=
|
|||||||
"company": d.company,
|
"company": d.company,
|
||||||
"sales_order": d.sales_order,
|
"sales_order": d.sales_order,
|
||||||
"delivery_note": d.delivery_note,
|
"delivery_note": d.delivery_note,
|
||||||
"income_account": d.unrealized_profit_loss_account
|
"income_account": get_income_account(d),
|
||||||
if d.is_internal_customer == 1
|
|
||||||
else d.income_account,
|
|
||||||
"cost_center": d.cost_center,
|
"cost_center": d.cost_center,
|
||||||
"stock_qty": d.stock_qty,
|
"stock_qty": d.stock_qty,
|
||||||
"stock_uom": d.stock_uom,
|
"stock_uom": d.stock_uom,
|
||||||
@ -150,6 +148,15 @@ def _execute(filters=None, additional_table_columns=None, additional_conditions=
|
|||||||
return columns, data, None, None, None, skip_total_row
|
return columns, data, None, None, None, skip_total_row
|
||||||
|
|
||||||
|
|
||||||
|
def get_income_account(row):
|
||||||
|
if row.enable_deferred_revenue:
|
||||||
|
return row.deferred_revenue_account
|
||||||
|
elif row.is_internal_customer == 1:
|
||||||
|
return row.unrealized_profit_loss_account
|
||||||
|
else:
|
||||||
|
return row.income_account
|
||||||
|
|
||||||
|
|
||||||
def get_columns(additional_table_columns, filters):
|
def get_columns(additional_table_columns, filters):
|
||||||
columns = []
|
columns = []
|
||||||
|
|
||||||
@ -358,6 +365,13 @@ def get_conditions(filters, additional_conditions=None):
|
|||||||
if filters.get("item_group"):
|
if filters.get("item_group"):
|
||||||
conditions += """and ifnull(`tabSales Invoice Item`.item_group, '') = %(item_group)s"""
|
conditions += """and ifnull(`tabSales Invoice Item`.item_group, '') = %(item_group)s"""
|
||||||
|
|
||||||
|
if filters.get("income_account"):
|
||||||
|
conditions += """
|
||||||
|
and (ifnull(`tabSales Invoice Item`.income_account, '') = %(income_account)s
|
||||||
|
or ifnull(`tabSales Invoice Item`.deferred_revenue_account, '') = %(income_account)s
|
||||||
|
or ifnull(`tabSales Invoice`.unrealized_profit_loss_account, '') = %(income_account)s)
|
||||||
|
"""
|
||||||
|
|
||||||
if not filters.get("group_by"):
|
if not filters.get("group_by"):
|
||||||
conditions += (
|
conditions += (
|
||||||
"ORDER BY `tabSales Invoice`.posting_date desc, `tabSales Invoice Item`.item_group desc"
|
"ORDER BY `tabSales Invoice`.posting_date desc, `tabSales Invoice Item`.item_group desc"
|
||||||
@ -399,6 +413,7 @@ def get_items(filters, additional_query_columns, additional_conditions=None):
|
|||||||
`tabItem`.`item_name` as i_item_name, `tabItem`.`item_group` as i_item_group,
|
`tabItem`.`item_name` as i_item_name, `tabItem`.`item_group` as i_item_group,
|
||||||
`tabSales Invoice Item`.sales_order, `tabSales Invoice Item`.delivery_note,
|
`tabSales Invoice Item`.sales_order, `tabSales Invoice Item`.delivery_note,
|
||||||
`tabSales Invoice Item`.income_account, `tabSales Invoice Item`.cost_center,
|
`tabSales Invoice Item`.income_account, `tabSales Invoice Item`.cost_center,
|
||||||
|
`tabSales Invoice Item`.enable_deferred_revenue, `tabSales Invoice Item`.deferred_revenue_account,
|
||||||
`tabSales Invoice Item`.stock_qty, `tabSales Invoice Item`.stock_uom,
|
`tabSales Invoice Item`.stock_qty, `tabSales Invoice Item`.stock_uom,
|
||||||
`tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.base_net_amount,
|
`tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.base_net_amount,
|
||||||
`tabSales Invoice`.customer_name, `tabSales Invoice`.customer_group, `tabSales Invoice Item`.so_detail,
|
`tabSales Invoice`.customer_name, `tabSales Invoice`.customer_group, `tabSales Invoice Item`.so_detail,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user