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


PHP CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet方法代碼示例

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


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

示例1: calculateNonDeductibleAmount

 /**
  * Calculate non deductible amount.
  *
  * CRM-11956
  * if non_deductible_amount exists i.e. Additional Details field set was opened [and staff typed something] -
  * if non_deductible_amount does NOT exist - then calculate it depending on:
  * $financialType->is_deductible and whether there is a product (premium).
  *
  * @param $params
  * @param $formValues
  *
  * @return array
  */
 protected function calculateNonDeductibleAmount($params, $formValues)
 {
     if (!empty($params['non_deductible_amount'])) {
         return $params['non_deductible_amount'];
     }
     $priceSetId = CRM_Utils_Array::value('price_set_id', $params);
     // return non-deductible amount if it is set at the price field option level
     if ($priceSetId && !empty($params['line_item'])) {
         $nonDeductibleAmount = CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet($priceSetId, $params['line_item']);
         if (!empty($nonDeductibleAmount)) {
             return $nonDeductibleAmount;
         }
     }
     $financialType = new CRM_Financial_DAO_FinancialType();
     $financialType->id = $params['financial_type_id'];
     $financialType->find(TRUE);
     if ($financialType->is_deductible) {
         if (isset($formValues['product_name'][0])) {
             $selectProduct = $formValues['product_name'][0];
         }
         // if there is a product - compare the value to the contribution amount
         if (isset($selectProduct)) {
             $productDAO = new CRM_Contribute_DAO_Product();
             $productDAO->id = $selectProduct;
             $productDAO->find(TRUE);
             // product value exceeds contribution amount
             if ($params['total_amount'] < $productDAO->price) {
                 return $params['total_amount'];
             } else {
                 return $productDAO->price;
             }
         } else {
             return '0.00';
         }
     } else {
         return $params['total_amount'];
     }
     return 0;
 }
開發者ID:nielosz,項目名稱:civicrm-core,代碼行數:52,代碼來源:Contribution.php

示例2: getNonDeductibleAmount

 /**
  * Get non-deductible amount.
  *
  * This is a bit too much about wierd form interpretation to be this deep.
  *
  * CRM-11885
  *  if non_deductible_amount exists i.e. Additional Details fieldset was opened [and staff typed something] -> keep
  * it.
  *
  * @param array $params
  * @param CRM_Financial_BAO_FinancialType $financialType
  * @param bool $online
  * @param CRM_Contribute_Form_Contribution_Confirm $form
  *
  * @return array
  */
 protected static function getNonDeductibleAmount($params, $financialType, $online, $form)
 {
     if (isset($params['non_deductible_amount']) && !empty($params['non_deductible_amount'])) {
         return $params['non_deductible_amount'];
     }
     $priceSetId = CRM_Utils_Array::value('priceSetId', $params);
     // return non-deductible amount if it is set at the price field option level
     if ($priceSetId && !empty($form->_lineItem)) {
         $nonDeductibleAmount = CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet($priceSetId, $form->_lineItem);
     }
     if (!empty($nonDeductibleAmount)) {
         return $nonDeductibleAmount;
     } else {
         if ($financialType->is_deductible) {
             if ($online && isset($params['selectProduct'])) {
                 $selectProduct = CRM_Utils_Array::value('selectProduct', $params);
             }
             if (!$online && isset($params['product_name'][0])) {
                 $selectProduct = $params['product_name'][0];
             }
             // if there is a product - compare the value to the contribution amount
             if (isset($selectProduct) && $selectProduct != 'no_thanks') {
                 $productDAO = new CRM_Contribute_DAO_Product();
                 $productDAO->id = $selectProduct;
                 $productDAO->find(TRUE);
                 // product value exceeds contribution amount
                 if ($params['amount'] < $productDAO->price) {
                     $nonDeductibleAmount = $params['amount'];
                     return $nonDeductibleAmount;
                 } else {
                     return $productDAO->price;
                 }
             } else {
                 return '0.00';
             }
         } else {
             return $params['amount'];
         }
     }
 }
開發者ID:nielosz,項目名稱:civicrm-core,代碼行數:56,代碼來源:Confirm.php


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