Skip to content

Instantly share code, notes, and snippets.

@foxtacles
Created November 2, 2013 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxtacles/7281996 to your computer and use it in GitHub Desktop.
Save foxtacles/7281996 to your computer and use it in GitHub Desktop.
b1 = BillingChecker.new(coupon: 0, vat: 1, margin: 1, first_date: DateTime.parse("2013-09-01"), end_time: DateTime.parse("2013-09-30"))
b2 = BillingChecker.new(coupon: 0, vat: 1, margin: 1, first_date: DateTime.parse("2013-10-01"), end_time: DateTime.parse("2013-10-31"))
b1.perform
b2.perform
result = b2.totals.map do |u|
uo = User.find_by_email u[:email]
us = b1.totals.detect{|t|t[:email] == u[:email]}
rc = us[:net_total] - User::DEFAULT_CREDIT
rc = rc > 0 ? 0 : (rc * -1)
oc = rc
bill = u[:net_total] - rc
{:id => uo.id, :bill => bill < 0 ? 0 : bill, :rc => bill < 0 ? (bill * -1) : 0, :oc => oc}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment