Files
sure/app/models/concerns/lunchflow_transaction_hash.rb
AdamWHY2K 3f5fff27ea feat: process pending transactions from lunchflow (#731)
* feat(config): add Lunchflow runtime configuration flags

* feat(api): add include_pending parameter to Lunchflow API

* feat(processor): add pending metadata support to Lunchflow processor

* feat(processor): generate temporary IDs for pending transactions

* feat(importer): integrate pending transaction support in sync

* fix(importer): improve deduplication for transactions without IDs

* feat(model): add Lunchflow pending support to Transaction scopes

* test: add Lunchflow processor pending metadata tests

* docs: update AGENTS.md for Lunchflow pending support

* chore: remove unused variable

* fix: simplify key check

* fix: dotenv-linter key order

* fix: avoid collapsing distinct pending transactions

* fix: prevent unbounded raw payload growth for blank IDs
2026-01-23 00:53:24 +01:00

29 lines
918 B
Ruby

# Shared concern for generating content-based hashes for Lunchflow transactions
# Used by both the importer (for deduplication) and processor (for temporary external IDs)
module LunchflowTransactionHash
extend ActiveSupport::Concern
private
# Generate a content-based hash for a transaction
# This creates a deterministic identifier based on transaction attributes
# Used for:
# - Deduplicating blank-ID transactions in the importer
# - Generating temporary external IDs in the processor
#
# @param tx [Hash] Transaction data with indifferent access
# @return [String] MD5 hash of transaction attributes
def content_hash_for_transaction(tx)
attributes = [
tx[:accountId],
tx[:amount],
tx[:currency],
tx[:date],
tx[:merchant],
tx[:description]
].compact.join("|")
Digest::MD5.hexdigest(attributes)
end
end