Skip to content

LF-5225: Unable to create a farm in Belarus or Venezuela due to currency validation error#4097

Open
litefarm-pr-bot wants to merge 2 commits intointegrationfrom
LF-5225-unable-to-create-a-farm-in-belarus-or-venezuela-due-to-currency-validation-error
Open

LF-5225: Unable to create a farm in Belarus or Venezuela due to currency validation error#4097
litefarm-pr-bot wants to merge 2 commits intointegrationfrom
LF-5225-unable-to-create-a-farm-in-belarus-or-venezuela-due-to-currency-validation-error

Conversation

@litefarm-pr-bot
Copy link
Copy Markdown
Collaborator

Description

The units.currency field on the Farm model uses a hardcoded JSON Schema enum of allowed ISO 4217 currency codes. This enum was last updated several years ago and does not include codes introduced by two currency redenominations: Belarus replaced BYR (Belarusian ruble, old) with BYN (Belarusian ruble, current) in 2016, and Venezuela replaced VEF (bolívar fuerte, old) with VES (bolívar soberano, current) in 2018. When a user attempts to create a farm in either country, the app resolves the currency ISO from the countries table — which already contains the current codes — and submits it to the API, where Objection.js rejects it with a ModelValidation enum error, blocking farm creation entirely.

The fix adds BYN and VES to the enum alongside the existing deprecated codes BYR and VEF. The old codes are intentionally kept: removing them would break validation for any existing farm records that were created when those codes were valid. A migration aligns Venezuela's ISO in the countries table between environments: production still held VEF while beta had already been updated to VES. The migration filters on both country_code and iso, making it a no-op on beta (where VES is already present) and safely idempotent.

Note: Belarus required only the enum fix — both environments already store BYN in the countries table. The environment divergence was specific to Venezuela. The table below summarises the full picture:

Country Old ISO (deprecated) New ISO (current) Beta countries table Prod countries table Enum before this PR Enum after this PR
Belarus BYR (pre-2016) BYN BYN BYN BYR only BYR + BYN
Venezuela VEF (pre-2018) VES VES VEF → migrated to VES VEF only VEF + VES

Jira link: https://lite-farm.atlassian.net/browse/LF-5225

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Changes reviewed in source code. The enum additions were verified against the countries table exports from both beta and production. The migration was verified to be defensive (filters on both country_code and iso) and confirmed to have identical starting state on both environments for all affected rows. No local API environment was spun up; CI will run the full test suite.

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

- Add BYN (Belarusian ruble, current) to farmModel currency enum alongside
  legacy BYR (pre-2016 redenomination) for backward compatibility
- Add VES (Venezuelan bolívar soberano, current) to enum alongside
  legacy VEF (pre-2018 redenomination) for backward compatibility
- Add migration to align Venezuela ISO in countries table: prod still had
  deprecated VEF; migration updates to VES, filtered defensively on both
  country_code and iso so it is a no-op on beta where VES is already present

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@litefarm-pr-bot litefarm-pr-bot requested review from a team as code owners March 19, 2026 22:11
@litefarm-pr-bot litefarm-pr-bot requested review from Duncan-Brain and removed request for a team March 19, 2026 22:11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant