My goal is to have commerce calculate the tax and always round up to the penny.

I'm trying to use "Convert data type" in my conditional state tax rule. The taxes are still calculated and applied as though no rounding has occurred. I've tried a few variations on this with the same results.

{ "commerce_tax_rate_ca_sales_tax" : {
"LABEL" : "Calculate CA Sales Tax",
"PLUGIN" : "rule",
"REQUIRES" : [ "commerce_order", "rules", "commerce_tax" ],
"USES VARIABLES" : { "commerce_line_item" : { "label" : "Line item", "type" : "commerce_line_item" } },
"IF" : [
{ "commerce_order_compare_address" : {
"commerce_order" : [ "commerce-line-item:order" ],
"address_field" : "commerce_customer_shipping|commerce_customer_address",
"address_component" : "administrative_area",
"value" : "CA"
}
},
{ "entity_has_field" : { "entity" : [ "commerce-line-item" ], "field" : "commerce_product" } },
{ "entity_has_field" : {
"entity" : [ "commerce-line-item:commerce-product" ],
"field" : "field_taxable"
}
},
{ "data_is" : {
"data" : [ "commerce-line-item:commerce-product:field-taxable" ],
"value" : 1
}
}
],
"DO" : [
{ "commerce_tax_rate_apply" : {
"USING" : {
"commerce_line_item" : [ "commerce-line-item" ],
"tax_rate_name" : "ca_sales_tax"
},
"PROVIDE" : { "applied_tax" : { "applied_tax" : "Applied tax" } }
}
},
{ "data_convert" : {
"USING" : {
"type" : "integer",
"value" : [ "applied-tax:amount" ],
"rounding_behavior" : "up"
},
"PROVIDE" : { "conversion_result" : { "conversion_result" : "Conversion result" } }
}
}
]
}
}

Comments

TR’s picture

Project: Rules » Commerce Core
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: Rules Core » Rules integration

Your conditions and actions are all specific to Commerce, and this rule depends on the internal details of Commerce entities and fields, so this is probably best handled in the Commerce issue queue.

If you conclude that "Convert data type" (a core Rules Action) isn't working properly, then please provide an export of a Rule that uses only core Rules events, conditions, and actions and that demonstrates the problem. Rules does have test cases to test the operation of this action, and these test case are all working. But not all possibilities are testes, so if there is a problem it would be useful to post a test case that demonstrates the problem.

bojanz’s picture

Status: Active » Closed (outdated)

This issue is 6 years old.

If a problem persists, open a new issue.
http://drupal.stackexchange.com/ is also a good place to look for support, and search for previous answers.