Skip to content

Add Money (finance) #21

@vhrcgcom

Description

@vhrcgcom

Description

Implement Money as a ValueObject in the finance module.

Spec: Decimal amount + CurrencyCode; immutable arithmetic helpers

Implementation checklist

  • Create src/finance/money.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/finance/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions