mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-16 16:15:02 +00:00
fix: remove incorrect report conditions and unset sales partner on consolidated sales invoice (#48669)
* fix: undo query changes for sales partner related reports * fix: patch to remove sales partner from consolidated sales invoice
This commit is contained in:
@@ -10,13 +10,13 @@
|
||||
"idx": 6,
|
||||
"is_standard": "Yes",
|
||||
"letterhead": null,
|
||||
"modified": "2025-07-17 16:47:20.596297",
|
||||
"modified": "2025-07-17 23:16:19.892044",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Partners Commission",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"query": "SELECT\n sales_partner as \"Sales Partner:Link / Sales Partner:220\",\n sum(base_net_total) as \"Invoiced Amount (Excl. Tax):Currency:220\",\n sum(amount_eligible_for_commission) as \"Amount Eligible for Commission:Currency:220\",\n sum(total_commission) as \"Total Commission:Currency:170\",\n sum(total_commission)*100 / sum(amount_eligible_for_commission) as \"Average Commission Rate:Percent:220\"\nFROM\n (\n SELECT\n sales_partner,\n base_net_total,\n total_commission,\n amount_eligible_for_commission\n FROM\n `tabSales Invoice` \n WHERE\n docstatus = 1\n AND NOT (is_consolidated = 1 AND is_created_using_pos = 0)\n AND IFNULL(base_net_total, 0) > 0\n AND IFNULL(total_commission, 0) > 0\n\n UNION ALL\n\n SELECT\n sales_partner,\n base_net_total,\n total_commission,\n amount_eligible_for_commission\n FROM\n `tabPOS Invoice`\n WHERE\n docstatus = 1\n AND IFNULL(base_net_total, 0) > 0\n AND IFNULL(total_commission, 0) > 0\n ) AS sub\nGROUP BY\n sales_partner\nORDER BY\n \"Total Commission:Currency:120\"",
|
||||
"query": "SELECT\n sales_partner as \"Sales Partner:Link / Sales Partner:220\",\n sum(base_net_total) as \"Invoiced Amount (Excl. Tax):Currency:220\",\n sum(amount_eligible_for_commission) as \"Amount Eligible for Commission:Currency:220\",\n sum(total_commission) as \"Total Commission:Currency:170\",\n sum(total_commission)*100 / sum(amount_eligible_for_commission) as \"Average Commission Rate:Percent:220\"\nFROM\n (\n SELECT\n sales_partner,\n base_net_total,\n total_commission,\n amount_eligible_for_commission\n FROM\n `tabSales Invoice` \n WHERE\n docstatus = 1\n AND IFNULL(base_net_total, 0) > 0\n AND IFNULL(total_commission, 0) > 0\n\n UNION ALL\n\n SELECT\n sales_partner,\n base_net_total,\n total_commission,\n amount_eligible_for_commission\n FROM\n `tabPOS Invoice`\n WHERE\n docstatus = 1\n AND IFNULL(base_net_total, 0) > 0\n AND IFNULL(total_commission, 0) > 0\n ) AS sub\nGROUP BY\n sales_partner\nORDER BY\n \"Total Commission:Currency:120\"",
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Sales Partners Commission",
|
||||
"report_type": "Query Report",
|
||||
|
||||
@@ -425,4 +425,5 @@ erpnext.patches.v15_0.rename_pos_closing_entry_fields #2025-06-13
|
||||
erpnext.patches.v15_0.update_pegged_currencies
|
||||
erpnext.patches.v15_0.set_status_cancelled_on_cancelled_pos_opening_entry_and_pos_closing_entry
|
||||
erpnext.patches.v15_0.set_company_on_pos_inv_merge_log
|
||||
erpnext.patches.v15_0.rename_price_list_to_buying_price_list
|
||||
erpnext.patches.v15_0.rename_price_list_to_buying_price_list
|
||||
erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
SalesInvoice = frappe.qb.DocType("Sales Invoice")
|
||||
|
||||
query = (
|
||||
frappe.qb.update(SalesInvoice)
|
||||
.set(SalesInvoice.sales_partner, "")
|
||||
.set(SalesInvoice.commission_rate, 0)
|
||||
.set(SalesInvoice.total_commission, 0)
|
||||
.where(SalesInvoice.is_consolidated == 1)
|
||||
)
|
||||
|
||||
# For develop/version-16
|
||||
if frappe.db.has_column("Sales Invoice", "is_created_using_pos"):
|
||||
query = query.where(SalesInvoice.is_created_using_pos == 0)
|
||||
|
||||
query.run()
|
||||
@@ -106,7 +106,4 @@ def get_conditions(filters, date_field):
|
||||
if filters.get("to_date"):
|
||||
conditions += f" and {date_field} <= %(to_date)s"
|
||||
|
||||
if filters.get("doctype") == "Sales Invoice":
|
||||
conditions += " and not (is_consolidated = 1 and is_created_using_pos = 0)"
|
||||
|
||||
return conditions
|
||||
|
||||
@@ -248,9 +248,6 @@ def get_actual_data(filters, sales_users_or_territory_data, date_field, sales_fi
|
||||
net_amount = child_doc.base_net_amount
|
||||
sales_field_col = parent_doc[sales_field]
|
||||
|
||||
if filters.get("doctype") == "Sales Invoice":
|
||||
query = query.where(~((parent_doc.is_consolidated == 0) & (parent_doc.is_created_using_pos == 1)))
|
||||
|
||||
query = query.select(
|
||||
child_doc.item_group,
|
||||
parent_doc[date_field],
|
||||
|
||||
@@ -137,9 +137,6 @@ def get_conditions(filters, date_field):
|
||||
if filters.get("brand"):
|
||||
conditions += " and dt_item.brand = %(brand)s"
|
||||
|
||||
if filters.get("doctype") == "Sales Invoice":
|
||||
conditions += " and not (is_consolidated = 1 and is_created_using_pos = 0)"
|
||||
|
||||
if filters.get("item_group"):
|
||||
lft, rgt = frappe.get_cached_value("Item Group", filters.get("item_group"), ["lft", "rgt"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user