efo_nelfo 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/Rakefile +1 -1
- data/lib/efo_nelfo/property.rb +3 -3
- data/lib/efo_nelfo/property_types.rb +1 -1
- data/lib/efo_nelfo/v40/va.rb +21 -0
- data/lib/efo_nelfo/v40/vl.rb +19 -3
- data/lib/efo_nelfo/version.rb +1 -1
- data/spec/efo_nelfo_spec.rb +9 -142
- data/spec/parsing/bh_spec.rb +54 -0
- data/spec/parsing/rh_spec.rb +19 -0
- data/spec/parsing/vh_spec.rb +62 -0
- data/spec/properties_spec.rb +1 -1
- data/spec/property_spec.rb +7 -2
- data/spec/spec_helper.rb +6 -1
- data/spec/va_spec.rb +18 -0
- data/spec/vl_spec.rb +34 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 894a44091085c1483965076057f66f3d3a8ed7fe
|
4
|
+
data.tar.gz: 1d26149077017f057cb31df8c8029c7ee226cd26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dacd19af0a3f6ef369a723820d03c7787ff2989f946e89e3ece4900c97818fd8fa0c485c94b476e92ab3757ebf8d594d2b7c1590de4e4a84249cbb0344129848
|
7
|
+
data.tar.gz: 70e158b44c968e0f2056adfbccf27b1e8e8d6338dc6d1f99e9b9e462a55469ad634a23407896f4f674768e0d65ad9a9f87e72df2d748654f5b8ef16db183566a
|
data/README.md
CHANGED
@@ -16,7 +16,11 @@ Supported formats:
|
|
16
16
|
|
17
17
|
Importing a CSV file:
|
18
18
|
|
19
|
-
# EfoNelfo.
|
19
|
+
# EfoNelfo.load "B12345678.332.csv" # => EfoNelfo::V40::VH
|
20
|
+
|
21
|
+
Parsing CSV:
|
22
|
+
|
23
|
+
# EfoNelfo.parse "VH;EFONELFO;4.0;foo;bar" # => EfoNelfo::V40::VH
|
20
24
|
|
21
25
|
Exporting CSV:
|
22
26
|
|
data/Rakefile
CHANGED
data/lib/efo_nelfo/property.rb
CHANGED
@@ -50,7 +50,7 @@ module EfoNelfo
|
|
50
50
|
when date?
|
51
51
|
new_value.is_a?(Date) ? new_value : Date.parse(new_value) rescue nil
|
52
52
|
when integer?
|
53
|
-
new_value.nil? ? nil : new_value.to_i
|
53
|
+
new_value.nil? && !required? ? nil : new_value.to_i
|
54
54
|
else
|
55
55
|
new_value
|
56
56
|
end
|
@@ -73,13 +73,13 @@ module EfoNelfo
|
|
73
73
|
|
74
74
|
# Returns true if the property is read only
|
75
75
|
def readonly?
|
76
|
-
options[:read_only]
|
76
|
+
options[:read_only] == true
|
77
77
|
end
|
78
78
|
|
79
79
|
# Returns true if the property is required
|
80
80
|
# Note: this is not in use yet
|
81
81
|
def required?
|
82
|
-
options[:required]
|
82
|
+
options[:required] == true
|
83
83
|
end
|
84
84
|
|
85
85
|
def boolean?; type == :boolean; end
|
data/lib/efo_nelfo/v40/va.rb
CHANGED
@@ -6,6 +6,27 @@ module EfoNelfo
|
|
6
6
|
property :product_number, alias: :VareNr, limit: 14, required: true
|
7
7
|
property :type, alias: :VaType, limit: 1, required: true
|
8
8
|
property :sales_package, alias: :SalgsPakning, limit: 9, type: :integer
|
9
|
+
|
10
|
+
def nrf_id
|
11
|
+
product_type == 4 && product_number.strip
|
12
|
+
end
|
13
|
+
|
14
|
+
def replacement?
|
15
|
+
type == 'E'
|
16
|
+
end
|
17
|
+
|
18
|
+
def alternative?
|
19
|
+
type == 'A'
|
20
|
+
end
|
21
|
+
|
22
|
+
def alternative_id?
|
23
|
+
type == 'V'
|
24
|
+
end
|
25
|
+
|
26
|
+
def package_size?
|
27
|
+
type == 'P'
|
28
|
+
end
|
29
|
+
|
9
30
|
end
|
10
31
|
end
|
11
32
|
end
|
data/lib/efo_nelfo/v40/vl.rb
CHANGED
@@ -9,7 +9,7 @@ module EfoNelfo
|
|
9
9
|
property :unit, alias: :MåleEnhet, limit: 1, type: :integer, required: true
|
10
10
|
property :price_unit, alias: :PrisEnhet, limit: 3, required: true
|
11
11
|
property :price_unit_desc, alias: :PrisEnhetTxt, limit: 8
|
12
|
-
property :price, alias: :Pris, limit: 10, type: :integer, required: true
|
12
|
+
property :price, alias: :Pris, limit: 10, decimals: 2, type: :integer, required: true
|
13
13
|
property :amount, alias: :Mengde, limit: 9, type: :integer, required: true
|
14
14
|
property :price_date, alias: :PrisDato, limit: 8, type: :date, required: true
|
15
15
|
property :status, alias: :Status, limit: 1, type: :integer, required: true
|
@@ -29,13 +29,29 @@ module EfoNelfo
|
|
29
29
|
product_type == 4 ? product_number : nil
|
30
30
|
end
|
31
31
|
|
32
|
+
def gross_price?
|
33
|
+
price_type.nil? || price_type == 'B'
|
34
|
+
end
|
35
|
+
|
36
|
+
def gross_price
|
37
|
+
gross_price? ? properties[:price].to_f : nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def net_price
|
41
|
+
net_price? ? properties[:price].to_f : nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def net_price?
|
45
|
+
price_type == 'N'
|
46
|
+
end
|
47
|
+
|
32
48
|
def images
|
33
49
|
info.map(&:image).compact
|
34
50
|
end
|
35
51
|
|
36
52
|
[ :weight, :dimension, :volume, :fdv, :hms ].each do |key|
|
37
53
|
define_method key do
|
38
|
-
|
54
|
+
fetch_from_info key
|
39
55
|
end
|
40
56
|
end
|
41
57
|
|
@@ -46,7 +62,7 @@ module EfoNelfo
|
|
46
62
|
|
47
63
|
private
|
48
64
|
|
49
|
-
def
|
65
|
+
def fetch_from_info(method)
|
50
66
|
vx = info.select(&"#{method}?".to_sym).compact.first
|
51
67
|
vx && vx.send(method)
|
52
68
|
end
|
data/lib/efo_nelfo/version.rb
CHANGED
data/spec/efo_nelfo_spec.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
-
# helper method that returns full path to csv files
|
5
|
-
def csv(filename)
|
6
|
-
File.expand_path("../samples/#{filename}", __FILE__)
|
7
|
-
end
|
8
|
-
|
9
4
|
describe EfoNelfo do
|
10
5
|
|
11
6
|
describe "properties" do
|
@@ -72,157 +67,29 @@ describe EfoNelfo do
|
|
72
67
|
|
73
68
|
end
|
74
69
|
|
75
|
-
describe ".parse" do
|
76
|
-
|
77
|
-
it "parses CSV and does the same as .load" do
|
78
|
-
filename = csv('B650517.032.csv')
|
79
|
-
parsed = EfoNelfo.parse File.read(filename)
|
80
|
-
loaded = EfoNelfo.load filename
|
81
|
-
parsed.source.must_equal loaded.source
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
70
|
describe ".load" do
|
87
|
-
|
88
71
|
describe "when passing in invalid file" do
|
89
72
|
it "raises an exception" do
|
90
73
|
lambda { EfoNelfo.load 'foo' }.must_raise Errno::ENOENT
|
91
74
|
end
|
92
75
|
end
|
93
76
|
|
94
|
-
describe "passing a Product file" do
|
95
|
-
let(:nelfo) { EfoNelfo.load(csv('varefil_eksempel.csv')) }
|
96
|
-
|
97
|
-
it { nelfo.must_be_instance_of EfoNelfo::V40::VH }
|
98
|
-
|
99
|
-
it "loads the order" do
|
100
|
-
nelfo.format.must_equal "EFONELFO"
|
101
|
-
nelfo.version.must_equal "4.0"
|
102
|
-
nelfo.post_type.must_equal "VH"
|
103
|
-
nelfo.SelgersId.must_equal "NO1234567879MVA"
|
104
|
-
nelfo.KjøpersId.must_be_nil
|
105
|
-
nelfo.KundeNr.must_be_nil
|
106
|
-
nelfo.from_date.must_equal Date.new(2004, 1, 22)
|
107
|
-
nelfo.to_date.must_be_nil
|
108
|
-
nelfo.currency.must_equal "NOK"
|
109
|
-
nelfo.contract_id.must_be_nil
|
110
|
-
nelfo.seller_name.must_equal "ONNINEN A/S"
|
111
|
-
nelfo.seller_address1.must_equal "P.B. 70"
|
112
|
-
nelfo.seller_address2.must_be_nil
|
113
|
-
nelfo.seller_zip.must_equal "1483"
|
114
|
-
nelfo.seller_office.must_equal "SKYTTA"
|
115
|
-
nelfo.seller_country.must_equal "NO"
|
116
|
-
end
|
117
|
-
|
118
|
-
it "adds product lines" do
|
119
|
-
nelfo.lines.count.must_equal 3
|
120
|
-
|
121
|
-
line = nelfo.lines.first
|
122
|
-
line.product_type.must_equal 1
|
123
|
-
line.product_number.must_equal "1006100"
|
124
|
-
line.name.must_equal "MATTE 3MM 100W/M2 100W"
|
125
|
-
line.description.must_equal "1,0 m2 0,5 x 2,0 m"
|
126
|
-
line.unit.must_equal 1
|
127
|
-
line.price_unit.must_equal "EA"
|
128
|
-
line.price_unit_desc.must_equal "STYKK"
|
129
|
-
line.price.must_equal 55300
|
130
|
-
line.amount.must_equal 10000
|
131
|
-
line.price_date.must_equal Date.new(2011,9,1)
|
132
|
-
line.status.must_equal 1
|
133
|
-
line.block_number.must_be_nil
|
134
|
-
line.discount_group.must_equal "1004"
|
135
|
-
line.fabrication.must_be_nil
|
136
|
-
line.type.must_be_nil
|
137
|
-
line.stocked.must_equal true
|
138
|
-
line.stocked?.must_equal true
|
139
|
-
line.sales_package.must_equal 10000
|
140
|
-
end
|
141
|
-
|
142
|
-
it "adds additional information to the product" do
|
143
|
-
line = nelfo.lines.first
|
144
|
-
line.info.first.value.must_equal "http://www.elektroskandia.no/image/products/1221102.gif"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe "passing a discount file" do
|
149
|
-
let(:nelfo) { EfoNelfo.load csv('rabatt.csv') }
|
150
|
-
it { nelfo.must_be_instance_of EfoNelfo::V40::RH }
|
151
|
-
# RH;EFONELFO;4.0;NO910478656MVA;NO000000000MVA;0;0;20130404;20140404;NOK;H;Alsell Norge AS;Vestre Svanholmen 4;;4313;SANDNES;NO
|
152
|
-
it "assigns attributes" do
|
153
|
-
nelfo.seller_id.must_equal "NO910478656MVA"
|
154
|
-
nelfo.buyer_id.must_equal "NO000000000MVA"
|
155
|
-
end
|
156
|
-
|
157
|
-
it "assigns lines" do
|
158
|
-
nelfo.lines.size.must_equal 4
|
159
|
-
line = nelfo.lines.last
|
160
|
-
line.product_type.must_equal 5
|
161
|
-
line.product_number.must_equal "P10501"
|
162
|
-
line.AvtaltPris.must_be_nil
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "passing a Order file" do
|
167
|
-
|
168
|
-
it "uses the correct version" do
|
169
|
-
lambda { EfoNelfo.load(csv('B123.v3.csv')) }.must_raise EfoNelfo::UnsupportedPostType
|
170
|
-
end
|
171
|
-
|
172
|
-
it "parses the file and returns an Order" do
|
173
|
-
EfoNelfo.load(csv('B650517.032.csv')).must_be_instance_of EfoNelfo::V40::BH
|
174
|
-
end
|
175
|
-
|
176
|
-
it "the order contains order information" do
|
177
|
-
order = EfoNelfo.load(csv('B650517.032.csv'))
|
178
|
-
order.post_type.must_equal 'BH'
|
179
|
-
order.format.must_equal 'EFONELFO'
|
180
|
-
order.version.must_equal '4.0'
|
181
|
-
end
|
182
|
-
|
183
|
-
it "the order contains orderlines" do
|
184
|
-
order = EfoNelfo.load(csv('B650517.032.csv'))
|
185
|
-
|
186
|
-
line = order.lines.first
|
187
|
-
line.must_be_instance_of EfoNelfo::V40::BL
|
188
|
-
|
189
|
-
line.post_type.must_equal 'BL'
|
190
|
-
|
191
|
-
line.index.must_equal 1
|
192
|
-
line.order_number.must_equal '1465'
|
193
|
-
line.item_count.must_equal 200
|
194
|
-
line.price_unit.must_equal "EA"
|
195
|
-
line.buyer_item_number.must_be_nil
|
196
|
-
line.delivery_date.must_equal Date.new(2010, 6, 1)
|
197
|
-
line.buyer_ref.must_be_nil
|
198
|
-
line.splitable.must_equal true
|
199
|
-
line.replacable.must_equal true
|
200
|
-
|
201
|
-
line.item_type.must_equal 1
|
202
|
-
line.item_number.must_equal '8000502'
|
203
|
-
line.item_name.must_equal '200L OSO STD BEREDER SUPER S'
|
204
|
-
line.item_description.must_be_nil
|
205
|
-
end
|
206
|
-
|
207
|
-
it "adds text to orderline" do
|
208
|
-
order = EfoNelfo.load(csv('B650517.032.csv'))
|
209
|
-
order.lines.first.text.first.to_s.must_equal "Her er litt fritekst"
|
210
|
-
end
|
211
|
-
|
212
|
-
it "stores the contents file in the Order object" do
|
213
|
-
filename = csv('B650517.032.csv')
|
214
|
-
order = EfoNelfo.load(filename)
|
215
|
-
order.source.must_equal File.read(filename)
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
77
|
# Loads all files in the samples directory
|
220
78
|
%w(B028579.594.csv B028579.596.csv B650517.031.csv B028579.595.csv B028579.597.csv B650517.030.csv B650517.032.csv).each do |file|
|
221
79
|
it "can load #{file}" do
|
222
80
|
EfoNelfo.load(csv(file)).must_be_instance_of EfoNelfo::V40::BH
|
223
81
|
end
|
224
82
|
end
|
83
|
+
end
|
84
|
+
|
225
85
|
|
86
|
+
describe ".parse" do
|
87
|
+
it "does the same as .load" do
|
88
|
+
filename = csv('B650517.032.csv')
|
89
|
+
parsed = EfoNelfo.parse File.read(filename)
|
90
|
+
loaded = EfoNelfo.load filename
|
91
|
+
parsed.source.must_equal loaded.source
|
92
|
+
end
|
226
93
|
end
|
227
94
|
|
228
95
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "parsing a BH.csv file" do
|
4
|
+
|
5
|
+
it "uses the correct version" do
|
6
|
+
lambda { EfoNelfo.load(csv('B123.v3.csv')) }.must_raise EfoNelfo::UnsupportedPostType
|
7
|
+
end
|
8
|
+
|
9
|
+
it "parses the file and returns an Order" do
|
10
|
+
EfoNelfo.load(csv('B650517.032.csv')).must_be_instance_of EfoNelfo::V40::BH
|
11
|
+
end
|
12
|
+
|
13
|
+
it "the order contains order information" do
|
14
|
+
order = EfoNelfo.load(csv('B650517.032.csv'))
|
15
|
+
order.post_type.must_equal 'BH'
|
16
|
+
order.format.must_equal 'EFONELFO'
|
17
|
+
order.version.must_equal '4.0'
|
18
|
+
end
|
19
|
+
|
20
|
+
it "the order contains orderlines" do
|
21
|
+
order = EfoNelfo.load(csv('B650517.032.csv'))
|
22
|
+
|
23
|
+
line = order.lines.first
|
24
|
+
line.must_be_instance_of EfoNelfo::V40::BL
|
25
|
+
|
26
|
+
line.post_type.must_equal 'BL'
|
27
|
+
|
28
|
+
line.index.must_equal 1
|
29
|
+
line.order_number.must_equal '1465'
|
30
|
+
line.item_count.must_equal 200
|
31
|
+
line.price_unit.must_equal "EA"
|
32
|
+
line.buyer_item_number.must_be_nil
|
33
|
+
line.delivery_date.must_equal Date.new(2010, 6, 1)
|
34
|
+
line.buyer_ref.must_be_nil
|
35
|
+
line.splitable.must_equal true
|
36
|
+
line.replacable.must_equal true
|
37
|
+
|
38
|
+
line.item_type.must_equal 1
|
39
|
+
line.item_number.must_equal '8000502'
|
40
|
+
line.item_name.must_equal '200L OSO STD BEREDER SUPER S'
|
41
|
+
line.item_description.must_be_nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it "adds text to orderline" do
|
45
|
+
order = EfoNelfo.load(csv('B650517.032.csv'))
|
46
|
+
order.lines.first.text.first.to_s.must_equal "Her er litt fritekst"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "stores the contents file in the Order object" do
|
50
|
+
filename = csv('B650517.032.csv')
|
51
|
+
order = EfoNelfo.load(filename)
|
52
|
+
order.source.must_equal File.read(filename)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "parsing a RH.csv file" do
|
4
|
+
let(:nelfo) { EfoNelfo.load csv('rabatt.csv') }
|
5
|
+
it { nelfo.must_be_instance_of EfoNelfo::V40::RH }
|
6
|
+
# RH;EFONELFO;4.0;NO910478656MVA;NO000000000MVA;0;0;20130404;20140404;NOK;H;Alsell Norge AS;Vestre Svanholmen 4;;4313;SANDNES;NO
|
7
|
+
it "assigns attributes" do
|
8
|
+
nelfo.seller_id.must_equal "NO910478656MVA"
|
9
|
+
nelfo.buyer_id.must_equal "NO000000000MVA"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "assigns lines" do
|
13
|
+
nelfo.lines.size.must_equal 4
|
14
|
+
line = nelfo.lines.last
|
15
|
+
line.product_type.must_equal 5
|
16
|
+
line.product_number.must_equal "P10501"
|
17
|
+
line.AvtaltPris.must_be_nil
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "parsing a VH.csv file" do
|
5
|
+
let(:nelfo) { EfoNelfo.load(csv('varefil_eksempel.csv')) }
|
6
|
+
|
7
|
+
it { nelfo.must_be_instance_of EfoNelfo::V40::VH }
|
8
|
+
|
9
|
+
it "loads the order" do
|
10
|
+
nelfo.format.must_equal "EFONELFO"
|
11
|
+
nelfo.version.must_equal "4.0"
|
12
|
+
nelfo.post_type.must_equal "VH"
|
13
|
+
nelfo.SelgersId.must_equal "NO1234567879MVA"
|
14
|
+
nelfo.KjøpersId.must_be_nil
|
15
|
+
nelfo.KundeNr.must_be_nil
|
16
|
+
nelfo.from_date.must_equal Date.new(2004, 1, 22)
|
17
|
+
nelfo.to_date.must_be_nil
|
18
|
+
nelfo.currency.must_equal "NOK"
|
19
|
+
nelfo.contract_id.must_be_nil
|
20
|
+
nelfo.seller_name.must_equal "ONNINEN A/S"
|
21
|
+
nelfo.seller_address1.must_equal "P.B. 70"
|
22
|
+
nelfo.seller_address2.must_be_nil
|
23
|
+
nelfo.seller_zip.must_equal "1483"
|
24
|
+
nelfo.seller_office.must_equal "SKYTTA"
|
25
|
+
nelfo.seller_country.must_equal "NO"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "adds product lines" do
|
29
|
+
nelfo.lines.count.must_equal 3
|
30
|
+
|
31
|
+
line = nelfo.lines.first
|
32
|
+
line.product_type.must_equal 1
|
33
|
+
line.product_number.must_equal "1006100"
|
34
|
+
line.name.must_equal "MATTE 3MM 100W/M2 100W"
|
35
|
+
line.description.must_equal "1,0 m2 0,5 x 2,0 m"
|
36
|
+
line.unit.must_equal 1
|
37
|
+
line.price_unit.must_equal "EA"
|
38
|
+
line.price_unit_desc.must_equal "STYKK"
|
39
|
+
line.price.must_equal 55300
|
40
|
+
line.amount.must_equal 10000
|
41
|
+
line.price_date.must_equal Date.new(2011,9,1)
|
42
|
+
line.status.must_equal 1
|
43
|
+
line.block_number.must_be_nil
|
44
|
+
line.discount_group.must_equal "1004"
|
45
|
+
line.fabrication.must_be_nil
|
46
|
+
line.type.must_be_nil
|
47
|
+
line.stocked.must_equal true
|
48
|
+
line.stocked?.must_equal true
|
49
|
+
line.sales_package.must_equal 10000
|
50
|
+
end
|
51
|
+
|
52
|
+
it "adds additional information to the product" do
|
53
|
+
line = nelfo.lines.first
|
54
|
+
line.info.first.value.must_equal "http://www.elektroskandia.no/image/products/1221102.gif"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "adds product alternatives" do
|
58
|
+
nelfo.lines.first.alternatives.first.must_be_instance_of EfoNelfo::V40::VA
|
59
|
+
nelfo.lines.first.alternatives.first.product_type.must_equal 1
|
60
|
+
nelfo.lines.first.alternatives.last.replacement?.must_equal true
|
61
|
+
end
|
62
|
+
end
|
data/spec/properties_spec.rb
CHANGED
@@ -142,7 +142,7 @@ describe EfoNelfo::Properties do
|
|
142
142
|
obj.date = Date.new 2012, 5, 30
|
143
143
|
obj.number = 3
|
144
144
|
obj.doable = true
|
145
|
-
obj.to_a.must_equal ["I am foo", nil, "20120530", 3, "J", "NO"]
|
145
|
+
obj.to_a.must_equal ["I am foo", nil, "20120530", "3", "J", "NO"]
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
data/spec/property_spec.rb
CHANGED
@@ -106,6 +106,10 @@ describe EfoNelfo::Property do
|
|
106
106
|
property.value.must_be_nil
|
107
107
|
end
|
108
108
|
|
109
|
+
it "nil becomes 0 when property is required" do
|
110
|
+
property.options[:required] = false
|
111
|
+
end
|
112
|
+
|
109
113
|
end
|
110
114
|
|
111
115
|
end
|
@@ -157,9 +161,10 @@ describe EfoNelfo::Property do
|
|
157
161
|
|
158
162
|
describe "type is :integer" do
|
159
163
|
let(:type) { :integer }
|
160
|
-
it { make_property(2).must_equal 2 }
|
161
|
-
it { make_property(100, type: :integer, decimals: 4).must_equal 100 }
|
164
|
+
it { make_property(2).must_equal "2" }
|
165
|
+
it { make_property(100, type: :integer, decimals: 4).must_equal "100" }
|
162
166
|
it { make_property(nil, type: :integer, decimals: 2).must_equal nil }
|
167
|
+
it { make_property(nil, type: :integer, required: true).must_equal "0" }
|
163
168
|
end
|
164
169
|
|
165
170
|
describe "type is :boolean" do
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,12 @@ require 'minitest/pride'
|
|
6
6
|
require 'awesome_print'
|
7
7
|
|
8
8
|
Turn.config do |c|
|
9
|
-
c.format = :
|
9
|
+
c.format = :progress
|
10
10
|
c.natural = true
|
11
11
|
c.loadpath = %w(lib spec)
|
12
12
|
end
|
13
|
+
|
14
|
+
# helper method that returns full path to csv files
|
15
|
+
def csv(filename)
|
16
|
+
File.expand_path("../samples/#{filename}", __FILE__)
|
17
|
+
end
|
data/spec/va_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe EfoNelfo::V40::VA do
|
4
|
+
|
5
|
+
describe "has aliases for various types" do
|
6
|
+
|
7
|
+
it { EfoNelfo::V40::VA.new(type: 'A').alternative?.must_equal true }
|
8
|
+
it { EfoNelfo::V40::VA.new(type: 'E').replacement?.must_equal true }
|
9
|
+
it { EfoNelfo::V40::VA.new(type: 'V').alternative_id?.must_equal true }
|
10
|
+
it { EfoNelfo::V40::VA.new(type: 'P').package_size?.must_equal true }
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
it "#nrf_id returns true if product_type is 4" do
|
15
|
+
EfoNelfo::V40::VA.new(product_type: 4, product_number: '1234').nrf_id.must_equal '1234'
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/spec/vl_spec.rb
CHANGED
@@ -33,6 +33,40 @@ describe EfoNelfo::V40::VL do
|
|
33
33
|
vl.volume.must_be_nil
|
34
34
|
end
|
35
35
|
|
36
|
+
it "#gross_price? returns true when price type is 'B'" do
|
37
|
+
vl.price_type = 'B'
|
38
|
+
vl.gross_price?.must_equal true
|
39
|
+
vl.net_price?.must_equal false
|
40
|
+
end
|
41
|
+
|
42
|
+
it "#gross_price? returns true when price type is nil" do
|
43
|
+
vl.price_type = nil
|
44
|
+
vl.gross_price?.must_equal true
|
45
|
+
vl.net_price?.must_equal false
|
46
|
+
end
|
47
|
+
|
48
|
+
it "#gross_price returns price when price is gross" do
|
49
|
+
EfoNelfo::V40::VL.new(price: 2050, price_type: 'B').gross_price.must_equal 20.5
|
50
|
+
end
|
51
|
+
|
52
|
+
it "#net_price returns nil when price is gross" do
|
53
|
+
EfoNelfo::V40::VL.new(price: 2050, price_type: 'B').net_price.must_be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it "#net_price returns price when price is net" do
|
57
|
+
EfoNelfo::V40::VL.new(price: 2050, price_type: 'N').net_price.must_equal 20.5
|
58
|
+
end
|
59
|
+
|
60
|
+
it "#gross_price returns nil when price is net" do
|
61
|
+
EfoNelfo::V40::VL.new(price: 2050, price_type: 'N').gross_price.must_be_nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "#net_price? returns true when price type is 'N'" do
|
65
|
+
vl.price_type = 'N'
|
66
|
+
vl.net_price?.must_equal true
|
67
|
+
vl.gross_price?.must_equal false
|
68
|
+
end
|
69
|
+
|
36
70
|
it "#urls returns list of vx lines containing a url" do
|
37
71
|
vl.info << { field: 'FOO', value: 'http://localhost/one?two'}
|
38
72
|
vl.info << { field: 'BAR', value: 'http://foo.example.com/one/two/three'}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: efo_nelfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gudleik Rasch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -145,6 +145,9 @@ files:
|
|
145
145
|
- spec/collection_spec.rb
|
146
146
|
- spec/csv_writer_spec.rb
|
147
147
|
- spec/efo_nelfo_spec.rb
|
148
|
+
- spec/parsing/bh_spec.rb
|
149
|
+
- spec/parsing/rh_spec.rb
|
150
|
+
- spec/parsing/vh_spec.rb
|
148
151
|
- spec/post_type_spec.rb
|
149
152
|
- spec/properties_spec.rb
|
150
153
|
- spec/property_spec.rb
|
@@ -161,6 +164,7 @@ files:
|
|
161
164
|
- spec/samples/varefil_eksempel.csv
|
162
165
|
- spec/samples/varer_small.csv
|
163
166
|
- spec/spec_helper.rb
|
167
|
+
- spec/va_spec.rb
|
164
168
|
- spec/vl_spec.rb
|
165
169
|
homepage: http://efo.no
|
166
170
|
licenses:
|
@@ -190,6 +194,9 @@ test_files:
|
|
190
194
|
- spec/collection_spec.rb
|
191
195
|
- spec/csv_writer_spec.rb
|
192
196
|
- spec/efo_nelfo_spec.rb
|
197
|
+
- spec/parsing/bh_spec.rb
|
198
|
+
- spec/parsing/rh_spec.rb
|
199
|
+
- spec/parsing/vh_spec.rb
|
193
200
|
- spec/post_type_spec.rb
|
194
201
|
- spec/properties_spec.rb
|
195
202
|
- spec/property_spec.rb
|
@@ -206,4 +213,5 @@ test_files:
|
|
206
213
|
- spec/samples/varefil_eksempel.csv
|
207
214
|
- spec/samples/varer_small.csv
|
208
215
|
- spec/spec_helper.rb
|
216
|
+
- spec/va_spec.rb
|
209
217
|
- spec/vl_spec.rb
|