Hey!
I use ubercart rc7 with VAT rc7. When I enabled the VAT module, everything was fine, but then... try out the views bulk operation, messed up the prices of the modified nodes. Ok I put aside that module. Yesterday I modified every node prop at Node Bulk Operations page (admin/content/node) and voala, prices changed everywhere. Ok lets debug. The change always decrease the price by the value of TAX.

In my case, I use 5% tax on every item. Lets see one:

Book costs 10euro
TAX on books is 5% = 0.5euro
Book costs without TAX: 9.5euro, stored value in the database.

after bulk operations, the stored item decrease 5% (not with "0.5euro", but (9.5-9.5*.5) = 0.475euro)

Then I disabled the VAT module, tried out node bulk operations and worked like excepted.

so what could be the problem?

mafe

CommentFileSizeAuthor
#5 uc_vat-mass-operation.patch2.29 KBmhrabovcin

Comments

mafe’s picture

ok here is a little fix:
...not with "0.5euro", but with (9.5*0.05)= 0.475euro... I overlooked the above math problem:)

longwave’s picture

I think this must be some interaction with hook_nodeapi in Views Bulk Operations, which is where uc_vat does the work to add or remove VAT as necessary for the product edit pages. I don't use VBO so I hadn't come across this before, but sounds like I will have to move the affected code out of hook_nodeapi and into hook_form_alter instead. Will keep this in mind when I work on adding further price field support to uc_vat.

mafe’s picture

OK, waiting for it:)
By the way, it is the same with node bulk operations, right? If I want to mass change nodes at admin/content/node, I can't do it right now because of this. E.g published or not published and so on...

mhrabovcin’s picture

The problem is that views_bulk_operations doesn't show node to editing form thus hook_nodeapi('prepare') (place where recalculation is done) is never fired. It loads node with node_load so only hook_nodeapi('load') is fired. On the other hand node_save fires the hook_nodeapi('presave').

It doesn't happen only on VBO but also on normal core mass update operations (like publishing, unpublishing nodes)

So when bulk operation runs on multiple nodes it loads nodes and price is without vat. on node save price is recalculated as it contains vat. Should be price calculation moved to $op = 'load' ?

mhrabovcin’s picture

StatusFileSize
new2.29 KB

moving price recalculation was bad idea. I've created patch that is working for me.

longwave’s picture

Status: Active » Fixed

Fix committed to CVS that removes hook_nodeapi entirely and replaces it with hook_form_alter and a submit callback to modify the prices on product node forms. I now want to try and make this even more generic so it can be used for price fields provided by other modules, if possible.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.