mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* 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
29 lines
918 B
Ruby
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
|