From cf3faf3b715251dc7b5edf2918e6005f82034eec Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Tue, 11 Jun 2024 12:05:30 -0700 Subject: [PATCH 1/7] initial updates 2.20.0 --- .github/workflows/dev-release.yaml | 6 +++--- .github/workflows/tfrs-release.yaml | 4 ++-- .pipeline/lib/config.js | 4 ++-- frontend/package.json | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dev-release.yaml b/.github/workflows/dev-release.yaml index 123cc43bf..17232775a 100644 --- a/.github/workflows/dev-release.yaml +++ b/.github/workflows/dev-release.yaml @@ -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 Dev release-2.19.0 +name: TFRS Dev release-2.20.0 on: push: - branches: [ release-2.19.0 ] + branches: [ release-2.20.0 ] paths: - frontend/** - backend/** @@ -16,7 +16,7 @@ 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: 2885 - RELEASE_NAME: release-2.19.0 + RELEASE_NAME: release-2.20.0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/tfrs-release.yaml b/.github/workflows/tfrs-release.yaml index 71c666580..a1ff9dcf7 100644 --- a/.github/workflows/tfrs-release.yaml +++ b/.github/workflows/tfrs-release.yaml @@ -1,7 +1,7 @@ ## 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.19.0 +name: TFRS release-2.20.0 on: workflow_dispatch: @@ -11,7 +11,7 @@ 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: 2885 - RELEASE_NAME: release-2.19.0 + RELEASE_NAME: release-2.20.0 concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.pipeline/lib/config.js b/.pipeline/lib/config.js index e2d91f9b5..9761549db 100644 --- a/.pipeline/lib/config.js +++ b/.pipeline/lib/config.js @@ -1,7 +1,7 @@ 'use strict'; const options= require('@bcgov/pipeline-cli').Util.parseArguments() const changeId = options.pr //aka pull-request -const version = '2.19.0' +const version = '2.20.0' const name = 'tfrs' const ocpName = 'apps.silver.devops' @@ -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.19.0' + releaseBranch: 'release-2.20.0' }, dev: {namespace:'0ab226-dev' , name: `${name}`, phase: 'dev' , changeId:changeId, suffix: `-dev` , instance: `${name}-dev` , version:`${version}`, tag:`dev-${version}`, dbServiceName: 'tfrs-spilo', diff --git a/frontend/package.json b/frontend/package.json index 24119d4c8..74b8885a5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "tfrs", - "version": "2.18.0", + "version": "2.20.0", "dependencies": { "@babel/eslint-parser": "^7.19.1", "@babel/plugin-proposal-object-rest-spread": "^7.20.7", From 486c50e8bf5c6f1c6b523164c4e39d98978e5d8f Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Tue, 11 Jun 2024 12:06:51 -0700 Subject: [PATCH 2/7] update pr number --- .github/workflows/dev-release.yaml | 2 +- .github/workflows/tfrs-release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-release.yaml b/.github/workflows/dev-release.yaml index 17232775a..e0779594c 100644 --- a/.github/workflows/dev-release.yaml +++ b/.github/workflows/dev-release.yaml @@ -15,7 +15,7 @@ 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: 2885 + PR_NUMBER: 2894 RELEASE_NAME: release-2.20.0 concurrency: diff --git a/.github/workflows/tfrs-release.yaml b/.github/workflows/tfrs-release.yaml index a1ff9dcf7..dec15e4ea 100644 --- a/.github/workflows/tfrs-release.yaml +++ b/.github/workflows/tfrs-release.yaml @@ -10,7 +10,7 @@ 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: 2885 + PR_NUMBER: 2894 RELEASE_NAME: release-2.20.0 concurrency: From a787ad6c94648e5d78573d95986fbcf086ef3982 Mon Sep 17 00:00:00 2001 From: Alex Zorkin <47334977+AlexZorkin@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:55:03 -0700 Subject: [PATCH 3/7] fix: fix for total previous credit reductions (#2902) Co-authored-by: Your Name --- backend/api/serializers/ComplianceReport.py | 81 +++++++------------ .../test_compliance_supplemental_reporting.py | 73 +++++++++++++++++ backend/requirements.txt | 2 +- 3 files changed, 102 insertions(+), 54 deletions(-) diff --git a/backend/api/serializers/ComplianceReport.py b/backend/api/serializers/ComplianceReport.py index 93c459fea..5b7f58741 100644 --- a/backend/api/serializers/ComplianceReport.py +++ b/backend/api/serializers/ComplianceReport.py @@ -89,62 +89,21 @@ def get_previous_report_was_credit(self, obj): def get_total_previous_credit_reductions(self, obj): # Return the total number of credits for all previous reductions for # supplemental reports - # previous_transactions = [] - submitted_reports = [] + previous_transactions = [] current = obj - submitted_reports_end = False - rejected_found = False - total_previous_reduction = Decimal(0.0) - # this is an attempt to simplify the process of calculation previous - # credit reductions - # If the last supplemental report was submitted we can just use the - # credit offset there as our previous reduction (which is credit offset A) - if current.supplements and current.supplements.status and \ - current.supplements.status.fuel_supplier_status_id in [ - "Submitted" - ] and current.supplements.status.director_status_id in [ - "Unreviewed" - ]: - total_previous_reduction = current.supplements.summary.credits_offset - submitted_reports_end = True - - while current.supplements is not None and not submitted_reports_end: + while current.supplements is not None: current = current.supplements - if current.status.director_status_id in [ - "Rejected" - ]: - rejected_found = True + if current.credit_transaction is not None and \ + current.status.director_status_id == "Accepted": + previous_transactions.append(current.credit_transaction) - if current.status.director_status_id in [ - "Accepted" - ]: - submitted_reports_end = True - - # if current.credit_transaction is not None and \ - # current.status.director_status_id not in ["Rejected"]: - # previous_transactions.append(current.credit_transaction) - if current.status.fuel_supplier_status_id == "Submitted" and \ - not submitted_reports_end and \ - not rejected_found: - submitted_reports.append(current) - - if rejected_found and submitted_reports_end and current.summary: - # Clear the submitted reports and we only care about the - # last accepted one - total_previous_reduction = current.summary.credits_offset - - # for transaction in previous_transactions: - # if transaction.type.the_type in ['Credit Reduction']: - # total_previous_reduction += transaction.number_of_credits - # elif transaction.type.the_type in ['Credit Validation']: - # total_previous_reduction -= transaction.number_of_credits - - if not rejected_found: - for report in submitted_reports: - if report.summary and report.summary.credits_offset_b: - total_previous_reduction += report.summary.credits_offset_b + for transaction in previous_transactions: + if transaction.type.the_type == 'Credit Reduction': + total_previous_reduction += transaction.number_of_credits + elif transaction.type.the_type == 'Credit Validation': + total_previous_reduction -= transaction.number_of_credits return total_previous_reduction @@ -1123,8 +1082,24 @@ def create(self, validated_data): original_summary.diesel_class_obligation summary.credits_offset = original_summary.credits_offset - summary.credits_offset_a = original_summary.credits_offset or \ - original_summary.credits_offset_a + + # Calculate the total credits offset from all previous ACCEPTED reports + # This is necessary because credits_offset_a should represent the cumulative + # credit reductions from all accepted previous reports, not just the most recent one. + # We iterate through all previous reports (supplements) and sum up their credit offsets, + # but only if the report was accepted by the director. + total_accepted_reductions = 0 + current = previous_report + + while current is not None: + if current.status.director_status_id == 'Accepted' and current.summary: + if current.summary.credits_offset > 0: + total_accepted_reductions += current.summary.credits_offset + elif current.summary.credits_offset_b > 0: + total_accepted_reductions += current.summary.credits_offset_b + current = current.supplements + + summary.credits_offset_a = total_accepted_reductions credits_offset_c = original_summary.credits_offset_c if credits_offset_c is not None and credits_offset_c > 0: diff --git a/backend/api/tests/test_compliance_supplemental_reporting.py b/backend/api/tests/test_compliance_supplemental_reporting.py index 8a7c2811b..140cf67e4 100644 --- a/backend/api/tests/test_compliance_supplemental_reporting.py +++ b/backend/api/tests/test_compliance_supplemental_reporting.py @@ -30,6 +30,11 @@ from api.models.Organization import Organization from .base_test_case import BaseTestCase from .payloads.supplemental_payloads import * +from decimal import Decimal +from unittest.mock import Mock, PropertyMock +from api.models.ComplianceReport import ComplianceReport +from api.serializers.ComplianceReport import ComplianceReportBaseSerializer + logger = logging.getLogger('supplemental_reporting') logger.setLevel(logging.INFO) @@ -157,3 +162,71 @@ def test_supplemental_accepted_by_director_success(self): data=json.dumps(obj['payload']) ) self.assertEqual(response.status_code, 200) + + def create_mock_report(self, credit_transaction=None, director_status="Accepted", supplements=None): + report = Mock(spec=ComplianceReport) + report.credit_transaction = credit_transaction + report.status = Mock() + type(report.status).director_status_id = PropertyMock(return_value=director_status) + report.supplements = supplements + return report + + def create_mock_transaction(self, transaction_type, number_of_credits): + transaction = Mock() + transaction.type = Mock() + type(transaction.type).the_type = PropertyMock(return_value=transaction_type) + transaction.number_of_credits = number_of_credits + return transaction + + def test_get_total_previous_credit_reductions_no_supplements(self): + report = self.create_mock_report(supplements=None) + assert ComplianceReportBaseSerializer.get_total_previous_credit_reductions(report) == Decimal('0.0') + + def test_get_total_previous_credit_reductions_single_reduction(self): + transaction = self.create_mock_transaction('Credit Reduction', Decimal('10.0')) + supplement = self.create_mock_report(credit_transaction=transaction, supplements=None) + report = self.create_mock_report(supplements=supplement) + + assert ComplianceReportBaseSerializer.get_total_previous_credit_reductions(report) == Decimal('10.0') + + def test_get_total_previous_credit_reductions_multiple_reductions(self): + transaction1 = self.create_mock_transaction('Credit Reduction', Decimal('10.0')) + transaction2 = self.create_mock_transaction('Credit Reduction', Decimal('5.0')) + supplement2 = self.create_mock_report(credit_transaction=transaction2, supplements=None) + supplement1 = self.create_mock_report(credit_transaction=transaction1, supplements=supplement2) + report = self.create_mock_report(supplements=supplement1) + + assert ComplianceReportBaseSerializer.get_total_previous_credit_reductions(report) == Decimal('15.0') + + def test_get_total_previous_credit_reductions_with_validation(self): + transaction1 = self.create_mock_transaction('Credit Reduction', Decimal('10.0')) + transaction2 = self.create_mock_transaction('Credit Validation', Decimal('3.0')) + supplement2 = self.create_mock_report(credit_transaction=transaction2, supplements=None) + supplement1 = self.create_mock_report(credit_transaction=transaction1, supplements=supplement2) + report = self.create_mock_report(supplements=supplement1) + + assert ComplianceReportBaseSerializer.get_total_previous_credit_reductions(report) == Decimal('7.0') + + def test_get_total_previous_credit_reductions_ignore_non_accepted(self): + transaction1 = self.create_mock_transaction('Credit Reduction', Decimal('10.0')) + transaction2 = self.create_mock_transaction('Credit Reduction', Decimal('5.0')) + supplement2 = self.create_mock_report(credit_transaction=transaction2, director_status="Rejected", supplements=None) + supplement1 = self.create_mock_report(credit_transaction=transaction1, supplements=supplement2) + report = self.create_mock_report(supplements=supplement1) + + assert ComplianceReportBaseSerializer.get_total_previous_credit_reductions(report) == Decimal('10.0') + + def test_get_supplemental_number_no_supplements(self): + report = self.create_mock_report(supplements=None) + assert ComplianceReportBaseSerializer.get_supplemental_number(report) == 0 + + def test_get_supplemental_number_single_supplement(self): + supplement = self.create_mock_report(supplements=None) + report = self.create_mock_report(supplements=supplement) + assert ComplianceReportBaseSerializer.get_supplemental_number(report) == 1 + + def test_get_supplemental_number_multiple_supplements(self): + supplement2 = self.create_mock_report(supplements=None) + supplement1 = self.create_mock_report(supplements=supplement2) + report = self.create_mock_report(supplements=supplement1) + assert ComplianceReportBaseSerializer.get_supplemental_number(report) == 2 \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt index 0b2952b25..18817ba92 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -41,7 +41,7 @@ python-crontab==2.6.0 python-dateutil==2.8.2 python-dotenv==0.21.0 pytz==2022.5 -requests==2.32.0 +requests==2.31.0 six==1.16.0 sqlparse==0.4.4 typing_extensions==4.4.0 From 1219857f78d1cd449ef27bfe63f2fb5c218454ea Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Tue, 13 Aug 2024 11:15:54 -0700 Subject: [PATCH 4/7] update pip to 24.0 as celery build failed --- openshift-v4/templates/celery/celery-bc.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openshift-v4/templates/celery/celery-bc.yaml b/openshift-v4/templates/celery/celery-bc.yaml index 5bec80a97..55ea84d2e 100644 --- a/openshift-v4/templates/celery/celery-bc.yaml +++ b/openshift-v4/templates/celery/celery-bc.yaml @@ -60,7 +60,7 @@ objects: RUN git clone https://github.com/bcgov/tfrs.git WORKDIR /app/tfrs RUN git checkout $TFRS_RELEASE - RUN pip install --upgrade pip \ + RUN pip install --upgrade pip==24.0 \ && pip install -r backend/requirements.txt RUN cp /app/tfrs/security-scan/scan-handler/celery.conf /etc/supervisor/conf.d RUN chgrp -R root /var/log/supervisor @@ -90,7 +90,7 @@ objects: to: kind: ImageStreamTag name: ${NAME}-celery:${VERSION} - resources: + resources: limits: cpu: 1500m memory: 1300Mi From 1bbf30d174645c95f77737c3df3bb3b464519273 Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Tue, 13 Aug 2024 12:21:33 -0700 Subject: [PATCH 5/7] update pip to 24.0 as scanhandler failed --- .../scan-handler/scan-handler-bc.yaml | 180 +++++++++--------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/openshift-v4/templates/scan-handler/scan-handler-bc.yaml b/openshift-v4/templates/scan-handler/scan-handler-bc.yaml index 52d36e550..6e245a979 100644 --- a/openshift-v4/templates/scan-handler/scan-handler-bc.yaml +++ b/openshift-v4/templates/scan-handler/scan-handler-bc.yaml @@ -5,97 +5,97 @@ metadata: name: scan-handler-bc creationTimestamp: parameters: -- name: NAME - displayName: - description: the module name entered when run yo bcdk:pipeline, which is tfrs - required: true -- name: SUFFIX - displayName: - description: sample is -pr-0 - required: true -- name: VERSION - displayName: - description: image tag name for output - required: true -- name: RELEASE_BRANCH - displayName: - description: the release branch name - required: true + - name: NAME + displayName: + description: the module name entered when run yo bcdk:pipeline, which is tfrs + required: true + - name: SUFFIX + displayName: + description: sample is -pr-0 + required: true + - name: VERSION + displayName: + description: image tag name for output + required: true + - name: RELEASE_BRANCH + displayName: + description: the release branch name + required: true objects: -- apiVersion: image.openshift.io/v1 - kind: ImageStream - metadata: - annotations: - description: Keeps track of changes in the celery image - labels: - shared: "true" - creationTimestamp: null - name: ${NAME}-scan-handler - spec: - lookupPolicy: - local: false - status: - dockerImageRepository: "" -- kind: BuildConfig - apiVersion: build.openshift.io/v1 - metadata: - name: ${NAME}-scan-handler${SUFFIX} - creationTimestamp: - spec: - triggers: [] - runPolicy: Serial - source: - type: Dockerfile - dockerfile: | - FROM artifacts.developer.gov.bc.ca/docker-remote/python:3.9.15 - RUN apt-get update \ - && apt-get install -y git \ - && apt-get install -y supervisor - WORKDIR /app - RUN git clone https://github.com/bcgov/tfrs.git - WORKDIR /app/tfrs - RUN git checkout ${tfrs_release} - RUN pip install --upgrade pip \ - && pip install -r backend/requirements.txt - RUN cp /app/tfrs/security-scan/scan-handler/scan-handler.conf /etc/supervisor/conf.d && \ - chgrp -R root /var/log/supervisor && \ - chmod -R g+w /var/log/supervisor && \ - chmod -R g+w /run || : && \ - chmod -R g+w /app - # RUN sed -i "s/chmod=0700/chmod=0770/g" /etc/supervisor/supervisord.conf - CMD ["supervisord"] - strategy: - type: Docker - dockerStrategy: - noCache: true - env: - - name: tfrs_release - value: ${RELEASE_BRANCH} - - name: ARTIFACTORY_USER - valueFrom: - secretKeyRef: - name: artifacts-default-cgcynz - key: username - - name: ARTIFACTORY_PASSWORD - valueFrom: - secretKeyRef: - name: artifacts-default-cgcynz - key: password - forcePull: true - output: - to: - kind: ImageStreamTag - name: ${NAME}-scan-handler:${VERSION} - resources: - limits: + - apiVersion: image.openshift.io/v1 + kind: ImageStream + metadata: + annotations: + description: Keeps track of changes in the celery image + labels: + shared: "true" + creationTimestamp: null + name: ${NAME}-scan-handler + spec: + lookupPolicy: + local: false + status: + dockerImageRepository: "" + - kind: BuildConfig + apiVersion: build.openshift.io/v1 + metadata: + name: ${NAME}-scan-handler${SUFFIX} + creationTimestamp: + spec: + triggers: [] + runPolicy: Serial + source: + type: Dockerfile + dockerfile: | + FROM artifacts.developer.gov.bc.ca/docker-remote/python:3.9.15 + RUN apt-get update \ + && apt-get install -y git \ + && apt-get install -y supervisor + WORKDIR /app + RUN git clone https://github.com/bcgov/tfrs.git + WORKDIR /app/tfrs + RUN git checkout ${tfrs_release} + RUN pip install --upgrade pip==24.0 \ + && pip install -r backend/requirements.txt + RUN cp /app/tfrs/security-scan/scan-handler/scan-handler.conf /etc/supervisor/conf.d && \ + chgrp -R root /var/log/supervisor && \ + chmod -R g+w /var/log/supervisor && \ + chmod -R g+w /run || : && \ + chmod -R g+w /app + # RUN sed -i "s/chmod=0700/chmod=0770/g" /etc/supervisor/supervisord.conf + CMD ["supervisord"] + strategy: + type: Docker + dockerStrategy: + noCache: true + env: + - name: tfrs_release + value: ${RELEASE_BRANCH} + - name: ARTIFACTORY_USER + valueFrom: + secretKeyRef: + name: artifacts-default-cgcynz + key: username + - name: ARTIFACTORY_PASSWORD + valueFrom: + secretKeyRef: + name: artifacts-default-cgcynz + key: password + forcePull: true + output: + to: + kind: ImageStreamTag + name: ${NAME}-scan-handler:${VERSION} + resources: + limits: cpu: 1500m memory: 1300Mi - requests: + requests: cpu: 750m - memory: 650Mi - postCommit: {} - nodeSelector: - successfulBuildsHistoryLimit: 5 - failedBuildsHistoryLimit: 5 - status: - lastVersion: 0 + memory: 650Mi + postCommit: {} + nodeSelector: + successfulBuildsHistoryLimit: 5 + failedBuildsHistoryLimit: 5 + status: + lastVersion: 0 From f310a6d3fb3ef0803f59ea0f7f8b60afdc9c9ab9 Mon Sep 17 00:00:00 2001 From: Alex Zorkin <47334977+AlexZorkin@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:16:08 -0700 Subject: [PATCH 6/7] Fix: Pending Deductions Logic for Previously Submitted Reports (#2904) * fix: fix for total previous credit reductions * fix: added pending deductions logic for previous submitted reports --------- Co-authored-by: Your Name --- backend/api/services/OrganizationService.py | 39 +++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/backend/api/services/OrganizationService.py b/backend/api/services/OrganizationService.py index 17f8107e0..34d7af4b1 100644 --- a/backend/api/services/OrganizationService.py +++ b/backend/api/services/OrganizationService.py @@ -30,7 +30,8 @@ def get_pending_transfers_value(organization): @staticmethod def get_pending_deductions( organization, - ignore_pending_supplemental=True + ignore_pending_supplemental=True, + compliance_period=None ): deductions = 0 deductions += OrganizationService.get_pending_transfers_value(organization) @@ -112,6 +113,36 @@ def get_pending_deductions( # if report.summary.credits_offset: # deductions -= report.summary.credits_offset + + # Adjust deductions for reports in the current compliance period + # This addresses a specific scenario where credits from the most recent + # submitted but not accepted report in the current period should not be + # considered as unavailable + if compliance_period: + # Get all unique report chains for the current compliance period + report_chains = ComplianceReport.objects.filter( + organization_id=organization.id, + compliance_period__description=str(compliance_period) + ).values('id').distinct() + + for chain in report_chains: + # Get all reports in this chain, ordered from newest to oldest + reports_in_chain = ComplianceReport.objects.filter( + id=chain['id'] + ).order_by('-id') + # Traverse the chain backwards, looking for the first submitted + # but not accepted report + for report in reports_in_chain: + if report.status.fuel_supplier_status.status in ["Submitted"] and \ + report.status.director_status.status not in ["Accepted", "Rejected"]: + # Subtract the credits_offset of this report from the total deductions + # This ensures that credits from the most recent relevant report + # are not incorrectly marked as unavailable + if report.summary and report.summary.credits_offset is not None: + deductions -= report.summary.credits_offset + # Break after processing the first relevant report in the chain + break + if deductions < 0: deductions = 0 @@ -160,6 +191,8 @@ def get_max_credit_offset(organization, compliance_year, exclude_reserved=False) Q(number_of_credits__gte=0) & Q(trade_effective_date__lte=effective_date_deadline)) ).aggregate(total=Sum('number_of_credits')) + + # print("CREDITS -- ", credits_until_deadline) # Query to sum up all approved, non-rescinded debits (outgoing credits) for the organization. all_debits = CreditTrade.objects.filter( @@ -192,6 +225,7 @@ def get_max_credit_offset(organization, compliance_year, exclude_reserved=False) ) ) ) + # print("DEBITS -- ", all_debits) # Calculate the net available balance by subtracting debits from credits. net_available_balance = 0 @@ -205,8 +239,9 @@ def get_max_credit_offset(organization, compliance_year, exclude_reserved=False) if exclude_reserved: pending_deductions = OrganizationService.get_pending_transfers_value(organization) else: - pending_deductions = OrganizationService.get_pending_deductions(organization, ignore_pending_supplemental=False) + pending_deductions = OrganizationService.get_pending_deductions(organization, ignore_pending_supplemental=False, compliance_period=compliance_year) + # print("PENDING DEDUCTIONS -- ", pending_deductions) # Deduct pending deductions from the available balance and ensure it does not drop below zero. available_balance_now = net_available_balance - pending_deductions if available_balance_now < 0: From f4fd05ea9cc90419c1532eb5e910c6573cde8f0c Mon Sep 17 00:00:00 2001 From: Kuan Fan Date: Wed, 4 Sep 2024 11:03:02 -0700 Subject: [PATCH 7/7] update approvers --- .github/workflows/tfrs-release.yaml | 35 +++++++++++------------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/.github/workflows/tfrs-release.yaml b/.github/workflows/tfrs-release.yaml index dec15e4ea..f668f8ea9 100644 --- a/.github/workflows/tfrs-release.yaml +++ b/.github/workflows/tfrs-release.yaml @@ -18,9 +18,7 @@ concurrency: cancel-in-progress: true jobs: - unit-test: - name: Run Backend Unit Tests runs-on: ubuntu-latest timeout-minutes: 60 @@ -28,17 +26,16 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - - name: Run coverage report for django tests + + - name: Run coverage report for django tests uses: kuanfandevops/django-test-action@itvr-django-test continue-on-error: true with: settings-dir-path: "backend/api" requirements-file: "backend/requirements.txt" managepy-dir: backend - - lint: + lint: name: Linting runs-on: ubuntu-latest timeout-minutes: 60 @@ -47,13 +44,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Frontend Linting + - name: Frontend Linting continue-on-error: true run: | cd frontend pwd npm install - npm run lint + npm run lint - name: Backend linting uses: github/super-linter/slim@v4 @@ -66,20 +63,18 @@ jobs: LOG_LEVEL: WARN build: - name: Build TFRS on Openshift runs-on: ubuntu-latest timeout-minutes: 60 steps: - ## it will checkout to /home/runner/work/itvr/itvr - name: Check out repository uses: actions/checkout@v3 ## Log in to Openshift with a token of service account - name: Log in to Openshift - ##uses: redhat-actions/oc-login@v1 + ##uses: redhat-actions/oc-login@v1 uses: smlgbl/oc-login@main with: openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} @@ -92,17 +87,15 @@ jobs: run: | cd .pipeline npm install - npm run build -- --pr=${{ env.PR_NUMBER }} --env=build + npm run build -- --pr=${{ env.PR_NUMBER }} --env=build deploy-on-test: - name: Deploy TFRS on Test runs-on: ubuntu-latest timeout-minutes: 240 needs: build steps: - ## it will checkout to /home/runner/work/itvr/itvr - name: Check out repository uses: actions/checkout@v3 @@ -114,13 +107,13 @@ jobs: openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} insecure_skip_tls_verify: true - namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools + namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools - name: Ask for approval for TFRS Test deployment uses: trstringer/manual-approval@v1.6.0 with: secret: ${{ github.TOKEN }} - approvers: AlexZorkin,emi-hi,tim738745,kuanfandevops,jig-patel,prv-proton,JulianForeman + approvers: AlexZorkin,kuanfandevops,prv-proton,JulianForeman,kevin-hashimoto,dhaselhan minimum-approvals: 1 issue-title: "TFRS ${{ env.RELEASE_NAME }} Test Deployment" @@ -128,17 +121,15 @@ jobs: run: | cd .pipeline npm install - npm run deploy -- --pr=${{ env.PR_NUMBER }} --env=test + npm run deploy -- --pr=${{ env.PR_NUMBER }} --env=test deploy-on-prod: - name: Deploy TFRS on Prod runs-on: ubuntu-latest timeout-minutes: 2880 needs: deploy-on-test steps: - ## it will checkout to /home/runner/work/itvr/itvr - name: Check out repository uses: actions/checkout@v3 @@ -150,13 +141,13 @@ jobs: openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }} openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} insecure_skip_tls_verify: true - namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools + namespace: ${{ secrets.OPENSHIFT_NAMESPACE_PLATE }}-tools - name: Ask for approval for TFRS Prod deployment uses: trstringer/manual-approval@v1.6.0 with: secret: ${{ github.TOKEN }} - approvers: AlexZorkin,kuanfandevops,tim738745,jig-patel,prv-proton,JulianForeman + approvers: AlexZorkin,kuanfandevops,prv-proton,JulianForeman,kevin-hashimoto,dhaselhan minimum-approvals: 2 issue-title: "TFRS ${{ env.RELEASE_NAME }} Prod Deployment" @@ -164,4 +155,4 @@ jobs: run: | cd .pipeline npm install - npm run deploy -- --pr=${{ env.PR_NUMBER }} --env=prod + npm run deploy -- --pr=${{ env.PR_NUMBER }} --env=prod