Skip to main content

Money Types

The Money type is defined in shared/money.ts for consistent monetary value handling.

Money Interface

export interface Money {
amount: number; // In minor units (cents, paisa)
currency: string; // ISO currency code (e.g., "BDT", "USD")
}

Usage

Always use minor units for monetary calculations:

const amount: Money = {
amount: 100000, // 1000 BDT (in paisa/cents)
currency: "BDT",
};

Why Minor Units?

Using minor units (cents, paisa) avoids floating-point precision issues:

// ❌ BAD - floating point errors
const total = 10.1 + 0.2; // 10.299999999999999

// ✅ GOOD - integer arithmetic
const total = 1010 + 20; // 1030 (minor units)