Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:added new entrant info page #2439

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def setUpTestData(cls):
("name", "name", 1000, None),
("operations", "operation", None, None),
("report_products", "report product", None, 0),
("new_entrant_productions", "report new entrant production", None, 0),
]
cls.test_object = RegulatedProduct.objects.create(
name="test product",
Expand Down
6 changes: 6 additions & 0 deletions bc_obps/registration/tests/models/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def setUpTestData(cls):
("reportproduct_created", "report product", None, None),
("reportproduct_updated", "report product", None, None),
("reportproduct_archived", "report product", None, None),
("reportnewentrantproduction_created", "report new entrant production", None, None),
("reportnewentrantproduction_updated", "report new entrant production", None, None),
("reportnewentrantproduction_archived", "report new entrant production", None, None),
("reportnewentrant_created", "report new entrant", None, None),
("reportnewentrant_updated", "report new entrant", None, None),
("reportnewentrant_archived", "report new entrant", None, None),
]

def test_unique_user_guid_and_business_guid_constraint(self):
Expand Down
3 changes: 3 additions & 0 deletions bc_obps/reporting/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
from .report_person_responsible import get_report_person_responsible_by_version_id
from .report_person_responsible import save_report_contact
from .report_additional_data import get_registration_purpose_by_version_id
from .reports import get_regulated_products_by_version_id
from .gas_type import get_gas_type
from .emission_category import get_emission_category
from .production_data import save_production_data
from .report_new_entrant_data import save_new_entrant_data
from .report_new_entrant_data import get_new_entrant_data
from .report_non_attributable_emissions import save_report
from .report_activity import save_report_activity_data, load_report_activity_data
2 changes: 1 addition & 1 deletion bc_obps/reporting/api/production_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def save_production_data(
tags=EMISSIONS_REPORT_TAGS,
description="""Retrieves the data for the production data page from the multiple ReportProduct rows""",
exclude_none=True,
auth=authorize("approved_industry_user"),
# auth=authorize("approved_industry_user"),
ayeshmcg marked this conversation as resolved.
Show resolved Hide resolved
)
@handle_http_errors()
def load_production_data(request: HttpRequest, report_version_id: int, facility_id: UUID) -> Tuple[Literal[200], dict]:
Expand Down
45 changes: 45 additions & 0 deletions bc_obps/reporting/api/report_new_entrant_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from typing import Literal, Tuple
from django.http import HttpRequest
from registration.decorators import handle_http_errors
from reporting.schema.generic import Message
from service.error_service.custom_codes_4xx import custom_codes_4xx
from service.report_service import ReportService
from .router import router
from ..schema.report_new_entrant import ReportNewEntrantSchemaIn, ReportNewEntrantDataOut
from ..service.report_new_entrant_service import ReportNewEntrantService


@router.get(
"report-version/{report_version_id}/new-entrant-data",
response={200: ReportNewEntrantDataOut},
tags=["Emissions Report"],
ayeshmcg marked this conversation as resolved.
Show resolved Hide resolved
)
def get_new_entrant_data(request: HttpRequest, report_version_id: int) -> Tuple[Literal[200], dict]:
report_new_entrant = ReportNewEntrantService.get_new_entrant_data(report_version_id) or {}
regulated_products = ReportService.get_regulated_products_by_version_id(report_version_id) or {}

response_data = {
"regulated_products": regulated_products,
"report_new_entrant_data": report_new_entrant,
}
print('response_data', response_data)
ayeshmcg marked this conversation as resolved.
Show resolved Hide resolved

return 200, response_data


@router.post(
"report-version/{report_version_id}/new-entrant-data",
response={200: int, custom_codes_4xx: Message},
tags=["Emissions Report"],
description="Saves the data for the new entrant report",
# auth=authorize("approved_industry_user"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auth

)
@handle_http_errors()
def save_new_entrant_data(
request: HttpRequest,
report_version_id: int,
payload: ReportNewEntrantSchemaIn,
) -> int:
ayeshmcg marked this conversation as resolved.
Show resolved Hide resolved
ReportNewEntrantService.save_new_entrant_data(report_version_id, payload)

return 200
18 changes: 17 additions & 1 deletion bc_obps/reporting/api/reports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Literal, Tuple
from typing import Literal, Tuple, List

from common.permissions import authorize
from django.http import HttpRequest
Expand All @@ -13,6 +13,7 @@
from reporting.schema.reporting_year import ReportingYearOut
from .router import router
from ..models import ReportingYear
from ..schema.report_regulated_products import RegulatedProductOut


@router.post(
Expand Down Expand Up @@ -71,3 +72,18 @@ def save_report(
@handle_http_errors()
def get_reporting_year(request: HttpRequest) -> Tuple[Literal[200], ReportingYear]:
return 200, ReportingYearService.get_current_reporting_year()


@router.get(
"/report-version/{version_id}/report-operation/regulated-products",
response={200: List[RegulatedProductOut], custom_codes_4xx: Message},
tags=EMISSIONS_REPORT_TAGS,
description="""Retrieves all regulated products associated with a report operation identified by its version ID.""",
# auth=authorize("approved_authorized_roles"),
)
ayeshmcg marked this conversation as resolved.
Show resolved Hide resolved
@handle_http_errors()
def get_regulated_products_by_version_id(
request: HttpRequest, version_id: int
) -> Tuple[Literal[200], List[RegulatedProductOut]]:
regulated_products = ReportService.get_regulated_products_by_version_id(version_id)
return 200, regulated_products
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
# Generated by Django 5.0.9 on 2024-11-08 02:33

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('registration', '0054_V1_13_0'),
('reporting', '0030_report_non_attributable_emissions'),
]

operations = [
migrations.CreateModel(
name='ReportNewEntrant',
fields=[
('created_at', models.DateTimeField(auto_now_add=True, null=True)),
('updated_at', models.DateTimeField(blank=True, null=True)),
('archived_at', models.DateTimeField(blank=True, null=True)),
(
'report_version',
models.OneToOneField(
db_comment='The associated report version for this new entrant record',
on_delete=django.db.models.deletion.CASCADE,
primary_key=True,
related_name='report_new_entrant',
serialize=False,
to='reporting.reportversion',
),
),
('authorization_date', models.DateField(db_comment='Date of authorization for emission reporting')),
(
'first_shipment_date',
models.DateField(
blank=True,
db_comment='Date of the first shipment related to this report (if applicable)',
null=True,
),
),
(
'new_entrant_period_start',
models.DateField(
blank=True, db_comment='Start date of the new entrant reporting period', null=True
),
),
(
'assertion_statement',
models.BooleanField(
blank=True, db_comment='Indicates if the assertion statement is certified', null=True
),
),
(
'flaring_emissions',
models.IntegerField(
blank=True, db_comment='Emissions from flaring activities', default=0, null=True
),
),
(
'fugitive_emissions',
models.IntegerField(
blank=True, db_comment='Unintentional emissions (fugitive)', default=0, null=True
),
),
(
'industrial_process_emissions',
models.IntegerField(
blank=True, db_comment='Emissions from industrial processes', default=0, null=True
),
),
(
'on_site_transportation_emissions',
models.IntegerField(
blank=True, db_comment='Emissions from on-site transportation', default=0, null=True
),
),
(
'stationary_fuel_combustion_emissions',
models.IntegerField(
blank=True, db_comment='Emissions from stationary fuel combustion', default=0, null=True
),
),
(
'venting_emissions_useful',
models.IntegerField(blank=True, db_comment='Venting emissions deemed useful', default=0, null=True),
),
(
'venting_emissions_non_useful',
models.IntegerField(blank=True, db_comment='Non-useful venting emissions', default=0, null=True),
),
(
'emissions_from_waste',
models.IntegerField(blank=True, db_comment='Emissions from waste disposal', default=0, null=True),
),
(
'emissions_from_wastewater',
models.IntegerField(
blank=True, db_comment='Emissions from wastewater processing', default=0, null=True
),
),
(
'co2_emissions_from_excluded_woody_biomass',
models.IntegerField(
blank=True, db_comment='CO2 emissions from excluded woody biomass', default=0, null=True
),
),
(
'other_emissions_from_excluded_biomass',
models.IntegerField(
blank=True, db_comment='Emissions from other excluded biomass', default=0, null=True
),
),
(
'emissions_from_excluded_non_biomass',
models.IntegerField(
blank=True, db_comment='Emissions from excluded non-biomass sources', default=0, null=True
),
),
(
'emissions_from_line_tracing',
models.IntegerField(
blank=True, db_comment='Emissions from line tracing activities', default=0, null=True
),
),
(
'emissions_from_fat_oil',
models.IntegerField(
blank=True, db_comment='Emissions from fat or oil sources', default=0, null=True
),
),
(
'archived_by',
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='%(class)s_archived',
to='registration.user',
),
),
(
'created_by',
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='%(class)s_created',
to='registration.user',
),
),
(
'updated_by',
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='%(class)s_updated',
to='registration.user',
),
),
],
options={
'db_table': 'erc"."report_new_entrant',
'db_table_comment': 'Table storing new entrant emissions data for the reporting system',
},
),
migrations.CreateModel(
name='ReportNewEntrantProduction',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True, null=True)),
('updated_at', models.DateTimeField(blank=True, null=True)),
('archived_at', models.DateTimeField(blank=True, null=True)),
(
'production_amount',
models.IntegerField(
blank=True,
db_comment='The amount of production associated with this report',
default=0,
null=True,
),
),
(
'archived_by',
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='%(class)s_archived',
to='registration.user',
),
),
(
'created_by',
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='%(class)s_created',
to='registration.user',
),
),
(
'product',
models.ForeignKey(
db_comment='The regulated product associated with this production record',
on_delete=django.db.models.deletion.CASCADE,
related_name='new_entrant_productions',
to='registration.regulatedproduct',
),
),
(
'report_new_entrant',
models.ForeignKey(
db_comment='The new entrant report to which this production record belongs',
on_delete=django.db.models.deletion.CASCADE,
related_name='productions',
to='reporting.reportnewentrant',
),
),
(
'updated_by',
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='%(class)s_updated',
to='registration.user',
),
),
],
options={
'db_table': 'erc"."report_new_entrant_production',
'db_table_comment': 'Table for storing production data related to new entrant emissions reporting',
},
),
]
4 changes: 4 additions & 0 deletions bc_obps/reporting/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from .report_additional_data import ReportAdditionalData
from .emission_category import EmissionCategory
from .emission_category_mapping import EmissionCategoryMapping
from .report_new_entrant import ReportNewEntrant
from .report_new_entrant_production import ReportNewEntrantProduction
from .report_non_attributable_emissions import ReportNonAttributableEmissions
from .report_product import ReportProduct

Expand Down Expand Up @@ -61,4 +63,6 @@
"EmissionCategoryMapping",
"ReportNonAttributableEmissions",
"ReportRawActivityData",
"ReportNewEntrant",
"ReportNewEntrantProduction"
]
Loading
Loading