Skip to content

MPDX-9600 - Staff Expense Report: Sort Income and Expenses in CSV exports by date#1788

Merged
zweatshirt merged 1 commit into
mainfrom
MPDX-9600
May 19, 2026
Merged

MPDX-9600 - Staff Expense Report: Sort Income and Expenses in CSV exports by date#1788
zweatshirt merged 1 commit into
mainfrom
MPDX-9600

Conversation

@zweatshirt
Copy link
Copy Markdown
Contributor

@zweatshirt zweatshirt commented May 19, 2026

Description

  • It is easier to read transactions as a chronological timeline as opposed to by category.
    List any PRs that this PR is dependent on and any Jira tickets that this PR is related to.
    https://jira.cru.org/browse/MPDX-9600

Testing

  • Impersonate someone with income and expenses
  • Go to hrTools/staffExpense
  • Export an income CSV, an expense CSV, and a dual income/expense CSV

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels (Add the label "Preview" to automatically create a preview environment)
  • I have run the Claude Code /pr-review command locally and fixed any relevant suggestions
  • I have requested a review from another person on the project
  • I have tested my changes in preview or in staging
  • I have cleaned up my commit history

@zweatshirt zweatshirt self-assigned this May 19, 2026
@zweatshirt zweatshirt added the Preview Environment Add this label to create an Amplify Preview label May 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Bundle sizes [mpdx-react]

Compared against d5c2533

No significant changes found

@zweatshirt zweatshirt marked this pull request as ready for review May 19, 2026 21:02
Copy link
Copy Markdown
Contributor Author

@zweatshirt zweatshirt left a comment

Choose a reason for hiding this comment

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

AI Multi-Agent Code Review

Verdict: ✅ CLEAN
Risk Score: 1/10 (LOW)
Agents: Architecture · Testing · Standards


Risk Assessment

Factor Points
src/components/**/*.tsx (medium-risk component) +1
Change volume <50 non-test lines +0
Single-domain scope ×1.0
Total 1/10

Architecture — ✅ APPROVED

Strengths:

  • [...transactions].sort(...) correctly avoids mutating the caller's array — no side effects on the input
  • localeCompare on ISO 8601 strings (YYYY-MM-DD) is safe and produces correct chronological order — no need to parse into Luxon just for comparison
  • Extracting dateSortTransactions separates sort policy from table-building in createTable, improving testability
  • Exporting the function enables a direct unit test rather than asserting order transitively through CSV output

Suggestions (no action required):

Suggestion: The surrounding file uses const arrow-function declarations; dateSortTransactions uses a function declaration. Minor style inconsistency — either is valid.

Suggestion: Array.prototype.sort is stable (ES2019+), so equal dates retain input order. If a secondary sort key is ever desired, the comparator can be extended at that point.


Testing — ✅ APPROVED_WITH_SUGGESTIONS

Strengths:

  • Test uses existing typed Transaction[] mock — no any leaks
  • mockData[0].transactedAt changed from '2025-07-01' to '2025-10-01', making input order Oct/Aug/Sep — the test would actually fail if sort were removed, not coincidentally pass
  • Assertion maps directly to transactedAt values and compares an exact array

Optional suggestions (no action required):

Suggestion: Edge cases not covered: empty array, single element, already-sorted input, ties/duplicate date. Low priority given the simplicity of the comparator.

Suggestion: The non-mutation guarantee (via [...transactions] spread) isn't explicitly tested. Adding one assertion that the original array order is unchanged after the call would lock that contract in.

Suggestion: mockData is now shared between download tests and the sort test. A future date change in mockData for another test could silently make the sort input already-sorted (and the test still pass). A local fixture inside the describe('dateSortTransactions') block would isolate this.


Standards — ✅ APPROVED

All checklist items pass: named export, no any, no new Date(), no debug output, no unused imports. The fixture date change from '2025-07-01' to '2025-10-01' is intentional — the earlier value was the earliest date and would have sorted first coincidentally, making the test trivially pass without exercising the sort.


Summary

Small, focused PR: extracts dateSortTransactions as a named export, wires it into createTable, and adds a direct unit test. All three agents approved. The sort approach (localeCompare on ISO 8601) is correct, the implementation is non-mutating, and the test genuinely exercises the reordering behavior.

🤖 Generated by multi-agent AI review (Architecture · Testing · Standards)

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

AI Review Auto-Approval

Risk Level: LOW (1/10)
Verdict: CLEAN (no issues found)

This PR was auto-approved because:

  • The multi-agent AI review determined it is low risk
  • No blocking issues were found

If you believe this PR needs human review, dismiss this approval and request a review manually.

@zweatshirt zweatshirt added Preview Environment Add this label to create an Amplify Preview and removed Preview Environment Add this label to create an Amplify Preview labels May 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Preview branch generated at https://MPDX-9600.d3dytjb8adxkk5.amplifyapp.com

@zweatshirt zweatshirt enabled auto-merge May 19, 2026 21:12
@zweatshirt zweatshirt merged commit d559bbb into main May 19, 2026
64 checks passed
@zweatshirt zweatshirt deleted the MPDX-9600 branch May 19, 2026 21:16
@zweatshirt zweatshirt changed the title MPDX-9600 - Sort Income and Expenses in CSV exports by date MPDX-9600 - Staff Expense Report: Sort Income and Expenses in CSV exports by date May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Preview Environment Add this label to create an Amplify Preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant