mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-10 07:55:21 +02:00
Merge branch 'main' of github.com:maybe-finance/maybe into zachgoll/rules-engine-v1
This commit is contained in:
commit
f7f59e0250
4 changed files with 30 additions and 7 deletions
|
@ -117,7 +117,7 @@ GEM
|
|||
bindex (0.8.1)
|
||||
bootsnap (1.18.4)
|
||||
msgpack (~> 1.2)
|
||||
brakeman (7.0.0)
|
||||
brakeman (7.0.1)
|
||||
racc
|
||||
builder (3.3.0)
|
||||
capybara (3.40.0)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -71,6 +71,8 @@ module Security::Provided
|
|||
|
||||
return price if price.present?
|
||||
|
||||
# Make sure we have a data provider before fetching
|
||||
return nil unless provider.present?
|
||||
response = provider.fetch_security_price(self, date: date)
|
||||
|
||||
return nil unless response.success? # Provider error
|
||||
|
|
|
@ -30,4 +30,15 @@ class TransfersControllerTest < ActionDispatch::IntegrationTest
|
|||
delete transfer_url(transfers(:one))
|
||||
end
|
||||
end
|
||||
|
||||
test "can add notes to transfer" do
|
||||
transfer = transfers(:one)
|
||||
assert_nil transfer.notes
|
||||
|
||||
patch transfer_url(transfer), params: { transfer: { notes: "Test notes" } }
|
||||
|
||||
assert_redirected_to transactions_url
|
||||
assert_equal "Transfer updated", flash[:notice]
|
||||
assert_equal "Test notes", transfer.reload.notes
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue