From f70eb51fc8cb6e52f4bb5898bc42ac47704c42a0 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 8 Jul 2015 00:19:12 +1200 Subject: [PATCH] remove redundant IF & rename contributionType to financialType --- CRM/Contribute/Form/Contribution.php | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 916faa9307..ea734591eb 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1792,39 +1792,39 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if (!empty($params['non_deductible_amount'])) { return $params['non_deductible_amount']; } - if (empty($params['non_deductible_amount'])) { - $contributionType = new CRM_Financial_DAO_FinancialType(); - $contributionType->id = $params['financial_type_id']; - if ($contributionType->is_deductible) { + $financialType = new CRM_Financial_DAO_FinancialType(); + $financialType->id = $params['financial_type_id']; - 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']; - } - // product value does NOT exceed contribution amount - else { - return $productDAO->price; - } + 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']; } - // contribution is deductible - but there is no product + // product value does NOT exceed contribution amount else { - return '0.00'; + return $productDAO->price; } } - // contribution is NOT deductible + // contribution is deductible - but there is no product else { - return $params['total_amount']; + return '0.00'; } } + // contribution is NOT deductible + else { + return $params['total_amount']; + } + return 0; } -- 2.25.1