SnapTrade: import Wealthsimple card activities with the right sign and merchant name
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_CARDandPREPAID_CARDas cash activities whose direction comes from the description:PURCHASEis an outflow,PAYMENTandREFUNDare inflows. A barePREPAID_CARDis inverted like other account-signed rows. A legacy bareCREDIT_CARD(always positive) keeps its sign. - Name the entry after the merchant, without the
CREDIT_CARD PURCHASE:prefix. - Add
snaptradetoDataEnrichmentsources. Renaming an existing SnapTrade entry on resync raised'snaptrade' is not a valid sourceand 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_CARDandPREPAID_CARDas cash activities; direction is taken from the description (PURCHASEis an outflow,PAYMENTandREFUNDare inflows). - Legacy bare
CREDIT_CARDrows keep their sign; barePREPAID_CARDrows are inverted like other account-signed rows. - Name the entry after the merchant without the
CREDIT_CARD PURCHASE:prefix. - Add
snaptradetoDataEnrichmentsources 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.