Class: Transactionable::BankAccount
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Transactionable::BankAccount
- Defined in:
- app/models/transactionable/bank_account.rb
Constant Summary collapse
- TYPES =
["checking", "savings"]
Instance Method Summary collapse
Instance Method Details
#amount_in_cents(amount) ⇒ Object
33 34 35 |
# File 'app/models/transactionable/bank_account.rb', line 33 def amount_in_cents(amount) (amount * 100).to_i end |
#credit!(amount) ⇒ Object
27 28 29 30 31 |
# File 'app/models/transactionable/bank_account.rb', line 27 def credit!(amount) remote_credit = remote.credit(amount: amount_in_cents(amount)) transaction = Transactionable::Credit.create_from_remote(remote_credit) credits << transaction end |
#remote ⇒ Object
11 12 13 14 15 |
# File 'app/models/transactionable/bank_account.rb', line 11 def remote if remote_bank_account && remote_bank_account.synced? remote_bank_account.fetch end end |
#sync ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/models/transactionable/bank_account.rb', line 17 def sync balanced_bank_account = remote self.bank_name = balanced_bank_account.bank_name self.description = balanced_bank_account.account_number self.name = balanced_bank_account.name self.can_debit = balanced_bank_account.can_debit self.account_type = balanced_bank_account.type save end |