* interim solution is just to return an empty array
*/
function _civicrm_api3_profile_getbillingpseudoprofile(&$params) {
- $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code');
+
$locations = civicrm_api3('address', 'getoptions', array('field' => 'location_type_id'));
$locationTypeID = array_search('Billing', $locations['values']);
if(empty($params['contact_id'])) {
+ $config = CRM_Core_Config::singleton();
$blanks = array(
'billing_first_name' => '',
'billing_middle_name' => '',
'billing_last_name' => '',
+ 'email-' . $locationTypeID => '',
+ 'billing_email-' . $locationTypeID => '',
+ 'billing_city-' . $locationTypeID => '',
+ 'billing_postal_code-' . $locationTypeID => '',
+ 'billing_street_address-' . $locationTypeID => '',
+ 'billing_country_id-' . $locationTypeID => $config->defaultContactCountry,
+ 'billing_state_province_id-' . $locationTypeID => $config->defaultContactStateProvince,
);
- foreach ($addressFields as $field) {
- $blanks['billing_' . $field . '_' . $locationTypeID] = '';
- }
return $blanks;
}
+
+ $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code');
$result = civicrm_api3('contact', 'getsingle', array(
'id' => $params['contact_id'],
'api.address.get.1' => array('location_type_id' => 'Billing', 'return' => $addressFields),
'first_name' => 'abc2',
'middle_name' => 'J.',
'last_name' => 'xyz2',
- 'prefix_id' => '3',
- 'suffix_id' => '3',
'email_greeting_id' => '1',
'email_greeting_custom' => '',
'email_greeting_display' => 'Dear abc1',
'postal_greeting_display' => 'Dear abc1',
'addressee_id' => '1',
'addressee_custom' => '',
- 'addressee_display' => '{contact.individual_prefix} abc1 J. xyz1 {contact.individual_suffix}',
+ 'addressee_display' => 'Mr. abc1 J. xyz1 II',
'job_title' => '',
- 'gender_id' => '',
'birth_date' => '',
'is_deceased' => 0,
'deceased_date' => '',
));
}
+ /**
+ * get Billing empty contact - this will return generic defaults
+ */
+ function testProfileGetBillingEmptyContact() {
+
+ $params = array(
+ 'profile_id' => array('Billing'),
+ );
+
+ $result = $this->callAPISuccess('profile', 'get', $params);
+ $this->assertEquals(array(
+ 'billing_first_name' => '',
+ 'billing_middle_name' => '',
+ 'billing_last_name' => '',
+ 'billing_street_address-5' => '',
+ 'billing_city-5' => '',
+ 'billing_state_province_id-5' => '',
+ 'billing_country_id-5' => '1228',
+ 'billing_email-5' => '',
+ 'email-5' => '',
+ 'billing_postal_code-5' => '',
+ ), $result['values']['Billing']);
+ }
/**
* check contact activity profile without activity id