Conditionally tax products based on taxonomy (conditional actions?)

Project:Ubercart Contributions
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

Our client's store has some products that should be taxed, others that shouldn't. This is based on taxonomy terms.

The products are all of a single content type, and adding a second (untaxed) content type is not feasible within the timeframe (and shouldn't be necessary, IMO)

We would like to remove the taxes from items with certain taxonomy terms, but don't see a way to do it currently. The client is in Columbia and Books are not taxed, whilst other products are.

Writing a hook in a custom module would be preferred to hacking the tax module, but if hacking uc_taxes is the only way, then this will be done.

Could a conditional action hook be written that can remove the tax from individual products, or do conditional actions only operate on an 'order' level?

Any help or advice is much appreciated.

--Steve

Version: 
Ubercart 2.0-RC1
sblair's picture
Offline
Joined: 06/08/2009
Juice: 146
hook_taxable

I guess what I need is a new hook...

Maybe a hook could be created called something like this:
hook_taxable($node);
or
hook_product_taxable($product);

At the very least, we would need the node or product object passed into the hook.
Then, I could implement the hook in my own module that returns true or false. If any implementation returns false, then that node is untaxed.

At the moment, I've hacked a hook into uc_taxes (function uc_taxes_apply_item_tax), but I'm still having a bit of trouble with it.
On the checkout screen, the tax listed in the 'Order total preview' pane is correct, but at the top in the 'Cart contents' pane, the tax is still listed, when it should come out to zero.

This leads me to believe that not all tax calculations are run through uc_taxes_apply_item_tax. Is this correct?
To further complicate matters, we're using the uc_vat module to add vat/tax into the displayed product price.

I'll continue to hack at it, because this is a required feature.
Any other method for performing this operation would be most welcome. Custom tax module?? O_o

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
Hi sblair, I need to do
Assigned to:sblair» leonk

Hi sblair,

I need to do exactly the same. Have you come any further with this?

I've recently done quite a fair bit of tweaking on the discounts alternative module, and table quote module. Both of which offer price alterations to the order at checkout. I may be naive to say this, but I may be able to use these two modules as templates for a custom tax module.

sblair's picture
Offline
Joined: 06/08/2009
Juice: 146
uc_vat
Assigned to:leonk» sblair

I ended up using a customized uc_vat module.
Since I had to do a lot of customization to the way taxes are calculated and displayed all over the site, I wrote a little function called MYMODULE_taxable($node) that just returned true or false.
Then I ran my tax checker function in various places of the uc_vat module.

I wouldn't call it elegant, but I didn't have to hack any core modules to do it!

If you'd like details on what I did, let me know and I'll craft a diff.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
Hi, Yeah the diff would be
Assigned to:sblair» leonk

Hi,

Yeah the diff would be great if you could upload. Thanks!

SirAndrewDavis's picture
Offline
Joined: 01/07/2010
Juice: 45
Tax by product code
Assigned to:leonk» SirAndrewDavis

Something like this would be very helpful for UK/EU sites were many products are exempt from tax or have a different tax rate. Ideally, you could set conditions based on product name.

guykit's picture
Offline
Joined: 02/16/2010
Juice: 5
#6
Category:» feature request
Assigned to:SirAndrewDavis» Guest

I really need the ability to associate a product with a tax rate - this doesn't seem too difficult in principle to me (but then I'm completely ignorant about the inner workings of Ubercart!) but it is vital to it's use in the EU. This (simple?) change would make it B2B usable, along with a properly functioning uc_vat_number module!

Can anyone write a patch or something at least?

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#7

I've made two modules that work for applying tax for taxonomy terms, thanks to sblair for his help with these...

uc_taxonomy_tax
Works with uc_taxes only, i.e. does not work with uc_vat

uc_vat_with_taxonomy
This is a tweaked version of the uc_vat module, to be used instead of uc_vat.

Thanks
Leon

AttachmentSize
uc_taxonomy_tax.zip 3.7 KB
uc_vat_with_taxonomy.zip 10.12 KB
durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#8

leonk - Thanks for the modules, they work great! You are a life saver. There does seem to be a bug in chrome (v5.0.342.8 beta) however. The tax script continually loops and eventually just pegs out my CPU. In the resources tab you can see it just duplicating requests for /taxes/calculate and cart/checkout/lineitems. In the log for chrome this is what I see:

XHR finished loading: "http://server.com/site/?q=taxes/calculate".
XHR finished loading: "http://server.com/site/?q=cart/checkout/payment_details/credit".
XHR finished loading: "http://server.com/site/?q=taxes/calculate".
XHR finished loading: "http://server.com/site/?q=cart/checkout/line_items".
XHR finished loading: "http://server.com/site/?q=taxes/calculate".
XHR finished loading: "http://server.com/site/?q=cart/checkout/line_items".
XHR finished loading: "http://server.com/site/?q=taxes/calculate".
XHR finished loading: "http://server.com/site/?q=cart/checkout/line_items".
XHR finished loading: "http://server.com/site/?q=taxes/calculate".
XHR finished loading: "http://server.com/site/?q=cart/checkout/line_items".
XHR finished loading: "http://server.com/site/?q=taxes/calculate".
XHR finished loading: "http://server.com/site/?q=cart/checkout/line_items".
XHR finished loading: "http://server.com/site/?q=taxes/calculate".

Thanks again for all your work. You should toss this up on the drupal.org site!

EDIT: Update Chrome to 5.0.342.9 beta, same issue. Also checked it on Chrome 4.1.249.1045, same.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#9

Hi Durrok,

Thanks for letting me know about the problem.

It's something to do with the shipping line item (if you deselect it from being included in the tax rate the looping should stop). I'll look into fixing it tomorrow.

It's not browser specific either, there's a problem in the code somewhere.

leon

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#10

Leon-

Thanks for the quick response. I was only able to duplicate this issue in chrome and actually could only get it to happen on the windows version. I tried it on in IE6-8, Firefox, and Safari without any issues. Chrome on the Mac didn't have an issue with it either. Very weird.

EDIT: Might be worth noting I am currently only using uc_taxonomy_tax.

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#11

Leon-

It is also adding the tax twice to the total. On the checkout screen it is correct but on the review page it adds another line with another instance of the tax and adds it to the total.

orderpreview.png = Order preview page
orderreview.ong = Review page

AttachmentSize
orderpreview.png 116.08 KB
orderreview.png 71.08 KB
leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#12

Hey, I think I've managed to fix those issue. If you can please test and report any further ones.

The problem was being caused by sending through tax rate id's that were already being used by uc_taxes. The solution was to simply set a new unique id.

However, this means that the tax is sent through and treated as a different rate. So if you are taxing other line items than just product, uc_taxes will tax these, and then uc_taxonomy_tax will apply the tax again to the products (if they haven't already been taxed through uc_taxes product classes). The approach means that the tax rates appear separately, so you could have TAX appearing twice on the order review screen. A temporary solution would be to set up different rates and name them appropriately (e.g. Product tax, Shipping tax).

I did think about hijacking the tax rates from the uc_taxes module and move them to a new table. This would then allow uc_taxonomy_tax do all the work that uc_taxes is supposed to do (plus check for taxonomy rates), resulting in no clashes. However, this may not be a perfect approach, as other modules may rely on loading tax rates through uc_taxes_rate_load().

Thanks

Leon

AttachmentSize
uc_taxonomy_tax.zip 4.7 KB
zbylo's picture
Offline
Joined: 04/15/2010
Juice: 3
#13

Hello,

You forgot about "uc_taxonomy_tax_get_safe_id()" function.

zbylo

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#14

Ah yes, sorry about that, quick name change and this should be okay...

AttachmentSize
uc_taxonomy_tax.zip 5.45 KB
durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#15

Leon - Tested it out and it works great! Thanks for providing this!

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#16

Whoops, spoke a little too soon. If there are any taxable items on the order it is now taxing the entire order. Previously it was not doing this.

Taxonomy term specified

Check an order's billing State/Province:
State: CA

Check an order's products:
Order has any of these products, Order may have other products.

Previous version it would only tax those products, now it taxes the whole order if those items are present.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#17

Hey Durrock,

For me it only taxes the products, not the entire order.

One thing to point out is that it's not done through conditional actions (maybe should have specified this as the title of the thread could be misleading). CA can only apply conditions for the entire order ("Order has any of these products").
Taxonomy terms are assigned to tax rates through the tax rate edit screen, in admin/store/settings/taxes/

Let me know if that works.

Thanks
Leon

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#18

Two terms on the site, Gear and Shellfish. Set it to only tax Gear, no conditions, 9% tax:

3x Shellfish($15x3) on my order = $45, no tax.
3x Shellfish($15x3) & 1x Gear($20) = $65, $5.85 in tax... it should only be taxing the $20 of gear, not the $65 on the order total.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#19

Can you tell me your tax rate settings (taxed line items, product types etc). As I can't recreate this problem.

Thanks
Leon

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#20

There must be a reason why those products are being added to the taxed amount. I can't work it what it might be. It shouldn't really be anything to do with other products in the cart, as the module goes through each item separately.

Anyway, try this new much cleaner version I have made (the previous versions was full of some quite embarrassingly bad code).

New version will need a reinstall.

Thanks

Leon

AttachmentSize
uc_taxonomy_tax.zip 3.19 KB
durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#21

Leon- Same deal.

No conditions set, gear is the selected taxonomy term. If there is even one item belonging to gear it taxes everything. I'll try to step through the module to see if I can figure out what is going on.

EDIT: Well that didn't take long to find. Line 197
if (in_array($term->tid, $tax->taxonomy_terms) && !in_array($term->type, $tax->taxed_product_types) && isset($products_to_tax[$term->nid])) {

!in_array($term->type, $tax->taxed_product_types) being the important part. $tax->taxed_product_types is set to "products", which all of my items of course belong to. Therefore none of your code below that executes and (I'm assuming here) Drupal just applies the tax rate per normal to all the items. If I change !in_array to in_array the code just loops.

Any ideas?

EDITx2: It does configure the tax correctly btw if I change it to in_array instead of !in_array.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#22

Hey Durrok -- For me that's line 170, I'm using the most recent module posted on this page. Let me know if I should be using a dif version as this isn't currently working at all for me.

i.e. adding 1 item to the cart that is set to be NOT taxed @ /admin/store/settings/taxes is still showing tax during checkout.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#23

Wow I fixed my own issue for once.

Line 166 was reading

function _uc_taxonomy_tax_apply_tax($tax, $terms_to_tax, $products_to_tax) {

I removed the leading _ in the function name and it's now, of course, calling the function.

EDIT: It's not charging tax on anything now. I'll just sit tight until someone else posts back.

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#24

Sorry about that, swore I grabbed the right one... must have just overwritten the previous version. You are correct, your latest one is not working... it taxes everything. I am more concerned with the loop issue that is still occurring however.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#25

Is this what's looping for you?

foreach ($terms_to_tax as $term)

Can you post your module so I can try it? I need to get something in place ASAP that stops charging tax on some of my client's items.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#26

Durrock,

the line you removed
if (in_array($term->tid, $tax->taxonomy_terms) && !in_array($term->type, $tax->taxed_product_types( && isset($products_to_tax[$term->nid])) {
Needs to be there.

The reason for this is that the uc taxes module would have already applied the tax (so we dont add the tax twice). If you are taxing items with class product, all items in that class will be taxed (possibly the whole order). I could imagine removing that line would cause the ajax loop requests again.

Instead, leave all the product classes blank in your tax rate settings, and it should work (as it has done for me) as you expect.

EDIT: this should not be causing the looping ajax requests. They are caused when two or more tax rates with identical ids are applied to the order (the reason for the uc_taxonomy_tax_get_unique_id function). In the latest version I changed it so that the original id was sent through as part of the tax rate, and the new unique id was only used for the key in the order->line_items array. This allows old orders to keep original tax rates (in case they have since been changed), but I did not properly test this. I am away from my computer at the moment but will check this soon.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#27

leonk, is there a reason for the leading underscore in

<?php
function _uc_taxonomy_tax_apply_tax($tax, $terms_to_tax, $products_to_tax) {
?>

or was that a typo? The module doesn't appear to do anything with this important function disabled, but enabled the entire order is always taxed, even if I only have 1 product that is of my non-taxed taxonomy term. (this is becoming a tongue twister)

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#28

Leon - I did not remove a line but disregard what I said as it was for the previous version.
Instead, leave all the product classes blank in your tax rate settings, and it should work (as it has done for me) as you expect.
Can you please clarify how this should work? To my knowledge I should be creating a tax rate and selecting the taxonomy term(s) I wish to have taxed by that rate... correct?

CS - The leading underscore just makes it a private instead of a public function, it's not commented out. It's still called on line 142.

I'll be messing with it a bit more today, I'll let you know what I find.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#29

I see what you're saying Durrok. I guess when I removed the underscore it was being called by a hook rather than publicly, which caused the tax to start disappearing. I'll mess with this too and report back.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#30

Durrock, that is right. The underscore refers to a private function. Csdesignco, removing this underscore means the function will never be called (it is not a hook like you say, it definitely will not be called), the module would then be useless.

I think the confusion here is that you are expecting the tax rates to be applied to items of class/node type AND (&&) taxonomy term. Instead, it works OR (||) taxonomy term.

Look at it like this, we cannot change what the uc_taxes module does. So this will always apply tax to the classes you have selected (regardless of terms, as it does not know about the uc_taxonomy_tax module).
The uc_taxonomy_tax module adds a separate tax line item, only for the products found with certain terms (but without the classes that would have already been taxed by uc_taxes, otherwise theyd appear twice). I think it is just as useful this way, as being able to target specific taxonomy terms is always going to be more powerful than product types.

Instead, leave all the product classes blank in your tax rate settings, and it should work (as it has done for me) as you expect.
Can you please clarify how this should work? To my knowledge I should be creating a tax rate and selecting the taxonomy term(s) I wish to have taxed by that rate... correct?

Yes, create a tax rate, select taxonomy terms and classes that should be taxed. Just remember they are separate, and not part of the same rule.
I guess this is something that should be a lot clearer in the module. Or perhaps it would be better to separate taxonomy tax rates entirely from the uc_taxes rates.

Let me know how it goes. Like I said it works fine for me, so if youre still getting problems, tell me the tax rate settings you have.

Thanks
Leon

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#31

Does my last post make sense? Maybe the way I've explained it as a bit confusing.

Any questions let me know.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#32

I'm a bit confused.

you are expecting the tax rates to be applied to items of class/node type AND (&&) taxonomy term. Instead, it works OR (||) taxonomy term.

I'm not sure about this. I only have 1 node type (product) and have 5 terms assigned. Let's call them Red, White, Black, Blue, Green. I assign the tax rate to Red, White, Black & Blue. I add 1 Green item to my cart and no tax appears. I add 1 Red item to my cart and no tax appears. I add 1 Green and 1 Red to my cart and no tax appears. Have I done anything wrong up to this point?

Perhaps I need to follow this line more clearly: Yes, create a tax rate, select taxonomy terms and classes that should be taxed. Just remember they are separate, and not part of the same rule. Same rule?

Thank you very much for your clarification.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#33

Okay, I can see that this is maybe a bit frustrating, but I'm trying to help and what I really need from you is the tax rate settings (that I asked way back in post 19). As I'm still unable to replicate the problems reported, and am at the moment stabbing in the dark.

So your tax rate has...
no taxed product types,
no taxed line items
several taxonomy terms selected

And when you go through the checkout, under 'Order total preview' no tax appears at all (with items with matching terms in the cart)?
If this is correct, can you tell me using Firebug what ajax requests are made to http://www.yoursite.com/taxes/calculate and if there is any response.
Also, can you tell me if the tax appears if you select the 'Product' product type.

But yes, Yes, create a tax rate, select taxonomy terms and classes that should be taxed. Just remember they are separate, and not part of the same rule. Same rule?
I can see being a bit confusing. They are still part of the same tax rate rule, I was just trying to clarify that product classes/node types and taxonomy terms are separate when it comes to calculating the tax.

On another note, regarding the Chrome issue. Is anyone still getting this? I have recently switch to Chrome on Mac and am now getting similar problems on the checkout (although wasn't before). Although disabling this module doesn't solve the problem, so I think there's a separate issue with some incompatibility between Ubercart and Chrome.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#34

Leon -- you're the man, and I couldn't see the forest from the trees. As I was typing this out...

<strong>Tax rate settings</strong>
Name: Tax
Rate: 0.074
Taxed Products: Apply tax to any product regardless of its shipability. [checked]
Taxed product types: Product [checked]

... I re-read your line no taxed product types. I did indeed have "product" selected as a product type and I now understand what you were saying in your post above. Thanks for working me through this one. I am now having a new issue wherein the un-taxed item (gift cards, in my case) are now showing -$0.74 tax on the checkout page. This has to be a result of my applying "Discount" under Taxed line items. I will get this worked out somehow.

Maybe changing line 20 of the uc_taxonomy_tax.module to read:

<?php
'#description' => t('Select taxonomy terms for this tax rate. If any "Taxed product type" is selected above, it will override this setting. '),
?>

would help other poor confused souls like me.

An another note, there are other issues with Chrome and Ajax calls or javascript that I find elsewhere. For example, CK Finder isn't really compatible with Chrome. If you try and edit an image or media object in Chrome you lose the src of the object.

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#35

Leon-

I meant to make few notes on this and I am kicking myself for not but essentially here is what is happening:

Both tax functions are calling a set of triggers. So you have the tax module and it goes in and says "OK execute all modules that have the calculate tax hook". It fires off your function and queues up the normal tax function as well. Your function triggers the calculate tax hook again. Now it has the normal tax function and your tax function queued. The normal tax function calls the hook again and... on and on it goes.

I had to shelve it to finish up some client work. The easiest work around is to comment out the apply tax function in the taxes module and just use yours. Obviously not perfect but for the time being it works. As soon as I wrap up this client work I will dive back into the code. More then happy to test any code in the mean time.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#36

Durrock,

I'm not sure about this. There's nothing in the hook_calculate_taxes that would suggest invoking the hook again.
Besides, the looping issue has been fixed now. The problem was sending back tax rates with identical id's to what has already been sent back by the uc_taxes hook_calculate_tax (it's a requirement that hook_calculate_tax returns a unique id).

The Chrome issue I'm having is completely different, no ajax requests are being made whatsoever.

csdesignco

Very glad you got it working. One thing I can't work it is why no tax was being added when you had the product type selected in your tax rate (it should be that all products are taxed).
In terms of the line items, these are always calculated for the entire order. This is the same with uc_taxes. The discount line item is not associated with any product so it will always be taxed if it's selected.
However, taxing the discount line item should result in negative tax (assuming the discount is negative, which it should be). So the tax $0.74 on your order may well be coming from somewhere else (possibly another line item).

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#37

Taxing the discount line item only resulted in negative tax when I installed this module. Before I did that, the discount (like 10% off the entire order) was being applied properly. If unchecked, the discount was applied *after* tax which isn't really correct.

I disabled UC Discount Framework and switched to Ubercart Discount Alternative. Have you used this module? It's really fantastic, and now the whole discount/tax thing works flawlessly.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#38

Any taxing of line items is actually done by the uc_taxes module. The uc_taxonomy_tax only applies tax to products (it ignores the line items because it knows that uc_taxes will handle them). But yes, it calculates the tax without discounts being applied.

And yes, I have been using the uc discounts alternative moudule. I'm currently working on a patch that allows tiered discounts within the same rule: http://drupal.org/node/540080

Durrock, have you managed to get the module working? Or is it no longer required?

Thanks
Leon

durrok's picture
Offline
Joined: 04/08/2010
Juice: 22
#39

Leon - No luck, it just loops. As I mentioned I haven't had time to look into it further... for now just commenting out the uc_taxes_calculate_tax fixes it. The loop I am getting is definitely ajax related.

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#40

Okay, there's still something not right then.

Can you give me a breakdown of your tax rate, and what products are in your cart when you test this (including their terms and product types).

Also, is this happening in several browsers or just Chrome?

Thanks
Leon

kenjil's picture
Offline
Joined: 04/29/2010
Juice: 10
#41

Thanks Leon for your uc_taxonomy_tax module. Saved me a lot of time.
I added a very simple module settings page where one can choose on which vocabularies taxes depending on taxonomy will apply. This clarifies a lot the settings of taxes where only choosen vocabularies terms appears.
Kenji

AttachmentSize
uc_taxonomy_tax.zip 5.24 KB
leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#42

Thanks kenjil,

I've made a few amendments to your changes, and updated the module to make it clearer how taxes are calculated. So now product types/taxonomy terms are separated on the tax rate edit screen, and are hidden/shown using javascript. Being able to pick both was confusing.

I'm going to look into hosting this on Drupal contrib, particularly because I'd like some form of version control.
Thanks

AttachmentSize
uc_taxonomy_tax.zip 4.99 KB
kenjil's picture
Offline
Joined: 04/29/2010
Juice: 10
#43

Okay. Seems I have wrong habits with programming on Drupal. I learnt something about Drupal variable_get/set and system_settings_form ... Thanks. Kenji

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#44

The most recent module doesn't seem to be working right. Taxonomy is lost upon page save, or rather saving and going back to "edit" the tax rate loses all taxonomy terms previously selected and shows "product type" by default in the dropdown. Using Firefox 3.6.3.

Also, I didn't realize until my customer informed me, but the setting "taxed line items" seems to be ignored. If I check "Discount" to be added before applying this tax, the tax doesn't change. i.e.

Subtotal: $45.40
Total discount: -$4.54
Subtotal excluding taxes: $40.86
Tax (0.074): $3.36
Order total: $44.22

But in reality the tax on $40.86 is only $3.02.

Update: The discount is causing the ajax call to loop. This is what runs continually in firebug:

POST /taxes/calculate
POST /fee/calculate
POST /cart/checkout/line_items
POST /taxes/calculate
POST /fee/calculate
POST /cart/checkout/line_items

and over and over...

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#45

Hi csdesignco,

Thanks for spotting the ajax loop bug. It appears that there was still a further conflict between tax rate ids. This should be now 100% fixed in the latest attached version.

I forgot to mention, but the new versions need to be reinstalled (that is why the taxonomy terms were not being saved for you). I've also attached a separate .install file which includes an update function if you can't do a reinstall. (Just paste this over the .install file in the module and run update.php).

In terms of taxing line items, these should appear as a separate tax rate on the order. It's a bit complicated to explain, but basically uc_taxonomy_tax does not deal with any line items, it leaves uc_taxes to work them out separately.

So if you have the discount line item selected, you should get something like this appearing on your order summary...

Subtotal: £50.00
Total discount: -£5.00
Subtotal excluding taxes: £45.00
Tax (17.5%): -£0.88
Tax (17.5%): £1.75
Order total: £45.88

The first Tax rate is returned from uc_taxes (for the discount line item) and the second from uc_taxonomy_tax (for the products in the cart).

The reason why this happens is that before only the one module was dealing with the tax (uc_taxes), it could then work out total products + shipping - discount (if these were selected) and insert it into the order in one go. Now we have two modules working separately to calculate tax, so they have to be inserted separately into the order.

This should be happening for you as it does for me (I've copied the above order summary directly from my checkout page). Try this out with the new module and let me know how you get on.

Thanks again
Leon

AttachmentSize
uc_taxonomy_tax.install.with_update.zip 574 bytes
uc_taxonomy_tax.zip 5 KB
leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#46

Made a small error with renaming constants in the last upload. Fixed in new one...

csdesignco, does that make sense about the discount line item, and more importantly have you got it working?

AttachmentSize
uc_taxonomy_tax.zip 5 KB
csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#47

You got it leonk! Works like a charm. Disabled and uninstalled the module, then installed the new module you posted. Tax works itself out now via the additional negative tax line, and it all made sense the way you wrote it on paper too.

Thanks for your dedicated support throughout this entire thread. With all of the changes that have been made you def deserve some version control on this one. Are you looking to just post it here @ contributions or @ Drupal.org?

leonk's picture
Offline
Joined: 01/15/2010
Juice: 128
#48

Thanks csdesign...

I've put the module up on ubercart: http://www.ubercart.org/project_project/ubercart_taxonomy_tax
and I'm in the process of adding it to Drupal contrib.

For now any issues with the module can be posted on the ubercart contrib link.

csdesignco's picture
Offline
Joined: 02/10/2010
Juice: 230
#49

I hate to say it, but I've posted an issue on the contrib page. Seems like my tax is only being calculated on the last product (products before it are being ignored): http://www.ubercart.org/project_issue/overall_tax_only_being_calculated_...

Eynox's picture
Offline
Joined: 01/25/2011
Juice: 3
#50