Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

CiviDiscount does not affect line item amounts #224

Closed
agileware-fj opened this issue Aug 5, 2019 · 8 comments
Closed

CiviDiscount does not affect line item amounts #224

agileware-fj opened this issue Aug 5, 2019 · 8 comments

Comments

@agileware-fj
Copy link

CiviDiscount does not affect line item amounts

Steps to reproduce:

  1. Set up a discount code to work with memberships
  2. Start an offline membership renewal
  3. Enter the discount code on the renewal form
  4. observe the amounts have been changed on the form
  5. submit the renewal
  6. observe the total amount of the resulting contribution is correct
  7. print an invoice for the contribution, or use some other method to check the line item amounts

Expected results:

  • The line item amount is adjusted for the discount
  • The total amount corresponds to the sum of the line items

Actual results:

  • The line item amount does not have the discount applied
  • There is no additional line item for the discount
  • The total amount has the discount applied, so is less than the sum of the lines.

I suspect this may be the results of hook_civicrm_buildAmount not actually being conferred to line items.

@agileware-fj
Copy link
Author

Agileware ref CIVICRM-1286

@agileware-fj
Copy link
Author

This may actually be a core issue, but seeing as cividiscount is the affected workflow, this seemed like a better place to start from.

@davejenx
Copy link

davejenx commented Aug 8, 2019

@agileware-fj I filed this core issue a few months ago: Incorrect line item created for back-end membership sign-up using price set and CiviDiscount. Do the conditions and symptoms fit? I was only able to replicate it in the specific conditions described there:

When doing a back-end membership sign-up using a price set, with an additional item e.g. donation and with a CiviDiscount code applying to the membership, the line item created for the membership does not reflect the discount but the contribution total does. The problem does not occur without the additional item.

I spent some time looking at it in a debugger and found that the price set was being instantiated twice, once with the discount, once without, causing the line items to be calculated without the discount. However if there was only one item, a different route through the code kicked in, overriding the line item amount.

I came up with a couple of approaches to fixing but they need more testing and review. I'm aiming to work on this a bit today/tomorrow, I'll update here with any progress & a link to a PR if I get that far.

Cheers,

Dave

@davejenx
Copy link

davejenx commented Aug 8, 2019

@agileware-fj Core PR created: civicrm/civicrm-core#14994 - would be great if you could test & review.

@davejenx
Copy link

davejenx commented Aug 9, 2019

@agileware-fj That PR had test failures, I'm going for an alternative approach: civicrm/civicrm-core#15004 - again would be great if you could test & review.

@JoeMurray
Copy link
Contributor

@Monish please monitor this thread and help push to complete and merge in coming days.

@agileware-fj
Copy link
Author

@davejenx sounds about right, except we didn't need to add an additional amount. Sound like this is most likely a core issue based on that, although seems like there are some opinions on your second PR's approach already.

@agileware-fj
Copy link
Author

After fix to dev/core#860 and some more extensive testing, I've determined that this is not a cividiscount issue. Closing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants