Class: Accountability::Transactions::Transaction
- Inherits:
-
Object
- Object
- Accountability::Transactions::Transaction
- Defined in:
- app/models/accountability/transactions.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#record ⇒ Object
Returns the value of attribute record.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #base_amount ⇒ Object
- #credit? ⇒ Boolean
- #debit? ⇒ Boolean
- #deductions ⇒ Object
-
#initialize(type, record:, amount:, description:, date: nil) ⇒ Transaction
constructor
A new instance of Transaction.
- #taxes ⇒ Object
Constructor Details
#initialize(type, record:, amount:, description:, date: nil) ⇒ Transaction
Returns a new instance of Transaction.
26 27 28 29 30 31 32 |
# File 'app/models/accountability/transactions.rb', line 26 def initialize(type, record:, amount:, description:, date: nil) @type = type @record = record @amount = amount @description = description @date = date.presence || record.created_at end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
24 25 26 |
# File 'app/models/accountability/transactions.rb', line 24 def amount @amount end |
#date ⇒ Object
Returns the value of attribute date.
24 25 26 |
# File 'app/models/accountability/transactions.rb', line 24 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
24 25 26 |
# File 'app/models/accountability/transactions.rb', line 24 def description @description end |
#record ⇒ Object
Returns the value of attribute record.
24 25 26 |
# File 'app/models/accountability/transactions.rb', line 24 def record @record end |
#type ⇒ Object
Returns the value of attribute type.
24 25 26 |
# File 'app/models/accountability/transactions.rb', line 24 def type @type end |
Instance Method Details
#base_amount ⇒ Object
42 43 44 |
# File 'app/models/accountability/transactions.rb', line 42 def base_amount debit? ? base_amount : record.base_price end |
#credit? ⇒ Boolean
38 39 40 |
# File 'app/models/accountability/transactions.rb', line 38 def credit? type == :credit end |
#debit? ⇒ Boolean
34 35 36 |
# File 'app/models/accountability/transactions.rb', line 34 def debit? type == :debit end |
#deductions ⇒ Object
46 47 48 |
# File 'app/models/accountability/transactions.rb', line 46 def deductions debit? ? [] : record.deductions end |
#taxes ⇒ Object
50 51 52 |
# File 'app/models/accountability/transactions.rb', line 50 def taxes debit? ? 0 : record.taxes end |