Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/family_merchants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ class FamilyMerchantsController < ApplicationController
def index
@breadcrumbs = [ [ "Home", root_path ], [ "Merchants", nil ] ]

@family_merchants = Current.family.merchants.alphabetically
# Show all merchants assigned to transactions (both FamilyMerchant and ProviderMerchant)
@family_merchants = Current.family.assigned_merchants.alphabetically

render layout: "settings"
end
Expand Down
20 changes: 19 additions & 1 deletion app/models/simplefin_entry/processor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require "digest/md5"

class SimplefinEntry::Processor
# simplefin_transaction is the raw hash fetched from SimpleFin API and converted to JSONB
def initialize(simplefin_transaction, simplefin_account:)
Expand Down Expand Up @@ -100,6 +102,22 @@ def date


def merchant
@merchant ||= SimplefinAccount::Transactions::MerchantDetector.new(data).detect_merchant
# Use SimpleFin's clean payee data for merchant detection
payee = data[:payee]&.strip
return nil unless payee.present?

@merchant ||= import_adapter.find_or_create_merchant(
provider_merchant_id: generate_merchant_id(payee),
name: payee,
source: "simplefin"
)
rescue ActiveRecord::RecordInvalid => e
Rails.logger.error "SimplefinEntry::Processor - Failed to create merchant '#{payee}': #{e.message}"
nil
end

def generate_merchant_id(merchant_name)
# Generate a consistent ID for merchants without explicit IDs
"simplefin_#{Digest::MD5.hexdigest(merchant_name.downcase)}"
end
end