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

Chore/compliance summary frontend & db #2504

Open
wants to merge 19 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
26 changes: 26 additions & 0 deletions bc_obps/registration/migrations/0058_remove_naics_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 5.0.8 on 2024-11-18 23:40

from django.db import migrations


def remove_naics_code(apps, schema_monitor):
'''
Remove unregulated naics_code value from naics_code table
'''

NaicsCode = apps.get_model('registration', 'NaicsCode')
NaicsCode.objects.get(naics_code='418990').delete()


def revert_remove_naics_code(apps, schema_monitor):
NaicsCode = apps.get_model('registration', 'NaicsCode')
NaicsCode.objects.create(naics_code='418990', naics_description='All other merchant wholesalers')


class Migration(migrations.Migration):

dependencies = [
('registration', '0057_remove_registrationpurpose_archived_by_and_more'),
]

operations = [migrations.RunPython(remove_naics_code, revert_remove_naics_code)] # No revert necessary
1 change: 0 additions & 1 deletion bc_obps/registration/tests/models/test_initial_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def test_naics_code_initial_data(self):
('331511', 'Iron foundries'),
('412110', 'Petroleum, petroleum products, and other hydrocarbons merchant wholesalers'),
('486210', 'Pipeline transportation of natural gas'),
('418990', 'All other merchant wholesalers'),
]
)
existing_codes = sorted(list(NaicsCode.objects.values_list('naics_code', 'naics_description')))
Expand Down
1 change: 1 addition & 0 deletions bc_obps/registration/tests/models/test_naics_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ def setUpTestData(cls):
("operations", "operation", None, None),
("operations_naics_secondary", "operation", None, None),
("operations_naics_tertiary", "operation", None, None),
("naicsregulatoryvalue_records", "naics regulatory value", None, None),
]
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),
("productemissionintensity_records", "product emission intensity", None, 0),
]
cls.test_object = RegulatedProduct.objects.create(
name="test product",
Expand Down
307 changes: 307 additions & 0 deletions bc_obps/reporting/migrations/0032_naics_regulatory_value_with_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
# Generated by Django 5.0.8 on 2024-11-18 22:44

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


def init_naics_regulatory_value_data(apps, schema_monitor):
'''
Add initial data to erc.naics_regulatory_value
'''

NaicsCode = apps.get_model('registration', 'NaicsCode')
NaicsRegulatoryValue = apps.get_model('reporting', 'NaicsRegulatoryValue')
NaicsRegulatoryValue.objects.bulk_create(
[
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=211110).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=212114).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=212220).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=212231).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=212233).id),
reduction_factor='0.8',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=212299).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=213118).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=311119).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=311310).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=311614).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=321111).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=321212).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=321216).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=321999).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=322111).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=322112).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=322121).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=322122).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=324110).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=325120).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=325181).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=325189).id),
reduction_factor='0.9',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=325190).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=327310).id),
reduction_factor='0.9',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=327410).id),
reduction_factor='0.9',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=327420).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=327990).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=331222).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=331313).id),
reduction_factor='0.95',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=331410).id),
reduction_factor='0.85',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=331511).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=412110).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
NaicsRegulatoryValue(
naics_code_id=(NaicsCode.objects.get(naics_code=486210).id),
reduction_factor='0.65',
tightening_rate='0.01',
valid_from='2023-01-01',
valid_to='9999-12-31',
),
]
)


class Migration(migrations.Migration):

dependencies = [
('registration', '0055_V1_14_0'),
('reporting', '0031_alter_reportemission_managers'),
]

operations = [
migrations.CreateModel(
name='NaicsRegulatoryValue',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
(
'reduction_factor',
models.DecimalField(
db_comment='The Province developed distinct reduction factors for products in the B.C. OBPS with disproportionately higher industrial process emissions than those produced in other sectors. https://www2.gov.bc.ca/assets/gov/environment/climate-change/action/carbon-tax/obps-technical-backgrounder.pdf',
decimal_places=4,
max_digits=5,
),
),
(
'tightening_rate',
models.DecimalField(
db_comment='Tightening rates are planned, yearly, gradual increases to BC OBPS stringency. https://www2.gov.bc.ca/assets/gov/environment/climate-change/action/carbon-tax/obps-technical-backgrounder.pdf',
decimal_places=4,
max_digits=5,
),
),
(
'valid_from',
models.DateField(
blank=True, db_comment='Date from which the regulatory values are applicable', null=True
),
),
(
'valid_to',
models.DateField(
blank=True, db_comment='Date until which the regulatory values are applicable', null=True
),
),
(
'naics_code',
models.ForeignKey(
db_comment='Foreign key to the naics_code record that is associated with the regulatory values in this record',
on_delete=django.db.models.deletion.DO_NOTHING,
related_name='%(class)s_records',
to='registration.naicscode',
),
),
],
options={
'db_table': 'erc"."naics_regulatory_values',
'db_table_comment': 'This table contains the regulatory values that apply to a naics code within a set timeframe from where the values are valid and when the values are no longer valid.',
},
),
migrations.RunPython(init_naics_regulatory_value_data), # No revert necessary
]
Loading