Handle IndexError if no data found

This commit is contained in:
Shreya 2018-10-05 13:22:09 +05:30
parent 75fa6b3ee8
commit 0d7bd43367
2 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,7 @@ frappe.query_reports["TDS Computation Summary"] = {
"fieldname":"company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company",
"default": frappe.defaults.get_default('company')
},
{

View File

@ -41,8 +41,10 @@ def get_result(filters):
for supplier in filters.supplier:
tds = frappe.get_doc("Tax Withholding Category", supplier.tax_withholding_category)
rate = [d.tax_withholding_rate for d in tds.rates if d.fiscal_year == filters.fiscal_year][0]
account = [d.account for d in tds.accounts if d.company == filters.company][0]
try:
account = [d.account for d in tds.accounts if d.company == filters.company][0]
except IndexError:
account = []
total_invoiced_amount, tds_deducted = get_invoice_and_tds_amount(supplier.name, account,
filters.company, filters.from_date, filters.to_date)