1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-09 23:45:21 +02:00

Fix merge errors

This commit is contained in:
Zach Gollwitzer 2025-04-14 12:06:07 -04:00
parent 5a694ad055
commit e07b2d844c
4 changed files with 47 additions and 91 deletions

View file

@ -6,11 +6,14 @@ class TransactionCategoriesController < ApplicationController
respond_to do |format|
format.html { redirect_back_or_to transaction_path(@entry) }
format.turbo_stream do
render turbo_stream: turbo_stream.replace(
"category_menu_transaction_#{@entry.transaction_id}",
partial: "categories/menu",
locals: { transaction: @entry.transaction }
)
render turbo_stream: [
turbo_stream.replace(
"category_menu_transaction_#{@entry.entryable_id}",
partial: "categories/menu",
locals: { transaction: @entry.transaction }
),
*flash_notification_stream_items
]
end
end
end
@ -19,4 +22,16 @@ class TransactionCategoriesController < ApplicationController
def entry_params
params.require(:entry).permit(:entryable_type, entryable_attributes: [ :id, :category_id ])
end
def needs_rule_notification?(transaction)
return false if Current.user.rule_prompts_disabled
if Current.user.rule_prompt_dismissed_at.present?
time_since_last_rule_prompt = Time.current - Current.user.rule_prompt_dismissed_at
return false if time_since_last_rule_prompt < 1.day
end
transaction.saved_change_to_category_id? &&
transaction.eligible_for_category_rule?
end
end

View file

@ -54,6 +54,8 @@ class TransactionsController < ApplicationController
if @entry.save
@entry.sync_account_later
@entry.lock_saved_attributes!
@entry.transaction.lock!(:tag_ids) if @entry.transaction.tags.any?
flash[:notice] = "Transaction created"
@ -69,6 +71,8 @@ class TransactionsController < ApplicationController
def update
if @entry.update(entry_params)
@entry.sync_account_later
@entry.lock_saved_attributes!
@entry.account_transaction.lock!(:tag_ids) if @entry.account_transaction.tags.any?
respond_to do |format|
format.html { redirect_back_or_to account_path(@entry.account), notice: "Transaction updated" }
@ -79,7 +83,8 @@ class TransactionsController < ApplicationController
partial: "transactions/header",
locals: { entry: @entry }
),
turbo_stream.replace(@entry)
turbo_stream.replace(@entry),
*flash_notification_stream_items
]
end
end
@ -89,6 +94,18 @@ class TransactionsController < ApplicationController
end
private
def needs_rule_notification?(transaction)
return false if Current.user.rule_prompts_disabled
if Current.user.rule_prompt_dismissed_at.present?
time_since_last_rule_prompt = Time.current - Current.user.rule_prompt_dismissed_at
return false if time_since_last_rule_prompt < 1.day
end
transaction.saved_change_to_category_id? &&
transaction.eligible_for_category_rule?
end
def entry_params
entry_params = params.require(:entry).permit(
:name, :enriched_name, :date, :amount, :currency, :excluded, :notes, :nature, :entryable_type,

View file

@ -1,7 +1,7 @@
class Merchant < ApplicationRecord
TYPES = %w[FamilyMerchant ProviderMerchant].freeze
has_many :transactions, dependent: :nullify, class_name: "Transaction"
has_many :transactions, dependent: :nullify
validates :name, presence: true
validates :type, inclusion: { in: TYPES }

92
db/schema.rb generated
View file

@ -10,7 +10,6 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_04_11_191422) do
ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
@ -20,81 +19,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
# Note that some types may not work with other database engines. Be careful if changing database.
create_enum "account_status", ["ok", "syncing", "error"]
create_table "account_balances", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "account_id", null: false
t.date "date", null: false
t.decimal "balance", precision: 19, scale: 4, null: false
t.string "currency", default: "USD", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.decimal "cash_balance", precision: 19, scale: 4, default: "0.0"
t.index ["account_id", "date", "currency"], name: "index_account_balances_on_account_id_date_currency_unique", unique: true
t.index ["account_id"], name: "index_account_balances_on_account_id"
end
create_table "account_entries", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "account_id", null: false
t.string "entryable_type"
t.uuid "entryable_id"
t.decimal "amount", precision: 19, scale: 4
t.string "currency"
t.date "date"
t.string "name", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "import_id"
t.text "notes"
t.boolean "excluded", default: false
t.string "plaid_id"
t.datetime "enriched_at"
t.string "enriched_name"
t.jsonb "locked_attributes", default: {}
t.index ["account_id"], name: "index_account_entries_on_account_id"
t.index ["import_id"], name: "index_account_entries_on_import_id"
end
create_table "account_holdings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "account_id", null: false
t.uuid "security_id", null: false
t.date "date", null: false
t.decimal "qty", precision: 19, scale: 4, null: false
t.decimal "price", precision: 19, scale: 4, null: false
t.decimal "amount", precision: 19, scale: 4, null: false
t.string "currency", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id", "security_id", "date", "currency"], name: "idx_on_account_id_security_id_date_currency_234024c8e3", unique: true
t.index ["account_id"], name: "index_account_holdings_on_account_id"
t.index ["security_id"], name: "index_account_holdings_on_security_id"
end
create_table "account_trades", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "security_id", null: false
t.decimal "qty", precision: 19, scale: 4
t.decimal "price", precision: 19, scale: 4
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "currency"
t.jsonb "locked_attributes", default: {}
t.index ["security_id"], name: "index_account_trades_on_security_id"
end
create_table "account_transactions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.uuid "category_id"
t.uuid "merchant_id"
t.jsonb "locked_attributes", default: {}
t.index ["category_id"], name: "index_account_transactions_on_category_id"
t.index ["merchant_id"], name: "index_account_transactions_on_merchant_id"
end
create_table "account_valuations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.jsonb "locked_attributes", default: {}
end
create_table "accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "subtype"
t.uuid "family_id", null: false
@ -276,6 +200,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
t.string "plaid_id"
t.datetime "enriched_at"
t.string "enriched_name"
t.jsonb "locked_attributes", default: {}
t.index ["account_id"], name: "index_entries_on_account_id"
t.index ["import_id"], name: "index_entries_on_import_id"
end
@ -448,6 +373,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
t.decimal "interest_rate", precision: 10, scale: 3
t.integer "term_months"
t.decimal "initial_balance", precision: 19, scale: 4
t.jsonb "locked_attributes", default: {}
end
create_table "merchants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@ -701,6 +627,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "currency"
t.jsonb "locked_attributes", default: {}
t.index ["security_id"], name: "index_trades_on_security_id"
end
@ -709,6 +636,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
t.datetime "updated_at", null: false
t.uuid "category_id"
t.uuid "merchant_id"
t.jsonb "locked_attributes", default: {}
t.index ["category_id"], name: "index_transactions_on_category_id"
t.index ["merchant_id"], name: "index_transactions_on_merchant_id"
end
@ -745,9 +673,9 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
t.uuid "last_viewed_chat_id"
t.boolean "show_ai_sidebar", default: true
t.boolean "ai_enabled", default: false, null: false
t.string "theme", default: "system"
t.boolean "rule_prompts_disabled", default: false
t.datetime "rule_prompt_dismissed_at"
t.string "theme", default: "system"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["family_id"], name: "index_users_on_family_id"
t.index ["last_viewed_chat_id"], name: "index_users_on_last_viewed_chat_id"
@ -757,6 +685,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
create_table "valuations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.jsonb "locked_attributes", default: {}
end
create_table "vehicles", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
@ -796,17 +725,12 @@ ActiveRecord::Schema[7.2].define(version: 2025_04_13_141446) do
add_foreign_key "messages", "chats"
add_foreign_key "plaid_accounts", "plaid_items"
add_foreign_key "plaid_items", "families"
<<<<<<< HEAD
add_foreign_key "rejected_transfers", "account_transactions", column: "inflow_transaction_id"
add_foreign_key "rejected_transfers", "account_transactions", column: "outflow_transaction_id"
add_foreign_key "rejected_transfers", "transactions", column: "inflow_transaction_id"
add_foreign_key "rejected_transfers", "transactions", column: "outflow_transaction_id"
add_foreign_key "rule_actions", "rules"
add_foreign_key "rule_conditions", "rule_conditions", column: "parent_id"
add_foreign_key "rule_conditions", "rules"
add_foreign_key "rules", "families"
=======
add_foreign_key "rejected_transfers", "transactions", column: "inflow_transaction_id"
add_foreign_key "rejected_transfers", "transactions", column: "outflow_transaction_id"
>>>>>>> e657c40d195012e396824cd346df1f0df8ef4e44
add_foreign_key "security_prices", "securities"
add_foreign_key "sessions", "impersonation_sessions", column: "active_impersonator_session_id"
add_foreign_key "sessions", "users"