Class: Xeroizer::Record::LineItem

Inherits:
Base
  • Object
show all
Defined in:
lib/xeroizer/models/line_item.rb

Constant Summary collapse

TAX_TYPE =
Account::TAX_TYPE

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!, #initialize, #inspect, #new_model_class, #new_record?, #non_calculated_attributes, #save, #saved!, #to_h, #to_json, #update_attributes

Methods included from XmlHelper

included

Methods included from ValidationHelper

included

Methods included from RecordAssociationHelper

included

Methods included from ModelDefinitionHelper

included

Methods included from ClassLevelInheritableAttributes

included

Constructor Details

This class inherits a constructor from Xeroizer::Record::Base

Instance Method Details

#line_amount(summary_only = false) ⇒ Object

Calculate the line_total (if there is a quantity and unit_amount). Description-only lines have been allowed since Xero V2.09.



32
33
34
35
36
# File 'lib/xeroizer/models/line_item.rb', line 32

def line_amount(summary_only = false)
  return attributes[:line_amount] if summary_only || @line_amount_set
  
  BigDecimal((quantity * unit_amount * ((100.0 - discount_rate)/100.0)).to_s).round(2) if quantity && unit_amount
end

#line_amount=(line_amount) ⇒ Object



25
26
27
28
# File 'lib/xeroizer/models/line_item.rb', line 25

def line_amount=(line_amount)
  @line_amount_set = true
  attributes[:line_amount] = line_amount
end