-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-20569: Add priceset validation on a partial payment use-case and other improvements #11000
Conversation
CRM/Price/BAO/PriceField.php
Outdated
@@ -814,9 +814,16 @@ public static function priceSetValidation($priceSetId, $fields, &$error, $allowN | |||
list($componentName) = explode(':', $fields['_qf_default']); | |||
// now we have all selected amount in hand. | |||
$totalAmount = array_sum($selectedAmounts); | |||
$actualTotalAmount = CRM_Utils_Array::value('partial_payment_total', $fields, CRM_Utils_Array::value('total_amount', $fields)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so $actualTotalAmount is actually
// The form offers a field to enter the amount paid. This may differ from the amount that is due to complete the purchase
$totalPaymentAmountEnteredOnForm = CRM_Utils_Array::value('partial_payment_total', $fields, CRM_Utils_Array::value('total_amount', $fields));
@@ -814,9 +814,16 @@ public static function priceSetValidation($priceSetId, $fields, &$error, $allowN | |||
list($componentName) = explode(':', $fields['_qf_default']); | |||
// now we have all selected amount in hand. | |||
$totalAmount = array_sum($selectedAmounts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$totalAmount = $sumOfSelectedOptions really?
CRM/Price/BAO/PriceField.php
Outdated
$actualTotalAmount >= $totalAmount && // if total amount is equal to all selected amount in hand | ||
(CRM_Utils_Array::value('contribution_status_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Contribute_DAO_Contribution', 'contribution_status_id', 'Partially paid')) | ||
) { | ||
$error['total_amount'] = ts('For partially paid contribution, amount must be less then the sum of all selected amount in hand'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ts('You have specified the status Partially Paid but have entered an amount that equals or exceeds the amount due. Please adjust the status of the payment or the amount');
I have made some wording comments. I can accept this fix on the basis that
So pending some readability improvements I'm OK with this. I note the partial_payment_amount being passes around is a bit tangental to the other fix & should really be a separate JIRA/PR. However, it seems like a minor addition of the param being passed & consistent with other code uses |
4a22a6c
to
aee297c
Compare
Thanks @eileenmcnaughton for your feedback. Made those changes, please have a look! |
CRM-20569: Add priceset validation on a partial payment use-case and other improvements
Technical Details
Contain two necessary changes:
partial_payment_total
other thentotal_amount
inCRM_Price_BAO_PriceSet::processAmount(...)
Comments
This PR extracts some of the improvements from #10352