-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Problem
The invoice generator currently applies a fixed decimal precision (typically 2 decimal places) to all currencies, but many currencies don't use decimal places at all. This creates incorrect formatting for currencies like:
- TWD (Taiwan Dollar) - Uses whole numbers only
- JPY (Japanese Yen) - Uses whole numbers only
- KRW (South Korean Won) - Uses whole numbers only
- VND (Vietnamese Dong) - Uses whole numbers only
Current Behavior
When generating an invoice with currency: "TWD"
and amount: 1000
, the output shows:
NT$1,000.00
Expected Behavior
For TWD and similar currencies, it should show:
NT$1,000
Proposed Solution
Add support for currency-specific decimal precision, either through:
- Automatic detection based on currency code:
const CURRENCY_DECIMALS = {
'USD': 2, 'EUR': 2, 'CAD': 2, 'GBP': 2,
'TWD': 0, 'JPY': 0, 'KRW': 0, 'VND': 0,
'BHD': 3, 'KWD': 3 // Some currencies use 3 decimals
};
- Manual override parameter:
{
currency: "TWD",
decimal_places: 0, // New optional parameter
// ... other invoice data
}
Use Cases
- Business invoicing in Asian markets (Taiwan, Japan, Korea)
- E-commerce platforms handling multiple currencies
- Financial applications requiring accurate currency display
Additional Context
This follows ISO 4217 currency standards where each currency has a defined minor unit. For example:
- USD minor unit = 2 (cents)
- TWD minor unit = 0 (no subdivision)
- JPY minor unit = 0 (no subdivision)
Metadata
Metadata
Assignees
Labels
No labels