Merge pull request #24468 from deepeshgarg007/lse_report_fix

fix: Division by 0 error in security exposure reports
This commit is contained in:
Deepesh Garg 2021-01-26 10:13:39 +05:30 committed by GitHub
commit ff3adfd1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 27 deletions

View File

@ -43,6 +43,7 @@ def get_data(filters):
currency = erpnext.get_company_currency(filters.get('company'))
for key, qty in iteritems(pledge_values):
if qty:
row = {}
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')
@ -54,7 +55,8 @@ def get_data(filters):
'total_qty': qty,
'current_value': current_value,
'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]) \
else 0.0,
'currency': currency
})

View File

@ -40,6 +40,7 @@ def get_data(filters):
currency = erpnext.get_company_currency(filters.get('company'))
for security, value in iteritems(current_pledges):
if value.get('qty'):
row = {}
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')