mirumee / prices

Python price handling for humans.
Other
268 stars 39 forks source link

Multiplication is allowed for different currencies #2

Closed maiksprenger closed 11 years ago

maiksprenger commented 11 years ago

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.

patrys commented 11 years ago

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

maiksprenger commented 11 years ago

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

patrys commented 11 years ago

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

mirekm commented 11 years ago

Indeed, sounds like a good place for an exception.

maiksprenger commented 11 years ago

I'd be happy with either solution.

patrys commented 11 years ago

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

maiksprenger commented 11 years ago

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.