On 17/07/13 09:24 +0200, Guillem Barba Domingo wrote: > 2013/7/15 Giedrius Slavinskas <[email protected]> > > > 2013/7/15 Guillem Barba Domingo <[email protected]> > > > >> Hi, related to the poll about bew methods in UoM instances, I found > >> confusing the names of parameters of compute_qty/price claamethods of UOM > >> (really, I think it's wrong). > >> > >> The signature is compute_qty(from_uom, qty, to_uom, round) > >> > > It is a good signature for a classmethod (basically a function). I don't > > see a benefit of changing something here. > > > >> But it does the next conversion: > >> "qty" of "to_UoM" => "from_UoM" > >> > > No, it converts in the oppositive way: "qty" of "from_uom" => "to_uom". > > > > My fault, the problem is not in compute_qty() method but in compute_price(). > > You can see an example in test0050uom_compute_price() [1] > The error is that, as well as in compute_qty() the 'factor' of 'from_uom' > is multiplied [2], in compute_price() it is divided [3]. The same for > 'rate' fields and 'to_uom' param. > > As the error is only in one method, the solution of simply swap the > parameter names (to mantain positional params) don't make sense, so the > method and tests must to be fixed and changed all modules that use it.
There is no mistake in this method.
It is perfectly normal that it does a different computation as
compute_qty (otherwise there will not be 2 methods).
The unittest must be read like this:
If the price is 100 per Kilogram, what is the price per Gram? 0.1.
--
Cédric Krier
B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/
pgpEorpmW803X.pgp
Description: PGP signature
