Unverified Commit e790273f authored by eileen's avatar eileen 🎱 Committed by GitHub

Merge pull request #13317 from eileenmcnaughton/order_pseudo

Fix order api to support a pseudoConstant for financial_type_id
parents 9ab4cac7 785f03e2
......@@ -61,6 +61,19 @@ function civicrm_api3_order_get($params) {
return civicrm_api3_create_success($contributions, $params, 'Order', 'get');
}
/**
* Adjust Metadata for Get action.
*
* The metadata is used for setting defaults, documentation & validation.
*
* @param array $params
* Array of parameters determined by getfields.
*/
function _civicrm_api3_order_get_spec(&$params) {
$params['id']['api.aliases'] = ['order_id'];
$params['id']['title'] = ts('Contribution / Order ID');
}
/**
* Add or update a Order.
*
......@@ -72,7 +85,7 @@ function civicrm_api3_order_get($params) {
* Api result array
*/
function civicrm_api3_order_create(&$params) {
$contribution = array();
$entity = NULL;
$entityIds = array();
if (CRM_Utils_Array::value('line_items', $params) && is_array($params['line_items'])) {
......@@ -202,12 +215,20 @@ function _civicrm_api3_order_create_spec(&$params) {
'title' => 'Total Amount',
'api.required' => TRUE,
);
$params['financial_type_id'] = array(
$params['financial_type_id'] = [
'name' => 'financial_type_id',
'title' => 'Financial Type',
'type' => CRM_Utils_Type::T_INT,
'api.required' => TRUE,
);
'table_name' => 'civicrm_contribution',
'entity' => 'Contribution',
'bao' => 'CRM_Contribute_BAO_Contribution',
'pseudoconstant' => [
'table' => 'civicrm_financial_type',
'keyColumn' => 'id',
'labelColumn' => 'name',
],
];
}
/**
......
......@@ -376,6 +376,11 @@ function _civicrm_api3_get_BAO($name) {
if ($name == 'PrintLabel') {
return 'CRM_Badge_BAO_Layout';
}
if ($name === 'Order') {
// Order basically maps to contribution at the top level but
// has enhanced access to other entities.
$name = 'Contribution';
}
$dao = _civicrm_api3_get_DAO($name);
if (!$dao) {
return NULL;
......
......@@ -211,7 +211,7 @@ class api_v3_OrderTest extends CiviUnitTestCase {
'contact_id' => $this->_individualId,
'receive_date' => '2010-01-20',
'total_amount' => 200,
'financial_type_id' => $this->_financialTypeId,
'financial_type_id' => 'Event Fee',
'contribution_status_id' => 1,
);
$priceFields = $this->createPriceSet();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment