Skip to content

Instantly share code, notes, and snippets.

@gtan66
Last active August 31, 2015 14:50
Show Gist options
  • Save gtan66/0e778c335c311b127ffe to your computer and use it in GitHub Desktop.
Save gtan66/0e778c335c311b127ffe to your computer and use it in GitHub Desktop.
Update batches that failed to update
batches = [
{batch_number: 14625, location: "South Station" },
{ batch_number: 14626, location: "Chinatown"},
{ batch_number: 14627, location: "Wonder Bread"},
{ batch_number: 14628, location: "Dupont Circle"},
{ batch_number: 14629, location: "Soho West"},
{ batch_number: 14630, location: "Bryant Park"},
{ batch_number: 14631, location: "Park South"},
{ batch_number: 14632, location: "42nd Street"},
{ batch_number: 14633, location: "FiDi"},
{ batch_number: 14634, location: "SOMA"},
{ batch_number: 14635, location: "Golden Gate"}
]
#has to be 8/1 EST
deposited_at = Time.new(2015, 8, 1, 10, 0, 0)
requested_at =Time.new(2015, 8, 1, 10, 0, 0)
batches.each{ |b|
@location = Location.find_by(name: b[:location])
credit_card_type = [nil, "unknown"]
payments = Payment.joins(:applied_to).can_deposit.includes(:applied_to => [:account, :location]).where(batch_number: b[:batch_number].to_s, credit_card_type: credit_card_type).where("account_balances.location_id = (?)", @location.id)
payments.each{ |p|
p.update_attributes(requested_at: requested_at)
p.reload
}
BillingService.new.deposit_payments!(payments, deposited_at)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment