Class: RVista::InvoiceLineItem
- Inherits:
-
Object
- Object
- RVista::InvoiceLineItem
- Defined in:
- lib/rvista/invoice_line_item.rb
Overview
represents a single line on an invoice. Has attributes like price, qty and description
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#discount_percent ⇒ Object
Returns the value of attribute discount_percent.
-
#discount_value ⇒ Object
Returns the value of attribute discount_value.
-
#ean ⇒ Object
Returns the value of attribute ean.
-
#firm_sale ⇒ Object
Returns the value of attribute firm_sale.
-
#gst ⇒ Object
Returns the value of attribute gst.
-
#gst_inclusive ⇒ Object
Returns the value of attribute gst_inclusive.
-
#line_num ⇒ Object
Returns the value of attribute line_num.
-
#nett_unit_price ⇒ Object
Returns the value of attribute nett_unit_price.
-
#nett_value ⇒ Object
Returns the value of attribute nett_value.
-
#po_number ⇒ Object
Returns the value of attribute po_number.
-
#qty ⇒ Object
Returns the value of attribute qty.
-
#qualifier ⇒ Object
Returns the value of attribute qualifier.
-
#rrp ⇒ Object
Returns the value of attribute rrp.
-
#unit_measure ⇒ Object
Returns the value of attribute unit_measure.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
-
.load_from_array(data) ⇒ Object
returns a new RVista::POALineItem object using the data passed in as an array.
Instance Method Summary collapse
-
#to_s ⇒ Object
output a string that represents this line item that meets the vista spec.
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/rvista/invoice_line_item.rb', line 11 def description @description end |
#discount_percent ⇒ Object
Returns the value of attribute discount_percent.
12 13 14 |
# File 'lib/rvista/invoice_line_item.rb', line 12 def discount_percent @discount_percent end |
#discount_value ⇒ Object
Returns the value of attribute discount_value.
14 15 16 |
# File 'lib/rvista/invoice_line_item.rb', line 14 def discount_value @discount_value end |
#ean ⇒ Object
Returns the value of attribute ean.
11 12 13 |
# File 'lib/rvista/invoice_line_item.rb', line 11 def ean @ean end |
#firm_sale ⇒ Object
Returns the value of attribute firm_sale.
14 15 16 |
# File 'lib/rvista/invoice_line_item.rb', line 14 def firm_sale @firm_sale end |
#gst ⇒ Object
Returns the value of attribute gst.
14 15 16 |
# File 'lib/rvista/invoice_line_item.rb', line 14 def gst @gst end |
#gst_inclusive ⇒ Object
Returns the value of attribute gst_inclusive.
13 14 15 |
# File 'lib/rvista/invoice_line_item.rb', line 13 def gst_inclusive @gst_inclusive end |
#line_num ⇒ Object
Returns the value of attribute line_num.
11 12 13 |
# File 'lib/rvista/invoice_line_item.rb', line 11 def line_num @line_num end |
#nett_unit_price ⇒ Object
Returns the value of attribute nett_unit_price.
13 14 15 |
# File 'lib/rvista/invoice_line_item.rb', line 13 def nett_unit_price @nett_unit_price end |
#nett_value ⇒ Object
Returns the value of attribute nett_value.
14 15 16 |
# File 'lib/rvista/invoice_line_item.rb', line 14 def nett_value @nett_value end |
#po_number ⇒ Object
Returns the value of attribute po_number.
11 12 13 |
# File 'lib/rvista/invoice_line_item.rb', line 11 def po_number @po_number end |
#qty ⇒ Object
Returns the value of attribute qty.
12 13 14 |
# File 'lib/rvista/invoice_line_item.rb', line 12 def qty @qty end |
#qualifier ⇒ Object
Returns the value of attribute qualifier.
11 12 13 |
# File 'lib/rvista/invoice_line_item.rb', line 11 def qualifier @qualifier end |
#rrp ⇒ Object
Returns the value of attribute rrp.
12 13 14 |
# File 'lib/rvista/invoice_line_item.rb', line 12 def rrp @rrp end |
#unit_measure ⇒ Object
Returns the value of attribute unit_measure.
12 13 14 |
# File 'lib/rvista/invoice_line_item.rb', line 12 def unit_measure @unit_measure end |
#value ⇒ Object
Returns the value of attribute value.
13 14 15 |
# File 'lib/rvista/invoice_line_item.rb', line 13 def value @value end |
Class Method Details
.load_from_array(data) ⇒ Object
returns a new RVista::POALineItem object using the data passed in as an array. The array should have exactly 14 items in it. Refer to the Vista standard to see what those 14 items should be.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rvista/invoice_line_item.rb', line 19 def self.load_from_array(data) item = self.new raise InvalidLineItemError, 'incorrect number of data points' unless data.size == 17 item.line_num = data[1].to_i item.po_number = data[2] item.qualifier = data[3] item.ean = data[4] item.description = data[5] item.qty = data[6].to_i item.unit_measure = data[7] item.rrp = BigDecimal.new(data[8]) unless data[8].nil? item.discount_percent = BigDecimal.new(data[9]) unless data[9].nil? item.nett_unit_price = BigDecimal.new(data[10]) unless data[10].nil? if data[11].eql?("Y") item.gst_inclusive = true else item.gst_inclusive = false end item.value = BigDecimal.new(data[12]) unless data[12].nil? item.discount_value = BigDecimal.new(data[13]) unless data[13].nil? item.nett_value = BigDecimal.new(data[14]) unless data[14].nil? item.gst = BigDecimal.new(data[15]) unless data[15].nil? if data[16].eql?("F") item.firm_sale = true else item.firm_sale = false end return item end |
Instance Method Details
#to_s ⇒ Object
output a string that represents this line item that meets the vista spec
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rvista/invoice_line_item.rb', line 52 def to_s msg = "" msg << "D," msg << "#{line_num.to_s[0,6]}," msg << "#{po_number.to_s[0,14]}," msg << "#{qualifier.to_s[0,3]}," msg << "#{ean.to_s[0,35]}," msg << "#{description.to_s[0,35]}," msg << "#{qty.to_s[0,17]}," msg << "#{unit_measure.to_s[0,3]}," msg << sprintf("%.0f", rrp) unless rrp.nil? msg << "," msg << sprintf("%.0f", discount_percent) unless discount_percent.nil? msg << "," msg << sprintf("%.0f", nett_unit_price) unless nett_unit_price.nil? msg << "," if gst_inclusive msg << "Y," else msg << "," end msg << sprintf("%.0f", value) unless value.nil? msg << "," msg << sprintf("%.0f", discount_value) unless discount_value.nil? msg << "," msg << sprintf("%.0f", nett_value) unless nett_value.nil? msg << "," msg << sprintf("%.0f", gst) unless gst.nil? msg << "," if firm_sale msg << "F" end return msg end |