Skip to content

Commit

Permalink
Merge pull request #200 from compucorp/civiplmmi-189-add-contribution…
Browse files Browse the repository at this point in the history
…-clause

CIVIPLMMI-189: Add Contribution Clause To Line Item Update Hook And Upgrader
  • Loading branch information
shahrukh-compuco authored Oct 3, 2024
2 parents d5a6db2 + 382976f commit bfaf0cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CRM/Financeextras/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public function upgrade_1003() {
->addValue('price_field_id', $priceField['id'])
->addValue('price_field_value_id', $priceFieldValueID)
->addClause('OR', ['price_field_id', 'IS NULL'], ['price_field_value_id', 'IS NULL'])
->addWhere('contribution_id', 'IS NOT NULL')
->execute();

return TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ private function updatePriceFieldValues(): void {
$record = (array) $this->objectRef;

if ($this->objectName !== 'LineItem' || !in_array($this->op, ['create', 'edit'])
|| ((!in_array($record['price_field_id'], [NULL, 'null'])) && (!in_array($record['price_field_value_id'], [NULL, 'null'])))) {
|| (!in_array($record['price_field_id'], [NULL, 'null']) && !in_array($record['price_field_value_id'], [NULL, 'null']))
|| in_array($record['contribution_id'], [NULL, 'null'])) {
return;
}

$priceSetId = \CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name');
$priceSet = current(\CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$priceSet = current(\CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$priceField = NULL;
$priceField = NULL;
foreach ($priceSet['fields'] as $field) {
if ($field['name'] == 'contribution_amount') {
$priceField = $field;
Expand Down

0 comments on commit bfaf0cb

Please sign in to comment.