Add Transaction Merchant management #686

Merged
jakubkottnauer merged 10 commits from 681-merchant-management into main 2024-04-30 03:17:28 +08:00
jakubkottnauer commented 2024-04-27 15:46:18 +08:00 (Migrated from github.com)

Closes #681

In addition to the issue requirements, I have also hooked up the merchants to transaction filtering.

Video:
Kapture 2024-04-28 at 12 54 23

/claim #681

Closes #681 In addition to the issue requirements, I have also hooked up the merchants to transaction filtering. Video: ![Kapture 2024-04-28 at 12 54 23](https://github.com/maybe-finance/maybe/assets/113784/a175a645-4ebd-4c6b-9964-5a5897bd4a3e) /claim #681
algora-pbc[bot] commented 2024-04-27 15:47:02 +08:00 (Migrated from github.com)
💵 To receive payouts, [sign up on Algora](https://console.algora.io/auth/signup), [link your Github account](https://console.algora.io/onboarding/solver) and [connect with Stripe/Alipay](https://console.algora.io/onboarding/solver).
jakubkottnauer commented 2024-04-28 19:02:21 +08:00 (Migrated from github.com)

@zachgoll ready for review 😄

@zachgoll ready for review 😄
zachgoll (Migrated from github.com) approved these changes 2024-04-29 22:37:20 +08:00
zachgoll (Migrated from github.com) left a comment

Awesome work on this. Thanks for adding this to the filters as well! One small comment about the delete behavior, but otherwise, looks like this is good to go!

Awesome work on this. Thanks for adding this to the filters as well! One small comment about the delete behavior, but otherwise, looks like this is good to go!
@@ -0,0 +29,4 @@
this.avatarTarget.style.borderColor = `color-mix(in srgb, ${color} 10%, white)`;
this.avatarTarget.style.color = color;
}
}
zachgoll (Migrated from github.com) commented 2024-04-29 22:10:06 +08:00

Nice idea for this 👍

Nice idea for this 👍
@@ -3,6 +3,7 @@ class Transaction < ApplicationRecord
belongs_to :account
belongs_to :category, optional: true
belongs_to :merchant, optional: true
zachgoll (Migrated from github.com) commented 2024-04-29 22:36:26 +08:00

We should probably update these lines to:

belongs_to :category, optional: true, dependent: :nullify
belongs_to :merchant, optional: true, dependent: :nullify

Currently, there is a database constraint for categories that nullifies the category field on all transactions when it is deleted introduced by this migration.

I'm still not 100% sure whether we should be doing this at the model level, DB level, or both. In the future, we may have other APIs modifying data (companion apps, etc.) which would lean towards handling it at the DB level. But for now, I think we can just do it at the model level here.

We should probably update these lines to: ``` belongs_to :category, optional: true, dependent: :nullify belongs_to :merchant, optional: true, dependent: :nullify ``` Currently, there is a database constraint for categories that nullifies the `category` field on all transactions when it is deleted introduced by [this migration](https://github.com/maybe-finance/maybe/blob/main/db/migrate/20240404112829_change_transaction_category_delete_behavior.rb). I'm still not 100% sure whether we should be doing this at the model level, DB level, or _both_. In the future, we may have other APIs modifying data (companion apps, etc.) which would lean towards handling it at the DB level. But for now, I think we can just do it at the model level here.
jakubkottnauer (Migrated from github.com) reviewed 2024-04-29 22:51:27 +08:00
@@ -3,6 +3,7 @@ class Transaction < ApplicationRecord
belongs_to :account
belongs_to :category, optional: true
belongs_to :merchant, optional: true
jakubkottnauer (Migrated from github.com) commented 2024-04-29 22:51:27 +08:00

Doesn't the has_many :transactions, dependent: :nullify on the Transaction::Category/ Transaction::Merchant models already take care of this?

94afe4bd3a/app/models/transaction/merchant.rb (L2)

Doesn't the `has_many :transactions, dependent: :nullify` on the `Transaction::Category`/ `Transaction::Merchant` models already take care of this? https://github.com/maybe-finance/maybe/blob/94afe4bd3abc826d14a64801b326b5d45fa38672/app/models/transaction/merchant.rb#L2
zachgoll (Migrated from github.com) reviewed 2024-04-30 03:17:05 +08:00
@@ -3,6 +3,7 @@ class Transaction < ApplicationRecord
belongs_to :account
belongs_to :category, optional: true
belongs_to :merchant, optional: true
zachgoll (Migrated from github.com) commented 2024-04-30 03:17:04 +08:00

Yep, you're 100% correct. I was thinking about that backwards!

Yep, you're 100% correct. I was thinking about that backwards!
Sign in to join this conversation.