ascetic_ddd.seedwork.domain.values.money.sum

Classes

Sum(augend, addend)

Represents the sum of two monetary expressions.

class ascetic_ddd.seedwork.domain.values.money.sum.Sum(augend, addend)[source]

Bases: Expression

Represents the sum of two monetary expressions.

This class enables complex expressions like (5 USD + 10 CHF) + 20 EUR to be built up and then reduced to a single currency when needed.

Parameters:
augend : Expression

addend : Expression

reduce(bank, to)[source]

Reduce this Sum to a Money object in the target currency.

This reduces both operands to the target currency and adds them.

Parameters:
bank

The bank to use for currency conversion

to

The target currency code

Return type:

Money

Returns:

Money object representing the sum in the target currency

plus(addend)[source]

Add another expression to this Sum.

Parameters:
addend

The expression to add

Return type:

Expression

Returns:

A new Sum expression

times(multiplier)[source]

Multiply this Sum by a scalar.

This distributes the multiplication: (a + b) * n = a*n + b*n

Parameters:
multiplier

The multiplier

Return type:

Expression

Returns:

A new Sum expression with both operands multiplied