222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/saucy/subscription.rb', line 222
def update_subscriptions!
recently_billed = where("next_billing_date <= ?", Time.now)
recently_billed.each do |account|
account.subscription_status = account.subscription.status
account.next_billing_date = account.subscription.next_billing_date
account.save!
if account.past_due?
BillingMailer.problem(account, account.subscription.transactions.last).deliver!
else
BillingMailer.receipt(account, account.subscription.transactions.last).deliver!
end
end
end
|