Skip to content

Commit

Permalink
Tracking pull request to merge release-2.6.0 to master (#2236)
Browse files Browse the repository at this point in the history
* update for new 2.6.0 release

* update PR_NUMBER

* feat: added line26C line to schedule summary to account for credit giveback scenarios

* chore: updated snapshots

* chore: test updates

* chore: updated linting and minor fixes

* chore: backend linting fixes

* WIP

* removing logging

* fixing linting

* removing jquery reference

* fix: tfrs-2131 - change so that attorney address title doesn't display if there are no attornery address fields

* fix: logic fix for schedule summary

* clamav image move (#2246)

* update image repo

* fix: bug fixes on create supplemental related to line 26C

* update approval list

* fix: removed incorrect logic

* chore: unit test update

* chore: docs updated for branch naming conventions

* chore: docs updated for branch naming conventions

* fix: updated compliance report details serializer to account for positive credit balances when setting penalty amount

* chore: updated comment

* Bump sqlparse from 0.4.3 to 0.4.4 in /backend

Bumps [sqlparse](https://github.com/andialbrecht/sqlparse) from 0.4.3 to 0.4.4.
- [Release notes](https://github.com/andialbrecht/sqlparse/releases)
- [Changelog](https://github.com/andialbrecht/sqlparse/blob/master/CHANGELOG)
- [Commits](andialbrecht/sqlparse@0.4.3...0.4.4)

---
updated-dependencies:
- dependency-name: sqlparse
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* feat: tfrs-2127 - download supplier users

* WIP

* WIP

* WIP

* update dashboard and compliance reporting page

* removing logging

* Update User.py

* add comment

* removing logging

* feat: tfrs-2159 - exact status filter on fuel suppliers page

* fix: tfrs-2258 - credit history table pagination fix

* fix: tfrs-2127 - changes to fs users spreadsheet download

* fix: tfrs-2127 - use external username

* minor fix

* unite test and some minor fix

* use UserCreationRequest to get external usernames

* fix linting and removing commented code

* fix: updated line 27 logic and added unit tests to cover cases

* chore: auto lint fixes

* chore: rebase and update snapshots

* Default Sorting by Latest Submission Date for the Secure File Submissions Table

* fix to close the confirmation window on submission

* rollback backend unrelated changes

* removing sorting on first 4 column and fix for sorting

* formating code

* chore(deps): bump django from 3.2.18 to 3.2.19 in /backend

Bumps [django](https://github.com/django/django) from 3.2.18 to 3.2.19.
- [Commits](django/django@3.2.18...3.2.19)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>

* default sorting for file submissions

* layout fix

* styling fix

* fix: fixed 3 bugs on compliance list view filtering, updating linting, snapshots updated

* cleanup

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: AlexZorkin <[email protected]>
Co-authored-by: Alex Zorkin <[email protected]>
Co-authored-by: jig-patel <[email protected]>
Co-authored-by: tim738745 <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Your Name <[email protected]>
Co-authored-by: Prashanth <[email protected]>
  • Loading branch information
8 people committed May 16, 2023
1 parent a73fdb1 commit b3f0a9c
Show file tree
Hide file tree
Showing 94 changed files with 4,224 additions and 3,899 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tfrs-release.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## For each release, the value of name, branches, RELEASE_NAME and PR_NUMBER need to be adjusted accordingly
## For each release, update lib/config.js: version and releaseBranch

name: TFRS release-2.5.0
name: TFRS release-2.6.0

on:
push:
branches: [ release-2.5.0 ]
branches: [ release-2.6.0 ]
paths:
- frontend/**
- backend/**
Expand All @@ -15,8 +15,8 @@ on:
env:
## The pull request number of the Tracking pull request to merge the release branch to main
## Also remember to update the version in .pipeline/lib/config.js
PR_NUMBER: 2187
RELEASE_NAME: release-2.5.0
PR_NUMBER: 2236
RELEASE_NAME: release-2.6.0

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
uses: trstringer/[email protected]
with:
secret: ${{ github.TOKEN }}
approvers: AlexZorkin,emi-hi,tim738745,vibhiquartech,kuanfandevops
approvers: AlexZorkin,emi-hi,tim738745,kuanfandevops,jig-patel
minimum-approvals: 1
issue-title: "TFRS ${{ env.RELEASE_NAME }} Test Deployment"

Expand Down
4 changes: 2 additions & 2 deletions .pipeline/lib/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
const options= require('@bcgov/pipeline-cli').Util.parseArguments()
const changeId = options.pr //aka pull-request
const version = '2.5.0'
const version = '2.6.0'
const name = 'tfrs'
const ocpName = 'apps.silver.devops'

Expand All @@ -13,7 +13,7 @@ options.git.repository='tfrs'
const phases = {
build: { namespace:'0ab226-tools' , name: `${name}`, phase: 'build' , changeId:changeId, suffix: `-build-${changeId}` ,
instance: `${name}-build-${changeId}` , version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`,
releaseBranch: 'release-2.5.0'
releaseBranch: 'release-2.6.0'
},
dev: {namespace:'0ab226-dev' , name: `${name}`, phase: 'dev' , changeId:changeId, suffix: `-dev` ,
instance: `${name}-dev` , version:`${version}`, tag:`dev-${version}`, dbServiceName: 'tfrs-spilo',
Expand Down
2 changes: 1 addition & 1 deletion backend/api/keycloak_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def authenticate(self, request):
audience=KEYCLOAK_AUDIENCE,
options={"verify_exp": True},
)
except (jwt.InvalidTokenError, jwt.ExpiredSignature, jwt.DecodeError) as exc:
except (jwt.InvalidTokenError, jwt.DecodeError) as exc:
print(str(exc))
token_validation_errors.append(exc)
raise Exception(str(exc))
Expand Down
18 changes: 18 additions & 0 deletions backend/api/migrations/0206_schedulesummary_credits_offset_c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.18 on 2023-03-22 22:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0205_auto_20230321_0206'),
]

operations = [
migrations.AddField(
model_name='schedulesummary',
name='credits_offset_c',
field=models.IntegerField(blank=True, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.18 on 2023-04-26 03:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0206_schedulesummary_credits_offset_c'),
]

# The "choices" attribute of the field below was changed so that the actual values (the first argument of each choice, or pair)
# match what is actually being saved in the database, which is the string value of an enum member of NotificationType.
# Previously, those actual values were the enum members themselves, and so when get_notification_type_display() was called
# on a NotificationSubscription model instance, we would not get the intended value.

operations = [
migrations.AlterField(
model_name='notificationsubscription',
name='notification_type',
field=models.CharField(choices=[('NotificationType.CREDIT_TRANSFER_CREATED', 'Credit Transfer Proposal Created'), ('NotificationType.CREDIT_TRANSFER_SIGNED_1OF2', 'Credit Transfer Proposal Signed 1/2'), ('NotificationType.CREDIT_TRANSFER_SIGNED_2OF2', 'Credit Transfer Proposal Signed 2/2'), ('NotificationType.CREDIT_TRANSFER_PROPOSAL_REFUSED', 'Credit Transfer Proposal Refused'), ('NotificationType.CREDIT_TRANSFER_PROPOSAL_ACCEPTED', 'Credit Transfer Proposal Accepted'), ('NotificationType.CREDIT_TRANSFER_RECOMMENDED_FOR_APPROVAL', 'Credit Transfer Proposal Recommended For Approval'), ('NotificationType.CREDIT_TRANSFER_RECOMMENDED_FOR_DECLINATION', 'Credit Transfer Proposal Recommended For Declination'), ('NotificationType.CREDIT_TRANSFER_DECLINED', 'Credit Transfer Proposal Declined'), ('NotificationType.CREDIT_TRANSFER_APPROVED', 'Credit Transfer Proposal Approved'), ('NotificationType.CREDIT_TRANSFER_RESCINDED', 'Credit Transfer Proposal Rescinded'), ('NotificationType.CREDIT_TRANSFER_COMMENT', 'Credit Transfer Proposal Comment Created Or Updated'), ('NotificationType.CREDIT_TRANSFER_INTERNAL_COMMENT', 'Credit Transfer Proposal Internal Comment Created Or Updated'), ('NotificationType.PVR_CREATED', 'PVR Created'), ('NotificationType.PVR_RECOMMENDED_FOR_APPROVAL', 'PVR Recommended For Approval'), ('NotificationType.PVR_RESCINDED', 'PVR Rescinded'), ('NotificationType.PVR_PULLED_BACK', 'PVR Pulled Back'), ('NotificationType.PVR_DECLINED', 'PVR Declined'), ('NotificationType.PVR_APPROVED', 'PVR Approved'), ('NotificationType.PVR_COMMENT', 'PVR Comment Created Or Updated'), ('NotificationType.PVR_INTERNAL_COMMENT', 'PVR Internal Comment Created Or Updated'), ('NotificationType.PVR_RETURNED_TO_ANALYST', 'PVR Returned to Analyst'), ('NotificationType.DOCUMENT_PENDING_SUBMISSION', 'Document Pending Submission'), ('NotificationType.DOCUMENT_SUBMITTED', 'Document Submitted'), ('NotificationType.DOCUMENT_SCAN_FAILED', 'Document Security Scan Failed'), ('NotificationType.DOCUMENT_RECEIVED', 'Document Received'), ('NotificationType.DOCUMENT_ARCHIVED', 'Document Archived'), ('NotificationType.COMPLIANCE_REPORT_DRAFT', 'Compliance Report Draft Saved'), ('NotificationType.COMPLIANCE_REPORT_SUBMITTED', 'Compliance Report Submitted'), ('NotificationType.COMPLIANCE_REPORT_RECOMMENDED_FOR_ACCEPTANCE_ANALYST', 'Compliance Report Recommended for Acceptance - Analyst'), ('NotificationType.COMPLIANCE_REPORT_RECOMMENDED_FOR_REJECTION_ANALYST', 'Compliance Report Recommended for Rejection - Analyst'), ('NotificationType.COMPLIANCE_REPORT_RECOMMENDED_FOR_ACCEPTANCE_MANAGER', 'Compliance Report Recommended for Acceptance - Manager'), ('NotificationType.COMPLIANCE_REPORT_RECOMMENDED_FOR_REJECTION_MANAGER', 'Compliance Report Recommended for Rejection - Manager'), ('NotificationType.COMPLIANCE_REPORT_ACCEPTED', 'Compliance Report Accepted'), ('NotificationType.COMPLIANCE_REPORT_REJECTED', 'Compliance Report Rejected'), ('NotificationType.COMPLIANCE_REPORT_REQUESTED_SUPPLEMENTAL', 'Compliance Report Requested Supplemental'), ('NotificationType.EXCLUSION_REPORT_DRAFT', 'Exclusion Report Draft Saved'), ('NotificationType.EXCLUSION_REPORT_SUBMITTED', 'Exclusion Report Submitted'), ('NotificationType.EXCLUSION_REPORT_RECOMMENDED_FOR_ACCEPTANCE_ANALYST', 'Exclusion Report Recommended for Acceptance - Analyst'), ('NotificationType.EXCLUSION_REPORT_RECOMMENDED_FOR_REJECTION_ANALYST', 'Exclusion Report Recommended for Rejection - Analyst'), ('NotificationType.EXCLUSION_REPORT_RECOMMENDED_FOR_ACCEPTANCE_MANAGER', 'Exclusion Report Recommended for Acceptance - Manager'), ('NotificationType.EXCLUSION_REPORT_RECOMMENDED_FOR_REJECTION_MANAGER', 'Exclusion Report Recommended for Rejection - Manager'), ('NotificationType.EXCLUSION_REPORT_ACCEPTED', 'Exclusion Report Accepted'), ('NotificationType.EXCLUSION_REPORT_REJECTED', 'Exclusion Report Rejected'), ('NotificationType.EXCLUSION_REPORT_REQUESTED_SUPPLEMENTAL', 'Exclusion Report Requested Supplemental')], max_length=128),
),
]
6 changes: 6 additions & 0 deletions backend/api/models/ComplianceReportSchedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,12 @@ class ScheduleSummary(Commentable):
db_comment="Banked credits used to offset outstanding debits "
"- Supplemental Report"
)
credits_offset_c = models.IntegerField(
blank=True,
null=True,
db_comment="Banked credits spent that will be returned due to "
"debit decrease - Supplemental Report"
)

class Meta:
db_table = 'compliance_report_summary'
Expand Down
2 changes: 1 addition & 1 deletion backend/api/models/NotificationSubscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NotificationSubscription(Auditable):
db_comment="The user subscribing to notifications on this channel"
)
notification_type = models.CharField(
choices=[(d, d.value) for d in NotificationType],
choices=[(str(d), d.value) for d in NotificationType],
max_length=128,
null=False,
blank=False,
Expand Down
102 changes: 67 additions & 35 deletions backend/api/serializers/ComplianceReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,14 @@ def get_summary(self, obj):
lines['20'] = obj.summary.diesel_class_obligation \
if obj.summary.diesel_class_obligation is not None \
else Decimal(0)
lines['26'] = obj.summary.credits_offset \
lines['26'] = Decimal(obj.summary.credits_offset) \
if obj.summary.credits_offset is not None else Decimal(0)
lines['26A'] = obj.summary.credits_offset_a \
lines['26A'] = Decimal(obj.summary.credits_offset_a) \
if obj.summary.credits_offset_a is not None else Decimal(0)
lines['26B'] = obj.summary.credits_offset_b \
lines['26B'] = Decimal(obj.summary.credits_offset_b) \
if obj.summary.credits_offset_b is not None else Decimal(0)
lines['26C'] = Decimal(obj.summary.credits_offset_c) \
if obj.summary.credits_offset_c is not None else Decimal(0)
else:
lines['6'] = Decimal(0)
lines['7'] = Decimal(0)
Expand All @@ -554,6 +556,7 @@ def get_summary(self, obj):
lines['26'] = Decimal(0)
lines['26A'] = Decimal(0)
lines['26B'] = Decimal(0)
lines['26C'] = Decimal(0)

if obj.schedule_a:
net_gasoline_class_transferred += \
Expand Down Expand Up @@ -603,7 +606,22 @@ def get_summary(self, obj):
lines['23'] = total_credits
lines['24'] = total_debits
lines['25'] = lines['23'] - lines['24']
lines['27'] = lines['25'] + lines['26']

# if current_balance is positive it means the supplier
# has a positive amount of credits for this compliance period
# and there is no penalty, otherwise use current_balance
# to calculate penalty
current_balance = lines['25'] + lines['26']
if current_balance > 0:
lines['27'] = 0
else:
lines['27'] = current_balance

# 26C represents credits that need to be returned to the fuel supplier.
# Line 27 should end up being zero in this situation because
# 26C is the difference between lines 26A and 25 when 26A > 25
if lines['26C'] is not None and lines['26C'] > 0:
lines['27'] = 0 # eqv. to lines['25'] + lines['26A'] - lines['26C']

# Penalty adjustment made by business area for
# 2023 and above compliance periods
Expand Down Expand Up @@ -1021,20 +1039,20 @@ def validate_status(self, value):
def create(self, validated_data):
status_data = validated_data.pop('status')
status = ComplianceReportWorkflowState.objects.create(**status_data)
cr = ComplianceReport.objects.create(
new_compliance_report = ComplianceReport.objects.create(
status=status,
**validated_data)
if 'supplements' in validated_data and \
validated_data['supplements'] is not None:
# need to copy all the schedule entries
original_report = validated_data['supplements']
if original_report.schedule_a is not None:
previous_report = validated_data['supplements']
if previous_report.schedule_a is not None:
schedule_a = ScheduleA.objects.create()
cr.schedule_a = schedule_a
new_compliance_report.schedule_a = schedule_a
schedule_a.save()
cr.save()
new_compliance_report.save()
for original_record in \
original_report.schedule_a.records.all():
previous_report.schedule_a.records.all():
record = ScheduleARecord()
record.schedule = schedule_a
record.trading_partner = original_record.trading_partner
Expand All @@ -1044,13 +1062,13 @@ def create(self, validated_data):
record.transfer_type = original_record.transfer_type
record.save()

if original_report.schedule_b is not None:
if previous_report.schedule_b is not None:
schedule_b = ScheduleB.objects.create()
cr.schedule_b = schedule_b
new_compliance_report.schedule_b = schedule_b
schedule_b.save()
cr.save()
new_compliance_report.save()
for original_record in \
original_report.schedule_b.records.all():
previous_report.schedule_b.records.all():
record = ScheduleBRecord()
record.schedule = schedule_b
record.provision_of_the_act = \
Expand All @@ -1064,13 +1082,13 @@ def create(self, validated_data):
original_record.schedule_d_sheet_index
record.save()

if original_report.schedule_c is not None:
if previous_report.schedule_c is not None:
schedule_c = ScheduleC.objects.create()
cr.schedule_c = schedule_c
new_compliance_report.schedule_c = schedule_c
schedule_c.save()
cr.save()
new_compliance_report.save()
for original_record in \
original_report.schedule_c.records.all():
previous_report.schedule_c.records.all():
record = ScheduleCRecord()
record.schedule = schedule_c
record.quantity = original_record.quantity
Expand All @@ -1080,12 +1098,12 @@ def create(self, validated_data):
record.rationale = original_record.rationale
record.save()

if original_report.schedule_d is not None:
if previous_report.schedule_d is not None:
schedule_d = ScheduleD.objects.create()
cr.schedule_d = schedule_d
new_compliance_report.schedule_d = schedule_d
schedule_d.save()
cr.save()
for original_sheet in original_report.schedule_d.sheets.all():
new_compliance_report.save()
for original_sheet in previous_report.schedule_d.sheets.all():
sheet = ScheduleDSheet()
sheet.schedule = schedule_d
sheet.feedstock = original_sheet.feedstock
Expand All @@ -1109,11 +1127,11 @@ def create(self, validated_data):
output.description = original_output.description
output.save()

if original_report.summary is not None:
if previous_report.summary is not None:
summary = ScheduleSummary.objects.create()
cr.summary = summary
cr.save()
original_summary = original_report.summary
new_compliance_report.summary = summary
new_compliance_report.save()
original_summary = previous_report.summary
summary.gasoline_class_retained = \
original_summary.gasoline_class_retained
summary.gasoline_class_deferred = \
Expand All @@ -1131,11 +1149,25 @@ def create(self, validated_data):
original_summary.diesel_class_previously_retained
summary.diesel_class_obligation = \
original_summary.diesel_class_obligation
summary.credits_offset_a = original_summary.credits_offset_a or \
original_summary.credits_offset

if original_report.status.director_status_id == 'Rejected':
current = original_report

summary.credits_offset = original_summary.credits_offset
summary.credits_offset_a = original_summary.credits_offset or \
original_summary.credits_offset_a

credits_offset_c = original_summary.credits_offset_c
if credits_offset_c is not None and credits_offset_c > 0:
# If credit_offset_c exists on an accepted supplemental report,
# it means we gave back credits, so credit_offset_a
# needs to be offset by credits_offset_c to account for this
# otherwise these credits could be claimed again
if previous_report.status.director_status_id == 'Accepted':
summary.credits_offset_a = original_summary.credits_offset_a \
- credits_offset_c
else:
summary.credits_offset_a = original_summary.credits_offset_a

if previous_report.status.director_status_id == 'Rejected':
current = previous_report
accepted_found = False

while current.supplements is not None and not accepted_found:
Expand All @@ -1150,11 +1182,11 @@ def create(self, validated_data):

summary.save()

if original_report.exclusion_agreement is not None:
if previous_report.exclusion_agreement is not None:
exclusion_agreement = ExclusionAgreement.objects.create()
cr.exclusion_agreement = exclusion_agreement
new_compliance_report.exclusion_agreement = exclusion_agreement
exclusion_agreement.save()
for original_record in original_report.exclusion_agreement.records.all():
for original_record in previous_report.exclusion_agreement.records.all():
record = ExclusionAgreementRecord()
record.exclusion_agreement = exclusion_agreement
record.transaction_partner = \
Expand All @@ -1167,7 +1199,7 @@ def create(self, validated_data):
record.transaction_type = original_record.transaction_type
record.save()

return cr
return new_compliance_report

def save(self, **kwargs):
super().save(**kwargs)
Expand Down
3 changes: 2 additions & 1 deletion backend/api/serializers/ComplianceReportSchedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,6 @@ class Meta:
'diesel_class_obligation', 'diesel_class_previously_retained',
'gasoline_class_retained', 'gasoline_class_deferred',
'gasoline_class_obligation', 'gasoline_class_previously_retained',
'credits_offset', 'credits_offset_a', 'credits_offset_b'
'credits_offset', 'credits_offset_a', 'credits_offset_b',
'credits_offset_c'
)
Loading

0 comments on commit b3f0a9c

Please sign in to comment.