Skip to content

Conversation

@rockaxorb13
Copy link

Description

This PR adds a new MonetaryUtil class to the @accordproject/concerto-util package. This utility provides functionality to convert numbers into their written word representation (e.g., converting 100 to "one hundred"), utilizing the n2words library.

Motivation

As discussed in the previous meeting, there is a need for monetary text conversion support within the library to facilitate the upcoming implementation of the Monetary type in the core model. This utility lays the groundwork for that feature.

Changes

  • New File: Added lib/monetary.js containing the MonetaryUtil class.
  • Dependencies: Added n2words to package.json.
  • Exports: Exposed MonetaryUtil via index.js for external consumption.

Verification

  • Validated that the new utility correctly converts numbers to text strings using the default locale ('en').
  • Confirmed the package installs and exports the new class correctly.

Next Steps

Once merged, this utility will be used by the concerto-core logic to handle monetary serialization and human-readable formatting.

"dependencies": {
"@supercharge/promise-pool": "1.7.0",
"debug": "4.3.7",
"n2words": "^3.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a pinned/exact package version to prevent supply chain attacks.

Copy link
Contributor

@dselman dselman left a comment

Choose a reason for hiding this comment

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

LGTM - just one small change required for the dependency on n2words. Can you also check that this webpacks ok and the increase in the bundle size?

Signed-off-by: Aadityavardhan Singh <[email protected]>
@rockaxorb13
Copy link
Author

Fixed! I've pinned the n2words dependency to version 3.0.0.

I also ran the build locally to verify the bundle size:
Build Status: ✅ Webpack compiled successfully.
Bundle Size: 140 KiB (minimized).

Ready for review!

@dselman
Copy link
Contributor

dselman commented Jan 7, 2026

Please address the build failures.

@rockaxorb13
Copy link
Author

@dselman Done! Ready for review

@github-actions
Copy link
Contributor

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants