rvista 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Rakefile +12 -58
- data/lib/rvista/po_line_item.rb +1 -1
- data/lib/rvista.rb +12 -23
- metadata +81 -36
- data/test/data/invoice/invalid_line.txt +0 -4
- data/test/data/invoice/invalid_missing_footer.txt +0 -3
- data/test/data/invoice/invalid_missing_header.txt +0 -3
- data/test/data/invoice/valid.txt +0 -4
- data/test/data/po/invalid_line.txt +0 -40
- data/test/data/po/invalid_missing_footer.txt +0 -39
- data/test/data/po/invalid_missing_header.txt +0 -39
- data/test/data/po/no_delivery_location.txt +0 -3
- data/test/data/po/quotes.txt +0 -13
- data/test/data/po/seperate_delivery_location.txt +0 -3
- data/test/data/po/valid.txt +0 -40
- data/test/data/poa/invalid_line.txt +0 -4
- data/test/data/poa/invalid_missing_footer.txt +0 -3
- data/test/data/poa/invalid_missing_header.txt +0 -3
- data/test/data/poa/valid.txt +0 -4
- data/test/unit/invoice_line_item_test.rb +0 -70
- data/test/unit/invoice_test.rb +0 -76
- data/test/unit/line_item_test.rb +0 -88
- data/test/unit/message_test.rb +0 -98
- data/test/unit/poa_line_item_test.rb +0 -91
- data/test/unit/poa_test.rb +0 -78
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -1,30 +1,20 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
require 'rake/testtask'
|
5
|
-
require "rake/gempackagetask"
|
6
1
|
require "rubygems"
|
2
|
+
require "bundler"
|
3
|
+
Bundler.setup
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
CLEAN.include "**/.*.sw*"
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/rdoctask'
|
13
8
|
|
14
9
|
desc "Default Task"
|
15
|
-
task :default => [ :
|
16
|
-
|
17
|
-
# Run all tests
|
18
|
-
desc "Run all test"
|
19
|
-
task :test => [ :test_units ]
|
10
|
+
task :default => [ :spec ]
|
20
11
|
|
21
|
-
#
|
22
|
-
desc "Run all
|
23
|
-
|
24
|
-
t.
|
25
|
-
t.
|
26
|
-
|
27
|
-
}
|
12
|
+
# run all rspecs
|
13
|
+
desc "Run all rspec files"
|
14
|
+
RSpec::Core::RakeTask.new("spec") do |t|
|
15
|
+
t.rspec_opts = ["--color", "--format progress"]
|
16
|
+
t.ruby_opts = "-w"
|
17
|
+
end
|
28
18
|
|
29
19
|
# Genereate the RDoc documentation
|
30
20
|
desc "Create documentation"
|
@@ -38,39 +28,3 @@ Rake::RDocTask.new("doc") do |rdoc|
|
|
38
28
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
39
29
|
rdoc.options << "--inline-source"
|
40
30
|
end
|
41
|
-
|
42
|
-
spec = Gem::Specification.new do |spec|
|
43
|
-
spec.name = PKG_NAME
|
44
|
-
spec.version = PKG_VERSION
|
45
|
-
spec.platform = Gem::Platform::RUBY
|
46
|
-
spec.summary = "A small library for reading Vista HDS ecommerce files"
|
47
|
-
spec.files = Dir.glob("{examples,lib,test}/**/**/*") + ["Rakefile"]
|
48
|
-
spec.require_path = "lib"
|
49
|
-
spec.test_files = Dir[ "test/test_*.rb" ]
|
50
|
-
spec.has_rdoc = true
|
51
|
-
spec.extra_rdoc_files = %w{README COPYING LICENSE CHANGELOG}
|
52
|
-
spec.rdoc_options << '--title' << 'rvista Documentation' <<
|
53
|
-
'--main' << 'README' << '-q'
|
54
|
-
spec.author = "James Healy"
|
55
|
-
spec.email = "jimmy@deefa.com"
|
56
|
-
spec.add_dependency('andand')
|
57
|
-
spec.add_dependency('chronic')
|
58
|
-
spec.description = <<END_DESC
|
59
|
-
rvista is a small library for reading Vista HDS order files.
|
60
|
-
END_DESC
|
61
|
-
end
|
62
|
-
|
63
|
-
desc "Generate a gem for rvista"
|
64
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
65
|
-
pkg.need_zip = true
|
66
|
-
pkg.need_tar = true
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "Report code statistics (KLOCs, etc) from the application"
|
70
|
-
task :stats do
|
71
|
-
require 'vendor/code_statistics'
|
72
|
-
#dirs = [["Library", "lib"],["Functional tests", "test/functional"],["Unit tests", "test/unit"]]
|
73
|
-
dirs = [["Library", "lib"],["Unit tests", "test/unit"]]
|
74
|
-
CodeStatistics.new(*dirs).to_s
|
75
|
-
end
|
76
|
-
|
data/lib/rvista/po_line_item.rb
CHANGED
@@ -18,7 +18,7 @@ module RVista
|
|
18
18
|
# standard to see what those 14 items should be.
|
19
19
|
def self.load_from_array(data)
|
20
20
|
item = self.new
|
21
|
-
raise InvalidLineItemError,
|
21
|
+
raise InvalidLineItemError, "incorrect number of data points (#{data.inspect})" unless data.size == 14
|
22
22
|
|
23
23
|
item.line_num = data[1].to_i
|
24
24
|
item.qualifier = data[2]
|
data/lib/rvista.rb
CHANGED
@@ -3,33 +3,22 @@
|
|
3
3
|
require 'andand'
|
4
4
|
require 'chronic'
|
5
5
|
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# http://ruport.blogspot.com/2008/03/fastercsv-api-shim-for-19.html
|
11
|
-
#
|
12
|
-
if RUBY_VERSION > "1.9"
|
13
|
-
require "csv"
|
14
|
-
unless defined? FasterCSV
|
15
|
-
class Object
|
16
|
-
FCSV = FasterCSV = CSV
|
17
|
-
alias_method :FasterCSV, :CSV
|
18
|
-
end
|
19
|
-
end
|
6
|
+
# FasterCSV is included in the 1.9 standard library as CSV
|
7
|
+
if RUBY_VERSION >= "1.9"
|
8
|
+
require 'csv'
|
9
|
+
FasterCSV = FCSV = CSV
|
20
10
|
else
|
21
11
|
require "fastercsv"
|
22
12
|
end
|
23
13
|
|
24
|
-
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require File.dirname(__FILE__) + '/rvista/poa_line_item'
|
14
|
+
require 'rvista/errors'
|
15
|
+
require 'rvista/message'
|
16
|
+
require 'rvista/invoice'
|
17
|
+
require 'rvista/invoice_line_item'
|
18
|
+
require 'rvista/po'
|
19
|
+
require 'rvista/po_line_item'
|
20
|
+
require 'rvista/poa'
|
21
|
+
require 'rvista/poa_line_item'
|
33
22
|
|
34
23
|
# Ruby module for reading Vista HDS EDI files
|
35
24
|
#
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rvista
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 9
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 6
|
9
|
+
- 7
|
10
|
+
version: 0.6.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- James Healy
|
@@ -9,30 +15,84 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-11-20 00:00:00 -05:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 11
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
version: 2.1.0
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
15
51
|
- !ruby/object:Gem::Dependency
|
16
52
|
name: andand
|
17
|
-
|
18
|
-
|
19
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
20
56
|
requirements:
|
21
57
|
- - ">="
|
22
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
23
62
|
version: "0"
|
24
|
-
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: *id003
|
25
65
|
- !ruby/object:Gem::Dependency
|
26
66
|
name: chronic
|
27
|
-
|
28
|
-
|
29
|
-
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
30
70
|
requirements:
|
31
71
|
- - ">="
|
32
72
|
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
33
76
|
version: "0"
|
34
|
-
|
35
|
-
|
77
|
+
type: :runtime
|
78
|
+
version_requirements: *id004
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: fastercsv
|
81
|
+
prerelease: false
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 1
|
90
|
+
- 5
|
91
|
+
- 0
|
92
|
+
version: 1.5.0
|
93
|
+
type: :runtime
|
94
|
+
version_requirements: *id005
|
95
|
+
description: rvista is a small library for reading Vista HDS files.
|
36
96
|
email: jimmy@deefa.com
|
37
97
|
executables: []
|
38
98
|
|
@@ -53,34 +113,13 @@ files:
|
|
53
113
|
- lib/rvista/message.rb
|
54
114
|
- lib/rvista/poa.rb
|
55
115
|
- lib/rvista/po_line_item.rb
|
56
|
-
- test/data/poa/invalid_line.txt
|
57
|
-
- test/data/poa/valid.txt
|
58
|
-
- test/data/poa/invalid_missing_header.txt
|
59
|
-
- test/data/poa/invalid_missing_footer.txt
|
60
|
-
- test/data/po/no_delivery_location.txt
|
61
|
-
- test/data/po/quotes.txt
|
62
|
-
- test/data/po/invalid_line.txt
|
63
|
-
- test/data/po/valid.txt
|
64
|
-
- test/data/po/seperate_delivery_location.txt
|
65
|
-
- test/data/po/invalid_missing_header.txt
|
66
|
-
- test/data/po/invalid_missing_footer.txt
|
67
|
-
- test/data/invoice/invalid_line.txt
|
68
|
-
- test/data/invoice/valid.txt
|
69
|
-
- test/data/invoice/invalid_missing_header.txt
|
70
|
-
- test/data/invoice/invalid_missing_footer.txt
|
71
|
-
- test/unit/poa_line_item_test.rb
|
72
|
-
- test/unit/poa_test.rb
|
73
|
-
- test/unit/message_test.rb
|
74
|
-
- test/unit/line_item_test.rb
|
75
|
-
- test/unit/invoice_line_item_test.rb
|
76
|
-
- test/unit/invoice_test.rb
|
77
116
|
- Rakefile
|
78
117
|
- README
|
79
118
|
- COPYING
|
80
119
|
- LICENSE
|
81
120
|
- CHANGELOG
|
82
121
|
has_rdoc: true
|
83
|
-
homepage:
|
122
|
+
homepage: https://github.com/yob/rvista
|
84
123
|
licenses: []
|
85
124
|
|
86
125
|
post_install_message:
|
@@ -93,21 +132,27 @@ rdoc_options:
|
|
93
132
|
require_paths:
|
94
133
|
- lib
|
95
134
|
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
96
136
|
requirements:
|
97
137
|
- - ">="
|
98
138
|
- !ruby/object:Gem::Version
|
139
|
+
hash: 3
|
140
|
+
segments:
|
141
|
+
- 0
|
99
142
|
version: "0"
|
100
|
-
version:
|
101
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
102
145
|
requirements:
|
103
146
|
- - ">="
|
104
147
|
- !ruby/object:Gem::Version
|
148
|
+
hash: 3
|
149
|
+
segments:
|
150
|
+
- 0
|
105
151
|
version: "0"
|
106
|
-
version:
|
107
152
|
requirements: []
|
108
153
|
|
109
154
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.3.
|
155
|
+
rubygems_version: 1.3.7
|
111
156
|
signing_key:
|
112
157
|
specification_version: 3
|
113
158
|
summary: A small library for reading Vista HDS ecommerce files
|
data/test/data/invoice/valid.txt
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
H,1111111,2222222,,0000009525908,,00,,060915,,000000,000000,,,,,,1111111,,
|
2
|
-
D,1,IB,0701180358,DIGGING TO AMERICA,3,0.00,EA,,,43,Y,,
|
3
|
-
D,2,IB,071267344X,THE LAST ENEMY,3,0.00,EA,,,43,Y,,
|
4
|
-
D,3,IB,1841593001,COLLECTED STORIES: DAHL,2,0.00,EA,,,43,Y,,
|
5
|
-
D,4,IB,1841591467,MY MAN JEEVES,2,0.00,EA,,,43,Y,,
|
6
|
-
J,5,IB,0099464462,TIME TRAVELERS WIFE,2,0.00,EA,,,43,Y,,
|
7
|
-
D,6,IB,0099408392,WHERE THE WILD THINGS ARE,2,0.00,EA,,,43,Y,,
|
8
|
-
D,7,IB,1857150295,A PASSAGE TO INDIA (EVERYMAN),1,0.00,EA,,,43,Y,,
|
9
|
-
D,8,IB,1857152689,BELOVED,1,0.00,EA,,,43,Y,,
|
10
|
-
D,9,IB,1841591211,CARRY ON JEEVES,1,0.00,EA,,,43,Y,,
|
11
|
-
D,10,IB,0091894492,CASA MORO,1,0.00,EA,,,43,Y,,
|
12
|
-
D,11,IB,1841591343,COCKTAIL TIME - EVERYMAN WODEHOUSE,1,0.00,EA,,,43,Y,,
|
13
|
-
D,12,IB,0099425157,COLOUR,1,0.00,EA,,,43,Y,,
|
14
|
-
D,13,IB,055299703X,DOWN UNDER,1,0.00,EA,,,43,Y,,
|
15
|
-
D,14,IB,1860460429,EDUCATION OF A GARDENER,1,0.00,EA,,,43,Y,,
|
16
|
-
D,15,IB,0099479028,I AM CHARLOTTE SIMMONS,1,0.00,EA,,,43,Y,,
|
17
|
-
D,16,IB,1841591297,MUCH OBLIGED JEEVES,1,0.00,EA,,,43,Y,,
|
18
|
-
D,17,IB,1857151348,NINETEEN EIGHTY-FOUR,1,0.00,EA,,,43,Y,,
|
19
|
-
D,18,IB,0099499126,NOT THAT SORT OF GIRL,1,0.00,EA,,,43,Y,,
|
20
|
-
D,19,IB,0099478560,PLOT AGAINST AMERICA,1,0.00,EA,,,43,Y,,
|
21
|
-
D,20,IB,185715214X,RABBIT NOVELS,1,0.00,EA,,,43,Y,,
|
22
|
-
D,21,IB,1841591041,RIGHT HO JEEVES,1,0.00,EA,,,43,Y,,
|
23
|
-
D,22,IB,1857150864,RIGHTS OF WOMAN,1,0.00,EA,,,43,Y,,
|
24
|
-
D,23,IB,0712661158,ROAD LESS TRAVELLED,1,0.00,EA,,,43,Y,,
|
25
|
-
D,24,IB,1845960211,SCOTTISH WORLD,1,0.00,EA,,,43,Y,,
|
26
|
-
D,25,IB,0099499134,SENSIBLE LIFE,1,0.00,EA,,,43,Y,,
|
27
|
-
D,26,IB,1857151739,SWORD OF HONOUR TRILOGY,1,0.00,EA,,,43,Y,,
|
28
|
-
D,27,IB,1841591270,THANKYOU JEEVES,1,0.00,EA,,,43,Y,,
|
29
|
-
D,28,IB,1857151399,THE OUTSIDER (EVERYMAN),1,0.00,EA,,,43,Y,,
|
30
|
-
D,29,IB,0712670769,THE ROAD LESS TRAVELLED AND BEYONG,1,0.00,EA,,,43,Y,,
|
31
|
-
D,30,IB,1857155068,THE THIRTY-NINE STEPS,1,0.00,EA,,,43,Y,,
|
32
|
-
D,31,IB,1857155033,THREE MUSKETEERS,1,0.00,EA,,,43,Y,,
|
33
|
-
D,32,IB,1857150759,TRIAL (EVERYMAN),1,0.00,EA,,,43,Y,,
|
34
|
-
D,33,IB,1857150074,TRISTRAM SHANDY,1,0.00,EA,,,43,Y,,
|
35
|
-
D,34,IB,1857151003,ULYSSES,1,0.00,EA,,,43,Y,,
|
36
|
-
D,35,IB,1841591424,VERY GOOD JEEVES,1,0.00,EA,,,43,Y,,
|
37
|
-
D,36,IB,0701179910,WILD MARY LIFE OF MARY WESLEY,1,0.00,EA,,,43,Y,,
|
38
|
-
D,37,IB,0099449897,WILL YOU PLEASE BE QUIET PLEASE,1,0.00,EA,,,43,Y,,
|
39
|
-
D,38,IB,1857152301,WINGS OF THE DOVE,1,0.00,EA,,,43,Y,,
|
40
|
-
S,38,,
|
@@ -1,39 +0,0 @@
|
|
1
|
-
H,1111111,2222222,,0000009525908,,00,,060915,,000000,000000,,,,,,1111111,,
|
2
|
-
D,1,IB,0701180358,DIGGING TO AMERICA,3,0.00,EA,,,43,Y,,
|
3
|
-
D,2,IB,071267344X,THE LAST ENEMY,3,0.00,EA,,,43,Y,,
|
4
|
-
D,3,IB,1841593001,COLLECTED STORIES: DAHL,2,0.00,EA,,,43,Y,,
|
5
|
-
D,4,IB,1841591467,MY MAN JEEVES,2,0.00,EA,,,43,Y,,
|
6
|
-
D,5,IB,0099464462,TIME TRAVELERS WIFE,2,0.00,EA,,,43,Y,,
|
7
|
-
D,6,IB,0099408392,WHERE THE WILD THINGS ARE,2,0.00,EA,,,43,Y,,
|
8
|
-
D,7,IB,1857150295,A PASSAGE TO INDIA (EVERYMAN),1,0.00,EA,,,43,Y,,
|
9
|
-
D,8,IB,1857152689,BELOVED,1,0.00,EA,,,43,Y,,
|
10
|
-
D,9,IB,1841591211,CARRY ON JEEVES,1,0.00,EA,,,43,Y,,
|
11
|
-
D,10,IB,0091894492,CASA MORO,1,0.00,EA,,,43,Y,,
|
12
|
-
D,11,IB,1841591343,COCKTAIL TIME - EVERYMAN WODEHOUSE,1,0.00,EA,,,43,Y,,
|
13
|
-
D,12,IB,0099425157,COLOUR,1,0.00,EA,,,43,Y,,
|
14
|
-
D,13,IB,055299703X,DOWN UNDER,1,0.00,EA,,,43,Y,,
|
15
|
-
D,14,IB,1860460429,EDUCATION OF A GARDENER,1,0.00,EA,,,43,Y,,
|
16
|
-
D,15,IB,0099479028,I AM CHARLOTTE SIMMONS,1,0.00,EA,,,43,Y,,
|
17
|
-
D,16,IB,1841591297,MUCH OBLIGED JEEVES,1,0.00,EA,,,43,Y,,
|
18
|
-
D,17,IB,1857151348,NINETEEN EIGHTY-FOUR,1,0.00,EA,,,43,Y,,
|
19
|
-
D,18,IB,0099499126,NOT THAT SORT OF GIRL,1,0.00,EA,,,43,Y,,
|
20
|
-
D,19,IB,0099478560,PLOT AGAINST AMERICA,1,0.00,EA,,,43,Y,,
|
21
|
-
D,20,IB,185715214X,RABBIT NOVELS,1,0.00,EA,,,43,Y,,
|
22
|
-
D,21,IB,1841591041,RIGHT HO JEEVES,1,0.00,EA,,,43,Y,,
|
23
|
-
D,22,IB,1857150864,RIGHTS OF WOMAN,1,0.00,EA,,,43,Y,,
|
24
|
-
D,23,IB,0712661158,ROAD LESS TRAVELLED,1,0.00,EA,,,43,Y,,
|
25
|
-
D,24,IB,1845960211,SCOTTISH WORLD,1,0.00,EA,,,43,Y,,
|
26
|
-
D,25,IB,0099499134,SENSIBLE LIFE,1,0.00,EA,,,43,Y,,
|
27
|
-
D,26,IB,1857151739,SWORD OF HONOUR TRILOGY,1,0.00,EA,,,43,Y,,
|
28
|
-
D,27,IB,1841591270,THANKYOU JEEVES,1,0.00,EA,,,43,Y,,
|
29
|
-
D,28,IB,1857151399,THE OUTSIDER (EVERYMAN),1,0.00,EA,,,43,Y,,
|
30
|
-
D,29,IB,0712670769,THE ROAD LESS TRAVELLED AND BEYONG,1,0.00,EA,,,43,Y,,
|
31
|
-
D,30,IB,1857155068,THE THIRTY-NINE STEPS,1,0.00,EA,,,43,Y,,
|
32
|
-
D,31,IB,1857155033,THREE MUSKETEERS,1,0.00,EA,,,43,Y,,
|
33
|
-
D,32,IB,1857150759,TRIAL (EVERYMAN),1,0.00,EA,,,43,Y,,
|
34
|
-
D,33,IB,1857150074,TRISTRAM SHANDY,1,0.00,EA,,,43,Y,,
|
35
|
-
D,34,IB,1857151003,ULYSSES,1,0.00,EA,,,43,Y,,
|
36
|
-
D,35,IB,1841591424,VERY GOOD JEEVES,1,0.00,EA,,,43,Y,,
|
37
|
-
D,36,IB,0701179910,WILD MARY LIFE OF MARY WESLEY,1,0.00,EA,,,43,Y,,
|
38
|
-
D,37,IB,0099449897,WILL YOU PLEASE BE QUIET PLEASE,1,0.00,EA,,,43,Y,,
|
39
|
-
D,38,IB,1857152301,WINGS OF THE DOVE,1,0.00,EA,,,43,Y,,
|
@@ -1,39 +0,0 @@
|
|
1
|
-
D,1,IB,0701180358,DIGGING TO AMERICA,3,0.00,EA,,,43,Y,,
|
2
|
-
D,2,IB,071267344X,THE LAST ENEMY,3,0.00,EA,,,43,Y,,
|
3
|
-
D,3,IB,1841593001,COLLECTED STORIES: DAHL,2,0.00,EA,,,43,Y,,
|
4
|
-
D,4,IB,1841591467,MY MAN JEEVES,2,0.00,EA,,,43,Y,,
|
5
|
-
D,5,IB,0099464462,TIME TRAVELERS WIFE,2,0.00,EA,,,43,Y,,
|
6
|
-
D,6,IB,0099408392,WHERE THE WILD THINGS ARE,2,0.00,EA,,,43,Y,,
|
7
|
-
D,7,IB,1857150295,A PASSAGE TO INDIA (EVERYMAN),1,0.00,EA,,,43,Y,,
|
8
|
-
D,8,IB,1857152689,BELOVED,1,0.00,EA,,,43,Y,,
|
9
|
-
D,9,IB,1841591211,CARRY ON JEEVES,1,0.00,EA,,,43,Y,,
|
10
|
-
D,10,IB,0091894492,CASA MORO,1,0.00,EA,,,43,Y,,
|
11
|
-
D,11,IB,1841591343,COCKTAIL TIME - EVERYMAN WODEHOUSE,1,0.00,EA,,,43,Y,,
|
12
|
-
D,12,IB,0099425157,COLOUR,1,0.00,EA,,,43,Y,,
|
13
|
-
D,13,IB,055299703X,DOWN UNDER,1,0.00,EA,,,43,Y,,
|
14
|
-
D,14,IB,1860460429,EDUCATION OF A GARDENER,1,0.00,EA,,,43,Y,,
|
15
|
-
D,15,IB,0099479028,I AM CHARLOTTE SIMMONS,1,0.00,EA,,,43,Y,,
|
16
|
-
D,16,IB,1841591297,MUCH OBLIGED JEEVES,1,0.00,EA,,,43,Y,,
|
17
|
-
D,17,IB,1857151348,NINETEEN EIGHTY-FOUR,1,0.00,EA,,,43,Y,,
|
18
|
-
D,18,IB,0099499126,NOT THAT SORT OF GIRL,1,0.00,EA,,,43,Y,,
|
19
|
-
D,19,IB,0099478560,PLOT AGAINST AMERICA,1,0.00,EA,,,43,Y,,
|
20
|
-
D,20,IB,185715214X,RABBIT NOVELS,1,0.00,EA,,,43,Y,,
|
21
|
-
D,21,IB,1841591041,RIGHT HO JEEVES,1,0.00,EA,,,43,Y,,
|
22
|
-
D,22,IB,1857150864,RIGHTS OF WOMAN,1,0.00,EA,,,43,Y,,
|
23
|
-
D,23,IB,0712661158,ROAD LESS TRAVELLED,1,0.00,EA,,,43,Y,,
|
24
|
-
D,24,IB,1845960211,SCOTTISH WORLD,1,0.00,EA,,,43,Y,,
|
25
|
-
D,25,IB,0099499134,SENSIBLE LIFE,1,0.00,EA,,,43,Y,,
|
26
|
-
D,26,IB,1857151739,SWORD OF HONOUR TRILOGY,1,0.00,EA,,,43,Y,,
|
27
|
-
D,27,IB,1841591270,THANKYOU JEEVES,1,0.00,EA,,,43,Y,,
|
28
|
-
D,28,IB,1857151399,THE OUTSIDER (EVERYMAN),1,0.00,EA,,,43,Y,,
|
29
|
-
D,29,IB,0712670769,THE ROAD LESS TRAVELLED AND BEYONG,1,0.00,EA,,,43,Y,,
|
30
|
-
D,30,IB,1857155068,THE THIRTY-NINE STEPS,1,0.00,EA,,,43,Y,,
|
31
|
-
D,31,IB,1857155033,THREE MUSKETEERS,1,0.00,EA,,,43,Y,,
|
32
|
-
D,32,IB,1857150759,TRIAL (EVERYMAN),1,0.00,EA,,,43,Y,,
|
33
|
-
D,33,IB,1857150074,TRISTRAM SHANDY,1,0.00,EA,,,43,Y,,
|
34
|
-
D,34,IB,1857151003,ULYSSES,1,0.00,EA,,,43,Y,,
|
35
|
-
D,35,IB,1841591424,VERY GOOD JEEVES,1,0.00,EA,,,43,Y,,
|
36
|
-
D,36,IB,0701179910,WILD MARY LIFE OF MARY WESLEY,1,0.00,EA,,,43,Y,,
|
37
|
-
D,37,IB,0099449897,WILL YOU PLEASE BE QUIET PLEASE,1,0.00,EA,,,43,Y,,
|
38
|
-
D,38,IB,1857152301,WINGS OF THE DOVE,1,0.00,EA,,,43,Y,,
|
39
|
-
S,38,,
|
data/test/data/po/quotes.txt
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
H,9027378,9013725,,16742,,00,,090819,,000000,000000,,,,,,9027378,,,
|
2
|
-
D,1,EN,9780486264035,Little Zoo Animals Coloring Bo,1,0.00,EA,,,40000,Y,,
|
3
|
-
D,2,EN,9780517228678,Vampire Stories,1,0.00,EA,,,40000,Y,,
|
4
|
-
D,3,EN,9780566087721,Project Management : 9Th Editi,1,0.00,EA,,,40000,Y,,
|
5
|
-
D,4,EN,9780566087981,Understanding and Managing Ris,1,0.00,EA,,,40000,Y,,
|
6
|
-
D,5,EN,9780754645986,Safety at the Sharp End : Trai,1,0.00,EA,,,40000,Y,,
|
7
|
-
D,6,EN,9780754651772,After Sibelius : Studies in Fi,1,0.00,EA,,,40000,Y,,
|
8
|
-
D,7,EN,9780754658115,The Counts of Laval : Culture ,1,0.00,EA,,,40000,Y,,
|
9
|
-
D,8,EN,9780827230262,Unveiling the Secret Life of B,1,0.00,EA,,,40000,Y,,
|
10
|
-
D,9,EN,9781426700187,Noah's Very Big Boat,1,0.00,EA,,,40000,Y,,
|
11
|
-
D,10,EN,9781426700231,The Cool Cat: A Modern "Tail",1,0.00,EA,,,40000,Y,,
|
12
|
-
D,11,EN,9781921421259,The Climate Caper,4,0.00,EA,,,40000,Y,,
|
13
|
-
S,11,,
|
data/test/data/po/valid.txt
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
H,1111111,2222222,,0000009525908,,00,,15-09-06,,000000,000000,,,,,,1111111,,
|
2
|
-
D,1,IB,0701180358,DIGGING TO AMERICA,3,0.00,EA,,,43,Y,,
|
3
|
-
D,2,IB,071267344X,THE LAST ENEMY,3,0.00,EA,,,43,Y,,
|
4
|
-
D,3,IB,1841593001,COLLECTED STORIES: DAHL,2,0.00,EA,,,43,Y,,
|
5
|
-
D,4,IB,1841591467,MY MAN JEEVES,2,0.00,EA,,,43,Y,,
|
6
|
-
D,5,IB,0099464462,TIME TRAVELERS WIFE,2,0.00,EA,,,43,Y,,
|
7
|
-
D,6,IB,0099408392,WHERE THE WILD THINGS ARE,2,0.00,EA,,,43,Y,,
|
8
|
-
D,7,IB,1857150295,A PASSAGE TO INDIA (EVERYMAN),1,0.00,EA,,,43,Y,,
|
9
|
-
D,8,IB,1857152689,BELOVED,1,0.00,EA,,,43,Y,,
|
10
|
-
D,9,IB,1841591211,CARRY ON JEEVES,1,0.00,EA,,,43,Y,,
|
11
|
-
D,10,IB,0091894492,CASA MORO,1,0.00,EA,,,43,Y,,
|
12
|
-
D,11,IB,1841591343,COCKTAIL TIME - EVERYMAN WODEHOUSE,1,0.00,EA,,,43,Y,,
|
13
|
-
D,12,IB,0099425157,COLOUR,1,0.00,EA,,,43,Y,,
|
14
|
-
D,13,IB,055299703X,DOWN UNDER,1,0.00,EA,,,43,Y,,
|
15
|
-
D,14,IB,1860460429,EDUCATION OF A GARDENER,1,0.00,EA,,,43,Y,,
|
16
|
-
D,15,IB,0099479028,I AM CHARLOTTE SIMMONS,1,0.00,EA,,,43,Y,,
|
17
|
-
D,16,IB,1841591297,MUCH OBLIGED JEEVES,1,0.00,EA,,,43,Y,,
|
18
|
-
D,17,IB,1857151348,NINETEEN EIGHTY-FOUR,1,0.00,EA,,,43,Y,,
|
19
|
-
D,18,IB,0099499126,NOT THAT SORT OF GIRL,1,0.00,EA,,,43,Y,,
|
20
|
-
D,19,IB,0099478560,PLOT AGAINST AMERICA,1,0.00,EA,,,43,Y,,
|
21
|
-
D,20,IB,185715214X,RABBIT NOVELS,1,0.00,EA,,,43,Y,,
|
22
|
-
D,21,IB,1841591041,RIGHT HO JEEVES,1,0.00,EA,,,43,Y,,
|
23
|
-
D,22,IB,1857150864,RIGHTS OF WOMAN,1,0.00,EA,,,43,Y,,
|
24
|
-
D,23,IB,0712661158,ROAD LESS TRAVELLED,1,0.00,EA,,,43,Y,,
|
25
|
-
D,24,IB,1845960211,SCOTTISH WORLD,1,0.00,EA,,,43,Y,,
|
26
|
-
D,25,IB,0099499134,SENSIBLE LIFE,1,0.00,EA,,,43,Y,,
|
27
|
-
D,26,IB,1857151739,SWORD OF HONOUR TRILOGY,1,0.00,EA,,,43,Y,,
|
28
|
-
D,27,IB,1841591270,THANKYOU JEEVES,1,0.00,EA,,,43,Y,,
|
29
|
-
D,28,IB,1857151399,THE OUTSIDER (EVERYMAN),1,0.00,EA,,,43,Y,,
|
30
|
-
D,29,IB,0712670769,THE ROAD LESS TRAVELLED AND BEYONG,1,0.00,EA,,,43,Y,,
|
31
|
-
D,30,IB,1857155068,THE THIRTY-NINE STEPS,1,0.00,EA,,,43,Y,,
|
32
|
-
D,31,IB,1857155033,THREE MUSKETEERS,1,0.00,EA,,,43,Y,,
|
33
|
-
D,32,IB,1857150759,TRIAL (EVERYMAN),1,0.00,EA,,,43,Y,,
|
34
|
-
D,33,IB,1857150074,TRISTRAM SHANDY,1,0.00,EA,,,43,Y,,
|
35
|
-
D,34,IB,1857151003,ULYSSES,1,0.00,EA,,,43,Y,,
|
36
|
-
D,35,IB,1841591424,VERY GOOD JEEVES,1,0.00,EA,,,43,Y,,
|
37
|
-
D,36,IB,0701179910,WILD MARY LIFE OF MARY WESLEY,1,0.00,EA,,,43,Y,,
|
38
|
-
D,37,IB,0099449897,WILL YOU PLEASE BE QUIET PLEASE,1,0.00,EA,,,43,Y,,
|
39
|
-
D,38,IB,1857152301,WINGS OF THE DOVE,1,0.00,EA,,,43,Y,,
|
40
|
-
S,38,,
|
data/test/data/poa/valid.txt
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
H,1111111,2222222,,,,,1234,15-09-06,,10-10-07,30-10-07,SP,1111111,Some Store
|
2
|
-
D,1,0701180358,,DIGGING TO AMERICA,10.00,1,0,10.00,,1111111,Some Store,,1,01,1,11.00,40.00,20071015,
|
3
|
-
D,2,071267344X,,THE LAST ENEMY,15.00,1,0,10.00,,1111111,Some Store,,7,02,5,16.50,50.00,20071015,
|
4
|
-
S,2,6
|
@@ -1,70 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rvista'
|
5
|
-
|
6
|
-
class InvoiceLineItemTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@row = []
|
10
|
-
@row << "D"
|
11
|
-
@row << "1"
|
12
|
-
@row << "1234"
|
13
|
-
@row << "EN"
|
14
|
-
@row << "9781857230765"
|
15
|
-
@row << "Eye of the World"
|
16
|
-
@row << "5"
|
17
|
-
@row << "EA"
|
18
|
-
@row << "19.95"
|
19
|
-
@row << "40.00"
|
20
|
-
@row << "17.95"
|
21
|
-
@row << "Y"
|
22
|
-
@row << "89.75"
|
23
|
-
@row << "35.90"
|
24
|
-
@row << "53.85"
|
25
|
-
@row << "2.00"
|
26
|
-
@row << "F"
|
27
|
-
end
|
28
|
-
|
29
|
-
# ensure the load_from_array method works as expected
|
30
|
-
def test_load_from_array
|
31
|
-
item = RVista::InvoiceLineItem.load_from_array(@row)
|
32
|
-
assert_kind_of RVista::InvoiceLineItem, item
|
33
|
-
|
34
|
-
assert_equal item.line_num, 1
|
35
|
-
assert_equal item.po_number, "1234"
|
36
|
-
assert_equal item.qualifier, "EN"
|
37
|
-
assert_equal item.ean, "9781857230765"
|
38
|
-
assert_equal item.description, "Eye of the World"
|
39
|
-
assert_equal item.qty, 5
|
40
|
-
assert_equal item.unit_measure, "EA"
|
41
|
-
assert_equal item.rrp, 19.95
|
42
|
-
assert_equal item.discount_percent, 40.00
|
43
|
-
assert_equal item.nett_unit_price, 17.95
|
44
|
-
assert_equal item.gst_inclusive, true
|
45
|
-
assert_equal item.value, 89.75
|
46
|
-
assert_equal item.discount_value, 35.90
|
47
|
-
assert_equal item.nett_value, 53.85
|
48
|
-
assert_equal item.gst, 2.00
|
49
|
-
assert_equal item.firm_sale, true
|
50
|
-
end
|
51
|
-
|
52
|
-
# ensure the load_from_file method throws the correct exceptions
|
53
|
-
# when it encounters a problem
|
54
|
-
def test_product_validation
|
55
|
-
assert_raise(RVista::InvalidLineItemError) {
|
56
|
-
item = RVista::InvoiceLineItem.load_from_array(%w[D blah])
|
57
|
-
}
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_to_s
|
61
|
-
item = RVista::InvoiceLineItem.load_from_array(@row)
|
62
|
-
str = item.to_s
|
63
|
-
arr = FasterCSV.parse(str).first
|
64
|
-
|
65
|
-
assert_equal 17, arr.size
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
|
data/test/unit/invoice_test.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rvista'
|
5
|
-
|
6
|
-
class InvoiceTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
VALID = File.dirname(__FILE__) + "/../data/invoice/valid.txt"
|
9
|
-
INVALID_MISSING_HEADER = File.dirname(__FILE__) + "/../data/invoice/invalid_missing_header.txt"
|
10
|
-
INVALID_MISSING_FOOTER = File.dirname(__FILE__) + "/../data/invoice/invalid_missing_footer.txt"
|
11
|
-
INVALID_LINE = File.dirname(__FILE__) + "/../data/invoice/invalid_line.txt"
|
12
|
-
INVALID_DOESNT_EXIST = File.dirname(__FILE__) + "/../data/blah.txt"
|
13
|
-
|
14
|
-
# ensure the load_from_file method works as expected
|
15
|
-
def test_load_from_file
|
16
|
-
msg = RVista::Invoice.load_from_file(VALID)
|
17
|
-
assert_kind_of RVista::Invoice, msg
|
18
|
-
assert_equal msg.items.size, 2
|
19
|
-
assert_equal msg.total_value, BigDecimal.new("2200")
|
20
|
-
assert_equal msg.total_qty, BigDecimal.new("5")
|
21
|
-
assert_equal msg.total_gst, BigDecimal.new("200")
|
22
|
-
|
23
|
-
validate_msg(msg)
|
24
|
-
end
|
25
|
-
|
26
|
-
# ensure the load_from_file method works as expected
|
27
|
-
def test_load_from_string
|
28
|
-
msg = RVista::Invoice.load_from_string(File.read(VALID))
|
29
|
-
assert_kind_of RVista::Invoice, msg
|
30
|
-
assert_equal msg.items.size, 2
|
31
|
-
|
32
|
-
validate_msg(msg)
|
33
|
-
end
|
34
|
-
|
35
|
-
# ensure the load_from_file method throws the correct exceptions
|
36
|
-
# when it encounters a problem
|
37
|
-
def test_product_validation
|
38
|
-
|
39
|
-
assert_raise(RVista::InvalidFileError) {
|
40
|
-
msg = RVista::Invoice.load_from_file(INVALID_MISSING_HEADER)
|
41
|
-
}
|
42
|
-
|
43
|
-
assert_raise(RVista::InvalidFileError) {
|
44
|
-
msg = RVista::Invoice.load_from_file(INVALID_MISSING_FOOTER)
|
45
|
-
}
|
46
|
-
|
47
|
-
assert_raise(RVista::InvalidLineItemError) {
|
48
|
-
msg = RVista::Invoice.load_from_file(INVALID_LINE)
|
49
|
-
}
|
50
|
-
|
51
|
-
assert_raise(RVista::InvalidFileError) {
|
52
|
-
msg = RVista::Invoice.load_from_file(INVALID_DOESNT_EXIST)
|
53
|
-
}
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_to_s
|
57
|
-
msg = RVista::Invoice.load_from_file(VALID)
|
58
|
-
content = File.read(VALID)
|
59
|
-
assert_equal content, msg.to_s
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
# ensures the properties of the supplied RVista::Invoice object
|
65
|
-
# match the properties specified in the VALID file
|
66
|
-
def validate_msg(msg)
|
67
|
-
assert_equal msg.sender_id, "1111111"
|
68
|
-
assert_equal msg.receiver_id, "2222222"
|
69
|
-
assert_equal msg.doc_type, "IN"
|
70
|
-
assert_equal msg.description, "Invoice"
|
71
|
-
assert_equal msg.doc_number, "5678"
|
72
|
-
assert_equal msg.doc_date, Chronic.parse("2007-10-11")
|
73
|
-
assert_equal msg.delivery_location, "1111111"
|
74
|
-
assert_equal msg.currency, nil
|
75
|
-
end
|
76
|
-
end
|
data/test/unit/line_item_test.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rvista'
|
5
|
-
|
6
|
-
class POLineItemTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@row = []
|
10
|
-
@row << "D"
|
11
|
-
@row << "1"
|
12
|
-
@row << "IB"
|
13
|
-
@row << "0701180358"
|
14
|
-
@row << "DIGGING TO AMERICA"
|
15
|
-
@row << "3"
|
16
|
-
@row << "0.00"
|
17
|
-
@row << "EA"
|
18
|
-
@row << nil
|
19
|
-
@row << nil
|
20
|
-
@row << "43"
|
21
|
-
@row << "Y"
|
22
|
-
@row << nil
|
23
|
-
@row << nil
|
24
|
-
|
25
|
-
@row2 = []
|
26
|
-
@row2 << "D"
|
27
|
-
@row2 << "1"
|
28
|
-
@row2 << "IB"
|
29
|
-
@row2 << "0701180358"
|
30
|
-
@row2 << "DIGGING TO AMERICA"
|
31
|
-
@row2 << "3"
|
32
|
-
@row2 << "0.00"
|
33
|
-
@row2 << "EA"
|
34
|
-
@row2 << nil
|
35
|
-
@row2 << nil
|
36
|
-
@row2 << "43"
|
37
|
-
@row2 << "N"
|
38
|
-
@row2 << nil
|
39
|
-
@row2 << nil
|
40
|
-
end
|
41
|
-
|
42
|
-
# ensure the load_from_array method works as expected
|
43
|
-
def test_load_from_array
|
44
|
-
item = RVista::POLineItem.load_from_array(@row)
|
45
|
-
assert_kind_of RVista::POLineItem, item
|
46
|
-
|
47
|
-
assert_equal item.line_num, 1
|
48
|
-
assert_equal item.qualifier, "IB"
|
49
|
-
assert_equal item.ean, "0701180358"
|
50
|
-
assert_equal item.description, "DIGGING TO AMERICA"
|
51
|
-
assert_equal item.qty, 3
|
52
|
-
assert_equal item.nett_unit_price, 0.00
|
53
|
-
assert_equal item.unit_measure, "EA"
|
54
|
-
assert_equal item.retail_unit_price, nil
|
55
|
-
assert_equal item.was_unit_price, nil
|
56
|
-
assert_equal item.discount, 43
|
57
|
-
assert_equal item.backorder, true
|
58
|
-
assert_equal item.additional_discount, nil
|
59
|
-
assert_equal item.firm_sale, nil
|
60
|
-
end
|
61
|
-
|
62
|
-
# ensure the load_from_file method throws the correct exceptions
|
63
|
-
# when it encounters a problem
|
64
|
-
def test_product_validation
|
65
|
-
|
66
|
-
assert_raise(RVista::InvalidLineItemError) {
|
67
|
-
item = RVista::POLineItem.load_from_array(%w[D blah])
|
68
|
-
}
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_to_s
|
73
|
-
item = RVista::POLineItem.load_from_array(@row)
|
74
|
-
str = item.to_s
|
75
|
-
arr = FasterCSV.parse(str).first
|
76
|
-
|
77
|
-
assert_equal 14, arr.size
|
78
|
-
|
79
|
-
item = RVista::POLineItem.load_from_array(@row2)
|
80
|
-
str = item.to_s
|
81
|
-
arr = FasterCSV.parse(str).first
|
82
|
-
|
83
|
-
assert_equal 14, arr.size
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
|
data/test/unit/message_test.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rvista'
|
5
|
-
|
6
|
-
class POTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
VALID = File.dirname(__FILE__) + "/../data/po/valid.txt"
|
9
|
-
VALID_QUOTES = File.dirname(__FILE__) + "/../data/po/quotes.txt"
|
10
|
-
INVALID_MISSING_HEADER = File.dirname(__FILE__) + "/../data/po/invalid_missing_header.txt"
|
11
|
-
INVALID_MISSING_FOOTER = File.dirname(__FILE__) + "/../data/po/invalid_missing_footer.txt"
|
12
|
-
INVALID_LINE = File.dirname(__FILE__) + "/../data/po/invalid_line.txt"
|
13
|
-
INVALID_DOESNT_EXIST = File.dirname(__FILE__) + "/../data/blah.txt"
|
14
|
-
|
15
|
-
# ensure the load_from_file method works as expected
|
16
|
-
def test_load_from_file
|
17
|
-
msg = RVista::PO.load_from_file(VALID)
|
18
|
-
assert_kind_of RVista::PO, msg
|
19
|
-
assert_equal msg.items.size, 38
|
20
|
-
|
21
|
-
validate_msg(msg)
|
22
|
-
end
|
23
|
-
|
24
|
-
# ensure the load_from_file method works as expected
|
25
|
-
def test_load_from_string
|
26
|
-
msg = RVista::PO.load_from_string(File.read(VALID))
|
27
|
-
assert_kind_of RVista::PO, msg
|
28
|
-
assert_equal msg.items.size, 38
|
29
|
-
|
30
|
-
validate_msg(msg)
|
31
|
-
end
|
32
|
-
|
33
|
-
# ensure files that (probably incorrectly) contain quotes can be
|
34
|
-
# parsed.
|
35
|
-
#
|
36
|
-
def test_files_with_quotes
|
37
|
-
msg = RVista::PO.load_from_string(File.read(VALID_QUOTES))
|
38
|
-
assert_kind_of RVista::PO, msg
|
39
|
-
assert_equal msg.items.size, 11
|
40
|
-
end
|
41
|
-
|
42
|
-
# ensure the load_from_file method throws the correct exceptions
|
43
|
-
# when it encounters a problem
|
44
|
-
def test_product_validation
|
45
|
-
|
46
|
-
assert_raise(RVista::InvalidFileError) {
|
47
|
-
msg = RVista::PO.load_from_file(INVALID_MISSING_HEADER)
|
48
|
-
}
|
49
|
-
|
50
|
-
assert_raise(RVista::InvalidFileError) {
|
51
|
-
msg = RVista::PO.load_from_file(INVALID_MISSING_FOOTER)
|
52
|
-
}
|
53
|
-
|
54
|
-
assert_raise(RVista::InvalidLineItemError) {
|
55
|
-
msg = RVista::PO.load_from_file(INVALID_LINE)
|
56
|
-
}
|
57
|
-
|
58
|
-
assert_raise(RVista::InvalidFileError) {
|
59
|
-
msg = RVista::PO.load_from_file(INVALID_DOESNT_EXIST)
|
60
|
-
}
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_to_s
|
65
|
-
msg = RVista::PO.load_from_file(VALID)
|
66
|
-
content = File.read(VALID)
|
67
|
-
assert_equal content, msg.to_s
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
# ensures the properties of the supplied RVista::PO object
|
73
|
-
# match the properties specified in the VALID file
|
74
|
-
def validate_msg(msg)
|
75
|
-
assert_equal msg.sender_id, "1111111"
|
76
|
-
assert_equal msg.receiver_id, "2222222"
|
77
|
-
assert_equal msg.internal_control_number, nil
|
78
|
-
assert_equal msg.po_number, "0000009525908"
|
79
|
-
assert_equal msg.po_subset_code, nil
|
80
|
-
assert_equal msg.purpose_code, "00"
|
81
|
-
assert_equal msg.purpose_desc, nil
|
82
|
-
assert_equal msg.date, Chronic.parse("2006-09-15")
|
83
|
-
assert_equal msg.myer_code, nil
|
84
|
-
assert_equal msg.supply_after, nil
|
85
|
-
assert_equal msg.supply_before, nil
|
86
|
-
assert_equal msg.advertised_date, nil
|
87
|
-
assert_equal msg.department, nil
|
88
|
-
assert_equal msg.supplier_ref, nil
|
89
|
-
assert_equal msg.buying_location, nil
|
90
|
-
assert_equal msg.buying_location_name, nil
|
91
|
-
assert_equal msg.delivery_location, "1111111"
|
92
|
-
assert_equal msg.delivery_location_name, nil
|
93
|
-
assert_equal msg.label_code, nil
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
|
@@ -1,91 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rvista'
|
5
|
-
|
6
|
-
class POALineItemTest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@row = []
|
10
|
-
@row << "D"
|
11
|
-
@row << "1"
|
12
|
-
@row << "0701180358"
|
13
|
-
@row << nil
|
14
|
-
@row << "DIGGING TO AMERICA"
|
15
|
-
@row << "10.00"
|
16
|
-
@row << "1"
|
17
|
-
@row << "0"
|
18
|
-
@row << "10.00"
|
19
|
-
@row << nil
|
20
|
-
@row << "1111111"
|
21
|
-
@row << "Some Store"
|
22
|
-
@row << nil
|
23
|
-
@row << "1"
|
24
|
-
@row << "01"
|
25
|
-
@row << "1"
|
26
|
-
@row << "11.00"
|
27
|
-
@row << "40.00"
|
28
|
-
@row << "20071015"
|
29
|
-
@row << nil
|
30
|
-
end
|
31
|
-
|
32
|
-
# ensure the load_from_array method works as expected
|
33
|
-
def test_load_from_array
|
34
|
-
item = RVista::POALineItem.load_from_array(@row)
|
35
|
-
assert_kind_of RVista::POALineItem, item
|
36
|
-
|
37
|
-
assert_equal item.line_num, 1
|
38
|
-
assert_equal item.ean, "0701180358"
|
39
|
-
assert_equal item.description, "DIGGING TO AMERICA"
|
40
|
-
assert_equal item.nett_unit_price, 10.00
|
41
|
-
assert_equal item.qty_inners, 0
|
42
|
-
assert_equal item.tax_rate, 10.00
|
43
|
-
assert_equal item.buying_location, "1111111"
|
44
|
-
assert_equal item.buying_location_name, "Some Store"
|
45
|
-
assert_equal item.delivered_qty, 1
|
46
|
-
assert_equal item.status_code, "01"
|
47
|
-
assert_equal item.demand_qty, 1
|
48
|
-
assert_equal item.rrp, 11.00
|
49
|
-
assert_equal item.discount_percent, 40.00
|
50
|
-
assert_equal item.availability_date, "20071015"
|
51
|
-
assert_equal item.text, nil
|
52
|
-
end
|
53
|
-
|
54
|
-
# ensure the load_from_file method throws the correct exceptions
|
55
|
-
# when it encounters a problem
|
56
|
-
def test_product_validation
|
57
|
-
|
58
|
-
assert_raise(RVista::InvalidLineItemError) {
|
59
|
-
item = RVista::POALineItem.load_from_array(%w[D blah])
|
60
|
-
}
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_status_text
|
65
|
-
item = RVista::POALineItem.load_from_array(@row)
|
66
|
-
assert_equal "Accepted: Title Shipped As Ordered", item.status_text
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_to_s
|
70
|
-
item = RVista::POALineItem.load_from_array(@row)
|
71
|
-
str = item.to_s
|
72
|
-
arr = FasterCSV.parse(str).first
|
73
|
-
|
74
|
-
assert_equal 20, arr.size
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_to_s_with_invalid_decimals
|
78
|
-
item = RVista::POALineItem.load_from_array(@row)
|
79
|
-
item.nett_unit_price = ""
|
80
|
-
item.rrp = ""
|
81
|
-
item.tax_rate = ""
|
82
|
-
item.discount_percent = ""
|
83
|
-
|
84
|
-
str = item.to_s
|
85
|
-
arr = FasterCSV.parse(str).first
|
86
|
-
assert_equal 20, arr.size
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
|
data/test/unit/poa_test.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rvista'
|
5
|
-
|
6
|
-
class POATest < Test::Unit::TestCase
|
7
|
-
|
8
|
-
VALID = File.dirname(__FILE__) + "/../data/poa/valid.txt"
|
9
|
-
INVALID_MISSING_HEADER = File.dirname(__FILE__) + "/../data/poa/invalid_missing_header.txt"
|
10
|
-
INVALID_MISSING_FOOTER = File.dirname(__FILE__) + "/../data/poa/invalid_missing_footer.txt"
|
11
|
-
INVALID_LINE = File.dirname(__FILE__) + "/../data/poa/invalid_line.txt"
|
12
|
-
INVALID_DOESNT_EXIST = File.dirname(__FILE__) + "/../data/blah.txt"
|
13
|
-
|
14
|
-
# ensure the load_from_file method works as expected
|
15
|
-
def test_load_from_file
|
16
|
-
msg = RVista::POA.load_from_file(VALID)
|
17
|
-
assert_kind_of RVista::POA, msg
|
18
|
-
assert_equal msg.items.size, 2
|
19
|
-
|
20
|
-
validate_msg(msg)
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
# ensure the load_from_file method works as expected
|
25
|
-
def test_load_from_string
|
26
|
-
msg = RVista::POA.load_from_string(File.read(VALID))
|
27
|
-
assert_kind_of RVista::POA, msg
|
28
|
-
assert_equal msg.items.size, 2
|
29
|
-
|
30
|
-
validate_msg(msg)
|
31
|
-
end
|
32
|
-
|
33
|
-
# ensure the load_from_file method throws the correct exceptions
|
34
|
-
# when it encounters a problem
|
35
|
-
def test_product_validation
|
36
|
-
|
37
|
-
assert_raise(RVista::InvalidFileError) {
|
38
|
-
msg = RVista::POA.load_from_file(INVALID_MISSING_HEADER)
|
39
|
-
}
|
40
|
-
|
41
|
-
assert_raise(RVista::InvalidFileError) {
|
42
|
-
msg = RVista::POA.load_from_file(INVALID_MISSING_FOOTER)
|
43
|
-
}
|
44
|
-
|
45
|
-
assert_raise(RVista::InvalidLineItemError) {
|
46
|
-
msg = RVista::POA.load_from_file(INVALID_LINE)
|
47
|
-
}
|
48
|
-
|
49
|
-
assert_raise(RVista::InvalidFileError) {
|
50
|
-
msg = RVista::POA.load_from_file(INVALID_DOESNT_EXIST)
|
51
|
-
}
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_to_s
|
56
|
-
msg = RVista::POA.load_from_file(VALID)
|
57
|
-
content = File.read(VALID)
|
58
|
-
assert_equal content, msg.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
# ensures the properties of the supplied RVista::POA object
|
64
|
-
# match the properties specified in the VALID file
|
65
|
-
def validate_msg(msg)
|
66
|
-
assert_equal msg.sender_id, "1111111"
|
67
|
-
assert_equal msg.receiver_id, "2222222"
|
68
|
-
assert_equal msg.po_number, "1234"
|
69
|
-
assert_equal msg.date, Chronic.parse("2006-09-15")
|
70
|
-
assert_equal msg.supply_after, Chronic.parse("2007-10-10")
|
71
|
-
assert_equal msg.supply_before, Chronic.parse("2007-10-30")
|
72
|
-
assert_equal msg.delivery_location, "1111111"
|
73
|
-
assert_equal msg.delivery_location_name, "Some Store"
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
|