mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
Multi-step account forms + clearer balance editing (#2427)
* Initial multi-step property form * Improve form structure, add optional tooltip help icons to form fields * Add basic inline alert component * Clean up and improve property form lifecycle * Implement Account status concept * Lint fixes * Remove whitespace * Balance editing, scope updates for account * Passing tests * Fix brakeman warning * Remove stale columns * data constraint tweaks * Redundant property
This commit is contained in:
parent
ba7e8d3893
commit
662f2c04ce
66 changed files with 1036 additions and 427 deletions
41
db/migrate/20250701161640_add_account_status.rb
Normal file
41
db/migrate/20250701161640_add_account_status.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
class AddAccountStatus < ActiveRecord::Migration[7.2]
|
||||
def up
|
||||
add_column :accounts, :status, :string, default: "active"
|
||||
change_column_null :entries, :amount, false
|
||||
|
||||
# Migrate existing data
|
||||
execute <<-SQL
|
||||
UPDATE accounts
|
||||
SET status = CASE
|
||||
WHEN scheduled_for_deletion = true THEN 'pending_deletion'
|
||||
WHEN is_active = true THEN 'active'
|
||||
WHEN is_active = false THEN 'disabled'
|
||||
ELSE 'draft'
|
||||
END
|
||||
SQL
|
||||
|
||||
remove_column :accounts, :is_active
|
||||
remove_column :accounts, :scheduled_for_deletion
|
||||
end
|
||||
|
||||
def down
|
||||
add_column :accounts, :is_active, :boolean, default: true, null: false
|
||||
add_column :accounts, :scheduled_for_deletion, :boolean, default: false
|
||||
|
||||
# Restore the original boolean fields based on status
|
||||
execute <<-SQL
|
||||
UPDATE accounts
|
||||
SET is_active = CASE
|
||||
WHEN status = 'active' THEN true
|
||||
WHEN status IN ('disabled', 'pending_deletion') THEN false
|
||||
ELSE false
|
||||
END,
|
||||
scheduled_for_deletion = CASE
|
||||
WHEN status = 'pending_deletion' THEN true
|
||||
ELSE false
|
||||
END
|
||||
SQL
|
||||
|
||||
remove_column :accounts, :status
|
||||
end
|
||||
end
|
16
db/schema.rb
generated
16
db/schema.rb
generated
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_06_23_162207) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_07_01_161640) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
@ -29,13 +29,12 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_23_162207) do
|
|||
t.uuid "accountable_id"
|
||||
t.decimal "balance", precision: 19, scale: 4
|
||||
t.string "currency"
|
||||
t.boolean "is_active", default: true, null: false
|
||||
t.virtual "classification", type: :string, as: "\nCASE\n WHEN ((accountable_type)::text = ANY (ARRAY[('Loan'::character varying)::text, ('CreditCard'::character varying)::text, ('OtherLiability'::character varying)::text])) THEN 'liability'::text\n ELSE 'asset'::text\nEND", stored: true
|
||||
t.virtual "classification", type: :string, as: "\nCASE\n WHEN ((accountable_type)::text = ANY ((ARRAY['Loan'::character varying, 'CreditCard'::character varying, 'OtherLiability'::character varying])::text[])) THEN 'liability'::text\n ELSE 'asset'::text\nEND", stored: true
|
||||
t.uuid "import_id"
|
||||
t.uuid "plaid_account_id"
|
||||
t.boolean "scheduled_for_deletion", default: false
|
||||
t.decimal "cash_balance", precision: 19, scale: 4, default: "0.0"
|
||||
t.jsonb "locked_attributes", default: {}
|
||||
t.string "status", default: "active"
|
||||
t.index ["accountable_id", "accountable_type"], name: "index_accounts_on_accountable_id_and_accountable_type"
|
||||
t.index ["accountable_type"], name: "index_accounts_on_accountable_type"
|
||||
t.index ["family_id", "accountable_type"], name: "index_accounts_on_family_id_and_accountable_type"
|
||||
|
@ -205,7 +204,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_23_162207) do
|
|||
t.uuid "account_id", null: false
|
||||
t.string "entryable_type"
|
||||
t.uuid "entryable_id"
|
||||
t.decimal "amount", precision: 19, scale: 4
|
||||
t.decimal "amount", precision: 19, scale: 4, null: false
|
||||
t.string "currency"
|
||||
t.date "date"
|
||||
t.string "name", null: false
|
||||
|
@ -216,12 +215,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_23_162207) do
|
|||
t.boolean "excluded", default: false
|
||||
t.string "plaid_id"
|
||||
t.jsonb "locked_attributes", default: {}
|
||||
t.index ["account_id", "date"], name: "index_entries_on_account_id_and_date"
|
||||
t.index ["account_id"], name: "index_entries_on_account_id"
|
||||
t.index ["amount"], name: "index_entries_on_amount"
|
||||
t.index ["date"], name: "index_entries_on_date"
|
||||
t.index ["entryable_id", "entryable_type"], name: "index_entries_on_entryable"
|
||||
t.index ["excluded"], name: "index_entries_on_excluded"
|
||||
t.index ["import_id"], name: "index_entries_on_import_id"
|
||||
end
|
||||
|
||||
|
@ -232,7 +226,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_23_162207) do
|
|||
t.date "date", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["date", "from_currency", "to_currency"], name: "index_exchange_rates_on_date_and_currencies"
|
||||
t.index ["from_currency", "to_currency", "date"], name: "index_exchange_rates_on_base_converted_date_unique", unique: true
|
||||
t.index ["from_currency"], name: "index_exchange_rates_on_from_currency"
|
||||
t.index ["to_currency"], name: "index_exchange_rates_on_to_currency"
|
||||
|
@ -691,7 +684,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_06_23_162207) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["tag_id"], name: "index_taggings_on_tag_id"
|
||||
t.index ["taggable_id", "taggable_type"], name: "index_taggings_on_taggable_id_and_type"
|
||||
t.index ["taggable_type", "taggable_id"], name: "index_taggings_on_taggable"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue