Skip to content

Commit

Permalink
Merge pull request #1844 from bcgov/fix/daniel-met-notmet-1782
Browse files Browse the repository at this point in the history
fix: Update met/not met logic
  • Loading branch information
dhaselhan authored Jan 30, 2025
2 parents 2119481 + 82de0d8 commit d07fe5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ const ComplianceReportSummary = ({
onSuccess: (response) => {
setSummaryData(response.data)
const renewablePenaltyAmount =
response.data?.renewableFuelTargetSummary.find(
response.data?.nonCompliancePenaltySummary.find(
(line) => line.line === 11
)
const lowCarbonPenaltyCredits =
response.data?.lowCarbonFuelTargetSummary.find(
(line) => line.line === 20
const lowCarbonPenaltyAmount =
response.data?.nonCompliancePenaltySummary.find(
(line) => line.line === 21
)

setHasMetRenewables(renewablePenaltyAmount.value > 0)
setHasMetLowCarbon(lowCarbonPenaltyCredits.value > 0)
setHasMetRenewables(renewablePenaltyAmount.totalValue <= 0)
setHasMetLowCarbon(lowCarbonPenaltyAmount.totalValue <= 0)
},
onError: (error) => {
alertRef.current?.triggerAlert({
Expand All @@ -75,15 +75,15 @@ const ComplianceReportSummary = ({
useEffect(() => {
if (data) {
setSummaryData(data)
const renewablePenaltyAmount = data?.renewableFuelTargetSummary.find(
const renewablePenaltyAmount = data?.nonCompliancePenaltySummary.find(
(line) => line.line === 11
)
const lowCarbonPenaltyCredits = data?.lowCarbonFuelTargetSummary.find(
(line) => line.line === 20
const lowCarbonPenaltyAmount = data?.nonCompliancePenaltySummary.find(
(line) => line.line === 21
)

setHasMetRenewables(renewablePenaltyAmount.value > 0)
setHasMetLowCarbon(lowCarbonPenaltyCredits.value > 0)
setHasMetRenewables(renewablePenaltyAmount.totalValue <= 0)
setHasMetLowCarbon(lowCarbonPenaltyAmount.totalValue <= 0)
setHasRecords(data && data.canSign)
}
if (isError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ describe('ComplianceReportSummary', () => {
renewableFuelTargetSummary: [
{ line: 1, gasoline: 100, diesel: 100, jetFuel: 100 },
{ line: 2, gasoline: 50, diesel: 50, jetFuel: 50 },
{ line: 4, gasoline: 30, diesel: 30, jetFuel: 30 },
{ line: 11, value: 0 }
{ line: 3, gasoline: 50, diesel: 50, jetFuel: 50 },
{ line: 4, gasoline: 30, diesel: 30, jetFuel: 30 }
],
lowCarbonFuelTargetSummary: [{ line: 20, value: 0 }],
nonCompliancePenaltySummary: [{ totalValue: 0 }, { totalValue: 0 }]
lowCarbonFuelTargetSummary: [],
nonCompliancePenaltySummary: [
{ line: 11, totalValue: 0 },
{ line: 21, totalValue: 0 },
{ totalValue: 0 }
]
}
})

Expand Down

0 comments on commit d07fe5f

Please sign in to comment.