Description
Implement Money as a ValueObject in the finance module.
Spec: Decimal amount + CurrencyCode; immutable arithmetic helpers
Implementation checklist
Implementation detail
Input / Output
Money is a composite value object.
|
Type |
| Input |
MoneyInput { amount: rust_decimal::Decimal, currency: CurrencyCode } |
| Output |
String — e.g. "10.00 EUR" |
Validation
amount may be any finite Decimal value (negative amounts are allowed — they represent debts).
currency must already be a valid CurrencyCode (validated on construction of that type).
Extra methods
amount() -> &rust_decimal::Decimal
currency() -> &CurrencyCode
Notes
Arithmetic helpers (add, subtract, convert) are out of scope for this type — Money is a validated, immutable record, not a calculator. Use rust_decimal directly on amount() if you need math.
References
Description
Implement
Moneyas aValueObjectin thefinancemodule.Spec:
Decimalamount +CurrencyCode; immutable arithmetic helpersImplementation checklist
src/finance/money.rsValueObjecttrait#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]src/finance/mod.rsandprelude# ExampleblockROADMAP.mdfrom ⬜ to ✅Implementation detail
Input / Output
Moneyis a composite value object.MoneyInput { amount: rust_decimal::Decimal, currency: CurrencyCode }String— e.g."10.00 EUR"Validation
amountmay be any finiteDecimalvalue (negative amounts are allowed — they represent debts).currencymust already be a validCurrencyCode(validated on construction of that type).Extra methods
amount() -> &rust_decimal::Decimalcurrency() -> &CurrencyCodeNotes
Arithmetic helpers (add, subtract, convert) are out of scope for this type —
Moneyis a validated, immutable record, not a calculator. Userust_decimaldirectly onamount()if you need math.References