本文整理汇总了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;
}
示例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'];
}
}
}