diff --git a/app/models/lunchflow_account.rb b/app/models/lunchflow_account.rb index 01087450d..d79daff70 100644 --- a/app/models/lunchflow_account.rb +++ b/app/models/lunchflow_account.rb @@ -21,10 +21,17 @@ class LunchflowAccount < ApplicationRecord # Map Lunchflow field names to our field names # Lunchflow API returns: { id, name, institution_name, institution_logo, provider, currency, status } + # Build display name: "Institution Name - Account Name" if institution is present + display_name = if snapshot[:institution_name].present? + "#{snapshot[:institution_name]} - #{snapshot[:name]}" + else + snapshot[:name] + end + update!( current_balance: nil, # Balance not provided by accounts endpoint currency: parse_currency(snapshot[:currency]) || "USD", - name: snapshot[:name], + name: display_name, account_id: snapshot[:id].to_s, account_status: snapshot[:status], provider: snapshot[:provider], diff --git a/app/models/lunchflow_entry/processor.rb b/app/models/lunchflow_entry/processor.rb index 11a7801dd..978528f28 100644 --- a/app/models/lunchflow_entry/processor.rb +++ b/app/models/lunchflow_entry/processor.rb @@ -25,7 +25,8 @@ class LunchflowEntry::Processor date: date, name: name, source: "lunchflow", - merchant: merchant + merchant: merchant, + notes: notes ) rescue ArgumentError => e # Re-raise validation errors (missing required fields, invalid data) @@ -65,20 +66,11 @@ class LunchflowEntry::Processor end def name - # Use Lunchflow's merchant and description to create informative transaction names - merchant_name = data[:merchant] - description = data[:description] + data[:merchant].presence || "Unknown transaction" + end - # Combine merchant + description when both are present and different - if merchant_name.present? && description.present? && merchant_name != description - "#{merchant_name} - #{description}" - elsif merchant_name.present? - merchant_name - elsif description.present? - description - else - "Unknown transaction" - end + def notes + data[:description].presence end def merchant diff --git a/app/views/lunchflow_items/setup_accounts.html.erb b/app/views/lunchflow_items/setup_accounts.html.erb index 63886fbe2..551292c7e 100644 --- a/app/views/lunchflow_items/setup_accounts.html.erb +++ b/app/views/lunchflow_items/setup_accounts.html.erb @@ -56,13 +56,7 @@

<%= lunchflow_account.name %> - <% if lunchflow_account.institution_metadata.present? && lunchflow_account.institution_metadata['name'].present? %> - • <%= lunchflow_account.institution_metadata["name"] %> - <% end %>

-

- <%= t(".balance") %>: <%= number_to_currency(lunchflow_account.current_balance || 0, unit: lunchflow_account.currency) %> -