-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Account Activity View + Account Forms (#1406)
* Remove balance mode, sketch out refactor * Activity view checkpoint * Entry partials, checkpoint * Finish txn partial * Give entries context when editing for different turbo responses * Calculate change of balance for each entry * Account tabs consolidation * Translations, linting, brakeman updates * Account actions concern * Finalize forms, get account system tests passing * Get tests passing * Lint, rubocop, schema updates * Improve routing and stream responses * Fix broken routes * Add import option for adding accounts * Fix system test * Fix test specificity * Fix sparklines * Improve account redirects
- Loading branch information
Showing
216 changed files
with
2,045 additions
and
1,622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
module AccountableResource | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
layout :with_sidebar | ||
before_action :set_account, only: [ :show, :edit, :update, :destroy ] | ||
end | ||
|
||
class_methods do | ||
def permitted_accountable_attributes(*attrs) | ||
@permitted_accountable_attributes = attrs if attrs.any? | ||
@permitted_accountable_attributes ||= [ :id ] | ||
end | ||
end | ||
|
||
def new | ||
@account = Current.family.accounts.build( | ||
currency: Current.family.currency, | ||
accountable: accountable_type.new, | ||
institution_id: params[:institution_id] | ||
) | ||
end | ||
|
||
def show | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def create | ||
@account = Current.family.accounts.create_and_sync(account_params.except(:return_to)) | ||
redirect_to account_params[:return_to].presence || @account, notice: t(".success") | ||
end | ||
|
||
def update | ||
@account.update_with_sync!(account_params.except(:return_to)) | ||
redirect_back_or_to @account, notice: t(".success") | ||
end | ||
|
||
def destroy | ||
@account.destroy! | ||
redirect_to accounts_path, notice: t(".success") | ||
end | ||
|
||
private | ||
def accountable_type | ||
controller_name.classify.constantize | ||
end | ||
|
||
def set_account | ||
@account = Current.family.accounts.find(params[:id]) | ||
end | ||
|
||
def account_params | ||
params.require(:account).permit( | ||
:name, :is_active, :balance, :subtype, :currency, :institution_id, :accountable_type, :return_to, | ||
accountable_attributes: self.class.permitted_accountable_attributes | ||
) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,12 @@ | ||
class CreditCardsController < ApplicationController | ||
before_action :set_account, only: :update | ||
|
||
def create | ||
account = Current.family | ||
.accounts | ||
.create_with_optional_start_balance! \ | ||
attributes: account_params.except(:start_date, :start_balance), | ||
start_date: account_params[:start_date], | ||
start_balance: account_params[:start_balance] | ||
|
||
account.sync_later | ||
redirect_to account, notice: t(".success") | ||
end | ||
|
||
def update | ||
@account.update_with_sync!(account_params) | ||
redirect_to @account, notice: t(".success") | ||
end | ||
|
||
private | ||
|
||
def set_account | ||
@account = Current.family.accounts.find(params[:id]) | ||
end | ||
|
||
def account_params | ||
params.require(:account) | ||
.permit( | ||
:name, :balance, :institution_id, :mode, :start_date, :start_balance, :currency, :accountable_type, | ||
accountable_attributes: [ | ||
:id, | ||
:available_credit, | ||
:minimum_payment, | ||
:apr, | ||
:annual_fee, | ||
:expiration_date | ||
] | ||
) | ||
end | ||
include AccountableResource | ||
|
||
permitted_accountable_attributes( | ||
:id, | ||
:available_credit, | ||
:minimum_payment, | ||
:apr, | ||
:annual_fee, | ||
:expiration_date | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class CryptosController < ApplicationController | ||
include AccountableResource | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class DepositoriesController < ApplicationController | ||
include AccountableResource | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class InvestmentsController < ApplicationController | ||
include AccountableResource | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.