Skip to content

Fix export csv - #31

Merged
paperplate merged 1 commit into
mainfrom
push-znlklqlqnloy
Jun 10, 2026
Merged

Fix export csv#31
paperplate merged 1 commit into
mainfrom
push-znlklqlqnloy

Conversation

@paperplate

@paperplate paperplate commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Corrected transaction amount formatting in CSV exports to display accurate currency values with proper decimal precision.
  • Tests

    • Added test coverage for the CSV export endpoint to validate format accuracy and response headers.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates transaction CSV export to derive the amount field from amount_cents converted to dollars with two-decimal formatting, replacing the prior amount_dollars reference. A test is added to verify the /api/transactions/export endpoint returns a valid CSV response with the correct headers and data.

Changes

Transaction CSV Export Amount Formatting

Layer / File(s) Summary
CSV export amount formatting with test validation
JustAnotherExpenseManager/routes/transactions.py, tests/test_routes.py
The export_transactions endpoint now formats the "amount" CSV column by dividing amount_cents by 100 with two-decimal precision instead of using amount_dollars. The new test test_export_transactions_csv verifies the endpoint returns status 200, the correct CSV attachment header, and expected column/data in the response.

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix export csv' is vague and generic, using non-descriptive terms that don't convey the specific nature of the change. Consider a more specific title such as 'Fix CSV export amount formatting to use cents-to-dollars conversion' to clearly indicate what was fixed.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch push-znlklqlqnloy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/test_routes.py (1)

123-129: ⚡ Quick win

Assert the exported amount format explicitly.

This test validates CSV presence but not the new cents→dollars formatting behavior. Add an assertion that exported amount values are two-decimal strings.

Proposed test hardening
 def test_export_transactions_csv(self, client, sample_transactions):
     response = client.get('/api/transactions/export')
     assert response.status_code == 200
     assert response.headers['Content-Disposition'].startswith('attachment; filename=')
     assert b'description,amount,type,category,date,tags' in response.data
     assert b'Restaurant' in response.data
+    import csv
+    from io import StringIO
+    rows = list(csv.DictReader(StringIO(response.data.decode('utf-8'))))
+    assert rows, "Expected at least one exported transaction row"
+    for row in rows:
+        whole, dot, frac = row['amount'].partition('.')
+        assert dot == '.' and len(frac) == 2 and whole.isdigit()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_routes.py` around lines 123 - 129, In
test_export_transactions_csv, add an assertion that the exported CSV's amount
column uses two-decimal dollar formatting by parsing response.data (or decoding
to text) and verifying the amount fields match a two-decimal pattern (e.g. regex
like ^\d+\.\d{2}$) for one or more sample rows from the CSV produced by the
sample_transactions fixture; update the test_export_transactions_csv function to
extract the CSV rows from response.data and assert the amount strings conform to
the two-decimal format.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_routes.py`:
- Around line 123-129: In test_export_transactions_csv, add an assertion that
the exported CSV's amount column uses two-decimal dollar formatting by parsing
response.data (or decoding to text) and verifying the amount fields match a
two-decimal pattern (e.g. regex like ^\d+\.\d{2}$) for one or more sample rows
from the CSV produced by the sample_transactions fixture; update the
test_export_transactions_csv function to extract the CSV rows from response.data
and assert the amount strings conform to the two-decimal format.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 44620ae5-92f0-4f75-a8b4-aff56cf3460f

📥 Commits

Reviewing files that changed from the base of the PR and between 940b14b and 107cbcb.

📒 Files selected for processing (2)
  • JustAnotherExpenseManager/routes/transactions.py
  • tests/test_routes.py

@paperplate
paperplate merged commit ab6d6e2 into main Jun 10, 2026
8 checks passed
@paperplate
paperplate deleted the push-znlklqlqnloy branch June 10, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant