Skip to content

Commit

Permalink
Tracking pull request to merge release-1.59.0 to master (#2153)
Browse files Browse the repository at this point in the history
* initial changes for 1.59.0

* update pr number

* fix: 2145 - compliance calculator rounding (#2154)

* Cleanup job (#2164)

* remove used apps (#2165)

* chore: 2156 - snapshot compliance ratio reductions (#2162)

* fix: adds effective/expiration date to model year object creation so those new years can be included in the ingest_sales_spreadsheet script (#2167)

* fix: zeva 2161 - Error When Attempting to Resubmit Deleted Rejected ZEV Models (#2169)

* fix: allows deleted vehicles to be resubmitted as drafts

* fix: adds missing model

* Tests for Dashboard Container (#2170)

* Bump gunicorn from 20.0.4 to 22.0.0 in /backend (#2159)

Bumps [gunicorn](https://github.com/benoitc/gunicorn) from 20.0.4 to 22.0.0.
- [Release notes](https://github.com/benoitc/gunicorn/releases)
- [Commits](benoitc/gunicorn@20.0.4...22.0.0)

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

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump idna from 2.8 to 3.7 in /backend (#2157)

Bumps [idna](https://github.com/kjd/idna) from 2.8 to 3.7.
- [Release notes](https://github.com/kjd/idna/releases)
- [Changelog](https://github.com/kjd/idna/blob/master/HISTORY.rst)
- [Commits](kjd/idna@v2.8...v3.7)

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

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: julianforeman <[email protected]>

* Bump sqlparse from 0.4.4 to 0.5.0 in /backend (#2158)

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

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

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* --- (#2173)

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

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: 2172 - supplementary report credits fix (#2174)

* Bump django from 3.2.20 to 3.2.25 in /backend (#2152)

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

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

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* give up artifactory (#2175)

* pull from docker directly

* Bump cryptography from 3.4.7 to 42.0.4 in /backend (#2151)

Bumps [cryptography](https://github.com/pyca/cryptography) from 3.4.7 to 42.0.4.
- [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst)
- [Commits](pyca/cryptography@3.4.7...42.0.4)

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

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: julianforeman <[email protected]>

* update cleanup cron

* update setup node version

* fix: 2178 - supp report ldv sales value + error upon issuance (#2179)

* fix: 2185 - supplemental report rounding (#2187)

* fix: 2185 - supplementary report rounding

* associated changes

* a fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: tim738745 <[email protected]>
Co-authored-by: Emily <[email protected]>
Co-authored-by: JulianForeman <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: julianforeman <[email protected]>
  • Loading branch information
6 people authored Jun 18, 2024
1 parent c708259 commit d5db7e5
Show file tree
Hide file tree
Showing 58 changed files with 624 additions and 1,953 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.58.0
name: Dev Build 1.59.0

on:
push:
branches: [ release-1.58.0 ]
branches: [ release-1.59.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: 2118
VERSION: 1.58.0
PR_NUMBER: 2153
VERSION: 1.59.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: 2118
pr-number: 2153

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.58.0
name: Release Build 1.59.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: 2118
VERSION: 1.58.0
PR_NUMBER: 2153
VERSION: 1.59.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: 2118
pr-number: 2153

build:

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/unit-test-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: refs/pull/${{ inputs.pr-number }}/head

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16.20.0
node-version: 20

- name: Frontend Jest coverage report
uses: ArtiomTr/[email protected]
Expand All @@ -44,7 +44,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: refs/pull/${{ inputs.pr-number }}/head

Expand Down
3 changes: 2 additions & 1 deletion backend/.s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ elif [[ -f requirements.txt ]]; then
pip install -r requirements.txt
else
echo "---> Installing dependencies from artifactory ..."
pip install -i https://$ARTIFACTORY_USER:$ARTIFACTORY_PASSWORD@artifacts.developer.gov.bc.ca/artifactory/api/pypi/pypi-remote/simple -r requirements.txt
# pip install -i https://$ARTIFACTORY_USER:[email protected]/artifactory/api/pypi/pypi-remote/simple -r requirements.txt
pip install -r requirements.txt
fi
fi

Expand Down
18 changes: 18 additions & 0 deletions backend/api/migrations/0005_auto_20240425_0941.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.18 on 2024-04-25 16:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0004_auto_20231024_0908'),
]

operations = [
migrations.AddField(
model_name='modelyearreportcomplianceobligation',
name='reduction_value',
field=models.DecimalField(blank=True, decimal_places=2, max_digits=20, null=True),
)
]
22 changes: 22 additions & 0 deletions backend/api/migrations/0006_auto_20240508_1553.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2.20 on 2024-05-08 22:53

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


class Migration(migrations.Migration):

dependencies = [
('api', '0005_auto_20240425_0941'),
]

operations = [
migrations.AlterUniqueTogether(
name='vehicle',
unique_together=set(),
),
migrations.AddConstraint(
model_name='vehicle',
constraint=models.UniqueConstraint(condition=models.Q(('validation_status', 'DELETED'), _negated=True), fields=('make', 'model_name', 'vehicle_zev_type', 'model_year'), name='unique_non_deleted_vehicles'),
),
]
7 changes: 7 additions & 0 deletions backend/api/models/model_year_report_compliance_obligation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class ModelYearReportComplianceObligation(Auditable):
decimal_places=2,
db_comment='Value of credit B'
)
reduction_value = models.DecimalField(
max_digits=20,
decimal_places=2,
db_comment='Reduction value',
blank=True,
null=True,
)
category = models.CharField(
blank=True,
max_length=100,
Expand Down
16 changes: 9 additions & 7 deletions backend/api/models/vehicle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.db import models
from enumfields import EnumField

from django.db.models import Q
from auditable.models import Auditable
from .vehicle_statuses import VehicleDefinitionStatuses

Expand Down Expand Up @@ -133,11 +133,13 @@ def get_credit_value(self):

return round(credit, 2)

class Meta:
db_table = 'vehicle'
unique_together = [[
'make', 'model_name', 'vehicle_zev_type',
'model_year'
]]
class Meta:
db_table = "vehicle"
constraints = [
models.UniqueConstraint(
fields=["make", "model_name", "vehicle_zev_type", "model_year"],
condition=~Q(validation_status="DELETED"),
name="unique_non_deleted_vehicles",
)]

db_table_comment = "List of credit-generating vehicle definitions"
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ModelYearReportComplianceObligationSnapshotSerializer(serializers.ModelSer
class Meta:
model = ModelYearReportComplianceObligation
fields = (
'credit_a_value', 'credit_b_value',
'credit_a_value', 'credit_b_value', 'reduction_value',
'category', 'model_year', 'update_timestamp',
)

Expand Down
10 changes: 8 additions & 2 deletions backend/api/services/icbc_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import math
import time
from django.db import transaction

from datetime import datetime
from dateutil.relativedelta import relativedelta
from api.models.icbc_registration_data import IcbcRegistrationData
from api.models.icbc_vehicle import IcbcVehicle
from api.models.model_year import ModelYear
Expand Down Expand Up @@ -131,12 +132,17 @@ def ingest_icbc_spreadsheet(excelfile, requesting_user, dateCurrentTo, previous_
# print("unique_vins", unique_vins.shape[0])

model_years = []

for unique_model_year in unique_model_years:
eff_date = datetime.strptime(str(unique_model_year), '%Y')
exp_date = eff_date + relativedelta(years=1) - relativedelta(days=1)
(model_year, _) = ModelYear.objects.get_or_create(
name=unique_model_year,
defaults={
'create_user': requesting_user.username,
'update_user': requesting_user.username
'update_user': requesting_user.username,
'effective_date': eff_date,
'expiration_date': exp_date
})
model_years.append(model_year)

Expand Down
2 changes: 1 addition & 1 deletion backend/api/services/model_year_report_ldv_sales.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def get_most_recent_ldv_sales(model_year_report):
ModelYearReportLDVSales.objects.filter(
model_year=model_year_report.model_year, model_year_report=model_year_report
)
.order_by("-create_timestamp")
.order_by("-update_timestamp")
.only("ldv_sales")
.first()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ def update_obligation(self, request):
model_year = ModelYear.objects.get(name=each['year'])
credit_a_value = each['a']
credit_b_value = each['b']
reduction_value = each.get('reduction_value')
compliance_obj = ModelYearReportComplianceObligation.objects.create(
model_year_report_id=id,
model_year=model_year,
category=category,
credit_a_value=credit_a_value,
credit_b_value=credit_b_value,
reduction_value=reduction_value,
from_gov=True
)
compliance_obj.save()
Expand Down Expand Up @@ -196,8 +198,9 @@ def details(self, request, *args, **kwargs):
report.validation_status == ModelYearReportStatuses.ASSESSED) or
request.user.is_government
)
use_from_gov_snapshot = request.GET.get('use_from_gov_snapshot') == 'True'

if is_assessment:
if is_assessment or use_from_gov_snapshot:
organization = report.organization
snapshot_from_gov = ModelYearReportComplianceObligation.objects.filter(
from_gov=True,
Expand Down
12 changes: 6 additions & 6 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ cffi
chardet==3.0.4
configparser==5.0.0
coverage==5.0.3
cryptography==3.4.7
Django==3.2.20
cryptography==42.0.4
Django==3.2.25
django-celery-beat==1.5.0
django-cors-headers==3.2.1
django-enumfields==2.1.1
django-filter==2.4.0
django-timezone-field==4.0
djangorestframework==3.12.4
djangorestframework-camel-case==1.1.2
gunicorn==20.0.4
idna==2.8
idna==3.7
gunicorn==22.0.0
importlib-metadata==1.5.0
isort==4.3.21
kombu==4.6.7
Expand All @@ -41,9 +41,9 @@ python-dateutil==2.8.1
python-dotenv==0.10.5
python-magic==0.4.18
pytz==2022.2.1
requests==2.31.0
requests==2.32.0
six==1.13.0
sqlparse==0.4.4
sqlparse==0.5.0
typed-ast
urllib3==1.25.11
vine==1.3.0
Expand Down
6 changes: 4 additions & 2 deletions frontend/Dockerfile-Openshift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Stage 1: Use yarn to build the app
FROM artifacts.developer.gov.bc.ca/docker-remote/node:16.20.0 as builder
# FROM artifacts.developer.gov.bc.ca/docker-remote/node:16.20.0 as builder
FROM node:16.20.0 as builder
WORKDIR /usr/src/app
COPY ./ ./
RUN npm install -g [email protected] \
Expand All @@ -8,7 +9,8 @@ RUN npm install -g [email protected] \
RUN yes | npm run dist

# Stage 2: Copy the JS React SPA into the Nginx HTML directory
FROM artifacts.developer.gov.bc.ca/docker-remote/bitnami/nginx:1.21.6
# FROM artifacts.developer.gov.bc.ca/docker-remote/bitnami/nginx:1.21.6
FROM bitnami/nginx:1.21.6
COPY ./nginx.conf /opt/bitnami/nginx/conf/
COPY --from=builder /usr/src/app/public/build /app
EXPOSE 8080
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zeva-frontend",
"version": "1.58.0",
"version": "1.59.0",
"private": true,
"dependencies": {
"@babel/eslint-parser": "^7.19.1",
Expand Down
23 changes: 13 additions & 10 deletions frontend/src/app/utilities/constructReassessmentReductions.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,49 @@
import Big from "big.js"

const constructReassessmentReductions = (reductions, prevReductions) => {
const result = {
reductionsToUpdate: [],
reductionsToAdd: []
}
const bigZero = new Big(0)
const potentialReductionsToAdd = []
if (reductions && prevReductions) {
for (const reduction of reductions) {
let foundCorrespondingPrevReduction = false
for (const prevReduction of prevReductions) {
if (reduction.type === prevReduction.type && reduction.modelYear === prevReduction.modelYear) {
if (reduction.creditA !== prevReduction.creditA) {
if (!(reduction.creditA.eq(prevReduction.creditA))) {
potentialReductionsToAdd.push({
creditClass: 'A',
modelYear: reduction.modelYear,
oldValue: prevReduction.creditA,
newValue: reduction.creditA
oldValue: prevReduction.creditA.toNumber(),
newValue: reduction.creditA.toNumber()
})
}
if (reduction.creditB !== prevReduction.creditB) {
if (!(reduction.creditB.eq(prevReduction.creditB))) {
potentialReductionsToAdd.push({
creditClass: 'B',
modelYear: reduction.modelYear,
oldValue: prevReduction.creditB,
newValue: reduction.creditB
oldValue: prevReduction.creditB.toNumber(),
newValue: reduction.creditB.toNumber()
})
}
foundCorrespondingPrevReduction = true
}
}
if (!foundCorrespondingPrevReduction) {
if (reduction.creditA) {
if (!(reduction.creditA.eq(bigZero))) {
result.reductionsToAdd.push({
creditClass: 'A',
modelYear: reduction.modelYear,
value: reduction.creditA
value: reduction.creditA.toNumber()
})
}
if (reduction.creditB) {
if (!(reduction.creditB.eq(bigZero))) {
result.reductionsToAdd.push({
creditClass: 'B',
modelYear: reduction.modelYear,
value: reduction.creditB
value: reduction.creditB.toNumber()
})
}
}
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/app/utilities/getSnapshottedReductions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Big from 'big.js'

const getSnapshottedComplianceRatioReductions = (complianceResponseDetails) => {
const result = {}
const reductionValueCategories = ['complianceRatioTotalReduction', 'complianceRatioClassAReduction', 'complianceRatioUnspecifiedReduction']
complianceResponseDetails.forEach((item) => {
const category = item.category
const reductionValue = item.reductionValue
if (reductionValue !== undefined && reductionValue !== null && reductionValueCategories.indexOf(category) > -1) {
result[category] = new Big(reductionValue)
}
})
return result
}

export default getSnapshottedComplianceRatioReductions
Loading

0 comments on commit d5db7e5

Please sign in to comment.