'contact_id' => $contactId,
'receive_date' => '2010-01-20',
'total_amount' => 300,
- 'financial_type_id' => 4,
- 'contribution_status_id' => 1,
+ 'financial_type_id' => $this->getFinancialTypeId('Event Fee'),
+ 'contribution_status_id' => 'Completed',
);
$priceFields = $this->createPriceSet('event', $event['id']);
foreach ($priceFields['values'] as $key => $priceField) {
'contact_id' => $contactId,
'receive_date' => '2010-01-20',
'total_amount' => 200,
- 'financial_type_id' => 2,
- 'contribution_status_id' => 1,
+ 'financial_type_id' => $this->getFinancialTypeId('Member Dues'),
+ 'contribution_status_id' => 'Completed',
);
$membershipType = $this->membershipTypeCreate();
$priceFields = $this->createPriceSet();
'is_active' => array('1' => 1),
'price_set_id' => $priceset->id,
'is_enter_qty' => 1,
- 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'),
+ 'financial_type_id' => $this->getFinancialTypeId('Event Fee'),
);
CRM_Price_BAO_PriceField::create($paramsField);
'is_active' => array('1' => 1, '2' => 1),
'price_set_id' => $priceSet['id'],
'is_enter_qty' => 1,
- 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'),
+ 'financial_type_id' => $this->getFinancialTypeId('Event Fee'),
);
$priceField = CRM_Price_BAO_PriceField::create($paramsField);
if ($componentId) {
$this->callAPISuccessGetCount('FinancialItem', array('description' => 'Sales Tax', 'amount' => 0), 0);
}
+ /**
+ * Return financial type id on basis of name
+ *
+ * @param string $name Financial type m/c name
+ *
+ * @return int
+ */
+ public function getFinancialTypeId($name) {
+ return CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $name, 'id', 'name');
+ }
+
/**
* Cleanup function for contents of $this->ids.
*
$membershipType = $this->callAPIAndDocument('membership_type', 'get', $params, __FUNCTION__, __FILE__);
$this->assertEquals($membershipType['values'][$id]['name'], 'General');
$this->assertEquals($membershipType['values'][$id]['member_of_contact_id'], $this->_contactID);
- $this->assertEquals($membershipType['values'][$id]['financial_type_id'], 2);
+ $this->assertEquals($membershipType['values'][$id]['financial_type_id'], $this->getFinancialTypeId('Member Dues'));
$this->assertEquals($membershipType['values'][$id]['duration_unit'], 'year');
$this->assertEquals($membershipType['values'][$id]['duration_interval'], '1');
$this->assertEquals($membershipType['values'][$id]['period_type'], 'rolling');