217
218
219
220
221
222
223
224
225
226
227
228
229
|
# File 'lib/saucy/subscription.rb', line 217
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
|