$params['id'], 'return' => 'financial_type_id', )); } $op = CRM_Core_Action::UPDATE; } CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op); } if (in_array($params['financial_type_id'], array_keys($types))) { $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params, TRUE); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); } else { throw new API_Exception('You do not have permission to create this line item'); } } /** * Adjust Metadata for Create action. * * The metadata is used for setting defaults, documentation & validation. * * @param array $params * Array of parameters determined by getfields. */ function _civicrm_api3_line_item_create_spec(&$params) { $params['entity_id']['api.required'] = 1; $params['qty']['api.required'] = 1; $params['unit_price']['api.required'] = 1; $params['line_total']['api.required'] = 1; $params['label']['api.default'] = 'line item'; } /** * Returns array of line_items matching a set of one or more group properties. * * @param array $params * Array of one or more valid property_name=>value pairs. If $params is set. * as null, all line_items will be returned (default limit is 25) * * @return array * Array of matching line_items */ function civicrm_api3_line_item_get($params) { if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types); $lineItems = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); if ($lineItems['count'] > 0) { foreach ($lineItems['values'] as $key => $items) { if (!in_array($items['financial_type_id'], array_keys($types))) { unset($lineItems['values'][$key]); } } return $lineItems; } } return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** * Delete an existing LineItem. * * This method is used to delete any existing LineItem given its id. * * @param array $params * Array containing id of the group to be deleted. * * @return array * API result array */ function civicrm_api3_line_item_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); }