/** * AccountInvoice.create API. * * @param array $params * * @return array * API result descriptor * * @throws \Exception */ function civicrm_api3_account_invoice_update_contribution($params) { if ($params['accounts_status_id'] == 1) { CRM_Accountsync_BAO_AccountInvoice::completeContributionFromAccountsStatus($params); return civicrm_api3_create_success(); } if ($params['accounts_status_id'] == 3) { CRM_Accountsync_BAO_AccountInvoice::cancelContributionFromAccountsStatus($params); return civicrm_api3_create_success(); } throw new Exception('Currently only complete is supported'); // return _civicrm_api3_basic_create('CRM_Accountsync_BAO_AccountInvoice', $params); }
/** * Check if entity is valid for this connector. * * If we are dealing with a Contribution AND the connector has a contact_id * then we will check that the line items in the invoice related to this contact ID. * * @param int $connector_id * @param int $financial_type_id * * @return bool */ function _accountsync_validate_for_connector($connector_id, $financial_type_id) { if ($connector_id == 0) { return TRUE; } $accounts_contact_id = _accountsync_get_account_contact_id($connector_id); static $connector_financial_types = array(); if (!in_array($financial_type_id, $connector_financial_types)) { $connector_financial_types[$financial_type_id] = CRM_Accountsync_BAO_AccountInvoice::getAccountsContact($financial_type_id); } if ($accounts_contact_id == CRM_Utils_Array::value($financial_type_id, $connector_financial_types)) { return TRUE; } else { return FALSE; } }