$this->processContribution($params);
}
elseif ($this->_batchInfo['type_id'] == $batchTypes['Membership']) {
- $this->processMembership($params);
+ $params['actualBatchTotal'] = $this->processMembership($params);
}
// update batch to close status
//process premiums
if (!empty($value['product_name'])) {
if ($value['product_name'][0] > 0) {
- list($products, $options) = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
+ [$products, $options] = CRM_Contribute_BAO_Premium::getPremiumProductInfo();
$value['hidden_Premium'] = 1;
$value['product_option'] = CRM_Utils_Array::value(
* Process membership records.
*
* @param array $params
- * Associated array of submitted values.
+ * Array of submitted values.
*
+ * @return float
+ * batch total monetary amount.
*
- * @return bool
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- private function processMembership(&$params) {
-
+ private function processMembership(array $params) {
+ $batchTotal = 0;
// get the price set associated with offline membership
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
$value['total_amount'] = (float) $value['total_amount'];
}
- $params['actualBatchTotal'] += $value['total_amount'];
+ $batchTotal += $value['total_amount'];
unset($value['financial_type']);
unset($value['payment_instrument']);
}
}
}
- return TRUE;
+ return $batchTotal;
}
/**
$form->_fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::VIEW);
$params = $this->getMembershipData();
- $this->assertTrue($form->testProcessMembership($params));
+ $this->assertEquals(4500.0, $form->testProcessMembership($params));
$result = $this->callAPISuccess('membership', 'get');
$this->assertEquals(3, $result['count']);
//check start dates #1 should default to 1 Jan this year, #2 should be as entered
$params['field'][2]['membership_end_date'] = "2017-03-31";
$params['field'][2]['receive_date'] = "2016-04-01";
- $this->assertTrue($form->testProcessMembership($params));
+ $this->assertEquals(3.0, $form->testProcessMembership($params));
$result = $this->callAPISuccess('membership', 'get')['values'];
// renewal dates should be from current if start_date and end_date is passed as NULL