Like i said in the main subject, adding product with dynamic price (included vat) handled with rules does not recalculate taxes.

I did a simple sample with kickstart:
Adjust the price of some product of type Top to enable "included vat"
And include a pricing rule to simply change the price to 100€

Rule:

{ "rules_another_price" : {
    "LABEL" : "Another price",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
    "ON" : { "commerce_product_calculate_sell_price" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "commerce-line-item" ],
          "type" : "commerce_line_item",
          "bundle" : { "value" : { "product" : "product" } }
        }
      },
      { "data_is" : {
          "data" : [ "commerce-line-item:commerce-product:type" ],
          "value" : "tops"
        }
      }
    ],
    "DO" : [
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : "10000",
          "component_name" : "base_price",
          "round_mode" : "1"
        }
      }
    ]
  }
}

Another consideration was to change de weight of the rules and flush the caches, but in my case was the same.
Taxes does not recalculate the modified price, any ideas?

CommentFileSizeAuthor
shoppingcart01.png88.03 KB7thkey

Comments

7thkey created an issue. See original summary.

7thkey’s picture

Issue summary: View changes
rszrama’s picture

Category: Bug report » Support request
Status: Active » Postponed (maintainer needs more info)

This is really just how the system works - including VAT in the purchase price means that calculation happens on product load, which precedes the sell price calculation process. Might be we need a better solution for this, but can you use the action to clear out included taxes first, adjust the price, and then re-apply tax?

7thkey’s picture

Thanks for the input @rszrama, finally found a solution like you said removing the included tax.

Something like this:

{ "rules_remove_vat" : {
    "LABEL" : "Remove VAT",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "1",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_line_item", "commerce_product_reference" ],
    "ON" : { "commerce_product_calculate_sell_price" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "commerce-line-item" ],
          "type" : "commerce_line_item",
          "bundle" : { "value" : { "product" : "product" } }
        }
      },
      { "data_is" : {
          "data" : [ "commerce-line-item:commerce-product:type" ],
          "value" : "product"
        }
      }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : {
            "type" : "commerce_price",
            "value" : [ "commerce-line-item:commerce-unit-price" ]
          },
          "PROVIDE" : { "variable_added" : { "unit_price" : "Added variable" } }
        }
      },
      { "data_calc" : {
          "USING" : { "input_1" : [ "unit-price:amount" ], "op" : "\/", "input_2" : "1.21" },
          "PROVIDE" : { "result" : { "unit_price_no_vat" : "Calculation result" } }
        }
      },
      { "commerce_line_item_unit_price_amount" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : [ "unit-price-no-vat" ],
          "component_name" : "base_price",
          "round_mode" : "1"
        }
      }
    ]
  }
}

The unit_price_no_vat removes 21% of VAT translated to 1.21

Next to it I have another rule adjusting the price and later the rule "Calculate taxes: VAT".
Hope this helps anyone having similar problem.