Class: Sendregning::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/sendregning/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Line

Returns a new instance of Line.



25
26
27
# File 'lib/sendregning/line.rb', line 25

def initialize(new_attributes={})
  self.attributes = new_attributes
end

Instance Attribute Details

#descObject

Description. String, max length: 75



12
13
14
# File 'lib/sendregning/line.rb', line 12

def desc
  @desc
end

#discountObject

Discount in percentage as decimal. Optional, defaults to 0



18
19
20
# File 'lib/sendregning/line.rb', line 18

def discount
  @discount
end

#itemNoObject

Returns the value of attribute itemNo.



23
24
25
# File 'lib/sendregning/line.rb', line 23

def itemNo
  @itemNo
end

#lineTaxAmountObject

Returns the value of attribute lineTaxAmount.



23
24
25
# File 'lib/sendregning/line.rb', line 23

def lineTaxAmount
  @lineTaxAmount
end

#lineTotalObject

Returns the value of attribute lineTotal.



23
24
25
# File 'lib/sendregning/line.rb', line 23

def lineTotal
  @lineTotal
end

#prodCodeObject

Product code. String, max length: 9



9
10
11
# File 'lib/sendregning/line.rb', line 9

def prodCode
  @prodCode
end

#qtyObject

Quantity, as decimal. Example: ‘7,5’



6
7
8
# File 'lib/sendregning/line.rb', line 6

def qty
  @qty
end

#taxObject

Tax rate. Valid rates are: ‘0’, ‘8’, ‘13’ and ‘25’. Default: ‘25’



21
22
23
# File 'lib/sendregning/line.rb', line 21

def tax
  @tax
end

#unitPriceObject

Price per unit in decimal. Example: ‘250,00’



15
16
17
# File 'lib/sendregning/line.rb', line 15

def unitPrice
  @unitPrice
end

Instance Method Details

#to_xml(options = {}) ⇒ Object

Renders line to XML



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sendregning/line.rb', line 30

def to_xml(options={})
  if options[:builder]
    xml = options[:builder]
  else
    xml = Builder::XmlMarkup.new(:indent=>2)
    xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
  end
  xml.line do |line|
    line.qty       self.qty       if @qty
    line.prodCode  self.prodCode  if @prodCode
    line.desc      self.desc      if @desc
    line.unitPrice self.unitPrice if @unitPrice
    line.discount  self.discount  if @discount
    line.tax       self.tax       if @tax
  end
end