Created
November 2, 2013 18:31
-
-
Save foxtacles/7281996 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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