Class: XmlConv::I2::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlconv/i2/position.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#article_eanObject

Returns the value of attribute article_ean.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def article_ean
  @article_ean
end

#customer_idObject

Returns the value of attribute customer_id.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def customer_id
  @customer_id
end

#delivery_dateObject

Returns the value of attribute delivery_date.



11
12
13
# File 'lib/xmlconv/i2/position.rb', line 11

def delivery_date
  @delivery_date
end

#free_textObject

Returns the value of attribute free_text.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def free_text
  @free_text
end

#numberObject

Returns the value of attribute number.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def number
  @number
end

#pharmacodeObject

Returns the value of attribute pharmacode.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def pharmacode
  @pharmacode
end

#priceObject

Returns the value of attribute price.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def price
  @price
end

#qtyObject

Returns the value of attribute qty.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def qty
  @qty
end

#unitObject

Returns the value of attribute unit.



9
10
11
# File 'lib/xmlconv/i2/position.rb', line 9

def unit
  @unit
end

Instance Method Details

#to_sObject



16
17
18
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
# File 'lib/xmlconv/i2/position.rb', line 16

def to_s
	output = <<-EOS
500:#{@number}
     EOS
#        output << "501:#{@article_ean}\n"
     [@customer_id, @pharmacode].compact.each { |id|
       #output << sprintf("502:%s\n", id)
       output << sprintf("501:%s\n", id)
     }
     output << sprintf("520:%s\n", @qty)
     if(@unit)
       output << sprintf("521:%s\n", @unit)
     end
	if(@delivery_date.is_a?(I2::Date))
		output << @delivery_date.to_s
	end
     if(@price)
       output << sprintf("604:%s\n", @price)
     end
     if(@free_text)
       output << "605:RS\n"
       txt = @free_text[0,280] ## upper limit: 40 lines of 70 chars
       while(!txt.empty?)
         output << sprintf("606:%s\n", txt.slice!(0,70))
       end
     end
	output
end