Transaction transfers, payments, and matching #883

Merged
zachgoll merged 11 commits from 858-allow-users-to-mark-transactions-as-payments-or-transfers-which-are-excluded-from-income-and-expense-calculations into main 2024-06-19 18:52:08 +08:00
zachgoll commented 2024-06-18 02:35:31 +08:00 (Migrated from github.com)

https://github.com/maybe-finance/maybe/assets/16676157/a1cde494-b89f-466a-8c74-da194934288a

Overview

This PR enables transaction transfers and subsets (payments).

Additionally, I have cleaned up some of the snapshot fixtures to make them easier to modify and more clear to read.

What is a "Transfer"?

A transfer represents a pair of transactions that:

  • Have opposite amounts (net zero)
  • Come from different accounts
  • Are generally (but not always) posted on the same day
  • Represent an outflow from one account and inflow to another account
  • Do not affect income or expense calculations

Transaction Matching

In a personal finance app like Maybe, we cannot guarantee the user will have both accounts "connected" to the app. Because of this, a transfer can also be represented by a single outgoing/incoming transaction to/from some external account. Even in these cases, the user generally will not want these transactions to be included in any "budgeting" calculations like income/expense.

Because we cannot guarantee both sides of the transfer can be found within the user's data, transaction "matching" must happen in two separate steps:

  1. Mark a transactions as a transfer by setting marked_as_transfer: true
  2. Create a Transfer record by asking the user to confirm both transactions for the identified transfer

The marked_as_transfer is a slightly denormalized convenience field that serves a few purposes:

  • Allows a user to easily mark 1+ transactions as "transfers" without having to manually confirm the details.
  • In the future, allows the system to auto-classify transfers without having to confirm that the match is correct
  • Improved query performance in both aggregation queries (summing income/expense and excluding transfers) and listing transactions in the global transactions view (no need to join to display a transaction row)
https://github.com/maybe-finance/maybe/assets/16676157/a1cde494-b89f-466a-8c74-da194934288a ## Overview This PR enables transaction transfers and subsets (payments). Additionally, I have cleaned up some of the snapshot fixtures to make them easier to modify and more clear to read. ## What is a "Transfer"? A transfer represents a pair of transactions that: - Have opposite amounts (net zero) - Come from different accounts - Are _generally_ (but not always) posted on the same day - Represent an _outflow_ from one account and _inflow_ to another account - Do not affect income or expense calculations ### Transaction Matching In a personal finance app like Maybe, we cannot guarantee the user will have _both_ accounts "connected" to the app. Because of this, a transfer can also be represented by a single outgoing/incoming transaction to/from some _external_ account. Even in these cases, the user _generally_ will not want these transactions to be included in any "budgeting" calculations like income/expense. Because we cannot guarantee both sides of the transfer can be found within the user's data, transaction "matching" must happen in two separate steps: 1. Mark a transactions as a transfer by setting `marked_as_transfer: true` 2. Create a `Transfer` record by asking the user to confirm both transactions for the identified transfer The `marked_as_transfer` is a slightly denormalized convenience field that serves a few purposes: - Allows a user to easily mark 1+ transactions as "transfers" without having to manually confirm the details. - In the future, allows the system to auto-classify transfers without having to confirm that the match is correct - Improved query performance in both aggregation queries (summing income/expense and excluding transfers) and listing transactions in the global transactions view (no need to join to display a transaction row)
gavin approved these changes 2024-06-18 10:16:52 +08:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gavin/maybe#883