sapoci 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efabe83f29509ca5c589d24c054e6ab09ce5f996
4
- data.tar.gz: 9c5a92ecb47b5e254c56fc7c4b57d7cf2dc3d5ef
3
+ metadata.gz: 31a56bf4eb76ed5dfb7df17a9142775bbb99e19f
4
+ data.tar.gz: 615ea0a0826d3de6f369394acb3f3953ab1feae2
5
5
  SHA512:
6
- metadata.gz: 80ab2a1392bf0d77d94ba3789e9bbdf164df64b2bf1c00b1acd75aa53ae1f1a00840bf297a62dc1f993e8f2e34e85375f6eeaf2be08f497c8e59a67da15c1687
7
- data.tar.gz: c44563afa1ee922db44602f6018bb534d73ceb991d5efc9695324f38cff28a6a6e8d2792de8e2f409bccfc24661f22d152de0c69282340df75f63e6b8c9aa0bb
6
+ metadata.gz: d88d4bd8ab73a9414a5c1e1d759b650dffcf4153909ed5ca92547c242f92350d38cfc22868c025ec1b6b753058795cb8d3bf9029312b4dccc97e8a54b2277b69
7
+ data.tar.gz: cbf129c4b3308992af62c58109fd35953432d9c0eec2aa55fcd0bc0d810b805716297646e7b6b026baa49c92a0af79485a25e7cae9e0fe656cc4356b8debe94c
@@ -71,7 +71,7 @@ module SAPOCI
71
71
  items[index].longtext = value
72
72
  end
73
73
  end
74
- items.inject([]) { |memo, (key, value)| memo << value }.sort_by(&:index)
74
+ items.inject([]) { |memo, (_, value)| memo << value }.sort_by(&:index)
75
75
  end
76
76
 
77
77
  # Parses a Rails-/Rack-compatible params hash and returns
@@ -115,7 +115,7 @@ module SAPOCI
115
115
  end if oci_values
116
116
  end # oci_name =~ /NEW_ITEM-/
117
117
  end
118
- items.inject([]) { |memo, (key, value)| memo << value }.sort_by(&:index)
118
+ items.inject([]) { |memo, (_, value)| memo << value }.sort_by(&:index)
119
119
  end
120
120
 
121
121
  end
@@ -7,16 +7,12 @@ require 'bigdecimal'
7
7
 
8
8
  module SAPOCI
9
9
  class Item
10
-
10
+
11
11
  attr_reader :index
12
12
  attr_accessor :description
13
13
  attr_accessor :matnr
14
- attr_accessor :quantity
15
14
  attr_accessor :unit
16
- attr_accessor :price
17
15
  attr_accessor :currency
18
- attr_accessor :priceunit
19
- attr_accessor :leadtime
20
16
  attr_accessor :longtext
21
17
  attr_accessor :vendor
22
18
  attr_accessor :vendormat
@@ -36,49 +32,108 @@ module SAPOCI
36
32
  attr_accessor :ext_category_id
37
33
  attr_accessor :ext_category
38
34
  attr_accessor :sld_sys_name
35
+ attr_accessor :mps_sage_number
36
+ attr_accessor :mps_sage_contract
39
37
  attr_accessor :cust_field1
40
38
  attr_accessor :cust_field2
41
39
  attr_accessor :cust_field3
42
40
  attr_accessor :cust_field4
43
41
  attr_accessor :cust_field5
44
-
42
+ attr_accessor :cust_field6
43
+ attr_accessor :cust_field7
44
+ attr_accessor :cust_field8
45
+ attr_accessor :cust_field9
46
+ attr_accessor :cust_field10
47
+ attr_accessor :cust_field11
48
+ attr_accessor :cust_field12
49
+ attr_accessor :cust_field13
50
+ attr_accessor :cust_field14
51
+ attr_accessor :cust_field15
52
+ attr_accessor :cust_field16
53
+ attr_accessor :cust_field17
54
+ attr_accessor :cust_field18
55
+ attr_accessor :cust_field19
56
+ attr_accessor :cust_field20
57
+ attr_accessor :cust_field21
58
+ attr_accessor :cust_field22
59
+ attr_accessor :cust_field23
60
+ attr_accessor :cust_field24
61
+ attr_accessor :cust_field25
62
+ attr_accessor :cust_field26
63
+ attr_accessor :cust_field27
64
+ attr_accessor :cust_field28
65
+ attr_accessor :cust_field29
66
+ attr_accessor :cust_field30
67
+
45
68
  # Initializes the item.
