Skip to main content

adk_payments/domain/
money.rs

1use serde::{Deserialize, Serialize};
2
3/// Currency-denominated amount stored as minor units plus an explicit scale.
4///
5/// `amount_minor` keeps commerce arithmetic exact and avoids floating-point
6/// rounding drift.
7#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct Money {
10    pub currency: String,
11    pub amount_minor: i64,
12    pub scale: u32,
13}
14
15impl Money {
16    /// Creates a money value using explicit minor units and scale.
17    #[must_use]
18    pub fn new(currency: impl Into<String>, amount_minor: i64, scale: u32) -> Self {
19        Self { currency: currency.into(), amount_minor, scale }
20    }
21}