}
elseif ($this->_batchInfo['type_id'] == $batchTypes['Membership']) {
CRM_Utils_System::setTitle(ts('Batch Data Entry for Memberships'));
- $customFields = CRM_Core_BAO_CustomField::getFields('Membership');
}
elseif ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment']) {
CRM_Utils_System::setTitle(ts('Batch Data Entry for Pledge Payments'));
- $customFields = CRM_Core_BAO_CustomField::getFields('Contribution');
}
$this->_fields = array();
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, CRM_Core_Action::VIEW);
$this->assign('rowCount', $this->_batchInfo['item_count'] + 1);
- $fileFieldExists = FALSE;
$preserveDefaultsArray = array(
'first_name',
'last_name',
$contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
$contactReturnProperties = array();
- $config = CRM_Core_Config::singleton();
for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
$this->addEntityRef("primary_contact_id[{$rowNumber}]", '', array(
// @todo - most of the wrangling in this function is because the api is not being used, especially date stuff.
$customFields = array();
foreach ($params['field'] as $key => $value) {
+ foreach ($value as $fieldKey => $fieldValue) {
+ if (isset($this->_fields[$fieldKey]) && $this->_fields[$fieldKey]['data_type'] === 'Money') {
+ $value[$fieldKey] = CRM_Utils_Rule::cleanMoney($fieldValue);
+ }
+ }
// if contact is not selected we should skip the row
if (empty($params['primary_contact_id'][$key])) {
continue;
// make contribution entry
$contrbutionParams = array_merge($value, array('membership_id' => $membership->id));
+ $contrbutionParams['skipCleanMoney'] = TRUE;
// @todo - calling this from here is pretty hacky since it is called from membership.create anyway
// This form should set the correct params & not call this fn directly.
CRM_Member_BAO_Membership::recordMembershipContribution($contrbutionParams);
$params = array(
'name' => $this->_membershipTypeName,
'description' => NULL,
- 'minimum_fee' => 10,
+ 'minimum_fee' => 1500,
'duration_unit' => 'year',
'member_of_contact_id' => $this->_orgContactID,
'period_type' => 'fixed',
/**
* Test Import.
+ *
+ * @param string $thousandSeparator
+ *
+ * @dataProvider getThousandSeparators
*/
- public function testProcessMembership() {
+ public function testProcessMembership($thousandSeparator) {
+ $this->setCurrencySeparators($thousandSeparator);
+
$form = new CRM_Batch_Form_Entry();
+ $profileID = $this->callAPISuccessGetValue('UFGroup', ['return' => 'id', 'name' => 'membership_batch_entry']);
+ $form->_fields = CRM_Core_BAO_UFGroup::getFields($profileID, FALSE, CRM_Core_Action::VIEW);
+
$params = $this->getMembershipData();
$this->assertTrue($form->testProcessMembership($params));
$result = $this->callAPISuccess('membership', 'get', array());
'return' => 'line_total',
)), $contribution['total_amount']);
+ $this->assertEquals(1500, $contribution['total_amount']);
$this->assertEquals($params['field'][$key]['trxn_id'], $contribution['trxn_id']);
}
}
'membership_end_date' => NULL,
'membership_source' => NULL,
'financial_type' => 2,
- 'total_amount' => 1,
+ 'total_amount' => $this->formatMoneyInput(1500),
'receive_date' => '2013-07-24',
'receive_date_time' => NULL,
'payment_instrument' => 1,
'membership_end_date' => NULL,
'membership_source' => NULL,
'financial_type' => 2,
- 'total_amount' => 1,
+ 'total_amount' => $this->formatMoneyInput(1500),
'receive_date' => '2013-07-17',
'receive_date_time' => NULL,
'payment_instrument' => NULL,
'membership_end_date' => '2013-12-01',
'membership_source' => NULL,
'financial_type' => 2,
- 'total_amount' => 1,
+ 'total_amount' => $this->formatMoneyInput(1500),
'receive_date' => '2013-07-17',
'receive_date_time' => NULL,
'payment_instrument' => NULL,