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

Intra-RC regression: User dashboard: show most recent contributions, not earliest #13903

Merged
merged 2 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion CRM/Contribute/Page/UserDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
*/
public function listContribution() {
$rows = civicrm_api3('Contribution', 'get', [
'options' => ['limit' => 12],
'options' => [
'limit' => 12,
'sort' => 'receive_date DESC',
],
'sequential' => 1,
'contact_id' => $this->_contactId,
'return' => [
Expand All @@ -54,6 +57,9 @@ public function listContribution() {
],
])['values'];

// We want oldest first, just among the most recent contributions
$rows = array_reverse($rows);

foreach ($rows as $index => $row) {
// This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
// which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons
Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public function testDashboardContentContributionsWithInvoicingEnabled() {
]);
$this->contributions[] = $this->contributionCreate([
'contact_id' => $this->contactID,
'receive_date' => '2018-11-21',
'receipt_date' => '2018-11-22',
'receive_date' => '2018-11-22',
'receipt_date' => '2018-11-23',
'trxn_id' => '',
'invoice_id' => '',
]);
Expand All @@ -109,7 +109,7 @@ public function testDashboardContentContributionsWithInvoicingEnabled() {
]);
$this->contributions[] = $this->contributionCreate([
'contact_id' => $this->contactID,
'receive_date' => '2018-11-21',
'receive_date' => '2018-11-20',
'amount_level' => 'high',
'contribution_status_id' => 'Cancelled',
'invoice_id' => NULL,
Expand All @@ -125,7 +125,7 @@ public function testDashboardContentContributionsWithInvoicingEnabled() {
];

$this->assertPageContains($expectedStrings);
$this->assertSmartyVariableArrayIncludes('contribute_rows', 0, [
$this->assertSmartyVariableArrayIncludes('contribute_rows', 1, [
'contact_id' => $this->contactID,
'contribution_id' => '1',
'total_amount' => '100.00',
Expand Down