Skip to content

Commit

Permalink
Fix missing financial_account_id for recurring contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Jul 24, 2023
1 parent 2ba54c4 commit 9cd8bfb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/WebformCivicrmPostProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -2340,10 +2340,9 @@ private function processContribution() {
if (empty($item['contribution_id'])) {
$item['contribution_id'] = $id;
}
$priceSetId = 'default_contribution_amount';

// Membership
if (!empty($item['membership_id'])) {
$priceSetId = 'default_membership_type_amount';
$item['entity_id'] = $item['membership_id'];
$lineItemArray = $this->utils->wf_civicrm_api('LineItem', 'get', [
'entity_table' => "civicrm_membership",
Expand All @@ -2359,13 +2358,19 @@ private function processContribution() {
if (!isset($firstLineItem['contribution_id'])) {
$item['id'] = $firstLineItem['id'];
}
$item['price_field_id'] = $firstLineItem['price_field_id'];
$item['price_field_value_id'] = $firstLineItem['price_field_value_id'];
}
}
$item['price_field_id'] = $this->utils->wf_civicrm_api('PriceField', 'get', [
'sequential' => 1,
'price_set_id' => $priceSetId,
'options' => ['limit' => 1],
])['id'] ?? NULL;
if (!isset($item['price_field_id'])) {
$priceFieldParams['where'][] = ['name', '=', 'contribution_amount'];
$priceFieldParams['where'][] = ['price_set_id.name', '=', 'default_contribution_amount'];
$item['price_field_id'] = $this->utils->wf_civicrm_api4('PriceField', 'get', $priceFieldParams, 0)['id'];

$priceFieldParams['where'][] = ['name', '=', 'contribution_amount'];
$priceFieldParams['where'][] = ['price_field_id', '=', $item['price_field_id']];
$item['price_field_value_id'] = $this->utils->wf_civicrm_api4('PriceField', 'get', $priceFieldParams, 0)['id'];
}

// Save the line_item
$line_result = $this->utils->wf_civicrm_api('line_item', 'create', $item);
Expand Down

0 comments on commit 9cd8bfb

Please sign in to comment.