Merge branch 'staging-fixes' into staging
This commit is contained in:
commit
64b4d98778
@ -230,7 +230,7 @@
|
|||||||
{% } %}
|
{% } %}
|
||||||
<td style="text-align: right">{%= format_currency(data[i][("total_invoiced_amt")], data[i]["currency"]) %}</td>
|
<td style="text-align: right">{%= format_currency(data[i][("total_invoiced_amt")], data[i]["currency"]) %}</td>
|
||||||
<td style="text-align: right">{%= format_currency(data[i][("total_paid_amt")], data[i]["currency"]) %}</td>
|
<td style="text-align: right">{%= format_currency(data[i][("total_paid_amt")], data[i]["currency"]) %}</td>
|
||||||
<td style="text-align: right">{%= report.report_name === "Accounts Receivable Summary" ? format_currency(data[i][__("Credit Note Amt")], data[i]["currency"]) : format_currency(data[i][__("Debit Note Amt")], data[i]["currency"]) %}</td>
|
<td style="text-align: right">{%= report.report_name === "Accounts Receivable Summary" ? format_currency(data[i][__("credit_note_amt")], data[i]["currency"]) : format_currency(data[i][__("debit_note_amt")], data[i]["currency"]) %}</td>
|
||||||
<td style="text-align: right">{%= format_currency(data[i][("total_outstanding_amt")], data[i]["currency"]) %}</td>
|
<td style="text-align: right">{%= format_currency(data[i][("total_outstanding_amt")], data[i]["currency"]) %}</td>
|
||||||
{% } %}
|
{% } %}
|
||||||
{% } %}
|
{% } %}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _, scrub
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport
|
from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport
|
||||||
|
|
||||||
@ -21,24 +21,92 @@ class AccountsReceivableSummary(ReceivablePayableReport):
|
|||||||
if party_naming_by == "Naming Series":
|
if party_naming_by == "Naming Series":
|
||||||
columns += [ args.get("party_type") + " Name::140"]
|
columns += [ args.get("party_type") + " Name::140"]
|
||||||
|
|
||||||
credit_debit_label = _("Credit Note Amt") if args.get('party_type') == 'Customer' else _("Debit Note Amt")
|
credit_debit_label = "Credit Note Amt" if args.get('party_type') == 'Customer' else "Debit Note Amt"
|
||||||
|
|
||||||
|
columns += [{
|
||||||
|
"label": _("Total Invoiced Amt"),
|
||||||
|
"fieldname": "total_invoiced_amt",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Total Paid Amt"),
|
||||||
|
"fieldname": "total_paid_amt",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 100
|
||||||
|
}]
|
||||||
|
|
||||||
columns += [
|
columns += [
|
||||||
_("Total Invoiced Amt") + ":Currency/currency:140",
|
{
|
||||||
_("Total Paid Amt") + ":Currency/currency:140",
|
"label": _(credit_debit_label),
|
||||||
credit_debit_label + ":Currency/currency:140",
|
"fieldname": scrub(credit_debit_label),
|
||||||
_("Total Outstanding Amt") + ":Currency/currency:160",
|
"fieldtype": "Currency",
|
||||||
"0-" + str(self.filters.range1) + ":Currency/currency:100",
|
"options": "currency",
|
||||||
str(self.filters.range1) + "-" + str(self.filters.range2) + ":Currency/currency:100",
|
"width": 140
|
||||||
str(self.filters.range2) + "-" + str(self.filters.range3) + ":Currency/currency:100",
|
},
|
||||||
str(self.filters.range3) + _("-Above") + ":Currency/currency:100"]
|
{
|
||||||
|
"label": _("Total Outstanding Amt"),
|
||||||
|
"fieldname": "total_outstanding_amt",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 160
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("0-" + str(self.filters.range1)),
|
||||||
|
"fieldname": scrub("0-" + str(self.filters.range1)),
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 160
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _(str(self.filters.range1) + "-" + str(self.filters.range2)),
|
||||||
|
"fieldname": scrub(str(self.filters.range1) + "-" + str(self.filters.range2)),
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 160
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _(str(self.filters.range2) + "-" + str(self.filters.range3)),
|
||||||
|
"fieldname": scrub(str(self.filters.range2) + "-" + str(self.filters.range3)),
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 160
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _(str(self.filters.range3) + _("-Above")),
|
||||||
|
"fieldname": scrub(str(self.filters.range3) + _("-Above")),
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"options": "currency",
|
||||||
|
"width": 160
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
if args.get("party_type") == "Customer":
|
if args.get("party_type") == "Customer":
|
||||||
columns += [
|
columns += [{
|
||||||
_("Territory") + ":Link/Territory:80",
|
"label": _("Territory"),
|
||||||
_("Customer Group") + ":Link/Customer Group:120"
|
"fieldname": "territory",
|
||||||
]
|
"fieldtype": "Link",
|
||||||
|
"options": "Territory",
|
||||||
|
"width": 80
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": _("Customer Group"),
|
||||||
|
"fieldname": "customer_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Customer Group",
|
||||||
|
"width": 80
|
||||||
|
}]
|
||||||
|
|
||||||
if args.get("party_type") == "Supplier":
|
if args.get("party_type") == "Supplier":
|
||||||
columns += [_("Supplier Group") + ":Link/Supplier Group:80"]
|
columns += [{
|
||||||
|
"label": _("Supplier Group"),
|
||||||
|
"fieldname": "supplier_group",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Supplier Group",
|
||||||
|
"width": 80
|
||||||
|
}]
|
||||||
|
|
||||||
columns.append({
|
columns.append({
|
||||||
"fieldname": "currency",
|
"fieldname": "currency",
|
||||||
|
@ -12,7 +12,7 @@ app_license = "GNU General Public License (v3)"
|
|||||||
source_link = "https://github.com/frappe/erpnext"
|
source_link = "https://github.com/frappe/erpnext"
|
||||||
|
|
||||||
develop_version = '12.x.x-develop'
|
develop_version = '12.x.x-develop'
|
||||||
staging_version = '11.0.3-beta.23'
|
staging_version = '11.0.3-beta.24'
|
||||||
|
|
||||||
error_report_email = "support@erpnext.com"
|
error_report_email = "support@erpnext.com"
|
||||||
|
|
||||||
|
@ -9,12 +9,12 @@ def execute():
|
|||||||
frappe.reload_doc('stock', 'doctype', 'purchase_receipt')
|
frappe.reload_doc('stock', 'doctype', 'purchase_receipt')
|
||||||
frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
|
frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
|
||||||
frappe.reload_doc('accounts', 'doctype', 'purchase_invoice')
|
frappe.reload_doc('accounts', 'doctype', 'purchase_invoice')
|
||||||
|
|
||||||
doctypes = ["Sales Order", "Sales Invoice", "Delivery Note",\
|
doctypes = ["Sales Order", "Sales Invoice", "Delivery Note",\
|
||||||
"Purchase Order", "Purchase Invoice", "Purchase Receipt", "Quotation", "Supplier Quotation"]
|
"Purchase Order", "Purchase Invoice", "Purchase Receipt", "Quotation", "Supplier Quotation"]
|
||||||
|
|
||||||
for doctype in doctypes:
|
for doctype in doctypes:
|
||||||
total_qty = frappe.db.sql('''
|
total_qty = frappe.db.sql('''
|
||||||
SELECT
|
SELECT
|
||||||
parent, SUM(qty) as qty
|
parent, SUM(qty) as qty
|
||||||
FROM
|
FROM
|
||||||
@ -22,14 +22,25 @@ def execute():
|
|||||||
GROUP BY parent
|
GROUP BY parent
|
||||||
''' % (doctype), as_dict = True)
|
''' % (doctype), as_dict = True)
|
||||||
|
|
||||||
when_then = []
|
# Query to update total_qty might become too big, Update in batches
|
||||||
for d in total_qty:
|
# batch_size is chosen arbitrarily, Don't try too hard to reason about it
|
||||||
when_then.append("""
|
batch_size = 100000
|
||||||
when dt.name = '{0}' then {1}
|
for i in range(0, len(total_qty), batch_size):
|
||||||
""".format(frappe.db.escape(d.get("parent")), d.get("qty")))
|
batch_transactions = total_qty[i:i + batch_size]
|
||||||
|
|
||||||
if when_then:
|
# UPDATE with CASE for some reason cannot use PRIMARY INDEX,
|
||||||
frappe.db.sql('''
|
# causing all rows to be examined, leading to a very slow update
|
||||||
UPDATE
|
|
||||||
`tab%s` dt SET dt.total_qty = CASE %s ELSE 0.0 END
|
# UPDATE with WHERE clause uses PRIMARY INDEX, but will lead to too many queries
|
||||||
''' % (doctype, " ".join(when_then)))
|
|
||||||
|
# INSERT with ON DUPLICATE KEY UPDATE uses PRIMARY INDEX
|
||||||
|
# and can perform multiple updates per query
|
||||||
|
# This is probably never used anywhere else as of now, but should be
|
||||||
|
values = []
|
||||||
|
for d in batch_transactions:
|
||||||
|
values.append("('{}', {})".format(d.parent, d.qty))
|
||||||
|
conditions = ",".join(values)
|
||||||
|
frappe.db.sql("""
|
||||||
|
INSERT INTO `tab{}` (name, total_qty) VALUES {}
|
||||||
|
ON DUPLICATE KEY UPDATE name = VALUES(name), total_qty = VALUES(total_qty)
|
||||||
|
""".format(doctype, conditions))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user