mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +00:00
style: bulk format code with black
v13 port because otherwise backports will result in conflicts always
This commit is contained in:
@@ -13,10 +13,19 @@ from erpnext.loan_management.report.applicant_wise_loan_security_exposure.applic
|
||||
|
||||
@frappe.whitelist()
|
||||
@cache_source
|
||||
def get_data(chart_name = None, chart = None, no_cache = None, filters = None, from_date = None,
|
||||
to_date = None, timespan = None, time_interval = None, heatmap_year = None):
|
||||
def get_data(
|
||||
chart_name=None,
|
||||
chart=None,
|
||||
no_cache=None,
|
||||
filters=None,
|
||||
from_date=None,
|
||||
to_date=None,
|
||||
timespan=None,
|
||||
time_interval=None,
|
||||
heatmap_year=None,
|
||||
):
|
||||
if chart_name:
|
||||
chart = frappe.get_doc('Dashboard Chart', chart_name)
|
||||
chart = frappe.get_doc("Dashboard Chart", chart_name)
|
||||
else:
|
||||
chart = frappe._dict(frappe.parse_json(chart))
|
||||
|
||||
@@ -30,28 +39,44 @@ def get_data(chart_name = None, chart = None, no_cache = None, filters = None, f
|
||||
labels = []
|
||||
values = []
|
||||
|
||||
if filters.get('company'):
|
||||
if filters.get("company"):
|
||||
conditions = "AND company = %(company)s"
|
||||
|
||||
loan_security_details = get_loan_security_details()
|
||||
|
||||
unpledges = frappe._dict(frappe.db.sql("""
|
||||
unpledges = frappe._dict(
|
||||
frappe.db.sql(
|
||||
"""
|
||||
SELECT u.loan_security, sum(u.qty) as qty
|
||||
FROM `tabLoan Security Unpledge` up, `tabUnpledge` u
|
||||
WHERE u.parent = up.name
|
||||
AND up.status = 'Approved'
|
||||
{conditions}
|
||||
GROUP BY u.loan_security
|
||||
""".format(conditions=conditions), filters, as_list=1))
|
||||
""".format(
|
||||
conditions=conditions
|
||||
),
|
||||
filters,
|
||||
as_list=1,
|
||||
)
|
||||
)
|
||||
|
||||
pledges = frappe._dict(frappe.db.sql("""
|
||||
pledges = frappe._dict(
|
||||
frappe.db.sql(
|
||||
"""
|
||||
SELECT p.loan_security, sum(p.qty) as qty
|
||||
FROM `tabLoan Security Pledge` lp, `tabPledge`p
|
||||
WHERE p.parent = lp.name
|
||||
AND lp.status = 'Pledged'
|
||||
{conditions}
|
||||
GROUP BY p.loan_security
|
||||
""".format(conditions=conditions), filters, as_list=1))
|
||||
""".format(
|
||||
conditions=conditions
|
||||
),
|
||||
filters,
|
||||
as_list=1,
|
||||
)
|
||||
)
|
||||
|
||||
for security, qty in iteritems(pledges):
|
||||
current_pledges.setdefault(security, qty)
|
||||
@@ -61,19 +86,15 @@ def get_data(chart_name = None, chart = None, no_cache = None, filters = None, f
|
||||
|
||||
count = 0
|
||||
for security, qty in iteritems(sorted_pledges):
|
||||
values.append(qty * loan_security_details.get(security, {}).get('latest_price', 0))
|
||||
values.append(qty * loan_security_details.get(security, {}).get("latest_price", 0))
|
||||
labels.append(security)
|
||||
count +=1
|
||||
count += 1
|
||||
|
||||
## Just need top 10 securities
|
||||
if count == 10:
|
||||
break
|
||||
|
||||
return {
|
||||
'labels': labels,
|
||||
'datasets': [{
|
||||
'name': 'Top 10 Securities',
|
||||
'chartType': 'bar',
|
||||
'values': values
|
||||
}]
|
||||
"labels": labels,
|
||||
"datasets": [{"name": "Top 10 Securities", "chartType": "bar", "values": values}],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user