From d8e91982ca8f8f5d537d67f0d47a1eb09b77f9ea Mon Sep 17 00:00:00 2001 From: pawan Date: Fri, 3 Nov 2017 21:52:07 +0530 Subject: [PATCH] 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" + } ] }, {