Skip to content

Be able to change decimal precision (Certain currencies don't use decimals) #105

@freivokh

Description

@freivokh

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:

  1. 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
};
  1. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions