Project:Ubercart Payment Method Adjustments
Version:6.x-1.0
Component:Miscellaneous
Category:bug report
Priority:major
Assigned:longwave
Status:reviewed & tested by the community

Issue Summary

Hi,
I'm experiencing some troubles at checkout and checkout review order.

I use pma and the tax module which applies 20% on total (subtotal+shipping+pma+etc).
On the checkout page everything is fine and the taxes are applied correctly on the total.
Unfortunately when I review the order (checkout/review) the tax is applied to everything but not the pma.
I also noticed if I push the button "back" and again "review order", taxes are applied correctly.

You can see this behaviour at www.bellearti.net/en/cart

Thank you for any advice

Patrizio

Comments

#1

I've got the same issue. Not sure, is the puzzle in Ubercart 2 VAT support module or in this one.

#2

I still have to solve this... the problem is that I have no idea where to begin.
Did you post a request on ubercart tax support?

#3

If anyone would like to try, I created a demo account on http://www.bellearti.net/en
user: demo
psw: demo

Many things are in Italian language, sorry for that

#4

Hi, I've opened an issue http://drupal.org/node/844722

#5

Does anyone else have this issue with PMA and Tax module?
I worked around studying code on both modules without any improvement...

#6

have a look here
http://www.ubercart.org/issue/3442/checkout_calculations_not_same_review...
(fix uc_pma.js , and comment how I think module should be changed)

#7

No, seriously, the problem is line_item for payment method is not set when taxes module apply taxes, I workaround this with this code in uc_pma.module (uc_pma_order func):

if ($adjustment['value'] && ($adjustment['value'] >= $min_adjust || $adjustment['value'] <= -$min_adjust)) {
        uc_order_line_item_add($arg1->order_id, 'payment_method', $adjustment['description'], $adjustment['value'], 3);
$setdone = FALSE; // workaround for taxes module
foreach($arg1->line_items as $i => $item) {
if($item['type']=='payment_method') {
$arg1->line_items[$i]['amount'] = $adjustment['value'];
$setdone = TRUE;
break;
}
}
if(!$setdone) {
$li = db_fetch_array(db_query("SELECT * FROM {uc_order_line_items} WHERE order_id=%d AND type='payment_method'",$arg1->order_id));
$arg1->line_items[]=$li;
}
}

this change $arg1 var, so when it is uc_taxes_order turn, it will find a line_items (there is something I do not like here, and I wonder why shipping module works correctly with taxes, while pma dont ...)

#8

I have also problems with pma + tax on the checkout page in payment pane. The payment adjustment is displayed but without taxes. On the total line in review page is everything correct with taxes.

payment_method_adjustment_description() has no mechanism to alter payment prices with taxes.

if (!strstr($adjustment, '%')) {

    ---->Here must be something to alter payment price to add taxes

    $adjustment = uc_currency_format(str_replace(variable_get('uc_currency_dec', '.'), ".", $adjustment));
}

Could someone help me how to get a price includng taxes?

#9

Category:support request» bug report
Priority:normal» major

I think it should be a bug issue because also of the other problems with pma + tax.

#10

I created the D5 version of this module, port to D6 was by Longwave. I'm not very familiar with the workings of this module on D6, but if someone has a clean patch that is tested and ready for commit, I will commit it. The patch in #7 scares me a bit and suggests that the fix doesn't need to happen in this module, but needs to happen in Tax code.

If someone is deeply invested in this module and wished to maintain the D6 branch, that would be fine too.

#11

I figured this problem out with my Recycling Fee module. Just set weight of the module (in "system" table) to something under zero (I set -2).
This caueses, that during review its function for store line_items called earlier that tax function and tax will be calculated corect.

#12

Assigned to:Anonymous» longwave
Status:active» needs review

There are two issues at play here. Firstly, uc_pma and uc_taxes both do their work in hook_order, so uc_pma's module weight must be lower than uc_taxes in order for tax to be calculated on the PMA line item. This problem will affect modules other than uc_pma, and is already noted at #603356: uc_taxes module's weight should be set heavier on install. The attached patch sets uc_pma's weight to -1 so it will run before uc_taxes.

Secondly, uc_pma does not update the $order object correctly during uc_pma_order. The patch in #7 would fix this, but in the attached patch I just put the line item data straight into the $order object using the data that is already available rather than hitting the database.

When testing the attached patch, please note you must run update.php to update the module weight.

@checker: yours is a slightly different issue that is only applicable when running uc_vat as well, however I think another issue should be opened for this, as it is more problematic to fix - the adjustment may not be taxed if the user is outside the EU, so we cannot just assume that the adjustment price should be taxed in all cases.

AttachmentSize
841348.patch 1.96 KB

#13

Updated patch attached, which includes support for uc_price() and can dynamically reload the adjustment descriptions during checkout. This handles cases where tax rules may apply to certain countries only, so the price can change depending on the user's country selection at checkout.

AttachmentSize
841348-2.patch 7.02 KB

#14

#15

yes! it works, I still have a problem with number format, I added $adjustment = str_replace(variable_get('uc_currency_dec', '.'), '.', $adjustment);
at line 233 of patched module ie. in function _payment_method_adjustment:

...
if (strstr($adjustment, '%')) {
$percent = TRUE;
$adjustment = str_replace('%', '', $adjustment);
$adjustment = str_replace(variable_get('uc_currency_dec', '.'), '.', $adjustment);
$adjustment /= 100;
}

and all work in Italy ;)

#16

Status:needs review» reviewed & tested by the community

The patch in #13 does what it says on the box. RTBC.

However it won't need the hook_update_N() function which lowers uc_pma's module weight as #603356: uc_taxes module's weight should be set heavier on install has been committed.