lib/xeroizer/models/credit_note.rb in xeroizer-float-2.15.3.13 vs lib/xeroizer/models/credit_note.rb in xeroizer-float-2.15.3.14
- old
+ new
@@ -55,10 +55,11 @@
decimal :sub_total, :calculated => true
decimal :total_tax, :calculated => true
decimal :total, :calculated => true
datetime_utc :updated_date_utc, :api_name => 'UpdatedDateUTC'
string :currency_code
+ decimal :currency_rate, :calculated => true
datetime :fully_paid_on_date
boolean :sent_to_contact
belongs_to :contact
has_many :line_items
@@ -79,9 +80,17 @@
# Access the contact ID without forcing a download of an
# incomplete, summary credit note.
def contact_id
attributes[:contact] && attributes[:contact][:contact_id]
end
+
+ def currency_rate
+ if attributes[:currency_rate]
+ BigDecimal.new(attributes[:currency_rate])
+ else
+ BigDecimal.new('1.0')
+ end
+ end
# Swallow assignment of attributes that should only be calculated automatically.
def sub_total=(value); raise SettingTotalDirectlyNotSupported.new(:sub_total); end
def total_tax=(value); raise SettingTotalDirectlyNotSupported.new(:total_tax); end
def total=(value); raise SettingTotalDirectlyNotSupported.new(:total); end