diff --git a/legal-api/src/legal_api/reports/report.py b/legal-api/src/legal_api/reports/report.py index d24811e40..091ae2c76 100644 --- a/legal-api/src/legal_api/reports/report.py +++ b/legal-api/src/legal_api/reports/report.py @@ -354,21 +354,23 @@ def _set_tax_id(self, filing): def _set_description(self, filing): legal_type = None - if self._filing.filing_type == 'alteration': - legal_type = self._filing.filing_json.get('filing').get('alteration').get('business', {}).get('legalType') + filing_json = self._filing.filing_json.get('filing', {}) + filing_type = self._filing.filing_type + + # Check for alteration filing type + if filing_type == 'alteration': + legal_type = filing_json.get('alteration', {}).get('business', {}).get('legalType') else: - legal_type = (self._filing.filing_json - .get('filing') - .get(self._filing.filing_type) - .get('nameRequest', {}) - .get('legalType')) + legal_type = filing_json.get(filing_type, {}).get('nameRequest', {}).get('legalType') + # Fallback: Check the general business section + if not legal_type: + legal_type = filing_json.get('business', {}).get('legalType') + + # Final fallback: Check the _business object if not legal_type and self._business: legal_type = self._business.legal_type - if not legal_type and self._filing.filing_type == 'noticeOfWithdrawal': - legal_type = self._filing.filing_json.get('filing').get('business', {}).get('legalType') - filing['numberedDescription'] = Business.BUSINESSES.get(legal_type, {}).get('numberedDescription') filing['numberedLegalNameSuffix'] = Business.BUSINESSES.get(legal_type, {}).get('numberedLegalNameSuffix')