Skip to content

Commit 9efe6b7

Browse files
ASESPRT-783: Fix status for 0 amount contributions
1 parent a40c351 commit 9efe6b7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Civi/Financeextras/Event/Listener/ContributionPaymentUpdatedListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ private static function updateContributionStatus($contributionId) {
1919
$contribution = \Civi\Api4\Contribution::get(FALSE)
2020
->addWhere('id', '=', $contributionId)
2121
->addWhere('contribution_status_id:name', 'IN', $allowedStatus)
22+
->addWhere('total_amount', '!=', 0)
2223
->execute()
2324
->first();
2425

tests/phpunit/Civi/Financeextras/ApiWrapper/PaymentTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static function setupBeforeClass(): void {
2828
self::$contribution = ContributionFabricator::fabricate($contributionParams);
2929
}
3030

31-
public function setUp() {
31+
public function setUp(): void {
3232
}
3333

3434
public function testMakingPartialPaymentUpdatesContributionToPartiallyPaid(): void {
@@ -57,4 +57,21 @@ public function testMakingFullPaymentUpdatesContributionToCompleted(): void {
5757
$this->assertEquals('Completed', $contribution['contribution_status']);
5858
}
5959

60+
public function testZeroAmountContributionIsCreatedAsCompleted(): void {
61+
$contact = ContactFabricator::fabricate();
62+
self::$contribution = ContributionFabricator::fabricate([
63+
'financial_type_id' => 'Donation',
64+
'receive_date' => date('Y-m-d'),
65+
'total_amount' => 0.00,
66+
'contact_id' => $contact['id'],
67+
'payment_instrument_id' => 'Credit Card',
68+
'trxn_id' => md5(time()),
69+
'currency' => 'GBP',
70+
]);
71+
72+
$contribution = civicrm_api3('Contribution', 'getSingle', ['id' => self::$contribution['id']]);
73+
74+
$this->assertEquals('Completed', $contribution['contribution_status']);
75+
}
76+
6077
}

0 commit comments

Comments
 (0)