46
69
  def initialize(index)
47
70
  @index = index
48
71
  end
49
-
72
+
50
73
  def quantity
51
- BigDecimal.new("0#{@quantity.to_s.strip.gsub(/,/,'.')}")
74
+ if defined?(@quantity)
75
+ BigDecimal.new("0#{@quantity.to_s.strip.gsub(/,/,'.')}")
76
+ else
77
+ BigDecimal.new("0.0")
78
+ end
79
+ end
80
+
81
+ def quantity=(value)
82
+ @quantity = value
52
83
  end
53
84
 
54
85
  def quantity_before_type_cast
55
86
  @quantity
56
87
  end
57
-
88
+
58
89
  def price
59
- BigDecimal.new("0#{@price.to_s.strip.gsub(/,/,'.')}")
90
+ if defined?(@price)
91
+ BigDecimal.new("0#{@price.to_s.strip.gsub(/,/,'.')}")
92
+ else
93
+ BigDecimal.new("0.0")
94
+ end
95
+ end
96
+
97
+ def price=(value)
98
+ @price = value
60
99
  end
61
-
100
+
62
101
  def price_before_type_cast
63
102
  @price
64
103
  end
65
104
 
66
105
  def priceunit
67
- BigDecimal.new("0#{@priceunit.to_s.strip.gsub(/,/,'.')}").nonzero? || 1
106
+ if defined?(@priceunit)
107
+ BigDecimal.new("0#{@priceunit.to_s.strip.gsub(/,/,'.')}").nonzero? || 1
108
+ else
109
+ 1
110
+ end
68
111
  end
69
-
112
+
113
+ def priceunit=(value)
114
+ @priceunit = value
115
+ end
116
+
70
117
  def priceunit_before_type_cast
71
118
  @priceunit
72
119
  end
73
120
 
74
121
  def leadtime
75
- @leadtime.to_i if @leadtime
122
+ if defined?(@leadtime) && @leadtime
123
+ @leadtime.to_i
124
+ else
125
+ 0
126
+ end
127
+ end
128
+
129
+ def leadtime=(value)
130
+ @leadtime = value
76
131
  end
77
132
 
78
133
  def leadtime_before_type_cast
79
134
  @leadtime
80
135
  end
81
-
136
+
82
137
  def service?
83
138
  self.service == "X"
84
139
  end
@@ -112,21 +167,48 @@ module SAPOCI
112
167
  html << hidden_field_tag("EXT_CATEGORY_ID", self.ext_category_id) unless self.ext_category_id.blank?
113
168
  html << hidden_field_tag("EXT_CATEGORY", self.ext_category) unless self.ext_category.blank?
114
169
  html << hidden_field_tag("SLD_SYS_NAME", self.sld_sys_name) unless self.sld_sys_name.blank?
170
+ html << hidden_field_tag("MPS_SAGE_NUMBER", self.mps_sage_number) unless self.mps_sage_number.blank?
171
+ html << hidden_field_tag("MPS_SAGE_CONTRACT", self.mps_sage_contract) unless self.mps_sage_contract.blank?
115
172
  html << hidden_field_tag("CUST_FIELD1", self.cust_field1) unless self.cust_field1.blank?
116
173
  html << hidden_field_tag("CUST_FIELD2", self.cust_field2) unless self.cust_field2.blank?
117
174
  html << hidden_field_tag("CUST_FIELD3", self.cust_field3) unless self.cust_field3.blank?
118
175
  html << hidden_field_tag("CUST_FIELD4", self.cust_field4) unless self.cust_field4.blank?
119
176
  html << hidden_field_tag("CUST_FIELD5", self.cust_field5) unless self.cust_field5.blank?
