当前位置: 首页>>代码示例>>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;未经允许,请勿转载。