From e552a51266a41420264e6732fe05a879b90f40a1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 Nov 2017 17:38:44 +0530 Subject: [PATCH] Minor cleanups --- .../sales_payment_summary.js | 3 +- .../sales_payment_summary.py | 28 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js index e599fcdba3..6b462144cd 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js @@ -33,7 +33,8 @@ frappe.query_reports["Sales Payment Summary"] = { "fieldname":"owner", "label": __("Owner"), "fieldtype": "Link", - "options": "User" + "options": "User", + "defaults": user }, { "fieldname":"cost_center", diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py index 1cc2f93d8e..bb80955a6b 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -6,14 +6,12 @@ import frappe from frappe import _ def execute(filters=None): - columns, data = [], [] columns=get_columns() data=get_sales_payment_data(filters, columns) return columns, data def get_columns(): - return [ _("Date") + ":Date:80", _("Owner") + "::150", @@ -27,16 +25,16 @@ def get_columns(): ] def get_sales_payment_data(filters, columns): - sales_invoice_data = get_sales_invoice_data(filters) data = [] for inv in sales_invoice_data: - row = [inv.posting_date, inv.owner, inv.mode_of_payment,inv.warehouse, inv.cost_center,inv.net_total, inv.total_taxes, inv.paid_amount, inv.net_total + inv.total_taxes - inv.paid_amount] + row = [inv.posting_date, inv.owner, inv.mode_of_payment,inv.warehouse, + inv.cost_center,inv.net_total, inv.total_taxes, inv.paid_amount, + (inv.net_total + inv.total_taxes - inv.paid_amount)] data.append(row) return data def get_conditions(filters): - conditions = "" if filters.get("company"): conditions += " a.company=%(company)s" if filters.get("customer"): conditions += " and a.customer = %(customer)s" @@ -51,10 +49,18 @@ def get_conditions(filters): return conditions def get_sales_invoice_data(filters): - conditions = get_conditions(filters) - return frappe.db.sql("""select a.owner, a.posting_date, c.mode_of_payment, b.warehouse, b.cost_center, - sum(a.net_total) as "net_total",sum(a.total_taxes_and_charges) as "total_taxes", sum(a.base_paid_amount) as "paid_amount" - from `tabSales Invoice` a, `tabSales Invoice Item` b, `tabSales Invoice Payment` c - where a.name = b.parent and a.name = c.parent and {conditions} - group by a.owner, a.posting_date, c.mode_of_payment, b.warehouse, b.cost_center""".format(conditions=conditions),filters, as_dict=1) \ No newline at end of file + return frappe.db.sql(""" + select + a.owner, a.posting_date, c.mode_of_payment, b.warehouse, b.cost_center, + sum(a.net_total) as "net_total", + sum(a.total_taxes_and_charges) as "total_taxes", + sum(a.base_paid_amount) as "paid_amount" + from `tabSales Invoice` a, `tabSales Invoice Item` b, `tabSales Invoice Payment` c + where + a.name = b.parent + and a.name = c.parent + and {conditions} + group by + a.owner, a.posting_date, c.mode_of_payment, b.warehouse, b.cost_center + """.format(conditions=conditions), filters, as_dict=1) \ No newline at end of file