mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 08:09:38 +02:00
Account namespace updates: part 6 (transactions) (#904)
* Move Transaction to Account namespace * Fix improper routes, improve separation of concerns * Replace account transactions list partial with view * Remove logs * Consolidate transaction views * Remove unused code * Transfer style tweaks * Remove more unused code * Add back totals by currency helper
This commit is contained in:
parent
cb3fd34f90
commit
da18c3d850
72 changed files with 575 additions and 522 deletions
44
app/controllers/account/transactions_controller.rb
Normal file
44
app/controllers/account/transactions_controller.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
class Account::TransactionsController < ApplicationController
|
||||
layout "with_sidebar"
|
||||
|
||||
before_action :set_account
|
||||
before_action :set_transaction, only: %i[ show update destroy ]
|
||||
|
||||
def index
|
||||
@transactions = @account.transactions.ordered
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
@transaction.update! transaction_params
|
||||
@transaction.sync_account_later
|
||||
|
||||
redirect_back_or_to account_transaction_url(@transaction.account, @transaction), notice: t(".success")
|
||||
end
|
||||
|
||||
def destroy
|
||||
@transaction.destroy!
|
||||
@transaction.sync_account_later
|
||||
redirect_back_or_to account_url(@transaction.account), notice: t(".success")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
@account = Current.family.accounts.find(params[:account_id])
|
||||
end
|
||||
|
||||
def set_transaction
|
||||
@transaction = @account.transactions.find(params[:id])
|
||||
end
|
||||
|
||||
def search_params
|
||||
params.fetch(:q, {}).permit(:start_date, :end_date, :search, accounts: [], account_ids: [], categories: [], merchants: [])
|
||||
end
|
||||
|
||||
def transaction_params
|
||||
params.require(:transaction).permit(:name, :date, :amount, :currency, :notes, :excluded, :category_id, :merchant_id, tag_ids: [])
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue