diff --git a/apps/quickbooks_online/utils.py b/apps/quickbooks_online/utils.py index 8303377b..91d0f238 100644 --- a/apps/quickbooks_online/utils.py +++ b/apps/quickbooks_online/utils.py @@ -124,9 +124,13 @@ def get_effective_tax_rates(self, tax_rates): effective_tax_rate = 0 tax_rate_refs = [] for tax_rate in tax_rates: - tax_rate_refs.append(tax_rate['TaxRateRef']) - tax_rate_id = tax_rate['TaxRateRef']['value'] - effective_tax_rate += self.connection.tax_rates.get_by_id(tax_rate_id)['RateValue'] + if 'TaxRateRef' in tax_rate: + tax_rate_refs.append(tax_rate['TaxRateRef']) + tax_rate_id = tax_rate['TaxRateRef']['value'] + tax_rate_by_id = self.connection.tax_rates.get_by_id(tax_rate_id) + + if 'RateValue' in tax_rate_by_id: + effective_tax_rate += tax_rate_by_id['RateValue'] return effective_tax_rate, tax_rate_refs