Fix emission allocation bugs identified in UAT #2637
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
card: bcgov/cas-reporting#468
Issues Resolved:
Bug 1: Unable to submit when all emissions have been 100% allocated
The problem: This bug was due to a precision issue. During testing, a user had all emissions showing as 100% allocated, but was prevented from saving by a validation error indicating an incorrect allocation. In fact, the validation was working as intended. There was an over-allocation of emissions. BUT the amount over was .000049% of the total. And because the percentage display only uses 2-digit precision, it still showed as just 100.00%.
The fix: This problem really only exists for values that are very slightly off 100%. If it is more substantially off, then it would not show 100.00% and the problem allocation would be obvious. So i have added some edge case handling. For values that are >100 and <100.01, display 100.01. And for values <100 and >99.99, display 99.99. This is only for displaying to the users and does not affect allocation amounts or validation. It just makes it more obvious to users where an allocation error is.
image1 <correct allocation to 100.00%>
image2 <an over-allocation of ~.000001%>
Bug 2: The totals of the totals allocated to products does not equal the total amount of emissions
The problem: Excluded emission allocations were being improperly included in the fields showing the total emissions allocated to a product which led to a double counting of emissions. This error was not present for the overall total emissions value, and so a discrepancy was seen.
The fix: omit excluded emission allocations from the calculation of total emissions allocated to each product.
To Test locally:
see #2553 and
"The easiest way to get some excluded emissions is to use a General Stationary Combustion activity, select a fuel that is classified as 'woody biomass' and choose 'CO2' as the gas type. That emission will be excluded." for instructions on adding reportable and excluded emissions to be allocated