Merge branch 'master' into develop
This commit is contained in:
commit
9771b9376d
@ -5,7 +5,7 @@ import frappe
|
|||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
__version__ = '9.2.22'
|
__version__ = '9.2.23'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.query_reports["Sales Payment Summary"] = {
|
frappe.query_reports["Sales Payment Summary"] = {
|
||||||
"filters": [
|
"filters": [
|
||||||
{
|
{
|
||||||
@ -23,12 +22,6 @@ frappe.query_reports["Sales Payment Summary"] = {
|
|||||||
"options": "Company",
|
"options": "Company",
|
||||||
"default": frappe.defaults.get_user_default("Company")
|
"default": frappe.defaults.get_user_default("Company")
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname":"mode_of_payment",
|
|
||||||
"label": __("Mode of Payment"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Mode of Payment"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname":"owner",
|
"fieldname":"owner",
|
||||||
"label": __("Owner"),
|
"label": __("Owner"),
|
||||||
@ -36,22 +29,10 @@ frappe.query_reports["Sales Payment Summary"] = {
|
|||||||
"options": "User",
|
"options": "User",
|
||||||
"defaults": user
|
"defaults": user
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname":"cost_center",
|
|
||||||
"label": __("Cost Center"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Cost Center"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname":"warehouse",
|
|
||||||
"label": __("Warehouse"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Warehouse"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname":"is_pos",
|
"fieldname":"is_pos",
|
||||||
"label": __("POS?"),
|
"label": __("POS?"),
|
||||||
"fieldtype": "Check"
|
"fieldtype": "Check"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
@ -1,9 +1,9 @@
|
|||||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.utils import cstr
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns, data = [], []
|
columns, data = [], []
|
||||||
@ -15,22 +15,23 @@ def get_columns():
|
|||||||
return [
|
return [
|
||||||
_("Date") + ":Date:80",
|
_("Date") + ":Date:80",
|
||||||
_("Owner") + "::150",
|
_("Owner") + "::150",
|
||||||
_("Payment Mode") + "::120",
|
_("Payment Mode") + "::140",
|
||||||
_("Warehouse") + ":Link/Cost Center:100",
|
|
||||||
_("Cost Center") + ":Link/Warehouse:100",
|
|
||||||
_("Sales and Returns") + ":Currency/currency:120",
|
_("Sales and Returns") + ":Currency/currency:120",
|
||||||
_("Taxes") + ":Currency/currency:120",
|
_("Taxes") + ":Currency/currency:120",
|
||||||
_("Payments") + ":Currency/currency:120",
|
_("Payments") + ":Currency/currency:120",
|
||||||
_("Reconciliation") + ":Currency/currency:120"
|
_("Outstanding Amount") + ":Currency/currency:150",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_sales_payment_data(filters, columns):
|
def get_sales_payment_data(filters, columns):
|
||||||
sales_invoice_data = get_sales_invoice_data(filters)
|
sales_invoice_data = get_sales_invoice_data(filters)
|
||||||
data = []
|
data = []
|
||||||
|
mode_of_payments = get_mode_of_payments(filters)
|
||||||
for inv in sales_invoice_data:
|
for inv in sales_invoice_data:
|
||||||
row = [inv.posting_date, inv.owner, inv.mode_of_payment,inv.warehouse,
|
mode_of_payment = inv["owner"]+cstr(inv["posting_date"])
|
||||||
inv.cost_center,inv.net_total, inv.total_taxes, inv.paid_amount,
|
row = [inv.posting_date, inv.owner,", ".join(mode_of_payments.get(mode_of_payment, [])),
|
||||||
(inv.net_total + inv.total_taxes - inv.paid_amount)]
|
inv.net_total,
|
||||||
|
inv.total_taxes, (inv.net_total + inv.total_taxes - inv.outstanding_amount),
|
||||||
|
inv.outstanding_amount]
|
||||||
data.append(row)
|
data.append(row)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -41,26 +42,48 @@ def get_conditions(filters):
|
|||||||
if filters.get("owner"): conditions += " and a.owner = %(owner)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("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("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"
|
if filters.get("is_pos"): conditions += " and a.is_pos = %(is_pos)s"
|
||||||
|
|
||||||
return conditions
|
return conditions
|
||||||
|
|
||||||
def get_sales_invoice_data(filters):
|
def get_sales_invoice_data(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select
|
select
|
||||||
a.owner, a.posting_date, c.mode_of_payment, b.warehouse, b.cost_center,
|
a.posting_date, a.owner,
|
||||||
sum(a.net_total) as "net_total",
|
sum(a.net_total) as "net_total",
|
||||||
sum(a.total_taxes_and_charges) as "total_taxes",
|
sum(a.total_taxes_and_charges) as "total_taxes",
|
||||||
sum(a.base_paid_amount) as "paid_amount"
|
sum(a.base_paid_amount) as "paid_amount",
|
||||||
from `tabSales Invoice` a, `tabSales Invoice Item` b, `tabSales Invoice Payment` c
|
sum(a.outstanding_amount) as "outstanding_amount"
|
||||||
where
|
from `tabSales Invoice` a
|
||||||
a.name = b.parent
|
where a.docstatus = 1
|
||||||
and a.name = c.parent
|
|
||||||
and {conditions}
|
and {conditions}
|
||||||
group by
|
group by
|
||||||
a.owner, a.posting_date, c.mode_of_payment, b.warehouse, b.cost_center
|
a.owner, a.posting_date
|
||||||
""".format(conditions=conditions), filters, as_dict=1)
|
""".format(conditions=conditions), filters, as_dict=1)
|
||||||
|
|
||||||
|
def get_mode_of_payments(filters):
|
||||||
|
mode_of_payments = {}
|
||||||
|
invoice_list = get_invoices(filters)
|
||||||
|
invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list])
|
||||||
|
if invoice_list:
|
||||||
|
inv_mop = frappe.db.sql("""select a.owner,a.posting_date,b.mode_of_payment
|
||||||
|
from `tabSales Invoice` a, `tabSales Invoice Payment` b
|
||||||
|
where a.name = b.parent
|
||||||
|
and a.name in ({invoice_list_names})
|
||||||
|
union
|
||||||
|
select a.owner,a.posting_date,b.mode_of_payment
|
||||||
|
from `tabSales Invoice` a, `tabPayment Entry` b,`tabPayment Entry Reference` c
|
||||||
|
where a.name = c.reference_name
|
||||||
|
and b.name = c.parent
|
||||||
|
and a.name in ({invoice_list_names})
|
||||||
|
""".format(invoice_list_names=invoice_list_names), as_dict=1)
|
||||||
|
for d in inv_mop:
|
||||||
|
mode_of_payments.setdefault(d["owner"]+cstr(d["posting_date"]), []).append(d.mode_of_payment)
|
||||||
|
return mode_of_payments
|
||||||
|
|
||||||
|
def get_invoices(filters):
|
||||||
|
conditions = get_conditions(filters)
|
||||||
|
return frappe.db.sql("""select a.name
|
||||||
|
from `tabSales Invoice` a
|
||||||
|
where a.docstatus = 1 and {conditions}""".format(conditions=conditions),
|
||||||
|
filters, as_dict=1)
|
@ -56,7 +56,7 @@ def validate_item_variant_attributes(item, args=None):
|
|||||||
if not args:
|
if not args:
|
||||||
args = {d.attribute.lower():d.attribute_value for d in item.attributes}
|
args = {d.attribute.lower():d.attribute_value for d in item.attributes}
|
||||||
|
|
||||||
attribute_values, numeric_values = get_attribute_values()
|
attribute_values, numeric_values = get_attribute_values(item)
|
||||||
|
|
||||||
for attribute, value in args.items():
|
for attribute, value in args.items():
|
||||||
if not value:
|
if not value:
|
||||||
@ -96,16 +96,17 @@ def validate_item_attribute_value(attributes_list, attribute, attribute_value, i
|
|||||||
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
|
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values for Item {2}").format(
|
||||||
attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
|
attribute_value, attribute, item), InvalidItemAttributeValueError, title=_('Invalid Attribute'))
|
||||||
|
|
||||||
def get_attribute_values():
|
def get_attribute_values(item):
|
||||||
if not frappe.flags.attribute_values:
|
if not frappe.flags.attribute_values:
|
||||||
attribute_values = {}
|
attribute_values = {}
|
||||||
numeric_values = {}
|
numeric_values = {}
|
||||||
for t in frappe.get_all("Item Attribute Value", fields=["parent", "attribute_value"]):
|
for t in frappe.get_all("Item Attribute Value", fields=["parent", "attribute_value"]):
|
||||||
attribute_values.setdefault(t.parent.lower(), []).append(t.attribute_value)
|
attribute_values.setdefault(t.parent.lower(), []).append(t.attribute_value)
|
||||||
|
|
||||||
for t in frappe.get_all('Item Attribute',
|
for t in frappe.get_all('Item Variant Attribute',
|
||||||
fields=["name", "from_range", "to_range", "increment"], filters={'numeric_values': 1}):
|
fields=["attribute", "from_range", "to_range", "increment"],
|
||||||
numeric_values[t.name.lower()] = t
|
filters={'numeric_values': 1, 'parent': item.variant_of}):
|
||||||
|
numeric_values[t.attribute.lower()] = t
|
||||||
|
|
||||||
frappe.flags.attribute_values = attribute_values
|
frappe.flags.attribute_values = attribute_values
|
||||||
frappe.flags.numeric_values = numeric_values
|
frappe.flags.numeric_values = numeric_values
|
||||||
|
Loading…
Reference in New Issue
Block a user