Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!code ../lib/currency.rb
- proc do |ks, vs, rereduce|
- {
- :booking_count => vs.inject(0) { |total, v| total + v['booking_count'] },
- :total_pax => vs.inject(0) { |total, v| total + v['total_pax'] },
- :total_cos_gbp => vs.inject(BigDecimal.new("0")) { |total, v| total + BigDecimal.new(v['total_cos_gbp']) }.format_currency,
- :total_sales => vs.inject(BigDecimal.new("0")) { |total, v| total + BigDecimal.new(v['total_sales']) }.format_currency,
- :total_cos => vs.map { |v| v['total_cos'] }.inject do |h, v|
- h.merge(v){|key, value1, value2| (BigDecimal.new(value1) + BigDecimal.new(value2)).format_currency}
- end
- }
- end
Add Comment
Please, Sign In to add comment