當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Contribute_BAO_Contribution::recordPartialPayment方法代碼示例

本文整理匯總了PHP中CRM_Contribute_BAO_Contribution::recordPartialPayment方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Contribute_BAO_Contribution::recordPartialPayment方法的具體用法?PHP CRM_Contribute_BAO_Contribution::recordPartialPayment怎麽用?PHP CRM_Contribute_BAO_Contribution::recordPartialPayment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Contribute_BAO_Contribution的用法示例。


在下文中一共展示了CRM_Contribute_BAO_Contribution::recordPartialPayment方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPartialPaymentTrxn

 /**
  * Function records partial payment, complete's contribution if payment is fully paid
  * and returns latest payment ie financial trxn
  *
  * @param array $contribution
  * @param array $params
  *
  * @return CRM_Core_BAO_FinancialTrxn
  */
 public static function getPartialPaymentTrxn($contribution, $params)
 {
     $trxn = CRM_Contribute_BAO_Contribution::recordPartialPayment($contribution, $params);
     $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']);
     $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount');
     $cmp = bccomp($total, $paid, 5);
     if ($cmp == 0 || $cmp == -1) {
         // If paid amount is greater or equal to total amount
         civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id']));
     }
     return $trxn;
 }
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:21,代碼來源:FinancialTrxn.php

示例2: civicrm_api3_payment_create

/**
 * Add a payment for a Contribution.
 *
 * @param array $params
 *   Input parameters.
 *
 * @throws API_Exception
 * @return array
 *   Api result array
 */
function civicrm_api3_payment_create(&$params)
{
    // Check if it is an update
    if (CRM_Utils_Array::value('id', $params)) {
        $amount = $params['total_amount'];
        civicrm_api3('Payment', 'cancel', $params);
        $params['total_amount'] = $amount;
    }
    // Get contribution
    $contribution = civicrm_api3('Contribution', 'getsingle', array('id' => $params['contribution_id']));
    if ($contribution['contribution_status'] != 'Partially paid') {
        throw new API_Exception('Please select a contribution which has a partial payment');
    } else {
        $trxn = CRM_Contribute_BAO_Contribution::recordPartialPayment($contribution, $params);
        $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']);
        $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount');
        $cmp = bccomp($total, $paid, 5);
        if ($cmp == 0 || $cmp == -1) {
            // If paid amount is greater or equal to total amount
            civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id']));
        }
    }
    if (CRM_Utils_Array::value('line_item', $params) && !empty($trxn)) {
        foreach ($params['line_item'] as $values) {
            foreach ($values as $id => $amount) {
                $p = array('id' => $id);
                $check = CRM_Price_BAO_LineItem::retrieve($p, $defaults);
                if (empty($check)) {
                    throw new API_Exception('Please specify a valid Line Item.');
                }
                // get financial item
                $sql = "SELECT fi.id\n          FROM civicrm_financial_item fi\n          INNER JOIN civicrm_line_item li ON li.id = fi.entity_id\n          WHERE li.contribution_id = %1 AND li.id = %2";
                $sqlParams = array(1 => array($params['contribution_id'], 'Integer'), 2 => array($id, 'Integer'));
                $fid = CRM_Core_DAO::singleValueQuery($sql, $sqlParams);
                // Record Entity Financial Trxn
                $eftParams = array('entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $trxn->id, 'amount' => $amount, 'entity_id' => $fid);
                civicrm_api3('EntityFinancialTrxn', 'create', $eftParams);
            }
        }
    } elseif (!empty($trxn)) {
        // Assign the lineitems proportionally
        CRM_Contribute_BAO_Contribution::assignProportionalLineItems($params, $trxn, $contribution);
    }
    $values = array();
    _civicrm_api3_object_to_array_unique_fields($trxn, $values[$trxn->id]);
    return civicrm_api3_create_success($values, $params, 'Payment', 'create', $trxn);
}
開發者ID:konadave,項目名稱:civicrm-core,代碼行數:57,代碼來源:Payment.php


注:本文中的CRM_Contribute_BAO_Contribution::recordPartialPayment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。