mirumee / prices

Python price handling for humans.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiplication is allowed for different currencies

maiksprenger opened this issue · comments

I'm looking through your source code because I'm quite interested in the module. Good work!

I noticed that __mul__ is implemented without checking for currency though. If I'm not mistaken, that's a bug.

Why would you ever multiplicate a price by anything other than a scalar (int or decimal.Decimal)?

Don't really know what to say... I guess it happens for the same reasons humans make the other mistakes that prices protects against.

I mean I'd rather forbid multiplying price by price altogether, not check for matching currencies.

Indeed, sounds like a good place for an exception.

I'd be happy with either solution.

I'm trying to fix it but can't manage to multiplicate two Price objects. Can you provide a test case?

Hello Patryk,

like I said, I just looked at the source code and saw mul being
implemented. So I'm afraid I can't provide a test case.