177
+ html << hidden_field_tag("CUST_FIELD6", self.cust_field6) unless self.cust_field6.blank?
178
+ html << hidden_field_tag("CUST_FIELD7", self.cust_field7) unless self.cust_field7.blank?
179
+ html << hidden_field_tag("CUST_FIELD8", self.cust_field8) unless self.cust_field8.blank?
180
+ html << hidden_field_tag("CUST_FIELD9", self.cust_field9) unless self.cust_field9.blank?
181
+ html << hidden_field_tag("CUST_FIELD10", self.cust_field10) unless self.cust_field10.blank?
182
+ html << hidden_field_tag("CUST_FIELD11", self.cust_field11) unless self.cust_field11.blank?
183
+ html << hidden_field_tag("CUST_FIELD12", self.cust_field12) unless self.cust_field12.blank?
184
+ html << hidden_field_tag("CUST_FIELD13", self.cust_field13) unless self.cust_field13.blank?
185
+ html << hidden_field_tag("CUST_FIELD14", self.cust_field14) unless self.cust_field14.blank?
186
+ html << hidden_field_tag("CUST_FIELD15", self.cust_field15) unless self.cust_field15.blank?
187
+ html << hidden_field_tag("CUST_FIELD16", self.cust_field16) unless self.cust_field16.blank?
188
+ html << hidden_field_tag("CUST_FIELD17", self.cust_field17) unless self.cust_field17.blank?
189
+ html << hidden_field_tag("CUST_FIELD18", self.cust_field18) unless self.cust_field18.blank?
190
+ html << hidden_field_tag("CUST_FIELD19", self.cust_field19) unless self.cust_field19.blank?
191
+ html << hidden_field_tag("CUST_FIELD20", self.cust_field20) unless self.cust_field20.blank?
192
+ html << hidden_field_tag("CUST_FIELD21", self.cust_field21) unless self.cust_field21.blank?
193
+ html << hidden_field_tag("CUST_FIELD22", self.cust_field22) unless self.cust_field22.blank?
194
+ html << hidden_field_tag("CUST_FIELD23", self.cust_field23) unless self.cust_field23.blank?
195
+ html << hidden_field_tag("CUST_FIELD24", self.cust_field24) unless self.cust_field24.blank?
196
+ html << hidden_field_tag("CUST_FIELD25", self.cust_field25) unless self.cust_field25.blank?
197
+ html << hidden_field_tag("CUST_FIELD26", self.cust_field26) unless self.cust_field26.blank?
198
+ html << hidden_field_tag("CUST_FIELD27", self.cust_field27) unless self.cust_field27.blank?
199
+ html << hidden_field_tag("CUST_FIELD28", self.cust_field28) unless self.cust_field28.blank?
200
+ html << hidden_field_tag("CUST_FIELD29", self.cust_field29) unless self.cust_field29.blank?
201
+ html << hidden_field_tag("CUST_FIELD30", self.cust_field30) unless self.cust_field30.blank?
120
202
  html << "<input type=\"hidden\" name=\"NEW_ITEM-LONGTEXT_#{index + 1}:132[]\" value=\"#{escape_html(self.longtext)}\" />" unless self.longtext.blank?
121
203
  html.join
122
204
  end
123
-
205
+
124
206
  private
125
-
207
+
126
208
  def hidden_field_tag(name, value, options = {})
127
209
  "<input type=\"hidden\" name=\"NEW_ITEM-#{name}[#{index + 1}]\" value=\"#{escape_html(value)}\" />"
128
210
  end
129
-
211
+
130
212
  ESCAPE_HTML = { "&" => "&amp;", "<" => "&lt;", ">" => "&gt;", "'" => "&#39;", '"' => "&quot;", }
131
213
  ESCAPE_HTML_PATTERN = Regexp.union(ESCAPE_HTML.keys)
132
214
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapoci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Eilhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: 1.3.6
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.4.6
109
+ rubygems_version: 2.5.1
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: SAP OCI enables users to parse SAP OCI compliant data from online shops.