Skip to content

Commit c17f44a

Browse files
author
Josh Waldrep
committed
fix linting x2
1 parent fe3a045 commit c17f44a

15 files changed

+100
-88
lines changed

app/controllers/simplefin_items_controller.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,13 @@ def apply_relink
365365
# Move holdings with duplicate guard (security,date,currency)
366366
if a_new.respond_to?(:holdings)
367367
a_new.holdings.find_each do |h|
368-
if manual.holdings.exists?(security_id: h.security_id, date: h.date, currency: h.currency)
369-
h.destroy!
370-
deleted_holdings += 1
371-
else
372-
h.update_columns(account_id: manual.id, updated_at: Time.current)
373-
moved_holdings += 1
374-
end
368+
if manual.holdings.exists?(security_id: h.security_id, date: h.date, currency: h.currency)
369+
h.destroy!
370+
deleted_holdings += 1
371+
else
372+
h.update_columns(account_id: manual.id, updated_at: Time.current)
373+
moved_holdings += 1
374+
end
375375
end
376376
end
377377

@@ -440,7 +440,7 @@ def apply_relink
440440
format.turbo_stream do
441441
# Render the card partial to HTML to avoid passing a Hash to the stream builder
442442
# Force HTML format explicitly so Rails does not look for a turbo_stream variant of the partial
443-
card_html = render_to_string(partial: "simplefin_items/simplefin_item", formats: [:html], locals: { simplefin_item: @simplefin_item })
443+
card_html = render_to_string(partial: "simplefin_items/simplefin_item", formats: [ :html ], locals: { simplefin_item: @simplefin_item })
444444
render turbo_stream: [
445445
turbo_stream.remove("modal"),
446446
turbo_stream.replace(view_context.dom_id(@simplefin_item), card_html)

app/models/account/provider_import_adapter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ def pending_merge?(existing_entry:, incoming_date:, incoming_pending:, incoming_
142142
end
143143

144144
# Chronology + window: existing must be earlier, incoming must be the later record
145-
earlier = [existing_entry.date, incoming_date].min
146-
later = [existing_entry.date, incoming_date].max
145+
earlier = [ existing_entry.date, incoming_date ].min
146+
later = [ existing_entry.date, incoming_date ].max
147147
return false unless later == incoming_date && later > earlier
148148
return false if (later - earlier).to_i > window_days
149149

app/models/simplefin_account/processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def auto_relink_existing_manual_account
4040
name = simplefin_account.name.to_s
4141
return if name.blank?
4242
family = simplefin_account.simplefin_item.family
43-
norm = ->(s){ s.to_s.downcase.gsub(/\s+/, " ").strip }
43+
norm = ->(s) { s.to_s.downcase.gsub(/\s+/, " ").strip }
4444

4545
manuals = family.accounts
4646
.left_joins(:account_providers)

app/models/simplefin_entry/processor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def pending?
163163
return !!explicit unless explicit.nil?
164164
p = posted_date
165165
t = transacted_date
166-
return (t && p && p > t)
166+
t && p && p > t
167167
end
168168

169169
def merchant

app/models/simplefin_item.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def dedup_simplefin_accounts!
174174
SimplefinItem.transaction do
175175
dupes.each_value do |list|
176176
keeper = list.find { |s| s.current_account.present? } || list.max_by(&:updated_at)
177-
(list - [keeper]).each do |dupe|
177+
(list - [ keeper ]).each do |dupe|
178178
keeper_acct = keeper.current_account
179179
dupe_acct = dupe.current_account
180180

@@ -241,8 +241,8 @@ def merge_duplicate_provider_accounts!
241241
groups.each_value do |links|
242242
accounts = Account.where(id: links.map(&:account_id))
243243
# Choose keeper by most entries, else newest by updated_at
244-
keeper = accounts.max_by { |a| [a.entries.count, a.updated_at.to_i] }
245-
(accounts - [keeper]).each do |dupe|
244+
keeper = accounts.max_by { |a| [ a.entries.count, a.updated_at.to_i ] }
245+
(accounts - [ keeper ]).each do |dupe|
246246
# Move entries (avoid duplicates by external_id+source)
247247
dupe.entries.find_each do |e|
248248
if e.external_id.present? && e.source.present? && keeper.entries.exists?(external_id: e.external_id, source: e.source)

db/migrate/20251030172500_add_cascade_on_account_deletes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# frozen_string_literal: true
2+
23
class AddCascadeOnAccountDeletes < ActiveRecord::Migration[7.0]
34
def up
45
# Clean up orphaned rows before re-adding foreign keys with cascade

lib/tasks/holdings_tools.rake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
namespace :sure do
1616
namespace :holdings do
1717
desc "Seed a previous snapshot for Day Change demo. Args: holding_id, change_pct=2, days_ago=1, dry_run=true"
18-
task :seed_prev_snapshot, [:holding_id, :change_pct, :days_ago, :dry_run] => :environment do |_, args|
18+
task :seed_prev_snapshot, [ :holding_id, :change_pct, :days_ago, :dry_run ] => :environment do |_, args|
1919
kv = {}
20-
[args[:holding_id], args[:change_pct], args[:days_ago], args[:dry_run]].each do |raw|
20+
[ args[:holding_id], args[:change_pct], args[:days_ago], args[:dry_run] ].each do |raw|
2121
next unless raw.is_a?(String) && raw.include?("=")
2222
k, v = raw.split("=", 2)
2323
kv[k.to_s] = v
@@ -44,7 +44,7 @@ namespace :sure do
4444
prev.external_id = nil
4545

4646
if dry_run
47-
puts({ ok: true, dry_run: true, holding_id: h.id, would_create: prev.attributes.slice("account_id","security_id","date","qty","price","amount","currency") }.to_json)
47+
puts({ ok: true, dry_run: true, holding_id: h.id, would_create: prev.attributes.slice("account_id", "security_id", "date", "qty", "price", "amount", "currency") }.to_json)
4848
else
4949
prev.save!
5050
puts({ ok: true, created_prev_id: prev.id, date: prev.date, amount: prev.amount, price: prev.price }.to_json)
@@ -55,7 +55,7 @@ namespace :sure do
5555
end
5656

5757
desc "Remove a snapshot by holding id. Args: id"
58-
task :remove_snapshot, [:id] => :environment do |_, args|
58+
task :remove_snapshot, [ :id ] => :environment do |_, args|
5959
id = args[:id]
6060
unless id
6161
puts({ ok: false, error: "usage", message: "Provide id" }.to_json)

lib/tasks/simplefin.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace :sure do
6262
puts({
6363
ok: false,
6464
error: "encryption_not_configured",
65-
message: "Rails.application.credentials.active_record_encryption is missing; cannot encrypt access_url",
65+
message: "Rails.application.credentials.active_record_encryption is missing; cannot encrypt access_url"
6666
}.to_json)
6767
exit 1
6868
end

lib/tasks/simplefin_backfill.rake

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,32 @@ namespace :sure do
8585
trans = t[:transacted_at]
8686

8787
# convert to Date where possible for window filtering
88-
posted_d = case posted
89-
when String then Date.parse(posted) rescue nil
90-
when Numeric then Time.zone.at(posted).to_date rescue nil
91-
when Date then posted
92-
when Time, DateTime then posted.to_date
93-
else nil
94-
end
95-
trans_d = case trans
96-
when String then Date.parse(trans) rescue nil
97-
when Numeric then Time.zone.at(trans).to_date rescue nil
98-
when Date then trans
99-
when Time, DateTime then trans.to_date
100-
else nil
101-
end
88+
posted_d =
89+
case posted
90+
when String
91+
Date.parse(posted) rescue nil
92+
when Numeric
93+
Time.zone.at(posted).to_date rescue nil
94+
when Date
95+
posted
96+
when Time, DateTime
97+
posted.to_date
98+
else
99+
nil
100+
end
101+
trans_d =
102+
case trans
103+
when String
104+
Date.parse(trans) rescue nil
105+
when Numeric
106+
Time.zone.at(trans).to_date rescue nil
107+
when Date
108+
trans
109+
when Time, DateTime
110+
trans.to_date
111+
else
112+
nil
113+
end
102114

103115
best = posted_d || trans_d
104116
# If neither date is available, skip (cannot window-match safely)
@@ -130,7 +142,7 @@ namespace :sure do
130142
if dry_run
131143
# Simulate: check if we can composite-match; we won't persist
132144
entry = acct.entries.find_by(external_id: external_id, source: "simplefin")
133-
entry ||= adapter.composite_match(source: "simplefin", name: SimplefinEntry::Processor.new(t, simplefin_account: sfa).send(:name), amount: SimplefinEntry::Processor.new(t, simplefin_account: sfa).send(:amount), date: (posted_d || trans_d), window_days: (acct.accountable_type.in?(["CreditCard", "Loan"]) ? 5 : 3))
145+
entry ||= adapter.composite_match(source: "simplefin", name: SimplefinEntry::Processor.new(t, simplefin_account: sfa).send(:name), amount: SimplefinEntry::Processor.new(t, simplefin_account: sfa).send(:amount), date: (posted_d || trans_d), window_days: (acct.accountable_type.in?([ "CreditCard", "Loan" ]) ? 5 : 3))
134146
matched = entry.present?
135147
total_matched += 1 if matched
136148
else
@@ -156,7 +168,7 @@ namespace :sure do
156168
desc "List and optionally delete known demo SimpleFin entries for a given Account. Args (named): account_id, dry_run=true, pattern"
157169
task :cleanup_demo_entries, [ :account_id, :dry_run, :pattern ] => :environment do |_, args|
158170
kv = {}
159-
[args[:account_id], args[:dry_run], args[:pattern]].each do |raw|
171+
[ args[:account_id], args[:dry_run], args[:pattern] ].each do |raw|
160172
next unless raw.is_a?(String) && raw.include?("=")
161173
k, v = raw.split("=", 2)
162174
kv[k.to_s] = v

lib/tasks/simplefin_debug.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace :sure do
5151
posted: posted,
5252
transacted_at: trans,
5353
pending_flag: t[:pending],
54-
inferred_pending: (trans.present? && posted.present? && posted.to_i > trans.to_i),
54+
inferred_pending: (trans.present? && posted.present? && posted.to_i > trans.to_i)
5555
}
5656
end
5757

0 commit comments

Comments
 (0)