moneylib 0.13.0

Library to deal with money in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
use std::{
    fmt::{Debug, Display},
    iter::Sum,
    marker::PhantomData,
    str::FromStr,
};

#[cfg(feature = "accounting")]
use crate::AccountingOps;

use crate::{
    BaseMoney, BaseOps, Decimal, Money, MoneyError, MoneyOps,
    base::{Amount, DecimalNumber},
    macros::dec,
    parse::{
        parse_code_locale_separator, parse_comma_thousands_separator,
        parse_dot_thousands_separator, parse_symbol_comma_thousands_separator,
        parse_symbol_dot_thousands_separator, parse_symbol_locale_separator,
    },
};
use crate::{Currency, MoneyFormatter};
use rust_decimal::{MathematicalOps, prelude::FromPrimitive, prelude::ToPrimitive};

/// Represents a monetary value without automatic rounding.
///
/// `RawMoney` is exactly like [`Money`] except it doesn't automatically round
/// amounts after each operation. It keeps full decimal precision and lets
/// callers decide when to round.
///
/// # Key Features
///
/// - **Type Safety**: Provides compile-time checks to ensure valid state.
/// - **Precision**: Uses 128-bit fixed-precision decimal for accurate calculations.
/// - **No Automatic Rounding**: Preserves all decimal places until explicitly rounded.
/// - **Zero-Cost**: `Copy` type with no heap allocations and currency metadata is zero-sized type.
///
/// # Conversion
///
/// - Convert from `Money` using [`Money::into_raw`]
/// - Convert to `Money` using [`RawMoney::finish`] (applies rounding)
///
/// # Where Rounding Happens
///
/// - [`BaseMoney::round`]: rounds using currency's minor unit (bankers rounding). Returns `RawMoney`.
/// - [`BaseMoney::round_with`]: rounds using custom decimal points and strategy. Returns `RawMoney`.
/// - [`RawMoney::finish`]: rounds to currency's minor unit using bankers rounding back to `Money`.
///
/// # Examples
///
/// ```
/// use moneylib::{Money, RawMoney, BaseMoney, macros::dec, iso::USD};
///
/// // Create RawMoney directly - no rounding
/// let raw = RawMoney::<USD>::new(dec!(100.567)).unwrap();
/// assert_eq!(raw.amount(), dec!(100.567));
///
/// // Convert from Money
/// let money = Money::<USD>::new(dec!(100.50)).unwrap();
/// let raw = money.into_raw();
/// assert_eq!(raw.amount(), dec!(100.50));
///
/// // Convert back to Money with rounding
/// let raw = RawMoney::<USD>::new(dec!(100.567)).unwrap();
/// let money = raw.finish();
/// assert_eq!(money.amount(), dec!(100.57));
/// ```
///
/// # See Also
///
/// - [`Money`] for automatically-rounded monetary values
/// - [`BaseMoney`] trait for core money operations and accessors
/// - [`BaseOps`] trait for arithmetic and comparison operations
/// - [`MoneyFormatter`] trait for custom formatting and rounding
#[derive(Copy, PartialEq, Eq)]
pub struct RawMoney<C: Currency> {
    amount: Decimal,
    _currency: PhantomData<C>,
}

impl<C> RawMoney<C>
where
    C: Currency,
{
    /// Creates a new `RawMoney` instance from Decimal without rounding.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, macros::dec, iso::USD};
    ///
    /// let raw = RawMoney::<USD>::from_decimal(dec!(123.309));
    /// assert_eq!(raw.amount(), dec!(123.309));
    /// ```
    #[inline]
    pub const fn from_decimal(amount: Decimal) -> Self {
        Self {
            amount,
            _currency: PhantomData,
        }
    }

    /// Creates a new `RawMoney` from minor amount i128 without rounding.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, macros::dec, iso::{USD, BHD, JPY}};
    ///
    /// // USD has 2 decimal places, so 12302 cents = $123.02
    /// let raw = RawMoney::<USD>::from_minor(12302).unwrap();
    /// assert_eq!(raw.amount(), dec!(123.02));
    ///
    /// // JPY has 0 decimal places
    /// let raw = RawMoney::<JPY>::from_minor(1000).unwrap();
    /// assert_eq!(raw.amount(), dec!(1000));
    ///
    /// // BHD has 3 decimal places
    /// let raw = RawMoney::<BHD>::from_minor(12345).unwrap();
    /// assert_eq!(raw.amount(), dec!(12.345));
    /// ```
    #[inline]
    pub fn from_minor(minor_amount: i128) -> Result<Self, MoneyError> {
        Ok(Self {
            amount: Decimal::from_i128(minor_amount)
                .ok_or(MoneyError::OverflowError)?
                .checked_div(
                    dec!(10)
                        .checked_powu(C::MINOR_UNIT.into())
                        .ok_or(MoneyError::OverflowError)?,
                )
                .ok_or(MoneyError::OverflowError)?,
            _currency: PhantomData,
        })
    }

    /// Converts this `RawMoney` to `Money`, applying rounding.
    ///
    /// Rounds the amount to the currency's minor unit precision using the
    /// bankers rounding rule, then returns a `Money` instance.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, macros::dec, iso::{USD, JPY, BHD}};
    ///
    /// let raw = RawMoney::<USD>::new(dec!(100.567)).unwrap();
    /// let money = raw.finish();
    /// assert_eq!(money.amount(), dec!(100.57));
    ///
    /// let raw_jpy = RawMoney::<JPY>::new(dec!(100.567)).unwrap();
    /// let money = raw_jpy.finish();
    /// assert_eq!(money.amount(), dec!(101));
    ///
    /// let raw_bhd = RawMoney::<BHD>::new(dec!(100.9999)).unwrap();
    /// let money = raw_bhd.finish();
    /// assert_eq!(money.amount(), dec!(101.000));
    /// ```
    #[inline]
    pub fn finish(self) -> Money<C> {
        Money::from_decimal(self.amount())
    }

    /// Parses a string in the format `"CCC amount"` (comma thousands separator and dot decimal separator).
    ///
    /// The format is `"CCC amount"` where `CCC` is a currency code (1-15 letters).
    ///
    /// For dot thousands separator format (e.g., `"EUR 1.234,56"`), use
    /// [`RawMoney::from_code_dot_thousands`] instead.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, macros::dec, iso::USD};
    /// use std::str::FromStr;
    ///
    /// let raw = RawMoney::<USD>::from_code_comma_thousands("USD 1,234.56789").unwrap();
    /// assert_eq!(raw.amount(), dec!(1234.56789));
    /// assert_eq!(raw.code(), "USD");
    ///
    /// assert!(RawMoney::<USD>::from_code_comma_thousands("EUR 100.00").is_err());
    /// ```
    pub fn from_code_comma_thousands(s: &str) -> Result<Self, MoneyError> {
        let s = s.trim();

        if let Some((currency_code, amount_str)) = parse_comma_thousands_separator(s) {
            if currency_code != C::CODE {
                return Err(MoneyError::CurrencyMismatchError(
                    currency_code.into(),
                    C::CODE.into(),
                ));
            }
            return Ok(Self::from_decimal(Decimal::from_str(&amount_str).map_err(
                |err| MoneyError::ParseStrError(err.to_string().into()),
            )?));
        }

        Err(MoneyError::ParseStrError(format!(
            "failed parsing {}, use format: <CODE> <AMOUNT> where <CODE> is defined and <AMOUNT> is comma-separated thousands(optional) and dot-separated decimal",
            s
        ).into()))
    }

    /// Creates a new `RawMoney` from a string with dot as the thousands separator
    /// and comma as the decimal separator (e.g., `"EUR 1.234,56"`).
    ///
    /// The format is `"CCC amount"` where `CCC` is a currency code (1-15 letters) and
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, iso::{EUR, USD}};
    ///
    /// let raw = RawMoney::<EUR>::from_code_dot_thousands("EUR 1.234,56").unwrap();
    /// assert_eq!(raw.code(), "EUR");
    ///
    /// assert!(RawMoney::<USD>::from_code_dot_thousands("EUR 1.234,56").is_err());
    /// ```
    pub fn from_code_dot_thousands(s: &str) -> Result<Self, MoneyError> {
        let s = s.trim();

        if let Some((currency_code, amount_str)) = parse_dot_thousands_separator(s) {
            if currency_code != C::CODE {
                return Err(MoneyError::CurrencyMismatchError(
                    currency_code.into(),
                    C::CODE.into(),
                ));
            }
            return Ok(Self::from_decimal(Decimal::from_str(&amount_str).map_err(
                |err| MoneyError::ParseStrError(err.to_string().into()),
            )?));
        }

        Err(MoneyError::ParseStrError(format!(
            "failed parsing {}, use format: <CODE> <AMOUNT> where <CODE> is defined and <AMOUNT> is dot-separated thousands(optional) and comma-separated decimal",
            s
        ).into()))
    }

    /// Parse from string with symbol, comma-separated thousands, dot-separated decimal, no rounding
    /// Example: $1,234.2249 into USD 1234.2249
    pub fn from_symbol_comma_thousands(s: &str) -> Result<Self, MoneyError> {
        let s = s.trim();

        if let Some((symbol, amount_str)) = parse_symbol_comma_thousands_separator::<C>(s) {
            if symbol != C::SYMBOL {
                return Err(MoneyError::CurrencyMismatchError(
                    symbol.into(),
                    C::SYMBOL.into(),
                ));
            }

            return Ok(Self::from_decimal(Decimal::from_str(&amount_str).map_err(
                |err| MoneyError::ParseStrError(err.to_string().into()),
            )?));
        }

        Err(MoneyError::ParseStrError(format!(
            "failed parsing {}, use format: <SYMBOL><AMOUNT> where <SYMBOL> is defined and <AMOUNT> is comma-separated thousands(optional) and dot-separated decimal",
            s
        ).into()))
    }

    /// Parse from string with symbol, dot-separated thousands, comma-separated decimal, no rounding
    /// Example: $1.234,2249 into USD 1234.2249
    pub fn from_symbol_dot_thousands(s: &str) -> Result<Self, MoneyError> {
        let s = s.trim();

        if let Some((symbol, amount_str)) = parse_symbol_dot_thousands_separator::<C>(s) {
            if symbol != C::SYMBOL {
                return Err(MoneyError::CurrencyMismatchError(
                    symbol.into(),
                    C::SYMBOL.into(),
                ));
            }

            return Ok(Self::from_decimal(Decimal::from_str(&amount_str).map_err(
                |err| MoneyError::ParseStrError(err.to_string().into()),
            )?));
        }

        Err(MoneyError::ParseStrError(format!(
            "failed parsing {}, use format: <SYMBOL><AMOUNT> where <SYMBOL> is defined and <AMOUNT> is dot-separated thousands(optional) and comma-separated decimal",
            s
        ).into()))
    }

    /// Parse from string with code, locale thousands and decimal separators.
    ///
    /// Code is space separated with amount.
    ///
    /// Currencies locale separators are from here: <https://docs.rs/currencylib>
    ///
    /// # Example
    /// ```
    /// use moneylib::{RawMoney, raw, iso::CHF, dec, BaseMoney};
    ///
    /// let money = RawMoney::<CHF>::from_code_locale_separator("CHF 1'123'456.2223").unwrap();
    /// assert_eq!(money.code(), "CHF");
    /// assert_eq!(money.symbol(), "â‚£");
    /// assert_eq!(money.amount(), dec!(1123456.2223));
    /// assert_eq!(money, raw!(CHF, 1123456.2223));
    /// ```
    pub fn from_code_locale_separator(s: &str) -> Result<Self, MoneyError> {
        let s = s.trim();

        if let Some((code, amount_str)) = parse_code_locale_separator::<C>(s) {
            if code != C::CODE {
                return Err(MoneyError::CurrencyMismatchError(
                    code.into(),
                    C::CODE.into(),
                ));
            }

            return Self::from_str(&amount_str)
                .map_err(|err| MoneyError::ParseStrError(err.to_string().into()));
        }

        Err(MoneyError::ParseStrError(format!(
            "failed parsing {}, use format: <CODE> <AMOUNT> where <CODE> is defined and <AMOUNT> is separated by locale separators",
            s
        ).into()))
    }

    /// Parse from string with symbol, locale thousands and decimal separators.
    ///
    /// There's no space between symbol and amount.
    ///
    /// Currencies locale separators are from here: <https://docs.rs/currencylib>
    ///
    /// # Example
    /// ```
    /// use moneylib::{RawMoney, raw, iso::CHF, dec, BaseMoney};
    ///
    /// let money = RawMoney::<CHF>::from_symbol_locale_separator("â‚£1'123'456.2223").unwrap();
    /// assert_eq!(money.code(), "CHF");
    /// assert_eq!(money.symbol(), "â‚£");
    /// assert_eq!(money.amount(), dec!(1123456.2223));
    /// assert_eq!(money, raw!(CHF, 1123456.2223));
    /// ```
    pub fn from_symbol_locale_separator(s: &str) -> Result<Self, MoneyError> {
        let s = s.trim();

        if let Some((symbol, amount_str)) = parse_symbol_locale_separator::<C>(s) {
            if symbol != C::SYMBOL {
                return Err(MoneyError::CurrencyMismatchError(
                    symbol.into(),
                    C::SYMBOL.into(),
                ));
            }

            return Self::from_str(&amount_str)
                .map_err(|err| MoneyError::ParseStrError(err.to_string().into()));
        }

        Err(MoneyError::ParseStrError(format!(
            "failed parsing {}, use format: <SYMBOL><AMOUNT> where <SYMBOL> is defined and <AMOUNT> is separated by locale separators",
            s
        ).into()))
    }
}

impl<C: Currency> Default for RawMoney<C> {
    /// Returns money with zero amount.
    fn default() -> Self {
        Self {
            amount: Decimal::default(),
            _currency: PhantomData,
        }
    }
}

impl<C: Currency> Ord for RawMoney<C>
where
    C: Currency + PartialEq + Eq,
{
    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
        self.amount.cmp(&other.amount)
    }
}

impl<C> PartialOrd for RawMoney<C>
where
    C: Currency + PartialEq + Eq,
{
    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
        Some(self.cmp(other))
    }
}

impl<C> Amount<C> for RawMoney<C>
where
    C: Currency,
{
    fn get_decimal(&self) -> Option<Decimal> {
        Some(self.amount())
    }
}

impl<C> FromStr for RawMoney<C>
where
    C: Currency,
{
    type Err = MoneyError;

    /// Parse money from string number.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{BaseMoney, RawMoney, iso::USD, raw, dec};
    /// use std::str::FromStr;
    ///
    /// let money = RawMoney::<USD>::from_str("12334.4439").unwrap();
    /// assert_eq!(money, raw!(USD, 12334.4439));
    /// assert_eq!(money.amount(), dec!(12334.4439));
    /// ```
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        let s = s.trim();
        let dec_num = Decimal::from_str(s).map_err(|err| {
            MoneyError::ParseStrError(format!("failed parsing money from string: {}", err).into())
        })?;
        Ok(Self::from_decimal(dec_num))
    }
}

