mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
parent
f8d64561cf
commit
b41897b5e5
3 changed files with 20 additions and 11 deletions
1
Gemfile
1
Gemfile
|
@ -58,6 +58,7 @@ gem "intercom-rails"
|
||||||
gem "plaid"
|
gem "plaid"
|
||||||
gem "rotp", "~> 6.3"
|
gem "rotp", "~> 6.3"
|
||||||
gem "rqrcode", "~> 2.2"
|
gem "rqrcode", "~> 2.2"
|
||||||
|
gem "activerecord-import"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "debug", platforms: %i[mri windows]
|
gem "debug", platforms: %i[mri windows]
|
||||||
|
|
|
@ -61,6 +61,8 @@ GEM
|
||||||
activemodel (= 7.2.2.1)
|
activemodel (= 7.2.2.1)
|
||||||
activesupport (= 7.2.2.1)
|
activesupport (= 7.2.2.1)
|
||||||
timeout (>= 0.4.0)
|
timeout (>= 0.4.0)
|
||||||
|
activerecord-import (2.1.0)
|
||||||
|
activerecord (>= 4.2)
|
||||||
activestorage (7.2.2.1)
|
activestorage (7.2.2.1)
|
||||||
actionpack (= 7.2.2.1)
|
actionpack (= 7.2.2.1)
|
||||||
activejob (= 7.2.2.1)
|
activejob (= 7.2.2.1)
|
||||||
|
@ -529,6 +531,7 @@ PLATFORMS
|
||||||
x86_64-linux-musl
|
x86_64-linux-musl
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
activerecord-import
|
||||||
aws-sdk-s3 (~> 1.177.0)
|
aws-sdk-s3 (~> 1.177.0)
|
||||||
bcrypt (~> 3.1)
|
bcrypt (~> 3.1)
|
||||||
benchmark-ips
|
benchmark-ips
|
||||||
|
|
|
@ -3,7 +3,7 @@ class TransactionImport < Import
|
||||||
transaction do
|
transaction do
|
||||||
mappings.each(&:create_mappable!)
|
mappings.each(&:create_mappable!)
|
||||||
|
|
||||||
rows.each do |row|
|
transactions = rows.map do |row|
|
||||||
mapped_account = if account
|
mapped_account = if account
|
||||||
account
|
account
|
||||||
else
|
else
|
||||||
|
@ -13,17 +13,22 @@ class TransactionImport < Import
|
||||||
category = mappings.categories.mappable_for(row.category)
|
category = mappings.categories.mappable_for(row.category)
|
||||||
tags = row.tags_list.map { |tag| mappings.tags.mappable_for(tag) }.compact
|
tags = row.tags_list.map { |tag| mappings.tags.mappable_for(tag) }.compact
|
||||||
|
|
||||||
entry = mapped_account.entries.build \
|
Account::Transaction.new(
|
||||||
|
category: category,
|
||||||
|
tags: tags,
|
||||||
|
entry: Account::Entry.new(
|
||||||
|
account: mapped_account,
|
||||||
date: row.date_iso,
|
date: row.date_iso,
|
||||||
amount: row.signed_amount,
|
amount: row.signed_amount,
|
||||||
name: row.name,
|
name: row.name,
|
||||||
currency: row.currency,
|
currency: row.currency,
|
||||||
notes: row.notes,
|
notes: row.notes,
|
||||||
entryable: Account::Transaction.new(category: category, tags: tags),
|
|
||||||
import: self
|
import: self
|
||||||
|
)
|
||||||
entry.save!
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Account::Transaction.import!(transactions, recursive: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue