mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Fix transfers#update to save notes (#2053)
This commit is contained in:
parent
4c72231312
commit
7096eefa2b
2 changed files with 27 additions and 6 deletions
|
@ -36,14 +36,11 @@ class TransfersController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
if transfer_update_params[:status] == "rejected"
|
||||
@transfer.reject!
|
||||
elsif transfer_update_params[:status] == "confirmed"
|
||||
@transfer.confirm!
|
||||
Transfer.transaction do
|
||||
update_transfer_status
|
||||
update_transfer_details
|
||||
end
|
||||
|
||||
@transfer.outflow_transaction.update!(category_id: transfer_update_params[:category_id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_back_or_to transactions_url, notice: t(".success") }
|
||||
format.turbo_stream
|
||||
|
@ -69,4 +66,17 @@ class TransfersController < ApplicationController
|
|||
def transfer_update_params
|
||||
params.require(:transfer).permit(:notes, :status, :category_id)
|
||||
end
|
||||
|
||||
def update_transfer_status
|
||||
if transfer_update_params[:status] == "rejected"
|
||||
@transfer.reject!
|
||||
elsif transfer_update_params[:status] == "confirmed"
|
||||
@transfer.confirm!
|
||||
end
|
||||
end
|
||||
|
||||
def update_transfer_details
|
||||
@transfer.outflow_transaction.update!(category_id: transfer_update_params[:category_id])
|
||||
@transfer.update!(notes: transfer_update_params[:notes])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue