From d8e91982ca8f8f5d537d67f0d47a1eb09b77f9ea Mon Sep 17 00:00:00 2001 From: pawan Date: Fri, 3 Nov 2017 21:52:07 +0530 Subject: [PATCH 1/5] Fixed Merge conflict --- .../report/sales_payment_summary/__init__.py | 0 .../sales_payment_summary.js | 56 +++++++++++++++++ .../sales_payment_summary.json | 26 ++++++++ .../sales_payment_summary.py | 60 +++++++++++++++++++ erpnext/config/accounts.py | 6 ++ 5 files changed, 148 insertions(+) create mode 100644 erpnext/accounts/report/sales_payment_summary/__init__.py create mode 100644 erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js create mode 100644 erpnext/accounts/report/sales_payment_summary/sales_payment_summary.json create mode 100644 erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py diff --git a/erpnext/accounts/report/sales_payment_summary/__init__.py b/erpnext/accounts/report/sales_payment_summary/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js new file mode 100644 index 0000000000..e599fcdba3 --- /dev/null +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.js @@ -0,0 +1,56 @@ +// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +frappe.query_reports["Sales Payment Summary"] = { + "filters": [ + { + "fieldname":"from_date", + "label": __("From Date"), + "fieldtype": "Date", + "default": frappe.datetime.get_today(), + "width": "80" + }, + { + "fieldname":"to_date", + "label": __("To Date"), + "fieldtype": "Date", + "default": frappe.datetime.get_today() + }, + { + "fieldname":"company", + "label": __("Company"), + "fieldtype": "Link", + "options": "Company", + "default": frappe.defaults.get_user_default("Company") + }, + { + "fieldname":"mode_of_payment", + "label": __("Mode of Payment"), + "fieldtype": "Link", + "options": "Mode of Payment" + }, + { + "fieldname":"owner", + "label": __("Owner"), + "fieldtype": "Link", + "options": "User" + }, + { + "fieldname":"cost_center", + "label": __("Cost Center"), + "fieldtype": "Link", + "options": "Cost Center" + }, + { + "fieldname":"warehouse", + "label": __("Warehouse"), + "fieldtype": "Link", + "options": "Warehouse" + }, + { + "fieldname":"is_pos", + "label": __("POS?"), + "fieldtype": "Check" + } + ] +}; diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.json b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.json new file mode 100644 index 0000000000..1ff56d3184 --- /dev/null +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.json @@ -0,0 +1,26 @@ +{ + "add_total_row": 0, + "apply_user_permissions": 1, + "creation": "2017-11-03 16:31:45.757516", + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "idx": 0, + "is_standard": "Yes", + "modified": "2017-11-03 17:00:37.871577", + "modified_by": "Administrator", + "module": "Accounts", + "name": "Sales Payment Summary", + "owner": "Administrator", + "ref_doctype": "Sales Invoice", + "report_name": "Sales Payment Summary", + "report_type": "Script Report", + "roles": [ + { + "role": "Accounts Manager" + }, + { + "role": "Accounts User" + } + ] +} \ No newline at end of file diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py new file mode 100644 index 0000000000..3e761b104d --- /dev/null +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -0,0 +1,60 @@ +# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe import msgprint, _ + +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", + _("Payment Mode") + "::120", + _("Warehouse") + ":Link/Cost Center:100", + _("Cost Center") + ":Link/Warehouse:100", + _("Sales and Returns") + ":Currency/currency:120", + _("Taxes") + ":Currency/currency:120", + _("Payments") + ":Currency/currency:120", + _("Reconciliation") + ":Currency/currency:120" + ] + +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] + 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" + if filters.get("owner"): conditions += " and a.owner = %(owner)s" + if filters.get("from_date"): conditions += " and a.posting_date >= %(from_date)s" + if filters.get("to_date"): conditions += " and a.posting_date <= %(to_date)s" + if filters.get("mode_of_payment"): conditions += " and c.mode_of_payment >= %(mode_of_payment)s" + if filters.get("warehouse"): conditions += " and b.warehouse <= %(warehouse)s" + if filters.get("cost_center"): conditions += " and b.cost_center <= %(cost_center)s" + if filters.get("is_pos"): conditions += " and a.is_pos = %(is_pos)s" + + 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 diff --git a/erpnext/config/accounts.py b/erpnext/config/accounts.py index cdce13ba35..58fb2f0b32 100644 --- a/erpnext/config/accounts.py +++ b/erpnext/config/accounts.py @@ -468,6 +468,12 @@ def get_data(): "name": "Customer Credit Balance", "doctype": "Customer" }, + { + "type": "report", + "is_query_report": True, + "name": "Sales Payment Summary", + "doctype": "Sales Invoice" + } ] }, { From 19f09b0b69fc62f2eb4ef682775671f379bb227e Mon Sep 17 00:00:00 2001 From: pawan Date: Sat, 4 Nov 2017 05:55:50 +0530 Subject: [PATCH 2/5] fix codacy issues --- .../report/sales_payment_summary/sales_payment_summary.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 3e761b104d..e1c8c52716 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import frappe -from frappe import msgprint, _ def execute(filters=None): @@ -18,7 +17,7 @@ def get_columns(): _("Date") + ":Date:80", _("Owner") + "::150", _("Payment Mode") + "::120", - _("Warehouse") + ":Link/Cost Center:100", + _("Warehouse") + ":Link/Cost Center:100", _("Cost Center") + ":Link/Warehouse:100", _("Sales and Returns") + ":Currency/currency:120", _("Taxes") + ":Currency/currency:120", @@ -34,7 +33,7 @@ def get_sales_payment_data(filters, columns): 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 = "" @@ -53,7 +52,7 @@ def get_conditions(filters): 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, + 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} From 271b7cd4f9388e285dd334f242a2527a0ae9cba5 Mon Sep 17 00:00:00 2001 From: pawan Date: Sat, 4 Nov 2017 07:53:52 +0530 Subject: [PATCH 3/5] codacy issues --- .../report/sales_payment_summary/sales_payment_summary.py | 1 + 1 file changed, 1 insertion(+) 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 e1c8c52716..1cc2f93d8e 100644 --- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py +++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ def execute(filters=None): From 5de499e5d5c45a7f567ff048391b691e10261651 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 6 Nov 2017 17:38:44 +0530 Subject: [PATCH 4/5] 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 From 6674ba8bd181dc2447b9a556945e14eafa2ab1fd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 7 Dec 2017 12:33:40 +0600 Subject: [PATCH 5/5] bumped to version 9.2.21 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 8f59fc84ef..2597ed957a 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -4,7 +4,7 @@ import inspect import frappe from erpnext.hooks import regional_overrides -__version__ = '9.2.20' +__version__ = '9.2.21' def get_default_company(user=None): '''Get default company for user'''