1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 23:59:40 +02:00

Add ability to delete Account (#582)

* Add ability to delete Account

Issue #571

* Fix ActiveJob::DeserializationError in AccountSyncJob when an account doesn't exists

* Use custom confirm modal for account deletion

* Revert "Fix ActiveJob::DeserializationError in AccountSyncJob when an account doesn't exists"

This reverts commit 8dbf634819.
This commit is contained in:
Mattia 2024-03-31 23:36:54 +02:00 committed by GitHub
parent 7fa77b4fd7
commit f6540c03ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 7 deletions

View file

@ -1,6 +1,7 @@
class AccountsController < ApplicationController
include Filterable
before_action :authenticate_user!
before_action :set_account, only: %i[ show update destroy sync ]
def new
@account = Account.new(
@ -10,7 +11,6 @@ class AccountsController < ApplicationController
end
def show
@account = Current.family.accounts.find(params[:id])
@balance_series = @account.series(period: @period)
@valuation_series = @account.valuations.to_series
end
@ -19,8 +19,6 @@ class AccountsController < ApplicationController
end
def update
@account = Current.family.accounts.find(params[:id])
if @account.update(account_params.except(:accountable_type))
@account.sync_later if account_params[:is_active] == "1"
@ -50,8 +48,12 @@ class AccountsController < ApplicationController
end
end
def destroy
@account.destroy!
redirect_to accounts_path, notice: t(".success")
end
def sync
@account = Current.family.accounts.find(params[:id])
@account.sync_later
respond_to do |format|
@ -67,6 +69,10 @@ class AccountsController < ApplicationController
private
def set_account
@account = Current.family.accounts.find(params[:id])
end
def account_params
params.require(:account).permit(:name, :accountable_type, :balance, :currency, :subtype, :is_active)
end