mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 08:09:38 +02:00
CSV Imports Overhaul (Transactions, Trades, Accounts, and Mint import support) (#1209)
* Remove stale 1.0 import logic and model * Fresh start * Checkpoint before removing nav * First working prototype * Add trade, account, and mint import flows * Basic working version with tests * System tests for each import type * Clean up mappings flow * Clean up PR, refactor stale code, tests * Add back row validations * Row validations * Fix import job test * Fix import navigation * Fix mint import configuration form * Currency preset for new accounts
This commit is contained in:
parent
23786b444a
commit
398b246965
103 changed files with 2420 additions and 1689 deletions
36
app/models/import/category_mapping.rb
Normal file
36
app/models/import/category_mapping.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
class Import::CategoryMapping < Import::Mapping
|
||||
class << self
|
||||
def mapping_values(import)
|
||||
import.rows.map(&:category).uniq
|
||||
end
|
||||
end
|
||||
|
||||
def selectable_values
|
||||
family_categories = import.family.categories.alphabetically.map { |category| [ category.name, category.id ] }
|
||||
|
||||
unless key.blank?
|
||||
family_categories.unshift [ "Add as new category", CREATE_NEW_KEY ]
|
||||
end
|
||||
|
||||
family_categories
|
||||
end
|
||||
|
||||
def requires_selection?
|
||||
false
|
||||
end
|
||||
|
||||
def values_count
|
||||
import.rows.where(category: key).count
|
||||
end
|
||||
|
||||
def mappable_class
|
||||
Category
|
||||
end
|
||||
|
||||
def create_mappable!
|
||||
return unless creatable?
|
||||
|
||||
self.mappable = import.family.categories.find_or_create_by!(name: key)
|
||||
save!
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue