lib/xeroizer/models/line_item.rb in xeroizer-0.3.5 vs lib/xeroizer/models/line_item.rb in xeroizer-0.4.0
- old
+ new
@@ -1,23 +1,15 @@
require 'xeroizer/models/account'
+require 'xeroizer/models/line_amount_type'
module Xeroizer
module Record
-
class LineItemModel < BaseModel
end
class LineItem < Base
-
- LINE_AMOUNT_TYPE = {
- "Inclusive" => 'CreditNote lines are inclusive tax',
- "Exclusive" => 'CreditNote lines are exclusive of tax (default)',
- "NoTax" => 'CreditNotes lines have no tax'
- } unless defined?(LINE_AMOUNT_TYPE)
- LINE_AMOUNT_TYPES = LINE_AMOUNT_TYPE.keys.sort
-
TAX_TYPE = Account::TAX_TYPE unless defined?(TAX_TYPE)
string :item_code
string :description
decimal :quantity
@@ -33,12 +25,10 @@
def line_amount=(value); raise SettingTotalDirectlyNotSupported.new(:line_amount); end
# Calculate the line_total (if there is a quantity and unit_amount).
# Description-only lines have been allowed since Xero V2.09.
def line_amount
- unless quantity.nil? && unit_amount.nil?
- quantity * unit_amount
- end
+ BigDecimal((quantity * unit_amount).to_s).round(2) if quantity && unit_amount
end
end
end