opcn1214-generator: cg.improvements.expense compares raw floats, so a valid report can fail to generate
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend
Research direction
Start at packages/opcn1214-generator/src/validate/capital-gains-rules.ts:178 and inspect the existing hundredths comparison in shareholders.dividendRights.total. Update the depreciation test to include 14.46 + 49.59 + 35.95, then search src/validate/ for other raw double amount comparisons. Done means the regression passes and no other amount comparisons there use raw doubles.
Written by the indexing model from the issue text.
Description
Problem
packages/opcn1214-generator/src/validate/capital-gains-rules.ts:178, in cg.improvements.expense:
if (typeof depreciation === 'number' && depreciation > expense) {
This compares raw doubles, so float residue decides the result. A depreciation summed in JS can land just above the expense: 14.46 + 49.59 + 35.95 is 100.00000000000001.
Repro: a 3077 improvement with expense: 100 and accumulatedDepreciation: 14.46 + 49.59 + 35.95.
field.decimalsaccepts the value. The file would hold000000010000for both amounts (10000 hundredths each).validate1214reportscg.improvements.expense: "Improvement 1 has an accumulated depreciation (100.00000000000001) above its expense (100)." Sogenerate1214throwsOpcn1214ValidationError.- The file written for
accumulatedDepreciation: 100is byte-identical, andparse1214of it reports nothing.
So validating the input and parsing the file disagree, and a fully depreciated improvement can block generation.
Fix
Compare in hundredths, as written to the file. shareholders.dividendRights.total already does this:
// Compared in hundredths, as written to the file: 14.46 + 49.59 + 35.95 is above 100.
if (
typeof depreciation === 'number' &&
Math.round(depreciation * 100) > Math.round(expense * 100)
) {
Done when
- The comparison works in hundredths.
- The test "accepts a depreciation equal to the expense…" includes the
14.46 + 49.59 + 35.95vector. - No other amount comparison in
src/validate/compares raw doubles. The same kind of bug came up in several places during the stack review.
Raised in the review of #5081 (FIX-3), which added this rule. The review wasn't posted because the PR merged first. Re-checked on main at 31245bc7f.
- Dominant language
- TypeScript
- Stars
- 30
- Forks
- 10
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 276
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Urigo/accounter-fullstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Urigo/accounter-fullstack#5302 ·
Maintainers usually reply within 2 days
-
1214 annual-audit-workflow
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Urigo/accounter-fullstack#5256 ·
Maintainers usually reply within 2 days
-
annual-audit-workflow
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
Urigo/accounter-fullstack#5252 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Urigo/accounter-fullstack#4919 ·
Maintainers usually reply within 2 days
-
Business-trip attendee mutations throw TypeError instead of a clear error when no row is affectedOpen
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Urigo/accounter-fullstack#4917 ·
Maintainers usually reply within 2 days
All issues in Urigo/accounter-fullstack
Similar issues
-
area: integrations documentation priority: P2 size: XS
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eddiejaoude/StackDash#798 ·
Maintainers usually reply within 1 day
-
bot:ai-assisted component:midnight-js status:untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
midnightntwrk/midnight-js#1790 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
area:vscode bug has repro platform:macos platform:vscode regression
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anthropics/claude-code#113502 ·
-
Add: Rajdhani TV HDOpencheck:passed streams:add
Difficulty 1/5 Under an hour Newbie friendliness 77/100
Maintainers usually reply within 1 day