Looking into my Magento database inside the sales_flat_order
table, I find – since the day I updated from the 1.4 to the 1.5 version – the values of discount_amount
being negative (e.g. -5 EUR for a 5 EUR coupon code).
Before that date (in the database), all the discount_amount
values are positive (e.g. 5 EUR for a 5 EUR coupon code).
Now I'm puzzled. Does Magento by standard store positive or negative values into the sales_flat_order
table?
I assume that there should be a positive number in that field and the negative number has been introduced in error. However gaining some clarification through feedback by others would be great.
Additional notes:
- The database design itself allows to store both negative and positive values in that column.
- In the admin, orders with both a positive or negative
discount_amount
(andbase_discount_amount
) do behave exactly the same with the only difference having the number displayed as negative or positive. But negative numbers magically get multiplied by -1 in the calculation.
Best Answer
The discount amounts on the complete order are stored with negative amounts, but are stored positively against each item that they effect.
sales_flat_order
sales_flat_order_item
The negative values is stored against the table
sales_flat_quote_address
and then copied across to the tablesales_flat_order