Class: XmlConv::I2::Order

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

Constant Summary collapse

I2_DELIVERY_CODES =
{
     ## janico
	:pickup		  =>	'070',
	:delivery	  =>	'060',
	:camion 	  =>	'010',
     ## globopharm
     :default    =>  '1',
     :before_9   =>  '3',
     :before_21  =>  '4',
     :before_16  =>  '5',
     :extracted  =>  '13',
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOrder

Returns a new instance of Order.



22
23
24
25
26
27
# File 'lib/xmlconv/i2/order.rb', line 22

def initialize
	@addresses = []
	@dates = []
	@positions = []
     @interface = "61"
end

Instance Attribute Details

#addressesObject (readonly)

Returns the value of attribute addresses.



21
22
23
# File 'lib/xmlconv/i2/order.rb', line 21

def addresses
  @addresses
end

#ade_idObject

Returns the value of attribute ade_id.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def ade_id
  @ade_id
end

#agentObject

Returns the value of attribute agent.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def agent
  @agent
end

#datesObject (readonly)

Returns the value of attribute dates.



21
22
23
# File 'lib/xmlconv/i2/order.rb', line 21

def dates
  @dates
end

#delivery_idObject

Returns the value of attribute delivery_id.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def delivery_id
  @delivery_id
end

#free_textObject

Returns the value of attribute free_text.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def free_text
  @free_text
end

#interfaceObject

Returns the value of attribute interface.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def interface
  @interface
end

#positionsObject (readonly)

Returns the value of attribute positions.



21
22
23
# File 'lib/xmlconv/i2/order.rb', line 21

def positions
  @positions
end

#sender_idObject

Returns the value of attribute sender_id.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def sender_id
  @sender_id
end

#terms_condObject

Returns the value of attribute terms_cond.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def terms_cond
  @terms_cond
end

#transport_costObject

Returns the value of attribute transport_cost.



19
20
21
# File 'lib/xmlconv/i2/order.rb', line 19

def transport_cost
  @transport_cost
end

Instance Method Details

#add_address(address) ⇒ Object



28
29
30
# File 'lib/xmlconv/i2/order.rb', line 28

def add_address(address)
	@addresses.push(address)
end

#add_date(date) ⇒ Object



31
32
33
# File 'lib/xmlconv/i2/order.rb', line 31

def add_date(date)
	@dates.push(date)
end

#add_position(position) ⇒ Object



34
35
36
# File 'lib/xmlconv/i2/order.rb', line 34

def add_position(position)
	@positions.push(position)
end

#to_sObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/xmlconv/i2/order.rb', line 37

def to_s
	output = <<-EOS
100:#{@sender_id}
101:#{@delivery_id}
	EOS
	@addresses.each { |addr| output << addr.to_s }
     numerals = [ 231, 236, 237, 238, 242 ]
	[
		@agent, @free_text, @interface, I2_DELIVERY_CODES[@terms_cond],
       @transport_cost,
	].each_with_index { |value, idx|
		unless(value.nil?)
			output << sprintf("%s:%s\n", numerals[idx], value)
		end
	}
     if(@ade_id)
       output << sprintf("250:ADE\n251:%s\n", @ade_id)
     end
	@dates.each { |date| output << date.to_s }
	@positions.each { |pos| output << pos.to_s }
	output
end