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:
Zach Gollwitzer
2025-01-27 16:56:46 -05:00
committed by GitHub
parent 0b4e314f58
commit de90b29201
18 changed files with 221 additions and 79 deletions

View File

@@ -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