Skip to content

Commit

Permalink
Tracking pull request to merge release-1.54.0 to master (#2027)
Browse files Browse the repository at this point in the history
* update release number

* updat epr number

* feat: zeva-1286 - attach documents to credit application (#2017)

* feat: zeva-1286 - attach documents to credit application

* fix code smells

* props validation

* fix unit tests

* fix: zeva-1833 - vehicle supplier navigation tabs (#2021)

* Feat: Active ZEV Models Default Filter #1356 (#2029)

* Modifying the filtering on the zev models list page to default to only active models

* Removing unneeded code

* Removed extra filter reset

* Added delete button to the rejected zev model page so it can be deleted (#2030)

* fix: removes print button from the actual printed page (#2031)

* chore: updates developer guide and import data for some changes to reflect change to crunchy  and dev instead of test, and note about fixing local database lock (#2032)

* feat: zeva-1942 - editable comments (#2034)

* Added logic to show deleted zev models to government users (#2038)

* fix: zeva-2022 - MY report summary rounding issues (#2037)

* fix: zeva-2007 - consumer sales not appearing (#2036)

* Feat: Returned Model Year Report Information #1276 (#2028)

* Adding display field to some report tables to allow reports to be returned, not show analyst adjustments and soft retain information

* Altering functionality

* Adding logic to not display assessment comments if a report is returned then re-submitted

* Removing some migrations to fix unit tests

* feat: zeva-2015 - credit application error downloads (#2039)

* fix: zeva-2040 - validated vins in credit application downloads (#2041)

* fix: adds submission message variable that creates a statement for the submission date and user (#2042)

-adds variable to the end of recommended and validated transactions

* fix: zeva-1942 - disable editing of comments upon rejection (#2047)

* feat: zeva-1875 - deficits - build-on-dev (#1958)

* feat: zeva-1875 - deficits

* fixes and changes

* some cleanup

* more fixes and changes

* fiz: zeva-2043 - credit transactions incorrect multiples (#2044)

---------

Co-authored-by: tim738745 <[email protected]>
Co-authored-by: JulianForeman <[email protected]>
Co-authored-by: Emily <[email protected]>
  • Loading branch information
4 people authored Nov 9, 2023
1 parent df327cd commit 024208d
Show file tree
Hide file tree
Showing 63 changed files with 907 additions and 227 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/dev-build.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## For each release, please update the value of workflow name, branches and PR_NUMBER
## Also update frontend/package.json version

name: Dev Build 1.53.0
name: Dev Build 1.54.0

on:
push:
branches: [ release-1.53.0 ]
branches: [ release-1.54.0 ]
paths:
- frontend/**
- backend/**
Expand All @@ -14,8 +14,8 @@ on:

env:
## The pull request number of the Tracking pull request to merge the release branch to main
PR_NUMBER: 1976
VERSION: 1.53.0
PR_NUMBER: 2027
VERSION: 1.54.0
GIT_URL: https://github.com/bcgov/zeva.git
TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
Expand All @@ -32,7 +32,7 @@ jobs:
call-unit-test:
uses: ./.github/workflows/unit-test-template.yaml
with:
pr-number: 1976
pr-number: 2027

build:

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-build.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## For each release, please update the value of workflow name, branches and PR_NUMBER
## Also update frontend/package.json version

name: Release Build 1.53.0
name: Release Build 1.54.0

on:
workflow_dispatch:
workflow_call:

env:
## The pull request number of the Tracking pull request to merge the release branch to main
PR_NUMBER: 1976
VERSION: 1.53.0
PR_NUMBER: 2027
VERSION: 1.54.0
GIT_URL: https://github.com/bcgov/zeva.git
TOOLS_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools
DEV_NAMESPACE: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-dev
Expand All @@ -27,7 +27,7 @@ jobs:
call-unit-test:
uses: ./.github/workflows/unit-test-template.yaml
with:
pr-number: 1976
pr-number: 2027

build:

Expand Down
34 changes: 34 additions & 0 deletions backend/api/migrations/0004_auto_20231024_0908.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.20 on 2023-10-24 16:08

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


class Migration(migrations.Migration):

dependencies = [
('api', '0003_auto_20230918_1445'),
]

operations = [
migrations.AddField(
model_name='modelyearreportassessment',
name='display',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='modelyearreportassessmentcomment',
name='display',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='modelyearreportldvsales',
name='display',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='modelyearreportmake',
name='display',
field=models.BooleanField(default=True),
)
]
3 changes: 2 additions & 1 deletion backend/api/models/model_year_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def get_credit_reductions(self):
model_year_report_id=self.id,
category__in=[
'ClassAReduction', 'UnspecifiedClassCreditReduction',
'CreditDeficit', 'ProvisionalBalanceAfterCreditReduction'
'CreditDeficit', 'ProvisionalBalanceAfterCreditReduction',
'ReductionsToOffsetDeficit'
]
)

Expand Down
4 changes: 4 additions & 0 deletions backend/api/models/model_year_report_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class ModelYearReportAssessment(Auditable):
decimal_places=2,
db_comment='amount of administrative penalty'
)
display = models.BooleanField(
default=True,
db_comment="field to determine if we should display this info"
)

class Meta:
db_table = 'model_year_report_assessment'
Expand Down
4 changes: 4 additions & 0 deletions backend/api/models/model_year_report_assessment_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class ModelYearReportAssessmentComment(Auditable):
db_column='assessment_comment',
db_comment="Comment left by idir about model year report"
)
display = models.BooleanField(
default=True,
db_comment="field to determine if we should display this info"
)

class Meta:
db_table = 'model_year_report_assessment_comment'
Expand Down
4 changes: 4 additions & 0 deletions backend/api/models/model_year_report_ldv_sales.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ModelYearReportLDVSales(Auditable):
default=False,
db_comment="Flag. True if this edit came from a government user."
)
display = models.BooleanField(
default=True,
db_comment="field to determine if we should display this info"
)

class Meta:
db_table = "model_year_report_ldv_sales"
Expand Down
4 changes: 4 additions & 0 deletions backend/api/models/model_year_report_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ModelYearReportMake(Auditable):
default=False,
db_comment="Flag. True if this edit came from a government user."
)
display = models.BooleanField(
default=True,
db_comment="field to determine if we should display this info"
)

class Meta:
db_table = 'model_year_report_make'
Expand Down
2 changes: 1 addition & 1 deletion backend/api/serializers/credit_agreement_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_create_user(self, obj):
class Meta:
model = CreditAgreementComment
fields = (
'id', 'comment', 'create_timestamp', 'create_user', 'to_director'
'id', 'comment', 'create_timestamp', 'update_timestamp', 'create_user', 'to_director'
)
read_only_fields = (
'id',
Expand Down
2 changes: 1 addition & 1 deletion backend/api/serializers/credit_transfer_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get_create_user(self, obj):
class Meta:
model = CreditTransferComment
fields = (
'id', 'comment', 'create_timestamp', 'create_user',
'id', 'comment', 'create_timestamp', 'update_timestamp', 'create_user',
)
read_only_fields = (
'id',
Expand Down
4 changes: 2 additions & 2 deletions backend/api/serializers/model_year_report_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def get_assessment(self, obj):
def get_assessment_comment(self, obj):
request = self.context.get('request')
assessment_comment = ModelYearReportAssessmentComment.objects.filter(
model_year_report=obj

model_year_report=obj,
display=True
).order_by('-create_timestamp')
if not request.user.is_government:
assessment_comment = ModelYearReportAssessmentComment.objects.filter(
Expand Down
2 changes: 1 addition & 1 deletion backend/api/serializers/model_year_report_ldv_sales.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ class ModelYearReportLDVSalesSerializer(ModelSerializer):
class Meta:
model = ModelYearReportLDVSales
fields = (
'id', 'ldv_sales', 'model_year',
'id', 'ldv_sales', 'model_year'
)
4 changes: 2 additions & 2 deletions backend/api/serializers/vehicle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from enumfields.drf import EnumField, EnumSupportSerializerMixin
from rest_framework.serializers import ModelSerializer, \
SerializerMethodField, SlugRelatedField, ValidationError
Expand Down Expand Up @@ -475,11 +476,10 @@ def get_pending_sales(self, instance):
return SalesSubmissionContent.objects.filter(
xls_make__iexact=instance.make,
xls_model__iexact=instance.model_name,
xls_model_year=str(instance.model_year.name) + '.0',
submission__validation_status__in=[
"SUBMITTED", "RECOMMEND_APPROVAL", "RECOMMEND_REJECTION", "CHECKED",
]
).count()
).filter(Q(xls_model_year=str(instance.model_year.name) + '.0') | Q(xls_model_year=str(instance.model_year.name))).count()

def get_sales_issued(self, instance):
return RecordOfSale.objects.filter(
Expand Down
9 changes: 9 additions & 0 deletions backend/api/services/credit_agreement_comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from api.models.credit_agreement_comment import CreditAgreementComment


def get_comment(comment_id):
return CreditAgreementComment.objects.filter(id=comment_id).first()


def delete_comment(comment_id):
CreditAgreementComment.objects.filter(id=comment_id).delete()
9 changes: 9 additions & 0 deletions backend/api/services/credit_transfer_comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from api.models.credit_transfer_comment import CreditTransferComment


def get_comment(comment_id):
return CreditTransferComment.objects.filter(id=comment_id).first()


def delete_comment(comment_id):
CreditTransferComment.objects.filter(id=comment_id).delete()
2 changes: 1 addition & 1 deletion backend/api/services/model_year_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def adjust_credits(id, request):
# overrides
reductions = ModelYearReportComplianceObligation.objects.filter(
model_year_report_id=id,
category__in=['ClassAReduction', 'UnspecifiedClassCreditReduction'],
category__in=['ClassAReduction', 'UnspecifiedClassCreditReduction', 'ReductionsToOffsetDeficit'],
from_gov=from_gov,
).order_by('model_year__name', 'update_timestamp')

Expand Down
21 changes: 16 additions & 5 deletions backend/api/services/sales_spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from api.models.vehicle import Vehicle
from api.models.icbc_snapshot_data import IcbcSnapshotData
from api.models.record_of_sale_statuses import RecordOfSaleStatuses
from api.models.vehicle_statuses import VehicleDefinitionStatuses
from api.services.sales_submission import get_vehicle_structures, get_map_of_sales_submission_content_ids_to_vehicles, get_map_of_vins_to_records_of_sales

logger = logging.getLogger('zeva.sales_spreadsheet')

Expand Down Expand Up @@ -374,7 +376,7 @@ def validate_spreadsheet(data, user_organization=None, skip_authorization=False)


def get_error(content):
warnings = content.warnings
warnings = content.warnings_list.split(",") if content.warnings_list is not None else []
error = ''
if 'ROW_NOT_SELECTED' in warnings and content.reason:
error += content.reason
Expand Down Expand Up @@ -407,6 +409,9 @@ def get_error(content):

if 'ROW_NOT_SELECTED' in warnings and error == '':
error += 'VIN not registered in BC; '

if 'WRONG_MODEL_YEAR' in warnings:
error += 'Wrong model year to be issued with compliance report; '
return error


Expand Down Expand Up @@ -503,7 +508,7 @@ def create_errors_spreadsheet(submission_id, organization_id, stream):
current_vehicle_col_width = 13

for content in submission_content:
if len(content.warnings) == 0:
if content.warnings_list is None:
next()

row += 1
Expand Down Expand Up @@ -593,11 +598,17 @@ def create_details_spreadsheet(submission_id, stream):

current_vehicle_col_width = 13
icbc_match = False
vehicle_structures = get_vehicle_structures(sales_submission, VehicleDefinitionStatuses.VALIDATED)
map_of_sales_submission_content_ids_to_vehicles = get_map_of_sales_submission_content_ids_to_vehicles(submission_content, vehicle_structures)
map_of_vins_to_records_of_sales = get_map_of_vins_to_records_of_sales(submission_content)
for content in submission_content:
validated = 'No'
if content.record_of_sale:
if content.record_of_sale.validation_status == RecordOfSaleStatuses.VALIDATED:
validated = 'Yes'
records_of_sales = map_of_vins_to_records_of_sales.get(content.xls_vin)
if records_of_sales is not None:
for record_of_sale in records_of_sales:
if record_of_sale.validation_status == RecordOfSaleStatuses.VALIDATED and record_of_sale.submission == sales_submission and record_of_sale.vehicle == map_of_sales_submission_content_ids_to_vehicles.get(content.id):
validated = 'Yes'
break
try:
icbc_record = icbc_data.get(vin=content.xls_vin)
icbc_match = True
Expand Down
4 changes: 2 additions & 2 deletions backend/api/services/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ def vehicles_sales(model_year, organization):
).filter(
Q(Q(
Q(xls_sale_date__lte=sales_to_date) &
Q(xls_model_year=str(report_year) + ".0") &
(Q(xls_model_year=str(report_year) + ".0") | Q(xls_model_year=str(report_year))) &
Q(xls_date_type="3") &
~Q(xls_sale_date="")
) |
Q(
Q(xls_sale_date__lte=to_date_str) &
Q(xls_model_year=str(report_year) + ".0") &
(Q(xls_model_year=str(report_year) + ".0") | Q(xls_model_year=str(report_year))) &
Q(xls_date_type="1") &
~Q(xls_sale_date="")
)
Expand Down
4 changes: 4 additions & 0 deletions backend/api/utilities/comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def update_comment_text(comment, comment_text):
comment.comment = comment_text
comment.save(update_fields=["comment", "update_timestamp"])
return comment
26 changes: 26 additions & 0 deletions backend/api/viewsets/credit_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from rest_framework import mixins, viewsets, permissions
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework import status

from api.models.credit_agreement import CreditAgreement
from api.models.credit_agreement_transaction_types import \
Expand All @@ -23,6 +24,9 @@
from api.services.send_email import notifications_credit_agreement
from api.models.model_year_report import ModelYearReport
from api.serializers.model_year_report import ModelYearReportSerializer, ModelYearReportsSerializer
from api.serializers.credit_agreement_comment import CreditAgreementCommentSerializer
from api.services.credit_agreement_comment import get_comment, delete_comment
from api.utilities.comment import update_comment_text


class CreditAgreementViewSet(
Expand Down Expand Up @@ -134,3 +138,25 @@ def list(self, request):

serializer = self.get_serializer(credit_agreements, many=True)
return Response(serializer.data)

@action(detail=True, methods=["PATCH"])
def update_comment(self, request, pk):
comment_id = request.data.get("comment_id")
comment_text = request.data.get("comment_text")
username = request.user.username
comment = get_comment(comment_id)
if username == comment.create_user:
updated_comment = update_comment_text(comment, comment_text)
serializer = CreditAgreementCommentSerializer(updated_comment)
return Response(serializer.data)
return Response(status=status.HTTP_403_FORBIDDEN)

@action(detail=True, methods=["PATCH"])
def delete_comment(self, request, pk):
comment_id = request.data.get("comment_id")
username = request.user.username
comment = get_comment(comment_id)
if username == comment.create_user:
delete_comment(comment_id)
return Response(status=status.HTTP_200_OK)
return Response(status=status.HTTP_403_FORBIDDEN)
Loading

0 comments on commit 024208d

Please sign in to comment.