When we switched to storing prices as integers in the currency's minor unit and converting them to the major unit on display, I believe we left behind usability in some of our Rules actions / conditions. Whereas before you could enter a price amount for comparison in major unit, now it only works in minor unit (at least in some places). It would be nice to be able to input prices as an administrator would expect in the major unit as on other price forms.

Comments

rszrama’s picture

Category: bug » feature

This isn't technically a bug... changing designation. I'm also not sure if this is something we can fix in Commerce or if we'll need an assist upstream in Rules.

fago’s picture

Unrelated, maybe there should be a direct input form for the price data type? That way, users could insert prices using a certain currency. It makes using arbitrary integers as prices harder though - but that might be confusing due to the minor-units anyway.

rszrama’s picture

Ahh, I'd love to do this but haven't had time to research how. Is it a fairly simple thing to do?

Related issue for that is: #1189818: Ensure Rules actions and conditions support price amount data entry by major units

fago’s picture

yep, that shouldn't be hard. You just have to add your own "UI class" for the data type.

Examples can be found in rules itself, e.g. the input for formatted text, or in flag. See the UI class in http://drupalcode.org/project/flag.git/blob/refs/heads/7.x-2.x:/flag.rul... (you won't need custom data wrapper, just the ui class).

@related: That's the same issue? :)

rszrama’s picture

lol I'm such a goober. I thought you were posting this on one of the other issues you posted to Commerce. : P

acrazyanimal’s picture

This issue may be related to the problem I am having. It may be a rules issue as well. Anyway, when setting the value for a 'price' variable in rules, for which I want to use to change the line-item price as a discount, I have to add two extra decimal places. Infact if decimals are included they are ignored completely. So if I set the value to 650.00 what is saved is 6. If I set the value to 65000 then the value saved is 650. The currency being used is CAD.

rszrama’s picture

Yep, that's the same issue. One thing, though - just make sure you're using the action from the Commerce Line Item group and not "Set a data value" to apply your discount. We'll get this sorted out soon enough. : )

acrazyanimal’s picture

I've tried both ways and both seem to work and both have the same issue. However, I'm using the line item action since it actually involves the currency.

mitchell’s picture

I'm pretty sure you can mark this is a duplicate of #1479526: Action: modulus, ceiling, floor (rounding).

rszrama’s picture

That issue doesn't seem to have anything to do with this one. : ?

fp’s picture

I'm not sure if what I am seeing is related to this issue, but I seem to experience the reverse:

* I create a "Data comparison" condition for a rule
* I expect to be able to enter an integer (eg: 1500 for $15) for The value to compare the data with but the value I submit is converted to a float ($1500.00).

The issue with this is that I cannot used the greater / smaller than operators due to:

569     if (!RulesData::typesMatch($data_info, array('type' => array('decimal', 'date')))) {
570       $options =& $form['parameter']['op']['settings']['op']['#options'];        
571       unset($options['<'], $options['>']);                                       
572     }  

In rules/modules/data.rules

Update: I was using ommerce-line-item:commerce-total instead of ommerce-line-item:commerce-total:amount in my rule.