Trouble with editing contributions with multiple line items

Created on 28 September 2023, about 1 year ago
Updated 12 October 2023, about 1 year ago

Problem/Motivation

If a contribution created by webform_civicrm with a participant fee and additional line items is edited in civicrm, the total amount and tax amount is recalculated and will only include the participant fee, additional line items are ignored.

Steps to reproduce

  1. Create a webform including event registration with participant fee and contribution with at least one additional line item.
  2. Make a submission to generate a contribution with multiple line items.
  3. In civicrm access the contribution's edit form and save.

Proposed resolution

I don't know what the way forward is here. Firstly, civicrm core's contribution edit form submit handler will only fetch other civicrm_participant line items in this case, additional line items generated by webform_civicrm are civicrm_contribution line items. Secondly, if additional line items ARE civicrm_participant line items on the same entity, the core code will add them all to the $params array but seems to deliberately select only the first line item when setting total_amount and tax_amount. This is the behaviour when the price set is a quick config price set, as is the default price set used by webform_civicrm. If the price set is not quick config all goes well even when the line items have different entity types. Perhaps webform_civicrm needs a non quick config price set to use, but I can't imagine a good reason for civi core to not loop through all line items even if it is quick config? webform_civicrm is not the only module/extension that makes it possible to create multiple quick config line items.

🐛 Bug report
Status

Active

Version

5.8

Component

CiviCRM Data Handling

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @aiden-grau
  • 🇨🇦Canada karing 🇨🇦

    Have you tried adding Line Item Editor extension? Any time I've raised any issue w/ Core not handling (multiple) line items as expected, I've have been told to install Line Item Editor extension by JMA. I've been hesitant to do that as it contained CRM overrides (perhaps still does), but sometimes clients do need to be able to edit line items.

  • Yes we are using that extension, if a line item is edited or added it does its thing and gets the totals correct, but it doesn't change the behaviour when the contribution edit form is submitted. I've used custom code in a hook_civicrm_pre implementation to check and correct the totals, but that doesn't seem like the right solution here. I think ideally the civicrm code needs to be improved, either that or perhaps modules creating multiple line item contributions need to do things differently (e.g. not use quick config)?

  • 🇨🇦Canada karing 🇨🇦

    CiviCRM Core should definitely loop through all line items regardless of their entity types, and regardless of whether they are quick config or not.

Production build 0.71.5 2024