It took me a while to debug this, even more because once I got to the ubercart code I then noticed that this module was overriding most callbacks around the logic.

Now because I looked at both codes this bug is both in your module and in ubercart, I guess I'll soon try to submit a patch to ubercart's queue as well.

The problem is that the logic uses to calculate the subtotal excluding tax in the line item is adding up all line items except tax and subtotal. This used to work fine until now but I just defined a line item with calculated => FALSE (as subtotal and total) and it only got added to the subtotal excluding tax line. The reason is that this property is not queried properly in the logic.

For reference, you can see uc_line_items_calculate().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hanoii’s picture

Attached is the patch.

hanoii’s picture

Title: subtotal excluding tax logic is wrong » subtotal excluding tax line item logic is wrong

cross-linking with the same ubercart's bug: #644840: subtotal excluding tax line item logic is wrong

hanoii’s picture

Status: Active » Needs review
hanoii’s picture

It's been a while, but I just had to review a bug I found on a site of my own and it was because of this patch. Basically the subtotal excluding ... line item was not being displayed because the $has_taxes variable was never being set because 'tax' line item has 'calculated' to FALSE, which is right.

Attached is a new patch with a revised logic, properly setting the $has_taxes variable and with the proper calculated logic, also I did clean up the code a little bit. Will update the ubercart patch as well.

jazzitup’s picture

FileSize
28.84 KB

The issue is still there. I've used your patch and the logic is still mixed up - take a look at the attached image.

Help:
Product price: 1,000.00 €
Shipping cost: 30.00 €
VAT: 23%
Discount per product: 50%

hanoii’s picture

What discount module are you using?

jazzitup’s picture

longwave’s picture

uc_discount is known to be currently incompatible with uc_vat, see #597992: Discount not reflected on total order (FIXED for Trigger: Calculate order discounts) and #677868: UC_VAT and UC_DISCOUNT compatibility problem - please discuss compatibility issues in those two threads, this is for a separate problem as far as I can see.

jazzitup’s picture

@longwave: Is there a workaround for this? Should we use http://drupal.org/project/uc_discounts_alt instead?

longwave’s picture

I don't think uc_discounts_alt works properly either, it does not take VAT into account at all at present - see #476348: Incompatible with Ubercart 2 VAT support

Discounts and VAT combined are a difficult problem to solve for a number of reasons, and I'm afraid I don't have any time to work on this at present.

hanoii’s picture

If your products are ALL affected by the same VAT rate you can try to use use uc_coupon.

The coupon will be applied to the subtotal of your products excluding vat and you can then apply vat to the Coupon line item which would end with a discount+vat.

@longwave, please correct me if I am wrong or I am missing something.

Although probably best to follow the discussion in the thread longwave pointed you to, so we don't populate this issue with comments that have nothing to do with it, I should have posted this one there... my bad.

longwave’s picture

Yes, uc_coupon should work as long as all your items have the same VAT rate and you apply VAT to the coupon line item. uc_fee and other modules that simply add line items to the order should also work in a similar fashion. Other discount modules are untested and probably unsupported at this time.

longwave’s picture

Status: Needs review » Fixed

@hanoii: Committed, thanks for your work - and apologies for taking so long to get around to reviewing it.

Status: Fixed » Closed (fixed)

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

ahimsauzi’s picture

Issue tags: +uc_coupon, +total, +rounding at checkout
FileSize
7.51 KB

Not sure if this should be reopened or if I am posting to the wrong thread so please accept my apology.

I have a similar issue with uc_coupon rounding to the next decimal point causing the total to be off by one penny.

I have a coupon that takes of 25% off. On some occasions, when the discounted amount reaches the rounding threshold, the total is off. For example, for a discount of -14.415, the discount is shown as 14.42 which is the correct rounding but when the order is totaled the rounding seems to go away leaving the total at +$0.01.

This sounds a bit confusing so please review the attached example:

Subtotal: $57.66
Shipping: $0.00
Coupon: $-14.42
Order: Total: $43.25 -> wrong amount should be 43.24

However, if I calculate the discount with out the rounding and round the total only I get the correct amount:

Subtotal: $57.66
Shipping: $0.00
Coupon: $-14.415 -> this amount gets passed to the order under admin/store/orders/ordernumber/edit but not to customer invoice or checkout pane.
Order: Total: $43.245 -> will be 43.25 after rounding = correct amount.

Anyone can help me figure out how to show the proper amount for the coupon in the checkout pane?

Thanks in advance,