Skip to content

Conversation

@LuckyGoyal039
Copy link

@LuckyGoyal039 LuckyGoyal039 commented Dec 4, 2025

Fixes: #15887

The currency fields were expecting values in micros (multiplied by 10^6), but
this requirement was not indicated anywhere in the workflow UI. Users had to
manually add a code node to multiply amounts by 10^6 before using the new
currency value.

This change integrates the micros conversion logic directly into
FormCurrencyFieldInput by using convertCurrencyAmountToCurrencyMicros and
convertCurrencyMicrosToCurrencyAmount utilities. This allows users to input
human-readable decimal amounts (e.g., 3.21 for $3.21) in the form, which are
automatically converted to micros internally for storage and processing.

This eliminates the need for users to add separate code nodes for conversion
and improves the user experience by making the expected input format clear.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Welcome!

Hello there, congrats on your first PR! We're excited to have you contributing to this project.
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.

Generated by 🚫 dangerJS against 1907ed7

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 4, 2025

Greptile Overview

Greptile Summary

Improved user experience by converting currency input from micros (e.g., 3210000) to human-readable format (e.g., 3.21) using convertCurrencyAmountToCurrencyMicros and convertCurrencyMicrosToCurrencyAmount utilities.

  • Added imports for currency converter utilities from ~/utils/convertCurrencyToCurrencyMicros
  • Updated handleAmountMicrosChange to convert user input to micros before storing
  • Modified defaultValue display to show human-readable amounts instead of micros
  • Changed label from "Amount Micros" to "Amount" for better clarity
  • Updated placeholder from "Set 3210000 for $3.21" to "Set 3.21 for $3.21"

Issues found:

  • Null/undefined handling may cause 0 values instead of null when clearing the field
  • Number() conversion of null/undefined produces 0 or NaN, leading to incorrect calculations

Confidence Score: 3/5

  • This PR improves UX significantly but has critical null-handling bugs that need to be fixed before merging
  • The core improvement (converting micros to human-readable format) is good and aligns with similar patterns in the codebase. However, there are two critical bugs in null/undefined handling that will cause incorrect behavior when clearing values or loading empty fields. The use of Number(null) and Number(undefined) without proper null checks will produce 0 or NaN values instead of preserving null state.
  • packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCurrencyFieldInput.tsx requires fixes for null/undefined handling on lines 48-49 and 75-76

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormCurrencyFieldInput.tsx 4/5 Converted currency input from micros to human-readable format with proper converter utilities. Changed label from "Amount Micros" to "Amount" and updated placeholder for better UX.

Sequence Diagram

sequenceDiagram
    participant User
    participant FormCurrencyFieldInput
    participant FormNumberFieldInput
    participant Converter as convertCurrencyToCurrencyMicros
    participant Parent as onChange callback

    User->>FormCurrencyFieldInput: Loads form with defaultValue
    FormCurrencyFieldInput->>Converter: convertCurrencyMicrosToCurrencyAmount(defaultValue.amountMicros)
    Converter-->>FormCurrencyFieldInput: Returns human-readable amount (e.g., 3.21)
    FormCurrencyFieldInput->>FormNumberFieldInput: Renders with converted defaultValue

    User->>FormNumberFieldInput: Enters amount (e.g., "3.21")
    FormNumberFieldInput->>FormCurrencyFieldInput: handleAmountMicrosChange(3.21)
    FormCurrencyFieldInput->>Converter: convertCurrencyAmountToCurrencyMicros(Number(3.21))
    Converter-->>FormCurrencyFieldInput: Returns 3210000 micros
    FormCurrencyFieldInput->>Parent: onChange({currencyCode, amountMicros: 3210000})
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:26830

This environment will automatically shut down when the PR is closed or after 5 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Workflow] - Amount expected by the API is in micros -> not told to users using the workflow UI

2 participants