On Sep 19, 2006, at 5:36 AM, Jacopo Cappellato wrote:

David E Jones wrote:
On Sep 19, 2006, at 2:10 AM, Jacopo Cappellato wrote:
On the other hand, the "amount" (that is stored in the OrderItem.amountSelected field) is used as a multiplier for the unit price: if a product (with require amount = Y) has a unit price of 2$ (ProductPrice) and you select an amount of 100 then the new unit price (in the cart/order) is 200; the "amount" will not affect in any way the quantity issued from inventory that is always the OrderItem.quantity field.
Is this correct?
I think this is correct, but unfortunately it is also a bug... The amount really should be multiplied by the quantity in order to get the total to deduct from inventory and so on.
Hmmm... but in this way we could have non integer inventory quantities
(since the amount value can be a non integer value)... do we really want
this to happen?

I think that non-integer inventory quantities are okay, and for some products they are necessary. In fact, is there any way to avoid this quite a few manufacturing materials like rope, wire, glue, paint/ lacquer, and so on?

PS: This makes me think that the amount multiplier has some potential and could be used also to express small unit prices (amount = 0.0001)... but the problem is that the new unitPrice is stored in the OrderItem.unitPrice field that has limited precision... maybe we should store there the original unit price and just get the order item total as: OrderItem.quantity * OrderItem.amountSelected * OrderItem.unitPrice
Isn't it done this way already, ie calculating the order item subtotal this way?
Not exactly in this way.
For example: if I order an item with original unit price of 15.99, quantity = 2 and amount = 1.5, in the OrderItem entity the following values are stored:

quantity = 2
selectedAmount = 1.5
unitPrice = 23.98 (!!! This is the result of 1.5 * 15.99 = 23.985)

and the order item subtotal is (correctly) calculated multiplying the quantity and the unitPrice: 47.96

Maybe we should instead store in the OrderItem:

quantity = 2
selectedAmount = 1.5
unitPrice = 15.99

and the order item subtotal should be calculated multiplying the quantity, the unitPrice and the selected amount: 2 * 1.5 * 15.99 = 47.97 But then the selectedAmount should be displayed in all the order view screens.
Should we try to clean/fix this?
If so, I could put some effort in this but first I'd like to be sure to understand the intended use of the amount field.

This is interesting, and a little scary... ;)

I've never actually looked into this in detail as Andy is the one who implemented it. I don't think I like this implementation decision though, so unless someone sees a reason why it would be better this way I think we should change it. I _can_ think of a couple of reasons why it is worse: it is not very intuitive, and it could lead to inaccurate price calculations.

-David

Reply via email to