Skip to content

Commit

Permalink
Update bc_obps/reporting/service/report_verification_service.py
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Bastianelli <[email protected]>

chore: implement review suggestions
  • Loading branch information
shon-button committed Jan 6, 2025
1 parent 2d413e4 commit 284ad9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
13 changes: 7 additions & 6 deletions bc_obps/reporting/service/report_verification_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ def get_report_needs_verification(version_id: int) -> bool:
Operation.Purposes.NEW_ENTRANT_OPERATION,
}
ATTRIBUTABLE_EMISSION_THRESHOLD = Decimal("25000000")
registration_purpose = ReportAdditionalDataService.get_registration_purpose_by_version_id(version_id)

# Registration Purpose: verification data is required if the registration purpose is in REGULATED_OPERATION_PURPOSES
registration_purpose_value = registration_purpose.get("registration_purpose", {})
# Fetch registration purpose
registration_purpose = ReportAdditionalDataService.get_registration_purpose_by_version_id(version_id)

if registration_purpose in REGULATED_OPERATION_PURPOSES:
return True
# Compare the enum value
if isinstance(registration_purpose, Operation.Purposes):
if registration_purpose in REGULATED_OPERATION_PURPOSES:
return True

# Emission threshold: verification data is required if the registration purpose is Reporting Operation, and total TCo₂e >+ 25,000
# Emission threshold: verification data is required if the registration purpose is Reporting Operation, and total TCo₂e >= 25,000
if registration_purpose == Operation.Purposes.REPORTING_OPERATION:
attributable_emissions = ComplianceService.get_emissions_attributable_for_reporting(version_id)
return attributable_emissions >= ATTRIBUTABLE_EMISSION_THRESHOLD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@


class TestReportVerificationService(TestCase):
REGULATED_OPERATION_PURPOSES = {
Operation.Purposes.OBPS_REGULATED_OPERATION,
Operation.Purposes.OPTED_IN_OPERATION,
Operation.Purposes.NEW_ENTRANT_OPERATION,
}
ATTRIBUTABLE_EMISSION_THRESHOLD = Decimal('25000000')

def setUp(self):
# Arrange: Create a report version
self.report_version = make_recipe('reporting.tests.utils.report_version')
Expand Down

0 comments on commit 284ad9e

Please sign in to comment.