Skip to content

fix(form): restore money conversion in createHeadlessForm when options are passed - #1429

Merged
gabrielseco merged 9 commits into
mainfrom
refactor/drop-get-forced-value
Sep 30, 2026
Merged

gabrielseco merged 9 commits into
mainfrom
refactor/drop-get-forced-value

Conversation

@gabrielseco

@gabrielseco gabrielseco commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Narrows #1424 to the change that actually fixes the Portugal extended work hours allowance. The extra helper it added for forced money values isn't needed, and the money conversion fix now lives in createHeadlessForm (from #1426) instead of a per-caller flag.

Why

The allowance is a forced money value that the schema computes from the salary. createHeadlessForm only turned transformMoneyFields on when no options object was passed at all, and Onboarding always passes one. So the schema saw the salary in major units instead of cents, and the allowance came out 100x too small (812 instead of 81257).

  • Submit already sends the right amount. When values are prepared for the API, every forced field is overwritten with the schema's own value, which is already in cents.
  • The shown amount comes from the schema's description text, not from the field value.

So the getForcedValue helper wasn't fixing anything. What it would change is the fieldData.value that a partner's custom forcedValue component receives (major units instead of the raw value). That prop is public, so if it ever changes it should be its own decision.

What changed

Toggle details
  • Removes getForcedValue from src/components/form/utils.ts, and its call sites in JSONSchemaForm.tsx and FieldSetField.tsx. They go back to passing const, as on main.
  • Removes the tests that only covered it: src/components/form/tests/utils.test.ts and JSONSchemaFormForcedValue.test.tsx.
  • Merges fix(forms): default transformMoneyFields per key #1426: createHeadlessForm now defaults transformMoneyFields to true for each call unless it's set explicitly, and invoice schedules drops its now-redundant explicit flag.
  • Drops the explicit transformMoneyFields: true in Onboarding/api.ts, since the new default covers it. Onboarding/api.ts is unchanged from main.
  • Keeps the Portugal flow test and useJSONSchemaFormMoneyForcedValue.test.tsx. Both fail when createHeadlessForm is reverted to main (812 instead of 81257, and "812.57 EUR" not shown), and pass with this change.
  • The new default also applies to ContractorOnboarding, ContractAmendment, CreateCompany and contractor-contract-details wherever they pass options together with field values. Only the Portugal Onboarding path has a test.
  • fix(onboarding): submit computed money forced values in the right unit #1424's description says both parts are needed and that without the helper the allowance is submitted 100x too large. That's not the case with the current submit path, so it should be updated once this is merged into fix(onboarding): submit computed money forced values in the right unit #1424.
  • No public API change. This keeps fieldData.value as it is on main.

Screenshots

N/A

Related Resources

Testing

  • Portugal flow test and useJSONSchemaForm hook test pass locally, and both fail when createHeadlessForm is reverted to main

🤖 Generated with Claude Code

cammellos and others added 5 commits September 29, 2026 18:32
Portugal's extended work hours allowance is a forced money value computed
from the salary. Onboarding built its render-time form without converting
money fields to cents, so the allowance was computed from the salary in
major units (100x too small), and the forced value was then written into
the form state in cents while the form keeps money in major units.
Validation recomputed the correct value and rejected the submission on a
field with no input to show the error, blocking the step.

- Onboarding's useJSONSchemaForm passes transformMoneyFields: true, since
  createHeadlessForm only defaults it on when no options are passed.
- Forced money values are converted from cents before being set in the form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Default transformMoneyFields to true whenever it's not explicitly set,
instead of only when the whole options object is missing. Callers that
pass options without transformMoneyFields (e.g. only jsfModify) now get
money fields converted to cents too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tails path