impl<C: Currency> Clone for RawMoney<C> {
    fn clone(&self) -> Self {
        Self {
            amount: self.amount,
            _currency: PhantomData,
        }
    }
}

/// Formats `RawMoney` using the currency code and full decimal precision.
///
/// # Examples
///
/// ```
/// use moneylib::{RawMoney, macros::dec, iso::USD};
///
/// let raw = RawMoney::<USD>::from_decimal(dec!(1234.567));
/// assert_eq!(format!("{}", raw), "USD 1,234.567");
///
/// let raw = RawMoney::<USD>::from_decimal(dec!(-1234.56));
/// assert_eq!(format!("{}", raw), "USD -1,234.56");
/// ```
impl<C> Display for RawMoney<C>
where
    C: Currency,
{
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.display())
    }
}

impl<C> Debug for RawMoney<C>
where
    C: Currency,
{
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "RawMoney({}, {})", C::CODE, self.amount)
    }
}

impl<C: Currency> Sum for RawMoney<C> {
    /// Sum all moneys
    ///
    /// WARN: PANIC! if overflowed.
    fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
        iter.fold(RawMoney::default(), |acc, b| acc + b)
    }
}

impl<'a, C: Currency> Sum<&'a RawMoney<C>> for RawMoney<C> {
    /// Sum all moneys(borrowed)
    ///
    /// WARN: PANIC!!! if overflowed.
    fn sum<I: Iterator<Item = &'a RawMoney<C>>>(iter: I) -> Self {
        iter.fold(RawMoney::default(), |acc, b| acc + b.clone())
    }
}

impl<C> BaseMoney<C> for RawMoney<C>
where
    C: Currency,
{
    #[inline]
    fn new(amount: impl DecimalNumber) -> Result<Self, MoneyError> {
        Ok(Self {
            amount: amount.get_decimal().ok_or(MoneyError::OverflowError)?,
            _currency: PhantomData,
        })
    }

    #[inline]
    fn amount(&self) -> Decimal {
        self.amount
    }

    /// Rounds explicitly to the currency's minor unit using bankers rounding.
    ///
    /// Unlike `Money`, this must be called explicitly. Returns `RawMoney`.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, macros::dec, iso::USD};
    ///
    /// let raw = RawMoney::<USD>::from_decimal(dec!(100.567));
    /// let rounded = raw.round();
    /// assert_eq!(rounded.amount(), dec!(100.57));
    ///
    /// // round() returns RawMoney, not Money
    /// let rounded_again = rounded.round();
    /// assert_eq!(rounded_again.amount(), dec!(100.57));
    /// ```
    #[inline]
    fn round(self) -> Self {
        Self {
            amount: self.amount().round_dp(C::MINOR_UNIT.into()),
            _currency: PhantomData,
        }
    }

    #[inline]
    fn round_with(self, decimal_points: u32, strategy: crate::base::RoundingStrategy) -> Self {
        Self {
            amount: self
                .amount
                .round_dp_with_strategy(decimal_points, strategy.into()),
            _currency: PhantomData,
        }
    }

    #[inline]
    fn truncate(&self) -> Self {
        Self::from_decimal(self.amount.trunc())
    }

    #[inline]
    fn truncate_with(&self, scale: u32) -> Self {
        Self::from_decimal(self.amount.trunc_with_scale(scale))
    }

    /// Returns the money amount in its smallest unit, rounding as needed.
    ///
    /// Since minor amounts must be integers, this rounds the raw amount
    /// to the currency's minor unit precision before computing the minor amount.
    ///
    /// # Examples
    ///
    /// ```
    /// use moneylib::{RawMoney, BaseMoney, macros::dec, iso::USD};
    ///
    /// let raw = RawMoney::<USD>::from_decimal(dec!(123.45));
    /// assert_eq!(raw.minor_amount().unwrap(), 12345_i128);
    ///
    /// // Extra precision is rounded before computing minor amount
    /// let raw = RawMoney::<USD>::from_decimal(dec!(123.238533));
    /// assert_eq!(raw.minor_amount().unwrap(), 12324_i128);
    /// ```
    #[inline]
    fn minor_amount(&self) -> Result<i128, MoneyError> {
        self.amount()
            .round_dp(C::MINOR_UNIT.into())
            .checked_mul(
                dec!(10)
                    .checked_powu(C::MINOR_UNIT.into())
                    .ok_or(MoneyError::OverflowError)?,
            )
            .ok_or(MoneyError::OverflowError)?
            .to_i128()
            .ok_or(MoneyError::OverflowError)
    }
}

impl<C> BaseOps<C> for RawMoney<C>
where
    C: Currency,
{
    #[inline]
    fn abs(&self) -> Self {
        Self::from_decimal(self.amount.abs())
    }

    #[inline]
    fn checked_add<RHS>(&self, rhs: RHS) -> Option<Self>
    where
        RHS: Amount<C>,
    {
        Some(Self::from_decimal(
            self.amount.checked_add(rhs.get_decimal()?)?,
        ))
    }

    #[inline]
    fn checked_sub<RHS>(&self, rhs: RHS) -> Option<Self>
    where
        RHS: Amount<C>,
    {
        Some(Self::from_decimal(
            self.amount.checked_sub(rhs.get_decimal()?)?,
        ))
    }

    #[inline]
    fn checked_mul<RHS>(&self, rhs: RHS) -> Option<Self>
    where
        RHS: DecimalNumber,
    {
        Some(Self::from_decimal(
            self.amount.checked_mul(rhs.get_decimal()?)?,
        ))
    }

    #[inline]
    fn checked_div<RHS>(&self, rhs: RHS) -> Option<Self>
    where
        RHS: DecimalNumber,
    {
        Some(Self::from_decimal(
            self.amount.checked_div(rhs.get_decimal()?)?,
        ))
    }
}

impl<C> MoneyFormatter<C> for RawMoney<C> where C: Currency {}

#[cfg(feature = "accounting")]
impl<C> AccountingOps<C> for RawMoney<C> where C: Currency {}

impl<C> MoneyOps<C> for RawMoney<C> where C: Currency {}