2024-02-02 09:05:04 -06:00
|
|
|
class AccountsController < ApplicationController
|
2025-02-21 11:57:59 -05:00
|
|
|
before_action :set_account, only: %i[sync chart sparkline]
|
2025-03-07 20:35:54 +05:30
|
|
|
include Periodable
|
2024-02-02 10:39:16 -06:00
|
|
|
|
2024-04-18 07:56:51 -04:00
|
|
|
def index
|
2025-02-21 11:57:59 -05:00
|
|
|
@manual_accounts = family.accounts.manual.alphabetically
|
|
|
|
@plaid_items = family.plaid_items.ordered
|
2024-04-18 07:56:51 -04:00
|
|
|
|
2025-02-21 11:57:59 -05:00
|
|
|
render layout: "settings"
|
2024-04-29 14:56:38 +01:00
|
|
|
end
|
|
|
|
|
2024-03-21 13:39:10 -04:00
|
|
|
def sync
|
2024-06-13 17:03:38 -04:00
|
|
|
unless @account.syncing?
|
2024-05-20 16:34:48 +02:00
|
|
|
@account.sync_later
|
2024-03-21 13:39:10 -04:00
|
|
|
end
|
2024-11-15 13:49:37 -05:00
|
|
|
|
|
|
|
redirect_to account_path(@account)
|
2024-03-21 13:39:10 -04:00
|
|
|
end
|
|
|
|
|
2024-11-27 16:01:50 -05:00
|
|
|
def chart
|
2025-03-07 17:35:55 -05:00
|
|
|
@chart_view = params[:chart_view] || "balance"
|
2024-11-27 16:01:50 -05:00
|
|
|
render layout: "application"
|
|
|
|
end
|
|
|
|
|
2025-02-21 11:57:59 -05:00
|
|
|
def sparkline
|
|
|
|
render layout: false
|
2025-05-26 20:05:16 -05:00
|
|
|
rescue => e
|
|
|
|
Rails.logger.error "Sparkline error for account #{@account.id}: #{e.message}"
|
|
|
|
render partial: "accounts/sparkline_error", layout: false
|
2025-02-21 11:57:59 -05:00
|
|
|
end
|
|
|
|
|
2024-02-02 10:39:16 -06:00
|
|
|
private
|
2025-02-21 11:57:59 -05:00
|
|
|
def family
|
|
|
|
Current.family
|
|
|
|
end
|
|
|
|
|
2024-05-17 09:09:32 -04:00
|
|
|
def set_account
|
2025-02-21 11:57:59 -05:00
|
|
|
@account = family.accounts.find(params[:id])
|
2024-05-17 09:09:32 -04:00
|
|
|
end
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|