The flow regression test only covers the legacy path while PRT is outside
JSF_V1_CONTRACT_DETAILS_COUNTRIES. These test the Onboarding useJSONSchemaForm
hook and JSONSchemaFormFields directly, so they keep covering the fix
whichever countries are on v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Submitting a forced value already uses the field's `const` in cents
(parseFormValuesToAPI overwrites the form value with it), and the default
forced value component doesn't render `value`. The `transformMoneyFields`
change alone fixes the PRT allowance; getForcedValue would only change
what custom forcedValue components receive in `fieldData.value`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Metric Current Previous Change Status
Total (gzip) 167.23 kB 167.25 kB -12 B (-0.0%) 🟢
Total (raw) 559.17 kB 559.22 kB -47 B (-0.0%) 🟢
CSS (gzip) 21.94 kB 21.94 kB 0 B (0%) 🟢
CSS (raw) 114.43 kB 114.43 kB 0 B (0%) 🟢

Size Limits

  • ✅ Total gzipped: 167.23 kB / 350 kB (47.8%)
  • ✅ Total raw: 559.17 kB / 850 kB (65.8%)
  • ✅ CSS gzipped: 21.94 kB / 25 kB (87.8%)

Largest Files (Top 5)

  1. CheckBoxField-CBXcXbix.js - 24.61 kB (0 B (0%))
  2. ContractorOnboarding-mgqIYo0S.js - 13.54 kB (new)
  3. Onboarding-CesFBlFc.js - 11.27 kB (new)
  4. Termination-C97V8csk.js - 11.08 kB (new)
  5. styles.css - 10.97 kB (0 B (0%))
View All Files (75 total)
File Size (gzip) Change
CheckBoxField-CBXcXbix.js 24.61 kB 0 B (0%)
ContractorOnboarding-mgqIYo0S.js 13.54 kB new
Onboarding-CesFBlFc.js 11.27 kB new
Termination-C97V8csk.js 11.08 kB new
styles.css 10.97 kB 0 B (0%)
index.css 10.97 kB 0 B (0%)
CostCalculator-D7zKfNSe.js 10.68 kB new
internals-CQxsI0di.js 8.23 kB new
index.js 5.05 kB +4 B (+0.1%)
JSONSchemaForm-DZ8d227x.js 4.92 kB new

✅ Bundle size check passed

@remotecom
remotecom changed the base branch from fix/computed-money-forced-value to main September 29, 2026 20:08
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-r1mwdv7ro-remotecom.vercel.app
Latest Commit:39b2adc

Deployed with vercel-action

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-5v7kbtmls-remotecom.vercel.app
Latest Commit:39b2adc

Deployed with vercel-action

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

📊 Coverage Report

✅ Coverage increased! 🎉

Metric Current Previous Change Status
Lines 86.41% 86.36% +0.05% 🟢
Statements 85.98% 85.93% +0.05% 🟢
Functions 84.92% 84.92% 0% ⚪
Branches 77.93% 77.80% +0.13% 🟢

Detailed Breakdown

Lines Coverage
  • Covered: 4853 / 5616
  • Coverage: 86.41%
  • Change: +0.05% (3 lines)
Statements Coverage
  • Covered: 4937 / 5742
  • Coverage: 85.98%
  • Change: +0.05% (3 statements)
Functions Coverage
  • Covered: 1290 / 1519
  • Coverage: 84.92%
  • Change: 0% (0 functions)
Branches Coverage
  • Covered: 3009 / 3861
  • Coverage: 77.93%
  • Change: +0.13% (5 branches)

✅ Coverage check passed

gabrielseco and others added 4 commits September 29, 2026 22:11
Correct submission of forced money values relies on parseFormValuesToAPI
overwriting the form value with the field's const. Covers a top-level field
and one nested in a fieldset; both fail with 100x the amount without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
createHeadlessForm now defaults transformMoneyFields per key (#1426), so
the explicit override in useJSONSchemaForm is redundant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/common/createHeadlessForm.tsx
@remotecom remotecom changed the title refactor(form): drop getForcedValue fix(form): restore money conversion in createHeadlessForm when options are passed Sep 29, 2026
@gabrielseco gabrielseco self-assigned this Sep 30, 2026
@gabrielseco
gabrielseco merged commit 089123c into main Sep 30, 2026
15 checks passed
@gabrielseco
gabrielseco deleted the refactor/drop-get-forced-value branch September 30, 2026 09:49
@gabrielseco gabrielseco mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants