mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Account-level import configuration templates (#1946)
* Account-level import configuration templates * Default import to family's preferred date format
This commit is contained in:
parent
5b2fa3d707
commit
0544089710
15 changed files with 108 additions and 43 deletions
|
@ -18,19 +18,8 @@ class Import::Mapping < ApplicationRecord
|
|||
find_by(key: key)&.mappable
|
||||
end
|
||||
|
||||
def sync(import)
|
||||
unique_values = mapping_values(import).uniq
|
||||
|
||||
unique_values.each do |value|
|
||||
mapping = find_or_initialize_by(key: value, import: import, create_when_empty: value.present?)
|
||||
mapping.save(validate: false) if mapping.new_record?
|
||||
end
|
||||
|
||||
where(import: import).where.not(key: unique_values).destroy_all
|
||||
end
|
||||
|
||||
def mapping_values(import)
|
||||
raise NotImplementedError, "Subclass must implement mapping_values"
|
||||
def mappables_by_key(import)
|
||||
raise NotImplementedError, "Subclass must implement mappables_by_key"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue