Class: SAPOCI::Item

Inherits:
Object show all
Defined in:
lib/sapoci/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index) ⇒ Item

Initializes the item.



46
47
48
# File 'lib/sapoci/item.rb', line 46

def initialize(index)
  @index = index
end

Instance Attribute Details

#attachmentObject

Returns the value of attribute attachment.



32
33
34
# File 'lib/sapoci/item.rb', line 32

def attachment
  @attachment
end

#attachment_purposeObject

Returns the value of attribute attachment_purpose.



34
35
36
# File 'lib/sapoci/item.rb', line 34

def attachment_purpose
  @attachment_purpose
end

#attachment_titleObject

Returns the value of attribute attachment_title.



33
34
35
# File 'lib/sapoci/item.rb', line 33

def attachment_title
  @attachment_title
end

#contractObject

Returns the value of attribute contract.



27
28
29
# File 'lib/sapoci/item.rb', line 27

def contract
  @contract
end

#contract_itemObject

Returns the value of attribute contract_item.



28
29
30
# File 'lib/sapoci/item.rb', line 28

def contract_item
  @contract_item
end

#currencyObject

Returns the value of attribute currency.



17
18
19
# File 'lib/sapoci/item.rb', line 17

def currency
  @currency
end

#cust_field1Object

Returns the value of attribute cust_field1.



39
40
41
# File 'lib/sapoci/item.rb', line 39

def cust_field1
  @cust_field1
end

#cust_field2Object

Returns the value of attribute cust_field2.



40
41
42
# File 'lib/sapoci/item.rb', line 40

def cust_field2
  @cust_field2
end

#cust_field3Object

Returns the value of attribute cust_field3.



41
42
43
# File 'lib/sapoci/item.rb', line 41

def cust_field3
  @cust_field3
end

#cust_field4Object

Returns the value of attribute cust_field4.



42
43
44
# File 'lib/sapoci/item.rb', line 42

def cust_field4
  @cust_field4
end

#cust_field5Object

Returns the value of attribute cust_field5.



43
44
45
# File 'lib/sapoci/item.rb', line 43

def cust_field5
  @cust_field5
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#ext_categoryObject

Returns the value of attribute ext_category.



37
38
39
# File 'lib/sapoci/item.rb', line 37

def ext_category
  @ext_category
end

#ext_category_idObject

Returns the value of attribute ext_category_id.



36
37
38
# File 'lib/sapoci/item.rb', line 36

def ext_category_id
  @ext_category_id
end

#ext_product_idObject

Returns the value of attribute ext_product_id.



31
32
33
# File 'lib/sapoci/item.rb', line 31

def ext_product_id
  @ext_product_id
end

#ext_quote_idObject

Returns the value of attribute ext_quote_id.



29
30
31
# File 'lib/sapoci/item.rb', line 29

def ext_quote_id
  @ext_quote_id
end

#ext_quote_itemObject

Returns the value of attribute ext_quote_item.



30
31
32
# File 'lib/sapoci/item.rb', line 30

def ext_quote_item
  @ext_quote_item
end

#ext_schema_typeObject

Returns the value of attribute ext_schema_type.



35
36
37
# File 'lib/sapoci/item.rb', line 35

def ext_schema_type
  @ext_schema_type
end

#indexObject (readonly)

Returns the value of attribute index.



11
12
13
# File 'lib/sapoci/item.rb', line 11

def index
  @index
end

#leadtimeObject

Returns the value of attribute leadtime.



19
20
21
# File 'lib/sapoci/item.rb', line 19

def leadtime
  @leadtime
end

#longtextObject

Returns the value of attribute longtext.



20
21
22
# File 'lib/sapoci/item.rb', line 20

def longtext
  @longtext
end

#manufactcodeObject

Returns the value of attribute manufactcode.



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

def manufactcode
  @manufactcode
end

#manufactmatObject

Returns the value of attribute manufactmat.



24
25
26
# File 'lib/sapoci/item.rb', line 24

def manufactmat
  @manufactmat
end

#matgroupObject

Returns the value of attribute matgroup.



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

def matgroup
  @matgroup
end

#matnrObject

Returns the value of attribute matnr.



13
14
15
# File 'lib/sapoci/item.rb', line 13

def matnr
  @matnr
end

#priceObject

Returns the value of attribute price.



16
17
18
# File 'lib/sapoci/item.rb', line 16

def price
  @price
end

#priceunitObject

Returns the value of attribute priceunit.



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

def priceunit
  @priceunit
end

#quantityObject

Returns the value of attribute quantity.



14
15
16
# File 'lib/sapoci/item.rb', line 14

def quantity
  @quantity
end

#serviceObject

Returns the value of attribute service.



26
27
28
# File 'lib/sapoci/item.rb', line 26

def service
  @service
end

#sld_sys_nameObject

Returns the value of attribute sld_sys_name.



38
39
40
# File 'lib/sapoci/item.rb', line 38

def sld_sys_name
  @sld_sys_name
end

#unitObject

Returns the value of attribute unit.



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

def unit
  @unit
end

#vendorObject

Returns the value of attribute vendor.



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

def vendor
  @vendor
end

#vendormatObject

Returns the value of attribute vendormat.



22
23
24
# File 'lib/sapoci/item.rb', line 22

def vendormat
  @vendormat
end

Instance Method Details

#leadtime_before_type_castObject



78
79
80
# File 'lib/sapoci/item.rb', line 78

def leadtime_before_type_cast
  @leadtime
end

#price_before_type_castObject



62
63
64
# File 'lib/sapoci/item.rb', line 62

def price_before_type_cast
  @price
end

#priceunit_before_type_castObject



70
71
72
# File 'lib/sapoci/item.rb', line 70

def priceunit_before_type_cast
  @priceunit
end

#quantity_before_type_castObject



54
55
56
# File 'lib/sapoci/item.rb', line 54

def quantity_before_type_cast
  @quantity
end

#service?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/sapoci/item.rb', line 82

def service?
  self.service == "X"
end

#to_html(options = {}) ⇒ Object

Returns the item properties as HTML hidden field tags.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/sapoci/item.rb', line 87

def to_html(options = {})
  html = []
  html << hidden_field_tag("DESCRIPTION",     self.description)     unless self.description.blank?
  html << hidden_field_tag("MATNR",           self.matnr)           unless self.matnr.blank?
  html << hidden_field_tag("QUANTITY",        "%015.3f" % self.quantity)
  html << hidden_field_tag("UNIT",            self.unit)            unless self.unit.blank?
  html << hidden_field_tag("PRICE",           "%015.3f" % self.price)
  html << hidden_field_tag("CURRENCY",        self.currency)        unless self.currency.blank?
  html << hidden_field_tag("PRICEUNIT",       self.priceunit.to_i)  if self.priceunit.to_i > 0
  html << hidden_field_tag("LEADTIME",        "%05d" % self.leadtime) if self.leadtime.to_i > 0
  html << hidden_field_tag("VENDOR",          self.vendor)          unless self.vendor.blank?
  html << hidden_field_tag("VENDORMAT",       self.vendormat)       unless self.vendormat.blank?
  html << hidden_field_tag("MANUFACTCODE",    self.manufactcode)    unless self.manufactcode.blank?
  html << hidden_field_tag("MANUFACTMAT",     self.manufactmat)     unless self.manufactmat.blank?
  html << hidden_field_tag("MATGROUP",        self.matgroup)        unless self.matgroup.blank?
  html << hidden_field_tag("SERVICE",         "X")                  if     self.service?
  html << hidden_field_tag("CONTRACT",        self.contract)        unless self.contract.blank?
  html << hidden_field_tag("CONTRACT_ITEM",   self.contract_item)   unless self.contract_item.blank?
  html << hidden_field_tag("EXT_QUOTE_ID",    self.ext_quote_id)    unless self.ext_quote_id.blank?
  html << hidden_field_tag("EXT_QUOTE_ITEM",  self.ext_quote_item)  unless self.ext_quote_item.blank?
  html << hidden_field_tag("EXT_PRODUCT_ID",  self.ext_product_id)  unless self.ext_product_id.blank?
  html << hidden_field_tag("ATTACHMENT",      self.attachment)      unless self.attachment.blank?
  html << hidden_field_tag("ATTACHMENT_TITLE", self.attachment_title) unless self.attachment_title.blank?
  html << hidden_field_tag("ATTACHMENT_PURPOSE", self.attachment_purpose) unless self.attachment_purpose.blank?
  html << hidden_field_tag("EXT_SCHEMA_TYPE", self.ext_schema_type) unless self.ext_schema_type.blank?
  html << hidden_field_tag("EXT_CATEGORY_ID", self.ext_category_id) unless self.ext_category_id.blank?
  html << hidden_field_tag("EXT_CATEGORY",    self.ext_category)    unless self.ext_category.blank?
  html << hidden_field_tag("SLD_SYS_NAME",    self.sld_sys_name)    unless self.sld_sys_name.blank?
  html << hidden_field_tag("CUST_FIELD1",     self.cust_field1)     unless self.cust_field1.blank?
  html << hidden_field_tag("CUST_FIELD2",     self.cust_field2)     unless self.cust_field2.blank?
  html << hidden_field_tag("CUST_FIELD3",     self.cust_field3)     unless self.cust_field3.blank?
  html << hidden_field_tag("CUST_FIELD4",     self.cust_field4)     unless self.cust_field4.blank?
  html << hidden_field_tag("CUST_FIELD5",     self.cust_field5)     unless self.cust_field5.blank?
  html << "<input type=\"hidden\" name=\"NEW_ITEM-LONGTEXT_#{index + 1}:132[]\" value=\"#{escape_html(self.longtext)}\" />" unless self.longtext.blank?
  html.join
end