Class: Xeroizer::Record::LineItem
- Defined in:
- lib/xeroizer/models/line_item.rb
Constant Summary collapse
Instance Attribute Summary
Attributes inherited from Base
#attributes, #complete_record_downloaded, #errors, #model, #parent
Instance Method Summary collapse
-
#line_amount(summary_only = false) ⇒ Object
Calculate the line_total (if there is a quantity and unit_amount).
- #line_amount=(line_amount) ⇒ Object
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
Methods included from ValidationHelper
Methods included from RecordAssociationHelper
Methods included from ModelDefinitionHelper
Methods included from ClassLevelInheritableAttributes
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 |