Skip to content

fix: match the card portion of Amazon refunds split with points - #105

Merged
eshaffer321 merged 1 commit into
mainfrom
fix/amazon-refund-card-portion
Oct 14, 2026
Merged

eshaffer321 merged 1 commit into
mainfrom
fix/amazon-refund-card-portion

Conversation

@eshaffer321

Copy link
Copy Markdown
Owner

Problem

An Amazon refund of +$31.24 was never categorized. Its order was paid $31.24 by card plus $11.15 in Amazon Visa points, and the Return Center reports the refund total ($42.39). Refund matching looked for a $42.39 credit, which never appears in Monarch.

Fix

  • Bump amazon-go to v0.5.0 (release). It flags refund rows on the payment transactions page (Transaction.IsRefund) and dates each row correctly.
  • convertGoTransaction maps IsRefund to refund, so a refunded order no longer looks like it has duplicate card charges.
  • FetchReturns fetches each refunded order's transactions (one request per order) and attaches RefundTenders to the return. It only does this when the rows match that return unambiguously (same issued day, sum equals the Return Center total).
  • Refund matching, item pricing, and same-day grouping use BankRefundAmount(), the card portion. Points-only refunds are skipped with an explicit reason. Returns without a breakdown behave as before.

Testing

  • Seven new tests across the provider, handler, and orchestrator; all failed with the fix disabled.
  • go test ./... -race passes.
  • ./itemize amazon -account wife -dry-run -days 14 now categorizes the refund against the +$31.24 credit.

Logged in docs/bug-fixes.md.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.56627% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.75%. Comparing base (9b61da0) to head (a6f0cac).

Files with missing lines Patch % Lines
internal/adapters/providers/amazon/returns.go 91.17% 4 Missing and 2 partials ⚠️
...ternal/application/sync/handlers/amazon_refunds.go 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #105      +/-   ##
==========================================
+ Coverage   65.48%   65.75%   +0.26%     
==========================================
  Files          51       51              
  Lines        7038     7110      +72     
==========================================
+ Hits         4609     4675      +66     
- Misses       2087     2091       +4     
- Partials      342      344       +2     
Flag Coverage Δ
unittests 65.75% <91.56%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/adapters/providers/amazon/provider.go 83.70% <100.00%> (ø)
internal/application/sync/amazon_returns.go 79.56% <100.00%> (ø)
...ternal/application/sync/handlers/amazon_refunds.go 88.23% <92.30%> (+0.50%) ⬆️
internal/adapters/providers/amazon/returns.go 82.60% <91.17%> (+2.26%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The Return Center reports a refund's total across all tenders, but the bank
feed only shows the card credit. Bump amazon-go to v0.5.0 for per-tender
refund rows, attach them to each return, and match on the card portion.
@eshaffer321
eshaffer321 force-pushed the fix/amazon-refund-card-portion branch from 3905fae to a6f0cac Compare October 14, 2026 11:54
@eshaffer321
eshaffer321 merged commit ac11fdd into main Oct 14, 2026
14 checks passed
@eshaffer321
eshaffer321 deleted the fix/amazon-refund-card-portion branch October 14, 2026 11:57
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