mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Add RejectedTransfer model, simplify auto matching (#1690)
* Allow transfers to match when inflow is after outflow * Simplify transfer auto matching with RejectedTransfer model * Validations * Reset migrations
This commit is contained in:
parent
0b4e314f58
commit
de90b29201
18 changed files with 221 additions and 79 deletions
|
@ -38,11 +38,14 @@ class TransfersController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
Transfer.transaction do
|
||||
@transfer.update!(transfer_update_params.except(:category_id))
|
||||
@transfer.outflow_transaction.update!(category_id: transfer_update_params[:category_id])
|
||||
if transfer_update_params[:status] == "rejected"
|
||||
@transfer.reject!
|
||||
elsif transfer_update_params[:status] == "confirmed"
|
||||
@transfer.confirm!
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue