Skip to content

Commit f2d841f

Browse files
Merge pull request #15771 from eileenmcnaughton/partially
dev/financial#100 Remove 'partially paid' as a contribution status option for 'record p…ayment'
2 parents 6712320 + eaba6ea commit f2d841f

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

CRM/Contribute/BAO/Contribution/Utils.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public static function formatAmount($amount, $decimals = 2) {
538538
* Array of contribution statuses in array('status id' => 'label') format
539539
*/
540540
public static function getContributionStatuses($usedFor = 'contribution', $id = NULL) {
541-
if ($usedFor == 'pledge') {
541+
if ($usedFor === 'pledge') {
542542
$statusNames = CRM_Pledge_BAO_Pledge::buildOptions('status_id', 'validate');
543543
}
544544
else {
@@ -562,25 +562,29 @@ public static function getContributionStatuses($usedFor = 'contribution', $id =
562562
'Pending refund',
563563
]);
564564

565-
// Event registration and New Membership backoffice form support partially paid payment,
566-
// so exclude this status only for 'New Contribution' form
567-
if ($usedFor == 'contribution') {
565+
if ($usedFor === 'contribution') {
568566
$statusNamesToUnset = array_merge($statusNamesToUnset, [
569567
'In Progress',
570568
'Overdue',
571569
'Partially paid',
572570
]);
573571
}
574-
elseif ($usedFor == 'participant') {
572+
elseif ($usedFor === 'participant') {
575573
$statusNamesToUnset = array_merge($statusNamesToUnset, [
576574
'Cancelled',
577575
'Failed',
576+
'In Progress',
577+
'Overdue',
578+
'Partially paid',
578579
]);
579580
}
580-
elseif ($usedFor == 'membership') {
581+
elseif ($usedFor === 'membership') {
581582
$statusNamesToUnset = array_merge($statusNamesToUnset, [
582583
'In Progress',
584+
'Cancelled',
585+
'Failed',
583586
'Overdue',
587+
'Partially paid',
584588
]);
585589
}
586590
}

tests/phpunit/CRM/Member/Form/MembershipTest.php

+16-18
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ public function testSubmitPartialPayment($thousandSeparator) {
657657
$this->createLoggedInUser();
658658
$priceSet = $this->callAPISuccess('PriceSet', 'Get', ["extends" => "CiviMember"]);
659659
$form->set('priceSetId', $priceSet['id']);
660-
$partiallyPaidAmount = 25;
660+
661661
CRM_Price_BAO_PriceSet::buildPriceSet($form);
662662
$params = [
663663
'cid' => $this->_individualId,
@@ -668,9 +668,9 @@ public function testSubmitPartialPayment($thousandSeparator) {
668668
'membership_type_id' => [23, $this->membershipTypeAnnualFixedID],
669669
'receive_date' => date('Y-m-d', time()) . ' 20:36:00',
670670
'record_contribution' => 1,
671-
'total_amount' => $this->formatMoneyInput($partiallyPaidAmount),
672-
'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
673-
'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid'),
671+
'total_amount' => $this->formatMoneyInput(50),
672+
'payment_instrument_id' => array_search('Check', $this->paymentInstruments, TRUE),
673+
'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'),
674674
//Member dues, see data.xml
675675
'financial_type_id' => '2',
676676
'payment_processor_id' => $this->_paymentProcessorID,
@@ -679,41 +679,39 @@ public function testSubmitPartialPayment($thousandSeparator) {
679679
$form->testSubmit($params);
680680
$membership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $this->_individualId]);
681681
// check the membership status after partial payment, if its Pending
682-
$this->assertEquals(array_search('Pending', CRM_Member_PseudoConstant::membershipStatus()), $membership['status_id']);
683-
$contribution = $this->callAPISuccessGetSingle('Contribution', [
684-
'contact_id' => $this->_individualId,
685-
]);
682+
$this->assertEquals(array_search('Pending', CRM_Member_PseudoConstant::membershipStatus(), TRUE), $membership['status_id']);
683+
$contribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $this->_individualId]);
684+
$this->callAPISuccess('Payment', 'create', ['contribution_id' => $contribution['id'], 'total_amount' => 25, 'payment_instrument_id' => 'Cash']);
685+
$contribution = $this->callAPISuccessGetSingle('Contribution', ['id' => $contribution['id']]);
686686
$this->assertEquals('Partially paid', $contribution['contribution_status']);
687-
// $this->assertEquals(50.00, $contribution['total_amount']);
688-
// $this->assertEquals(25.00, $contribution['net_amount']);
689687

690688
// Step 2: submit the other half of the partial payment
691689
// via AdditionalPayment form to complete the related contribution
692690
$form = new CRM_Contribute_Form_AdditionalPayment();
693691
$submitParams = [
694692
'contribution_id' => $contribution['contribution_id'],
695693
'contact_id' => $this->_individualId,
696-
'total_amount' => $this->formatMoneyInput($partiallyPaidAmount),
694+
'total_amount' => $this->formatMoneyInput(25),
697695
'currency' => 'USD',
698696
'financial_type_id' => 2,
699697
'receive_date' => '2015-04-21 23:27:00',
700698
'trxn_date' => '2017-04-11 13:05:11',
701699
'payment_processor_id' => 0,
702-
'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
700+
'payment_instrument_id' => array_search('Check', $this->paymentInstruments, TRUE),
703701
'check_number' => 'check-12345',
704702
];
705703
$form->cid = $this->_individualId;
706704
$form->testSubmit($submitParams);
707705
$membership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $this->_individualId]);
708706
// check the membership status after additional payment, if its changed to 'New'
709-
$this->assertEquals(array_search('New', CRM_Member_PseudoConstant::membershipStatus()), $membership['status_id']);
707+
$this->assertEquals(array_search('New', CRM_Member_PseudoConstant::membershipStatus(), TRUE), $membership['status_id']);
710708

711709
// check the contribution status and net amount after additional payment
712710
$contribution = $this->callAPISuccessGetSingle('Contribution', [
713711
'contact_id' => $this->_individualId,
714712
]);
715713
$this->assertEquals('Completed', $contribution['contribution_status']);
716-
// $this->assertEquals(50.00, $contribution['net_amount']);
714+
$this->validateAllPayments();
717715
}
718716

719717
/**
@@ -724,14 +722,14 @@ public function testSubmitPartialPayment($thousandSeparator) {
724722
public function testSubmitRecur() {
725723
CRM_Core_Session::singleton()->getStatus(TRUE);
726724
$pendingVal = $this->callAPISuccessGetValue('OptionValue', [
727-
'return' => "id",
728-
'option_group_id' => "contribution_status",
729-
'label' => "Pending Label**",
725+
'return' => 'id',
726+
'option_group_id' => 'contribution_status',
727+
'label' => 'Pending Label**',
730728
]);
731729
//Update label for Pending contribution status.
732730
$this->callAPISuccess('OptionValue', 'create', [
733731
'id' => $pendingVal,
734-
'label' => "PendingEdited",
732+
'label' => 'PendingEdited',
735733
]);
736734

737735
$form = $this->getForm();

0 commit comments

Comments
 (0)