SnapTrade: import Wealthsimple card activities with the right sign and merchant name

Merged
LU
13d ago
+91-2

Fixes #5729

Wealthsimple card activities from SnapTrade now name their direction in the description (CREDIT_CARD PURCHASE: <merchant>, CREDIT_CARD REFUND: <merchant>, CREDIT_CARD PAYMENT) and are signed from the account's side. Debit card spend arrives as PREPAID_CARD. Neither type was mapped, so the provider sign passed through and purchases were stored as income.

Changes:

  • Map CREDIT_CARD and PREPAID_CARD as cash activities whose direction comes from the description: PURCHASE is an outflow, PAYMENT and REFUND are inflows. A bare PREPAID_CARD is inverted like other account-signed rows. A legacy bare CREDIT_CARD (always positive) keeps its sign.
  • Name the entry after the merchant, without the CREDIT_CARD PURCHASE: prefix.
  • Add snaptrade to DataEnrichment sources. Renaming an existing SnapTrade entry on resync raised 'snaptrade' is not a valid source and skipped the row, so an existing wrong sign could never be corrected.

Tests cover purchase, refund, payment, legacy and prepaid rows, and a resync that renames an entry and corrects its sign.

Verified on a self-hosted v0.7.6 instance with the same change backported: after a sync, November card purchases became expenses with merchant names, and card payments auto-matched with the chequing withdrawals.


Summary by cubic

Fixes #5729. Wealthsimple card activities from SnapTrade now import with the correct sign and merchant names, where purchases were previously stored as income.

  • Map CREDIT_CARD and PREPAID_CARD as cash activities; direction is taken from the description (PURCHASE is an outflow, PAYMENT and REFUND are inflows).
  • Legacy bare CREDIT_CARD rows keep their sign; bare PREPAID_CARD rows are inverted like other account-signed rows.
  • Name the entry after the merchant without the CREDIT_CARD PURCHASE: prefix.
  • Add snaptrade to DataEnrichment sources so resyncs can rename entries and correct their sign instead of skipping them.

Summary by CodeRabbit

  • New Features
    • Added support for importing SnapTrade credit-card and prepaid-card activity, including purchases, payments, and refunds.
    • Added support for importing substitute dividend activity.
  • Bug Fixes
    • Card activity amounts now reflect the transaction type, and merchant names appear when available.
    • Resyncing card transactions updates existing amounts and merchant names without errors.