Commit | Line | Data |
---|---|---|
55e55e84 | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
a30c801b | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
55e55e84 | 5 | | | |
a30c801b TO |
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 | | |
55e55e84 | 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) { | |
50f8ceb1 | 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"); | |
e3a78cba | 28 | } |
50f8ceb1 | 29 | |
ddaf2161 | 30 | return _civicrm_api3_basic_create('CRM_Core_BAO_FinancialTrxn', $params, 'FinancialTrxn'); |
55e55e84 | 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 | } | |
b494e85f PN |
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; | |
429a0484 | 70 | } |