Skip to content

Instantly share code, notes, and snippets.

@chinloongtan
Last active December 23, 2015 19:21
Show Gist options
  • Save chinloongtan/9182ff23031bd6e0c2cc to your computer and use it in GitHub Desktop.
Save chinloongtan/9182ff23031bd6e0c2cc to your computer and use it in GitHub Desktop.
slips.map { |slip_num, details|
[slip_num.split('_')[1].to_i, {
number_transactions: details[:transactions].count,
total_amount: details[:transactions].map{ |t_num| transactions.find{ |t| t[:id] == t_num } }.map{ |t| t[:payout] ? (t[:amount] * (-1)) : t[:amount] }.reduce(:+),
shop: Hash[shops][details[:shop]]
}]
}.to_h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment