Skip to content

Commit

Permalink
Sync financial type if contribution has only one line item.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfb committed Feb 13, 2020
1 parent ffff218 commit aa81b84
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CRM/Lineitemedit/Form/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ public function submit($values, $isTest = FALSE) {
$lineItem = CRM_Price_BAO_LineItem::create($params);
$lineItem = $lineItem->toArray();

// Sync financial type if contribution has only one line item.
if ($values['financial_type_id'] != $this->_lineitemInfo['financial_type_id'] && civicrm_api3('LineItem', 'getcount', ['contribution_id' => $this->_lineitemInfo['contribution_id']]) < 2) {
civicrm_api3('Contribution', 'create', ['financial_type_id' => $values['financial_type_id'], 'id' => $this->_lineitemInfo['contribution_id']]);
}

// calculate balance, tax and paidamount later used to adjust transaction
$updatedAmount = CRM_Price_BAO_LineItem::getLineTotal($this->_lineitemInfo['contribution_id']);
$taxAmount = CRM_Lineitemedit_Util::getTaxAmountTotalFromContributionID($this->_lineitemInfo['contribution_id']);
Expand Down

0 comments on commit aa81b84

Please sign in to comment.