2024-02-02 09:05:04 -06:00
|
|
|
class AccountsController < ApplicationController
|
2024-07-26 18:00:41 +02:00
|
|
|
layout :with_sidebar
|
2024-05-17 09:09:32 -04:00
|
|
|
|
2024-11-04 20:27:31 -05:00
|
|
|
before_action :set_account, only: %i[sync]
|
2024-02-02 10:39:16 -06:00
|
|
|
|
2024-04-18 07:56:51 -04:00
|
|
|
def index
|
2024-11-15 13:49:37 -05:00
|
|
|
@manual_accounts = Current.family.accounts.manual.active.alphabetically
|
|
|
|
@plaid_items = Current.family.plaid_items.active.ordered
|
2024-04-18 07:56:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def summary
|
2024-11-04 20:27:31 -05:00
|
|
|
@period = Period.from_param(params[:period])
|
2024-04-18 07:56:51 -04:00
|
|
|
snapshot = Current.family.snapshot(@period)
|
|
|
|
@net_worth_series = snapshot[:net_worth_series]
|
|
|
|
@asset_series = snapshot[:asset_series]
|
|
|
|
@liability_series = snapshot[:liability_series]
|
2024-05-03 12:11:31 +00:00
|
|
|
@accounts = Current.family.accounts
|
|
|
|
@account_groups = @accounts.by_group(period: @period, currency: Current.family.currency)
|
2024-04-18 07:56:51 -04:00
|
|
|
end
|
|
|
|
|
2024-04-29 14:56:38 +01:00
|
|
|
def list
|
2024-11-08 15:10:05 +01:00
|
|
|
@period = Period.from_param(params[:period])
|
2024-07-16 14:08:24 -04:00
|
|
|
render layout: false
|
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-07-05 13:36:18 +02:00
|
|
|
def sync_all
|
2024-11-15 13:49:37 -05:00
|
|
|
unless Current.family.syncing?
|
|
|
|
Current.family.sync_later
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to accounts_path
|
2024-07-05 13:36:18 +02:00
|
|
|
end
|
|
|
|
|
2024-02-02 10:39:16 -06:00
|
|
|
private
|
2024-05-17 09:09:32 -04:00
|
|
|
def set_account
|
|
|
|
@account = Current.family.accounts.find(params[:id])
|
|
|
|
end
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|