1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00

Allow CSV imports to be configured with single or multi-account mode (#1943)

* Allow CSV imports to be configured to a single account or multiple accounts

* Initialize import directly from accounts page

* Fix brakeman warnings

* Fix schema

* Fix Synth check
This commit is contained in:
Zach Gollwitzer 2025-03-03 12:47:30 -05:00 committed by GitHub
parent e907b073ed
commit c5da8ea550
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 118 additions and 57 deletions

View file

@ -4,6 +4,10 @@ class Import::ConfirmsController < ApplicationController
before_action :set_import
def show
if @import.mapping_steps.empty?
return redirect_to import_path(@import)
end
redirect_to import_clean_path(@import), alert: "You have invalid data, please edit until all errors are resolved" unless @import.cleaned?
end

View file

@ -8,6 +8,7 @@ class Import::UploadsController < ApplicationController
def update
if csv_valid?(csv_str)
@import.account = Current.family.accounts.find_by(id: params.dig(:import, :account_id))
@import.assign_attributes(raw_file_str: csv_str, col_sep: upload_params[:col_sep])
@import.save!(validate: false)

View file

@ -18,7 +18,8 @@ class ImportsController < ApplicationController
end
def create
import = Current.family.imports.create! import_params
account = Current.family.accounts.find_by(id: params.dig(:import, :account_id))
import = Current.family.imports.create!(type: import_params[:type], account: account)
redirect_to import_upload_path(import)
end