7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/models/recurring_payment.rb', line 7
def schedule_payment(date)
unless self.payment_account.nil?
if self.billing_account.has_outstanding_balance?
payment_amount = self.billing_account.outstanding_balance
if payment_amount < self.pay_up_to_amount
money = Money.create(
:amount => payment_amount.to_d,
:description => "AutoPayment",
:currency => Currency.usd
)
financial_txn = FinancialTxn.create(
:apply_date => date,
:money => money
)
financial_txn.description = "AutoPayment"
financial_txn.account = self.payment_account.account_root
financial_txn.save
PaymentApplication.create(
:financial_txn => financial_txn,
:payment_applied_to => self.billing_account,
:money => money,
:comment => "AutoPayment"
)
else
end
end end
end
|