当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contribute_BAO_Contribution::checkFinancialTypeChange方法代码示例

本文整理汇总了PHP中CRM_Contribute_BAO_Contribution::checkFinancialTypeChange方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contribute_BAO_Contribution::checkFinancialTypeChange方法的具体用法?PHP CRM_Contribute_BAO_Contribution::checkFinancialTypeChange怎么用?PHP CRM_Contribute_BAO_Contribution::checkFinancialTypeChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contribute_BAO_Contribution的用法示例。


在下文中一共展示了CRM_Contribute_BAO_Contribution::checkFinancialTypeChange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: civicrm_api3_contribution_create

/**
 * Add or update a Contribution.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 * @return array
 *   Api result array
 */
function civicrm_api3_contribution_create(&$params)
{
    $values = array();
    _civicrm_api3_custom_format_params($params, $values, 'Contribution');
    $params = array_merge($params, $values);
    if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
        $error = array();
        //throw error for invalid status change such as setting completed back to pending
        //@todo this sort of validation belongs in the BAO not the API - if it is not an OK
        // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
        CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error);
        if (array_key_exists('contribution_status_id', $error)) {
            throw new API_Exception($error['contribution_status_id']);
        }
    }
    if (!empty($params['id']) && !empty($params['financial_type_id'])) {
        $error = array();
        CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
        if (array_key_exists('financial_type_id', $error)) {
            throw new API_Exception($error['financial_type_id']);
        }
    }
    _civicrm_api3_contribution_create_legacy_support_45($params);
    // Make sure tax calculation is handled via api.
    $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:37,代码来源:Contribution.php

示例2: civicrm_api3_contribution_create

/**
 * Add or update a Contribution.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 * @return array
 *   Api result array
 */
function civicrm_api3_contribution_create(&$params)
{
    $values = array();
    _civicrm_api3_custom_format_params($params, $values, 'Contribution');
    $params = array_merge($params, $values);
    if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
        if (empty($params['id'])) {
            $op = CRM_Core_Action::ADD;
        } else {
            if (empty($params['financial_type_id'])) {
                $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['id'], '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))) {
            return civicrm_api3_create_error('You do not have permission to create this contribution');
        }
    }
    if (!empty($params['id']) && !empty($params['contribution_status_id'])) {
        $error = array();
        //throw error for invalid status change such as setting completed back to pending
        //@todo this sort of validation belongs in the BAO not the API - if it is not an OK
        // action it needs to be blocked there. If it is Ok through a form it needs to be OK through the api
        CRM_Contribute_BAO_Contribution::checkStatusValidation(NULL, $params, $error);
        if (array_key_exists('contribution_status_id', $error)) {
            throw new API_Exception($error['contribution_status_id']);
        }
    }
    if (!empty($params['id']) && !empty($params['financial_type_id'])) {
        $error = array();
        CRM_Contribute_BAO_Contribution::checkFinancialTypeChange($params['financial_type_id'], $params['id'], $error);
        if (array_key_exists('financial_type_id', $error)) {
            throw new API_Exception($error['financial_type_id']);
        }
    }
    _civicrm_api3_contribution_create_legacy_support_45($params);
    // Make sure tax calculation is handled via api.
    // @todo this belongs in the BAO NOT the api.
    $params = CRM_Contribute_BAO_Contribution::checkTaxAmount($params);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Contribution');
}
开发者ID:scardinius,项目名称:civicrm-core,代码行数:52,代码来源:Contribution.php

示例3: formRule

 /**
  * Global form rule.
  *
  * @param array $fields
  *   The input form values.
  * @param array $files
  *   The uploaded files if any.
  * @param $self
  *
  * @return bool|array
  *   true if no errors, else array of errors
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     // Check for Credit Card Contribution.
     if ($self->_mode) {
         if (empty($fields['payment_processor_id'])) {
             $errors['payment_processor_id'] = ts('Payment Processor is a required field.');
         } else {
             // validate payment instrument (e.g. credit card number)
             CRM_Core_Payment_Form::validatePaymentInstrument($fields['payment_processor_id'], $fields, $errors, NULL);
         }
     }
     // Do the amount validations.
     if (empty($fields['total_amount']) && empty($self->_lineItems)) {
         if ($priceSetId = CRM_Utils_Array::value('price_set_id', $fields)) {
             CRM_Price_BAO_PriceField::priceSetValidation($priceSetId, $fields, $errors);
         }
     }
     $softErrors = CRM_Contribute_Form_SoftCredit::formRule($fields, $errors, $self);
     if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) {
         $sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']);
         // For taxable contribution we need to deduct taxable amount from
         // (net amount + fee amount) before comparing it with total amount
         if (!empty($self->_values['tax_amount'])) {
             $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($self->_id);
             if (!(CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails))) {
                 $sum = CRM_Utils_Money::format($sum - $self->_values['tax_amount'], NULL, '%a');
             }
         }
         if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) {
             $errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount');
         }
     }
     //CRM-16285 - Function to handle validation errors on form, for recurring contribution field.
     CRM_Contribute_BAO_ContributionRecur::validateRecurContribution($fields, $files, $self, $errors);
     // Form rule for status http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
     if ($self->_action & CRM_Core_Action::UPDATE && $self->_id && $self->_values['contribution_status_id'] != $fields['contribution_status_id']) {
         CRM_Contribute_BAO_Contribution::checkStatusValidation($self->_values, $fields, $errors);
     }
     // CRM-16015, add form-rule to restrict change of financial type if using price field of different financial type
     if ($self->_action & CRM_Core_Action::UPDATE && $self->_id && $self->_values['financial_type_id'] != $fields['financial_type_id']) {
         CRM_Contribute_BAO_Contribution::checkFinancialTypeChange(NULL, $self->_id, $errors);
     }
     //FIXME FOR NEW DATA FLOW http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+4.3+Data+Flow
     if (!empty($fields['fee_amount']) && !empty($fields['financial_type_id']) && ($financialType = CRM_Contribute_BAO_Contribution::validateFinancialType($fields['financial_type_id']))) {
         $errors['financial_type_id'] = ts("Financial Account of account relationship of 'Expense Account is' is not configured for Financial Type : ") . $financialType;
     }
     // $trxn_id must be unique CRM-13919
     if (!empty($fields['trxn_id'])) {
         $queryParams = array(1 => array($fields['trxn_id'], 'String'));
         $query = 'select count(*) from civicrm_contribution where trxn_id = %1';
         if ($self->_id) {
             $queryParams[2] = array((int) $self->_id, 'Integer');
             $query .= ' and id !=%2';
         }
         $tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams);
         if ($tCnt) {
             $errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id']));
         }
     }
     $errors = array_merge($errors, $softErrors);
     return $errors;
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:75,代码来源:Contribution.php


注:本文中的CRM_Contribute_BAO_Contribution::checkFinancialTypeChange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。