Skip to content
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

dev/core#1463 Fix record payment form errors #16071

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CRM/Contribute/Form/AdditionalPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,15 @@ public function preProcess() {
CRM_Utils_System::setTitle($title);
return;
}
$entityType = 'contribution';
if ($this->_component == 'event') {
$entityType = 'participant';
$this->_contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_id, 'contribution_id', 'participant_id');
$eventId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $this->_id, 'event_id', 'id');
}
else {
$this->_contributionId = $this->_id;
}

$paymentDetails = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_id, $this->_component, FALSE, TRUE);
$paymentAmt = CRM_Contribute_BAO_Contribution::getContributionBalance($this->_id);
$paymentAmt = CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId);

$this->_amtPaid = $paymentDetails['paid'];
$this->_amtTotal = $paymentDetails['total'];
Expand Down Expand Up @@ -272,7 +269,7 @@ public function buildQuickForm() {
*/
public static function formRule($fields, $files, $self) {
$errors = [];
if ($self->_paymentType == 'owed' && $fields['total_amount'] > $self->_owed) {
if ($self->_paymentType == 'owed' && (int) $fields['total_amount'] > (int) $self->_owed) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://lab.civicrm.org/dev/core/issues/1463#note_28671, maybe, the complete check should be removed? Hmm, but that might add some more discussion as what needs to be done to the main contribution amount when the form is submitted with > owed amount?

$errors['total_amount'] = ts('Payment amount cannot be greater than owed amount');
}
if ($self->_paymentType == 'refund' && $fields['total_amount'] != abs($self->_refund)) {
Expand Down