Guest User

Untitled

a guest
May 28th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!code ../lib/currency.rb
  2.  
  3. proc do |ks, vs, rereduce|
  4. {
  5. :booking_count => vs.inject(0) { |total, v| total + v['booking_count'] },
  6. :total_pax => vs.inject(0) { |total, v| total + v['total_pax'] },
  7. :total_cos_gbp => vs.inject(BigDecimal.new("0")) { |total, v| total + BigDecimal.new(v['total_cos_gbp']) }.format_currency,
  8. :total_sales => vs.inject(BigDecimal.new("0")) { |total, v| total + BigDecimal.new(v['total_sales']) }.format_currency,
  9. :total_cos => vs.map { |v| v['total_cos'] }.inject do |h, v|
  10. h.merge(v){|key, value1, value2| (BigDecimal.new(value1) + BigDecimal.new(value2)).format_currency}
  11. end
  12. }
  13. end
Add Comment
Please, Sign In to add comment