Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.4.6, 4.5
-
Fix Version/s: 4.5
-
Component/s: CiviCRM API
-
Labels:
-
Documentation Required?:None
Description
Suppose I have an event with some associated price set, and I want to add a participant using the API. The price set has multiple price field values. For example:
civicrm_api(
'Participant',
'create',
array(
'version' => 3,
'contact_id' => 6537,
'event_id' => 47,
'participant_fee_level' => CRM_Core_DAO::VALUE_SEPARATOR.
"Deelnemer - 3".CRM_Core_DAO::VALUE_SEPARATOR.
"Begeleider - 3".CRM_Core_DAO::VALUE_SEPARATOR,
'participant_fee_amount' => 30,
'participant_fee_currency' => 'EUR',
'participant_status_id' => 1,
'participant_role_id' => 1,
'participant_register_date' => '2014-07-28',
));
The participant is created, with this line item:
---------------------------------------------------------------------------------------------------+
id | entity_table | entity_id | price_field_id | label | qty | unit_price | line_total |
---------------------------------------------------------------------------------------------------+
21 | civicrm_participant | 3388 | 24 | Deelnemer - 3Begeleider - 3 | 1 | 30.00 | 30.00 |
---------------------------------------------------------------------------------------------------+
I think this is incorrect. Two line items should be created, one for each price field value, like
-------------------------------------------------------------------------------+
id | entity_table | entity_id | price_field_id | label | qty | unit_price | line_total |
-------------------------------------------------------------------------------+
22 | civicrm_participant | 3389 | 24 | Deelnemer | 3 | 10.00 | 30.00 |
23 | civicrm_participant | 3389 | 25 | Begeleider | 3 | 5.00 | 15.00 |
-------------------------------------------------------------------------------+
I created a unit test and a possible fix. I will push a pull request in a moment, so that it can be reviewed.