Problem/Motivation

When an order discount line item is added, it does not get VAT.
Raising prio as this makes discounts (legally) unusable in VAT enabled shops.

Proposed resolution

What we need:
* If you use commerce_tax then a patch for commerce_discount: #2429595: Order discounts are not taken into account during tax calculation
* A rule like below

For reverse calculation

* commerce_vat: #2276233: Reverse calculation messes up price components on discount

For mixed vat rates

* commerce_vat: #2276331: Allow proportional vat calculation
* https://drupal.org/project/commerce_vat_proportional
* A rule like below

For giftcards (commerce_gc)

* A patch for https://drupal.org/project/commerce_vat_proportional in #2797207: Pass entity objects instead of wrappers
* A rule like below with the difference that the event is "Before saving a commerce line item" and there's an additional action "Set data value" which sets commerce_line_item:commerce_total:data value to commerce_line_item:commerce_unit_price:data.

Please review so we can get this in.

Rules

Simple vat (ups, only de-standard, international solution needed)

{ "rules_apply_discount_vat" : {
    "LABEL" : "Apply discount vat",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_vat", "commerce_discount" ],
    "ON" : { "commerce_discount_order_discount_line_item" : [] },
    "DO" : [
      { "commerce_vat_rate_apply" : {
          "USING" : {
            "commerce_line_item" : [ "commerce_line_item" ],
            "vat_rate_name" : "de_standard"
          },
          "PROVIDE" : { "applied_vat" : { "applied_vat" : "Applied vat" } }
        }
      }
    ]
  }
}

Proportional vat

{ "rules_add_proportional_vat_to_discount" : {
    "LABEL" : "Add proportional vat to discount",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_vat_proportional", "commerce_discount" ],
    "ON" : { "commerce_discount_order_discount_line_item" : [] },
    "DO" : [
      { "commerce_vat_proportional_apply" : { "commerce_line_item" : [ "commerce_line_item" ] } }
    ]
  }
}

Comments

geek-merlin’s picture

Title: Use order discount with VAT » [META] Use order discount with VAT
Issue summary: View changes

After a long day and night i think i got it, but it needs some fixes and improvements.

jamesfk’s picture

Hi Axel,

Thanks for all your work on this issue.

We have a B2C store in the UK and are seeing some strange VAT calculations after applying these patches and enabling the proportional vat module. Once a product discount is added, the vat display on the product page is wrong and on the cart page completely off.

Are there any additional configurational steps or rules that need to be adjusted to make all these patches work?

Many thanks,
James

geek-merlin’s picture

hi james,

you should care to check your vat application rules that you don't charge multiple vat (the rules advanced settings page has an option to debug. also with devel module you can debug the resulting price array in the vat rules!)

another idea i have: this is thoroughly tested and running in production with the "reverse calculation" option of the vat module (it's a bit hidden but you should find it). I can not imagine something breaks without that option but i did not test that. Maybe you want to try and report back.

With this info you should be able to track this down and report back exact information *where* those strange things happen.

;-)
axel

Mizpah’s picture

StatusFileSize
new102.68 KB

Hi folks,

Am currently testing this and running into some issues with unusual pricing - I can see if the pricing array is charging the vat twice, or if it is firing a second time to recalculate correctly?

The baseline (test) configuration is as follows:

A test product, priced at 8.33 (ex vat). UK VAT (20%).

This seems as expected (See Image 3) - However when we add a discount, things get a little funky (image 4):

If we add a 10% Discount (using the discount module) the price now goes up! Our 8.33 base product, is now showing as 11.63 (See Image 2). We are using a line item discount (using discount module) and 'formatted price' to display the line item value.
(Note: adding shipping complicates this still further).

The desire is to take the discount off the gross value, (10.00 becomes 9.00), and recalculate the proportional vat after discount. I actually want to modify the totals the customer sees to simply show subtotal, discount, shipping, new-total - all inc vat - but retain the ex-vat calculations for the invoice)

The summary totals are:

Line Items - £11.63 (should be £10.00, confused as to why this has increased!)

Subtotal - £8.33 (I would ideally show 9.00 (subtotal after discount) here, but the correct ex-vat subtotal would be £7.50 after discount?)
20% VAT - £3.30 (20% vat on 7.50, i.e. £1.50 would now be correct here?)
10% Off First Order - £0.83 (this is 10% off the ex-vat base price, am looking for 10% off the whole, this is correct net, but not gross)
Total - £10.80 (from a user perspective, they are expecting £9.00, (10% off the original £10.00, a £1.00 discount)

The rules evaluation log looks like this:

0 ms Reacting on event Calculating the sell price of a product.
5.294 ms Evaluating conditions of rule Calculate EC Supply VAT. [edit]
" Evaluating or Place of Supply is in United Kingdom. [edit]
11.819 ms The condition component_commerce_vat_place_of_supply_gb evaluated to TRUE [edit]
11.824 ms AND evaluated to FALSE.
11.883 ms Evaluating conditions of rule First Order Discount. [edit]
12.234 ms The condition commerce_product_contains_products evaluated to FALSE [edit]
12.241 ms AND evaluated to TRUE.
" Rule First Order Discount fires. [edit]
0 ms Rule First Order Discount fires.
0.08 ms Evaluating the action commerce_discount_percentage. [edit]
" Reacting on event Added an order discount.
0 ms Reacting on event Added an order discount.
0.155 ms Evaluating conditions of rule Add proportional VAT to discount. [edit]
0.162 ms AND evaluated to TRUE.
" Rule Add proportional VAT to discount fires. [edit]
0 ms Rule Add proportional VAT to discount fires.
0.067 ms Evaluating the action commerce_vat_proportional_apply. [edit]
1.239 ms Rule Add proportional VAT to discount has fired.
1.428 ms Finished reacting on event Added an order discount.
7.037 ms Rule First Order Discount has fired.
19.358 ms Evaluating conditions of rule Unset the price of disabled products in the cart. [edit]
19.496 ms The condition data_is_empty evaluated to FALSE [edit]
19.596 ms The condition entity_has_field evaluated to TRUE [edit]
20.105 ms The condition data_is evaluated to FALSE [edit]
20.112 ms AND evaluated to FALSE.
20.168 ms Evaluating conditions of rule Calculate VAT. [edit]
20.175 ms AND evaluated to TRUE.
" Rule Calculate VAT fires. [edit]
0 ms Rule Calculate VAT fires.
0.071 ms Evaluating the action commerce_vat_place_of_supply. [edit]
" Executing rule Calculate United Kingdom VAT. [edit]
0 ms Executing rule Calculate United Kingdom VAT.
0.153 ms Evaluating conditions of rule Calculate United Kingdom VAT. [edit]
" Evaluating or Place of Supply is in United Kingdom. [edit]
1.343 ms The condition component_commerce_vat_place_of_supply_gb evaluated to TRUE [edit]
1.348 ms AND evaluated to TRUE.
" Rule Calculate United Kingdom VAT fires. [edit]
10.59 ms Finished executing of rule Calculate United Kingdom VAT.
41.275 ms Rule Calculate VAT has fired.
61.474 ms Finished reacting on event Calculating the sell price of a product.
" Reacting on event Apply a discount to a given order.
" Reacting on event Before saving a commerce order.
" Reacting on event After updating an existing commerce order.
" Reacting on event Select available payment methods for an order.

Looking at the pricing array using this:

$line_item = commerce_line_item_load(1073);
dpm($line_item->commerce_unit_price[LANGUAGE_NONE][0]['data']['components']);

We get:

... (Array, 4 elements)

0 (Array, 3 elements)
name (String, 10 characters ) base_price
price (Array, 3 elements)
amount (String, 3 characters ) 833
currency_code (String, 3 characters ) GBP
data (Array, 2 elements)
included (Boolean) TRUE

1 (Array, 3 elements)
name (String, 28 characters ) discount|10% Off First Order
price (Array, 3 elements)
amount (Float) -83
currency_code (String, 3 characters ) GBP
data (Array, 2 elements)
included (Boolean) TRUE

2 (Array, 3 elements)
name (String, 23 characters ) vat|gb_standard|20_2011
price (Array, 3 elements)
amount (Float) 300
currency_code (String, 3 characters ) GBP
data (Array, 2 elements)
included (Boolean) TRUE

3 (Array, 3 elements)
name (String, 23 characters ) vat|gb_standard|20_2011
price (Array, 3 elements)
amount (Float) 210
currency_code (String, 3 characters ) GBP
data (Array, 2 elements)
included (Boolean) TRUE

Have spent a very long time trying to work this out, any help would be appreciated! I am using the current kickstarter (updated via pantheon), the devel versions of commerce_vat and commerce_discount and all the patches above are applied.

Cheers!

Mizpah’s picture

StatusFileSize
new63.11 KB

Comment to add image 4 referenced above.

Mizpah’s picture

Can anyone confirm if they have the same issue? Or conversely if it works for them on the current kickstarter release? Really need to get this resolved this week.

geek-merlin’s picture

hi martin, from the figures i'm quite sure that the problem is that vat is added twice!

HTH!

Mizpah’s picture

Hi Axel,

Actually sitting here chewing it over atm - I have come to the same conclusion, but I have not yet worked out why :P Does the rules reaction rules log data seem correct? I can confirm that this behaviour only occurs when the proportional vat rule is in play.

I am currently testing implementing everything from scratch in a new kickstarter2 install to see if I can replicate this, or if its down to a site specific config. Thanks again for the work on these needed UK updates.

geek-merlin’s picture

i'm horribly busy these days and my brain's in other things these days...
but i can remember that on the production site that i configured this, i only had order level discounts.

remember: order level discounts are the very reason proportional vat is needed.
any product level discount should be just applied.

i just checked that rules event commerce_discount_line_item should only fire on order discounts (where a discount line item is added, not only a discount price component) - if it's different, that's a bug.
i also checked that the provided proportional_vat rule fires on that very event.
You also said that it's an order discount, so OK.

To debug

To debug please use the devel module and use its debug rules action to print the price array after each step!
This will tell you where things go wrong.

PS: Please also check that the proportional-vat rule gets the correct (discount, not product) line item. I used percentage discounts as you do so it should work, but we never know.
If that's the problem, please report at that patch #2276335: Add discount postprocess hook so we have to amend.

Mizpah’s picture

Thanks Alex,

Have just got back from a family Birthday - I am seeing similar behaviour on a brand new Kickstarter site, where the vat rule is firing twice. Am going to create another test use case that covers everything and document it (Reverse calculation, 2 line items, 1 % order discount excluding shipping, 1 line item discount, shipping cost. Display of items 'inc vat' in the checkout, correct vat invoice production at end of process).

Will get every step documented alongside the rules array and the debug info. Also sending you a PM!

Frays’s picture

Hi,
Thanks for all yours work on this issue
Did you solve this issue with your brand new Kickstarter @Mizpah ?
I just want my product to have the correct taxe when they are discounted.
I try so many thing and I can't get it to work.
On kickstart v2 there is not the Commerce VAT module by default, do I need to install it to solve this issue?

Ante890’s picture

Thank you Alex

Have you tested this with fixed_amount discount that results in free orders ? It seems doesn't work properly.

geek-merlin’s picture

Issue summary: View changes

* re-rolled commerce_discount patch, splitting it up,
* changed commerce_vat_proportional dev accordingly,
* did some fixes to both.

There have been issues with patch and module, so please update before doing further tests.

F117’s picture

StatusFileSize
new186.34 KB
new80.8 KB

Is there any intentions to make this work with the native commerce_tax module?
I just made a vanilla install with latest modules (except rules 2.8..), where the problem exist. I also tried all dev-releases with no luck.

Depending on the weight of the discount rule I can get VAT or DISCOUNT right, but not both.. The final price calculated is correct though.
Example

maxplus’s picture

Hi Axel,
I started doing further testing and when working with order discounts ($ off) it works correct for me.

But when working with product discounts, suddenly the calculation goes wrong:
- the VAT amount on line item level gets a strange 41,77 % amount instead of the default 21%
- it does not matter if I use $off or %off, the discount is always resulting in $off

I'm also getting this warning:
"Warning: Illegal offset type in isset or empty in commerce_currency_load() (line 493 of /var/.../httpdocs/sites/all/modules/commerce/commerce.module)."

I will check if I'm working with all the latest patches and report back after testing.

geek-merlin’s picture

Fixed both commerce_discount patches - have fun!

maxplus’s picture

Thanks Axel,

after some testing today I found this problem:

1. When I apply a order discount: all OK
2. When I apply a product discount: all OK
3. When I apply both a order discount AND a product discount on THE SAME PRODUCT: VAT calculation is wrong
=> it looks like in that case both taxes are calculated and are added so we get some kind of a double tax...

cwarts’s picture

Thanks Axel :-)

Well, i confirm the Problem mentioned by maxplus above.

i think the discount is calculated from the line item price incl. Vat - while using % off discount.

Fixed amount off, seems to be correct.

F117’s picture

Hi again guys,
I've apllied both patch 2418033-2 and 2276335-8, but VAT is still displayed wrong (with product % off). :(
Are you using commerce_vat or commerce_tax?

geek-merlin’s picture

#17:

3. When I apply both a order discount AND a product discount on THE SAME PRODUCT: VAT calculation is wrong

wow. as they say "you won't get it foolproof as the fool has more phantasy"... (no offense! ;-)
you might use rules debug settings and devel to debug why...

Mantalo Conseil’s picture

People using Commerce Discount with Commerce Tax can find a way to solve it here : https://www.drupal.org/node/2429595

Enjoy!

periksson’s picture

Hi,

I think we need a rule where we calculate proportionality based on the line items including VAT. I think this is the rule used in Sweden.

Would this go into commerce_vat_proportional module?

geek-merlin’s picture

@nwpullman2 #22:
are you sure proportional vat must be calculated including vat? i can't believet his makes sense, but ok, vat rules are not required to make sense.
can you provide some evidence on that? best would be you open an issue against commerce_vat_proportioal module and link it here.

if there is some evidence this is needed me (as maintainer) is willing to include that feature.

geek-merlin’s picture

#21: thanks for linkint that. after a quick review i get the impression this is some interesting custom coding that does not have the potential for a generic solution.

F117’s picture

I don't want to sound rude, but why am I completely ignored?
Stating the issue persist with commerce_tax and asking for guidance isn't looked good upon.. apparently

periksson’s picture

@axel.rutz #23
Sorry, my mistake. I just called the tax office to get this sorted out (it only took an hour). The amounts are calculated excluding VAT applied on the discount excl. VAT if selling to corporations and applied reversely if the price is incl. VAT selling to consumers.

Case closed :-)

geek-merlin’s picture

@liquidize #19:
> Are you using commerce_vat or commerce_tax?

it's all about commerce_vat, see summary.

geek-merlin’s picture

@nwpullman2 #26:
all the better for your vat system ;-)

geek-merlin’s picture

@liquidize #14:
debugging vat rules is beyond the scope of this issue and may be handled in a separate support issue.
i may advise you to learn using rules debug mode and the devel debug rules action.

geek-merlin’s picture

Issue summary: View changes

Improved summary a lot to be a checklist for different needs.
Added rules exports so everyone can copy-paste them.

Please join the effort, test and on success set rtbc, so we can get this in.

caw67’s picture

pictures at #14 are correct. discount and coupon module doesnt work correct with tax module or vat (and eu vat) module! is ti a problem of the tax / vat module? or of the discount module? i dont know...

geek-merlin’s picture

Issue summary: View changes

Annotated rule in summary (not international yet)

caw67’s picture

not international?? but tax isnt international...

mglaman’s picture

Tagging for Commerce Sprint and marking for 1.0 release, to get working with VAT/tax.

geek-merlin’s picture

Feel free to PM me on this.

Scott Robertson’s picture

Status: Active » Closed (duplicate)
Related issues: +#2429595: Order discounts are not taken into account during tax calculation

Trying to clean up all these various issues that duplicates of one another.

Scott Robertson’s picture

Issue summary: View changes
Status: Closed (duplicate) » Active

Actually, will leave this open as it points to other issues as well. Just updating one of the issue links.

Pierre.G’s picture

Actually, the issue #2429595: Order discounts are not taken into account during tax calculation is about commerce_tax, not commerce_vat.

Please tell me if I misunderstood the problem, but here are my thoughts. Note that I'm working in REVERSE mode so for me, everything is based on the price including taxes because my store is mainly Business To Customer and not Business to Business (that's how it works in France and maybe in other countries).

For this workcase, the commerce_vat module is fine for the product_discount. It's working well with discounts.

You can enhance the display with this two hooks :

/*
 * Implements hook_commerce_price_component_type_info_alter().
 */
function MYMODULE_commerce_price_component_type_info_alter(&$component_types) {
  // Change the "Subtotal" label by a more explicit "Excluding taxes" label (in french : "Sous-total HT")
  $component_types['base_price']['display_title'] = t('Total (excl. taxes)');
}

/*
 * Implements hook_commerce_price_formatted_components_alter().
 */
function MYMODULE_commerce_price_formatted_components_alter(&$components, $price, $entity) {
  // Display the discount before displaying VAT
  // Don't know why, but before that, discount had a NULL weight.
  foreach ($components as $key => &$component) {
    if (strpos($key, 'discount|') !== false) {
      $component['weight'] = -10;
    }
  }
}

The VAT is calculated for each product, relatively to the discounts, and that's fine cause different products can have different VAT rates. The discounts and VATs are then added in the Order total calculation.

The problem is when we use an order_discount.
The VATs are not re-calculated. So they are wrong.

Two cases:

- When it's a percentage discount: just use a product discount. The result will be the same and as the VAT is calculated on products and not on order, it will work well.

- When it's a fixed discount: there's a problem and we need some improvements for this case. The VAT is already calculated and if we add a fixed discount on the order calculation, the VAT will not be updated.
Also, with a fixed discount amount and multiple TVAs rates, how do we decide how to reduce each TVA rate ?
My suggestion would be to calculate what percentage of the order total is the fixed discount and to apply this percentage to each VATs of the order total.

Any thoughts or suggestion ?

czigor’s picture

Issue summary: View changes
czigor’s picture

Issue summary: View changes

I use this with giftcards (commerce_gc) so I can't use the commerce_discount_order_discount_line_item rules event. The commerce_line_item presave event did the job with the following modifications:
1. Apply the patch in #2797207: Pass entity objects instead of wrappers.
2. Add a rules action to the rule that sets the commerce_line_item:commerce_total:data value to commerce_line_item:commerce_unit_price:data.

czigor’s picture

The above configuration also works for discount based order coupons, even for discount amounts greater then the order total. (Have not tested product discounts yet.)

We also don't get the negative order totals mentioned in #2429595: Order discounts are not taken into account during tax calculation but I think that issue is for commerce_tax, not for commerce_vat. So I'm not even sure I need the patch in #2429595: Order discounts are not taken into account during tax calculation.

czigor’s picture

czigor’s picture

Below is the working configuration we use (in a drush makefile format). Only the VAT-relevant patches are shown, there are some others that should be irrelevant.

With this we can use order discount coupons (commerce_discount + commerce_coupon modules) and giftcard coupons (commerce_gc module) in a way that they always decrease the VAT price component of the order total proportionally to the respective products' line item total price.

Applying a coupon with larger amount than the order total also yields the expected 0 VAT.

Also works with products with different VAT rates.

; Dev version because of https://www.drupal.org/node/2597566
projects[commerce_coupon][type] = module
projects[commerce_coupon][download][type] = git
projects[commerce_coupon][download][url] = http://git.drupal.org/project/commerce_coupon.git
projects[commerce_coupon][download][revision] = 5b2d5f46bf1445112c8b020b84027e92e00a0832

projects[commerce_discount][version] = "1.0-alpha8"
projects[commerce_discount][patch][] = https://www.drupal.org/files/issues/commerce_discount-2429595-32-vat.patch

projects[commerce_gc][version] = "1.0-rc1"
projects[commerce_gc][patch][] = https://www.drupal.org/files/issues/commerce_gc-2801405-2-vat-support.patch

projects[commerce_vat][version] = "1.0-rc2"
projects[commerce_vat][patch][] = https://www.drupal.org/files/issues/commerce_vat-2276233-10-reverse.patch
projects[commerce_vat][patch][] = https://www.drupal.org/files/issues/commerce_vat-2276331-1.patch

projects[commerce_vat_proportional][type] = module
projects[commerce_vat_proportional][download][type] = git
projects[commerce_vat_proportional][download][url] = https://git.drupal.org/project/commerce_vat_proportional.git
projects[commerce_vat_proportional][download][revision] = 3bf62f7463276d6a831674d45cdd6739640438d3
projects[commerce_vat_proportional][patch][] = https://www.drupal.org/files/issues/commerce_vat_proportional-2801451-2-fix_formula.patch
projects[commerce_vat_proportional][patch][] = https://www.drupal.org/files/issues/commerce_vat_proportional-2801467-2-giftcards.patch

Our rule export is:

{ "rules_my_discount_vat" : {
    "LABEL" : "My Discount VAT",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_vat_proportional", "entity" ],
    "ON" : { "commerce_line_item_presave" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "commerce-line-item" ],
          "type" : "commerce_line_item",
          "bundle" : { "value" : {
              "commerce_discount" : "commerce_discount",
              "giftcard_use" : "giftcard_use"
            }
          }
        }
      }
    ],
    "DO" : [
      { "commerce_vat_proportional_apply" : { "commerce_line_item" : [ "commerce_line_item" ] } },
      { "data_set" : {
          "data" : [ "commerce-line-item:commerce-total:data" ],
          "value" : [ "commerce-line-item:commerce-unit-price:data" ]
        }
      }
    ]
  }
}

(Note that it's using a different rules event and an additional data_set action.)

I don't dare to update the issue description yet, since there seems to be an unclear legal point in #2801451: Fix formula.

pontus.froden’s picture

comment #43 works for more but you don't need the patch for commerce_discount if you use the latest version (beta5 for the moment)

The only issue for me right now is that I have to refresh the page one extra time for the discount to be applied. But it could be something else on my page causing that one.

czigor’s picture

Our current working VAT+discounts+giftcards makefile is the following. (Not all patches are relevant.)

projects[commerce][version] = "1.14"
; Improve product loading in commerce_product_reference_entity_view() (https://www.drupal.org/node/2724647)
projects[commerce][patch][] = https://www.drupal.org/files/issues/commerce-2724647-improve-product-loading-30.patch

projects[commerce_ch_vat][version] = "1.0-rc1"
projects[commerce_ch_vat][patch][] = https://www.drupal.org/files/issues/commerce_ch_vat-2920600-vat2018-4.patch

projects[commerce_coupon][version] = "2.0"

projects[commerce_discount][version] = "1.0-beta5"
; Add currency support https://www.drupal.org/node/2345311
projects[commerce_discount][patch][] = https://www.drupal.org/files/issues/commerce_discount-2345311-13-currency.patch
projects[commerce_discount][patch][] = https://www.drupal.org/files/issues/commerce_discount-2429595-47_vat.patch

projects[commerce_eu_vat][version] = "2.4"

projects[commerce_gc][type] = module
projects[commerce_gc][download][type] = git
projects[commerce_gc][download][url] = http://git.drupal.org/project/commerce_gc.git
projects[commerce_gc][download][revision] = 44c09d387e83df7b25bf7be3c2e2f9e911da009b
projects[commerce_gc][patch][] = https://www.drupal.org/files/issues/commerce_gc-2650048-2-column.patch
projects[commerce_gc][patch][] = https://www.drupal.org/files/issues/commerce_gc-2801405-2-vat-support.patch
projects[commerce_gc][patch][] = https://www.drupal.org/files/issues/commerce_gc-2534226-5-multicurrency.patch
projects[commerce_gc][patch][] = https://www.drupal.org/files/issues/commerce_gc-gift_card_checkout_via_rules-2470557-13-7.x.patch
projects[commerce_gc][patch][] = https://www.drupal.org/files/issues/commerce_gc-2862812-2-preserve_gc_transactions.patch

projects[commerce_vat][version] = "1.0-rc2"
projects[commerce_vat][patch][] = https://www.drupal.org/files/issues/commerce_vat-2238545-2.patch
projects[commerce_vat][patch][] = https://www.drupal.org/files/issues/commerce_vat-place_of_supply-2567147-3.patch
projects[commerce_vat][patch][] = https://www.drupal.org/files/issues/commerce_vat-2276233-12-reverse.patch
projects[commerce_vat][patch][] = https://www.drupal.org/files/issues/commerce_vat-2276331-1.patch

projects[commerce_vat_proportional][type] = module
projects[commerce_vat_proportional][download][type] = git
projects[commerce_vat_proportional][download][url] = https://git.drupal.org/project/commerce_vat_proportional.git
projects[commerce_vat_proportional][download][revision] = 3bf62f7463276d6a831674d45cdd6739640438d3
projects[commerce_vat_proportional][patch][] = https://www.drupal.org/files/issues/commerce_vat_proportional-2801451-2-fix_formula.patch
projects[commerce_vat_proportional][patch][] = https://www.drupal.org/files/issues/commerce_vat_proportional-2801467-2-giftcards.patch

Our proportional VAT is applied on line item presave via rules:

{ "rules_my_discount_vat" : {
    "LABEL" : "MyDiscount VAT",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_vat_proportional", "entity" ],
    "ON" : { "commerce_line_item_presave" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "commerce-line-item" ],
          "type" : "commerce_line_item",
          "bundle" : { "value" : { "commerce_discount" : "commerce_discount" } }
        }
      }
    ],
    "DO" : [
      { "commerce_vat_proportional_apply" : { "commerce_line_item" : [ "commerce_line_item" ] } },
      { "data_set" : {
          "data" : [ "commerce-line-item:commerce-total:data" ],
          "value" : [ "commerce-line-item:commerce-unit-price:data" ]
        }
      }
    ]
  }
}
oturpin’s picture

Hello,
I intended to try this method, but after installing https://drupal.org/project/commerce_vat_proportional, I get a unknown event "commerce_discount_line_item" ?
Is there any incompatibility with discount 1.0B5-3 ?
Thx