fix: Division by 0 error in security exposure reports
This commit is contained in:
parent
164079127f
commit
7a4db2214a
@ -43,22 +43,24 @@ def get_data(filters):
|
|||||||
currency = erpnext.get_company_currency(filters.get('company'))
|
currency = erpnext.get_company_currency(filters.get('company'))
|
||||||
|
|
||||||
for key, qty in iteritems(pledge_values):
|
for key, qty in iteritems(pledge_values):
|
||||||
row = {}
|
if qty:
|
||||||
current_value = flt(qty * loan_security_details.get(key[1], {}).get('latest_price', 0))
|
row = {}
|
||||||
valid_upto = loan_security_details.get(key[1], {}).get('valid_upto')
|
current_value = flt(qty * loan_security_details.get(key[1], {}).get('latest_price', 0))
|
||||||
|
valid_upto = loan_security_details.get(key[1], {}).get('valid_upto')
|
||||||
|
|
||||||
row.update(loan_security_details.get(key[1]))
|
row.update(loan_security_details.get(key[1]))
|
||||||
row.update({
|
row.update({
|
||||||
'applicant_type': applicant_type_map.get(key[0]),
|
'applicant_type': applicant_type_map.get(key[0]),
|
||||||
'applicant_name': key[0],
|
'applicant_name': key[0],
|
||||||
'total_qty': qty,
|
'total_qty': qty,
|
||||||
'current_value': current_value,
|
'current_value': current_value,
|
||||||
'price_valid_upto': valid_upto,
|
'price_valid_upto': valid_upto,
|
||||||
'portfolio_percent': flt(current_value * 100 / total_value_map.get(key[0]), 2),
|
'portfolio_percent': flt(current_value * 100 / total_value_map.get(key[0]), 2) if total_value_map.get(key[0]) \
|
||||||
'currency': currency
|
else 0.0,
|
||||||
})
|
'currency': currency
|
||||||
|
})
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -40,21 +40,22 @@ def get_data(filters):
|
|||||||
currency = erpnext.get_company_currency(filters.get('company'))
|
currency = erpnext.get_company_currency(filters.get('company'))
|
||||||
|
|
||||||
for security, value in iteritems(current_pledges):
|
for security, value in iteritems(current_pledges):
|
||||||
row = {}
|
if value.get('qty'):
|
||||||
current_value = flt(value.get('qty', 0) * loan_security_details.get(security, {}).get('latest_price', 0))
|
row = {}
|
||||||
valid_upto = loan_security_details.get(security, {}).get('valid_upto')
|
current_value = flt(value.get('qty', 0) * loan_security_details.get(security, {}).get('latest_price', 0))
|
||||||
|
valid_upto = loan_security_details.get(security, {}).get('valid_upto')
|
||||||
|
|
||||||
row.update(loan_security_details.get(security))
|
row.update(loan_security_details.get(security))
|
||||||
row.update({
|
row.update({
|
||||||
'total_qty': value.get('qty'),
|
'total_qty': value.get('qty'),
|
||||||
'current_value': current_value,
|
'current_value': current_value,
|
||||||
'price_valid_upto': valid_upto,
|
'price_valid_upto': valid_upto,
|
||||||
'portfolio_percent': flt(current_value * 100 / total_portfolio_value, 2),
|
'portfolio_percent': flt(current_value * 100 / total_portfolio_value, 2),
|
||||||
'pledged_applicant_count': value.get('applicant_count'),
|
'pledged_applicant_count': value.get('applicant_count'),
|
||||||
'currency': currency
|
'currency': currency
|
||||||
})
|
})
|
||||||
|
|
||||||
data.append(row)
|
data.append(row)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user