Skip to content

feat: add cents support to money widget#1756

Merged
lyubov-voloshko merged 2 commits into
mainfrom
feature/money-widget-cents-support
May 5, 2026
Merged

feat: add cents support to money widget#1756
lyubov-voloshko merged 2 commits into
mainfrom
feature/money-widget-cents-support

Conversation

@gugu
Copy link
Copy Markdown
Contributor

@gugu gugu commented May 5, 2026

Adds opt-in cents: true widget_param so the money widget can render and edit values stored as Stripe-style integer minor units. Zero-decimal currencies (JPY, KRW, VND, ...) bypass division per Stripe convention.

Adds opt-in `cents: true` widget_param so the money widget can render and
edit values stored as Stripe-style integer minor units. Zero-decimal
currencies (JPY, KRW, VND, ...) bypass division per Stripe convention.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 5, 2026 12:29
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Warning

Rate limit exceeded

@gugu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 4 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8591f900-7812-4917-96b8-a7a3b8bcff80

📥 Commits

Reviewing files that changed from the base of the PR and between d073b1b and dd76870.

📒 Files selected for processing (8)
  • frontend/src/app/components/dashboard/db-table-view/db-table-widgets/db-table-widgets.component.ts
  • frontend/src/app/components/ui-components/record-edit-fields/money/money.component.spec.ts
  • frontend/src/app/components/ui-components/record-edit-fields/money/money.component.ts
  • frontend/src/app/components/ui-components/record-view-fields/money/money.component.spec.ts
  • frontend/src/app/components/ui-components/record-view-fields/money/money.component.ts
  • frontend/src/app/components/ui-components/table-display-fields/money/money.component.spec.ts
  • frontend/src/app/components/ui-components/table-display-fields/money/money.component.ts
  • frontend/src/app/consts/currencies.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/money-widget-cents-support

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds opt-in cents: true handling for money widgets so they can display and edit integer minor-unit values, extending the existing money widget flow across table display, record view, and record edit components.

Changes:

  • Added shared helpers for zero-decimal currencies and minor-unit conversion in currencies.ts.
  • Updated money display/view components to format minor-unit values when widget_params.cents is enabled.
  • Updated the money edit component and tests to load/save minor units and documented the new widget param.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/app/consts/currencies.ts Adds zero-decimal currency metadata and conversion helpers used by money widgets.
frontend/src/app/components/ui-components/table-display-fields/money/money.component.ts Applies minor-unit formatting in table money display.
frontend/src/app/components/ui-components/table-display-fields/money/money.component.spec.ts Adds table-display tests for cents and zero-decimal behavior.
frontend/src/app/components/ui-components/record-view-fields/money/money.component.ts Applies minor-unit formatting in record-view money display.
frontend/src/app/components/ui-components/record-view-fields/money/money.component.spec.ts Adds record-view tests for cents behavior.
frontend/src/app/components/ui-components/record-edit-fields/money/money.component.ts Adds minor-unit load/save logic and currency-aware decimal handling in the editor.
frontend/src/app/components/ui-components/record-edit-fields/money/money.component.spec.ts Adds editor tests for loading, saving, rounding, and currency switching with cents.
frontend/src/app/components/dashboard/db-table-view/db-table-widgets/db-table-widgets.component.ts Documents the new cents widget parameter in widget configuration help text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +136 to +143
if (this.amount !== '' && this.amount !== null && this.amount !== undefined) {
const numericAmount = typeof this.amount === 'string' ? parseFloat(this.amount) : this.amount;
if (!Number.isNaN(numericAmount)) {
const rounded = parseFloat(numericAmount.toFixed(this.decimalPlaces));
this.amount = rounded;
this.displayAmount = this.formatAmount(rounded);
}
}
const cleanNumber = numberMatch[1].replace(/,/g, '');
this.amount = parseFloat(cleanNumber) || '';
const parsed = parseFloat(cleanNumber);
this.amount = Number.isNaN(parsed) ? '' : this._fromMinorUnits(parsed);
Comment on lines +77 to +86
export function isZeroDecimalCurrency(code: string): boolean {
return ZERO_DECIMAL_CURRENCIES.has(code);
}

export function getCurrencyDecimalPlaces(code: string): number {
return isZeroDecimalCurrency(code) ? 0 : 2;
}

export function getCurrencyMinorUnitFactor(code: string): number {
return isZeroDecimalCurrency(code) ? 1 : 100;
@lyubov-voloshko lyubov-voloshko merged commit ac2f753 into main May 5, 2026
16 of 17 checks passed
@lyubov-voloshko lyubov-voloshko deleted the feature/money-widget-cents-support branch May 5, 2026 13:05
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