Class: Xeroizer::Record::BankTransaction
- Inherits:
-
Base
- Object
- Base
- Xeroizer::Record::BankTransaction
show all
- Defined in:
- lib/xeroizer/models/bank_transaction.rb
Constant Summary
collapse
- BANK_TRANSACTION_STATUS =
{
'ACTIVE' => 'Active bank transactions',
'DELETED' => 'Deleted bank transactions',
}
- BANK_TRANSACTION_STATUSES =
BANK_TRANSACTION_STATUS.keys.sort
- BANK_TRANSFER_TYPES =
[ 'SPEND-TRANSFER', 'RECEIVE-TRANSFER' ]
Instance Attribute Summary
Attributes inherited from Base
#attributes, #complete_record_downloaded, #errors, #model, #parent
Instance Method Summary
collapse
Methods inherited from Base
#[], #[]=, #as_json, build, #complete_record_downloaded?, #download_complete_record!, #inspect, #new_model_class, #new_record?, #non_calculated_attributes, #save, #saved!, #to_h, #to_json, #update_attributes
Methods included from XmlHelper
included
included
included
included
included
Constructor Details
Returns a new instance of BankTransaction.
20
21
22
23
|
# File 'lib/xeroizer/models/bank_transaction.rb', line 20
def initialize(parent)
super parent
self.line_amount_types = "Exclusive"
end
|
Instance Method Details
#currency_rate ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/xeroizer/models/bank_transaction.rb', line 66
def currency_rate
if attributes[:currency_rate]
BigDecimal.new(attributes[:currency_rate])
else
BigDecimal.new('1.0')
end
end
|
#is_transfer? ⇒ Boolean
100
101
102
|
# File 'lib/xeroizer/models/bank_transaction.rb', line 100
def is_transfer?
BANK_TRANSFER_TYPES.include? attributes[:type]
end
|
#sub_total ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/xeroizer/models/bank_transaction.rb', line 80
def sub_total
return attributes[:total] if is_transfer?
if ought_to_recalculate_totals?
result = LineItemSum.sub_total(self.line_items)
result -= total_tax if line_amount_types == 'Inclusive'
result
else
attributes[:sub_total]
end
end
|
#sub_total=(value) ⇒ Object
#total ⇒ Object
78
|
# File 'lib/xeroizer/models/bank_transaction.rb', line 78
def total; sub_total + total_tax; end
|
#total_tax ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/xeroizer/models/bank_transaction.rb', line 92
def total_tax
return BigDecimal.new('0') if is_transfer?
return ought_to_recalculate_totals? ?
LineItemSum.total_tax(self.line_items) :
attributes[:total_tax]
end
|
#total_tax=(value) ⇒ Object