ascetic_ddd.seedwork.domain.values.money.money

Classes

IMoneyExporter()

Money(amount, currency)

Represents a monetary amount in a specific currency.

class ascetic_ddd.seedwork.domain.values.money.money.Money(amount, currency)[source]

Bases: Expression

Represents a monetary amount in a specific currency.

This is the fundamental class in the Money pattern, representing an amount with its associated currency.

Parameters:
amount : int

currency : Currency

property amount : int

Get the amount.

currency()[source]

Get the currency code.

Return type:

str

static dollar(amount)[source]

Create a Money object in USD.

Return type:

Money

Parameters:
amount : int

times(multiplier)[source]

Multiply this Money by a scalar.

Parameters:
multiplier

The multiplier

Return type:

Expression

Returns:

A new Money object with the multiplied amount

plus(addend)[source]

Add another expression to this Money.

Parameters:
addend

The expression to add

Return type:

Expression

Returns:

A Sum expression representing the addition

reduce(bank, to)[source]

Reduce this Money to the target currency.

Parameters:
bank

The bank to use for currency conversion

to

The target currency code

Return type:

Money

Returns:

Money object in the target currency

export(exporter)[source]
Return type:

None

Parameters:
exporter : IMoneyExporter

class ascetic_ddd.seedwork.domain.values.money.money.IMoneyExporter[source]

Bases: object

set_amount(value)[source]
Return type:

None

Parameters:
value : int

set_currency(value)[source]
Return type:

None

Parameters:
value : Currency