Merge pull request #18266 from sunilpawar/dev_912
[civicrm-core.git] / api / v3 / FinancialTrxn.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * This api exposes CiviCRM FinancialItem.
14 *
15 * @package CiviCRM_APIv3
16 */
17
18 /**
19 * Save a Financial Item.
20 *
21 * @param array $params
22 *
23 * @return array
24 */
25 function civicrm_api3_financial_trxn_create($params) {
26 if (empty($params['id']) && empty($params['contribution_id']) && empty($params['entity_id'])) {
27 throw new API_Exception("Mandatory key(s) missing from params array: both contribution_id and entity_id are missing");
28 }
29
30 return _civicrm_api3_basic_create('CRM_Core_BAO_FinancialTrxn', $params, 'FinancialTrxn');
31 }
32
33 /**
34 * Get a Financialtrxn.
35 *
36 * @param array $params
37 *
38 * @return array
39 * Array of retrieved Financial trxn property values.
40 */
41 function civicrm_api3_financial_trxn_get($params) {
42 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
43 }
44
45 /**
46 * Delete a Financial trxn.
47 *
48 * @param array $params
49 *
50 * @return array
51 * Array of deleted values.
52 */
53 function civicrm_api3_financial_trxn_delete($params) {
54 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
55 }
56
57 /**
58 * Adjust Metadata for Create action.
59 *
60 * The metadata is used for setting defaults, documentation & validation.
61 *
62 * @param array $params
63 * Array of parameters determined by getfields.
64 */
65 function _civicrm_api3_financial_trxn_create_spec(&$params) {
66 $params['to_financial_account_id']['api.required'] = 1;
67 $params['status_id']['api.required'] = 1;
68 $params['payment_instrument_id']['api.required'] = 1;
69 $params['total_amount']['api.required'] = 1;
70 }