oddb2xml 2.5.0 → 2.5.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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Elexis_Artikelstamm_v003.xsd +387 -0
  4. data/Elexis_Artikelstamm_v5.xsd +513 -0
  5. data/Gemfile +2 -6
  6. data/History.txt +11 -0
  7. data/README.md +35 -27
  8. data/artikelstamm.md +68 -0
  9. data/bin/compare_v5 +41 -0
  10. data/bin/oddb2xml +3 -15
  11. data/data/article_overrides.yaml +51859 -0
  12. data/data/gtin2ignore.yaml +30510 -0
  13. data/data/product_overrides.yaml +4 -0
  14. data/lib/oddb2xml/builder.rb +543 -192
  15. data/lib/oddb2xml/cli.rb +82 -62
  16. data/lib/oddb2xml/compare.rb +189 -0
  17. data/lib/oddb2xml/compressor.rb +6 -3
  18. data/lib/oddb2xml/downloader.rb +79 -64
  19. data/lib/oddb2xml/extractor.rb +67 -40
  20. data/lib/oddb2xml/options.rb +76 -77
  21. data/lib/oddb2xml/parslet_compositions.rb +18 -1
  22. data/lib/oddb2xml/util.rb +25 -3
  23. data/lib/oddb2xml/version.rb +1 -1
  24. data/oddb2xml.gemspec +8 -5
  25. data/oddb2xml.xsd +1 -0
  26. data/spec/artikelstamm_spec.rb +383 -0
  27. data/spec/builder_spec.rb +147 -118
  28. data/spec/calc_spec.rb +3 -15
  29. data/spec/cli_spec.rb +24 -35
  30. data/spec/compare_spec.rb +24 -0
  31. data/spec/compressor_spec.rb +1 -3
  32. data/spec/data/Elexis_Artikelstamm_v5.xsd +513 -0
  33. data/spec/data/Preparations.xml +2200 -0
  34. data/spec/data/Publications.xls +0 -0
  35. data/spec/data/artikelstamm_N_010917.xml +39 -0
  36. data/spec/data/artikelstamm_N_011217.xml +17 -0
  37. data/spec/data/artikelstamm_P_010917.xml +86 -0
  38. data/spec/data/artikelstamm_P_011217.xml +63 -0
  39. data/spec/data/oddb2xml_files_lppv.txt +2 -0
  40. data/spec/data/refdata_NonPharma.xml +38 -0
  41. data/spec/data/refdata_Pharma.xml +220 -0
  42. data/spec/data/swissmedic_orphan.xlsx +0 -0
  43. data/spec/data/swissmedic_package.xlsx +0 -0
  44. data/spec/data/transfer.dat +59 -19
  45. data/spec/data/v5_first.xml +102 -0
  46. data/spec/data/v5_second.xml +184 -0
  47. data/spec/data_helper.rb +72 -0
  48. data/spec/downloader_spec.rb +19 -27
  49. data/spec/extractor_spec.rb +27 -33
  50. data/spec/fixtures/vcr_cassettes/artikelstamm.json +1 -0
  51. data/spec/options_spec.rb +73 -66
  52. data/spec/spec_helper.rb +73 -24
  53. data/test_options.rb +4 -2
  54. metadata +100 -21
  55. data/spec/data/XMLPublications.zip +0 -0
  56. data/spec/data/compressor/oddb_article.xml +0 -0
  57. data/spec/data/compressor/oddb_fi.xml +0 -0
  58. data/spec/data/compressor/oddb_fi_product.xml +0 -0
  59. data/spec/data/compressor/oddb_limitation.xml +0 -0
  60. data/spec/data/compressor/oddb_product.xml +0 -0
  61. data/spec/data/compressor/oddb_substance.xml +0 -0
@@ -9,14 +9,15 @@ require 'oddb2xml/xml_definitions'
9
9
  module Oddb2xml
10
10
  module TxtExtractorMethods
11
11
  def initialize(str)
12
+ Oddb2xml.log("TxtExtractorMethods #{str} #{str.to_s.size} bytes")
12
13
  @io = StringIO.new(str)
13
14
  end
14
15
  def to_hash
15
16
  data = {}
16
17
  while line = @io.gets
17
18
  next unless line =~ /\d{13}/
18
- ean = line.chomp.gsub("\"", '')
19
- data[ean] = true
19
+ ean13 = line.chomp.gsub("\"", '')
20
+ data[ean13] = true
20
21
  end
21
22
  data
22
23
  end
@@ -24,6 +25,7 @@ module Oddb2xml
24
25
  class Extractor
25
26
  attr_accessor :xml
26
27
  def initialize(xml)
28
+ Oddb2xml.log("Extractor #{xml } xml #{xml.size} bytes")
27
29
  @xml = xml
28
30
  end
29
31
  end
@@ -37,6 +39,7 @@ module Oddb2xml
37
39
  result = PreparationsEntry.parse(@xml.sub(Strip_For_Sax_Machine, ''), :lazy => true)
38
40
  result.Preparations.Preparation.each do |seq|
39
41
  item = {}
42
+ item[:data_origin] = 'bag_xml'
40
43
  item[:refdata] = true
41
44
  item[:product_key] = seq.ProductCommercial
42
45
  item[:desc_de] = (desc = seq.DescriptionDe) ? desc : ''
@@ -81,8 +84,7 @@ module Oddb2xml
81
84
  puts "BagXmlExtractor: Setting missing GTIN #{pac.GTIN} in SwissmedicNo8 #{pac.SwissmedicNo8} BagDossierNo #{pac.BagDossierNo} PackId #{pac.PackId} #{item[:name_de]}."
82
85
  end
83
86
  end
84
- ean = pac.GTIN.to_i
85
-
87
+ ean13 = pac.GTIN.to_s
86
88
  # packages
87
89
  exf = {:price => '', :valid_date => '', :price_code => ''}
88
90
  if pac.Prices and pac.Prices.ExFactoryPrice
@@ -96,14 +98,14 @@ module Oddb2xml
96
98
  pub[:valid_date] = pac.Prices.PublicPrice.ValidFromDate if pac.Prices.PublicPrice.ValidFromDate
97
99
  pub[:price_code] = pac.Prices.PublicPrice.PriceTypeCode if pac.Prices.PublicPrice.PriceTypeCode
98
100
  end
99
- item[:packages][ean] = {
100
- :ean => ean,
101
+ item[:packages][ean13] = {
102
+ :ean13 => ean13,
101
103
  :swissmedic_category => (cat = pac.SwissmedicCategory) ? cat : '',
102
104
  :swissmedic_number8 => (num = pac.SwissmedicNo8) ? num : '',
103
105
  :prices => { :exf_price => exf, :pub_price => pub },
104
106
  }
105
107
  # related all limitations
106
- item[:packages][ean][:limitations] = []
108
+ item[:packages][ean13][:limitations] = []
107
109
  limitations = Hash.new{|h,k| h[k] = [] }
108
110
  if seq.Limitations
109
111
  limitations[:seq] = seq.Limitations.Limitation.collect { |x| x }
@@ -132,11 +134,11 @@ module Oddb2xml
132
134
  id = item[key].to_s
133
135
  when :pac
134
136
  key = :swissmedic_number8
135
- id = item[:packages][ean][key].to_s
137
+ id = item[:packages][ean13][key].to_s
136
138
  end
137
- if id.empty? && item[:packages][ean][ :swissmedic_number8]
139
+ if id.empty? && item[:packages][ean13][ :swissmedic_number8]
138
140
  key = :swissmedic_number8
139
- id = item[:packages][ean][key].to_s
141
+ id = item[:packages][ean13][key].to_s
140
142
  end
141
143
  lims.each do |lim|
142
144
  limitation = {
@@ -160,13 +162,13 @@ module Oddb2xml
160
162
  end
161
163
  end
162
164
  limitation[:del] = deleted
163
- item[:packages][ean][:limitations] << limitation
165
+ item[:packages][ean13][:limitations] << limitation
164
166
  end if lims
165
167
  end
166
168
  # limitation points
167
169
  pts = pac.PointLimitations.PointLimitation.first # only first points
168
- item[:packages][ean][:limitation_points] = pts ? pts.Points : ''
169
- data[ean] = item
170
+ item[:packages][ean13][:limitation_points] = pts ? pts.Points : ''
171
+ data[ean13] = item
170
172
  end
171
173
  end
172
174
  data
@@ -183,24 +185,30 @@ module Oddb2xml
183
185
  result = SwissRegArticleEntry.parse(@xml.sub(Strip_For_Sax_Machine, ''), :lazy => true)
184
186
  items = result.ARTICLE.ITEM
185
187
  items.each do |pac|
188
+ ean13 = (gtin = pac.GTIN.to_s) ? gtin: '0'
189
+ if ean13.size != 13
190
+ puts "Refdata #{@type} ean13: Fixed incorrect length #{ean13.size} for #{ean13}"
191
+ ean13 = ean13[1..-1]
192
+ end
186
193
  item = {}
194
+ item[:data_origin] = 'refdata'
187
195
  item[:refdata] = true
188
196
  item[:_type] = (typ = pac.ATYPE.downcase.to_sym) ? typ: ''
189
- item[:ean] = (gtin = pac.GTIN.to_i) ? gtin: 0
190
- item[:pharmacode] = (phar = pac.PHAR.to_i) ? phar: 0
197
+ item[:ean13] = ean13
198
+ item[:pharmacode] = (phar = pac.PHAR.to_s) ? phar: '0'
191
199
  item[:last_change] = (date = Time.parse(pac.DT).to_s) ? date: '' # Date and time of last data change
192
200
  item[:desc_de] = (dscr = pac.NAME_DE) ? dscr: ''
193
201
  item[:desc_fr] = (dscr = pac.NAME_FR) ? dscr: ''
194
202
  item[:atc_code] = (code = pac.ATC) ? code.to_s : ''
195
- item[:company_name] = (nam = pac.AUTH_HOLDER_NAME) ? nam: ''
196
- item[:company_ean] = (gln = pac.AUTH_HOLDER_GLN) ? gln: ''
203
+ item[:company_name] = (nam = pac.AUTH_HOLDER_NAME) ? nam: ''
204
+ item[:company_ean] = (gln = pac.AUTH_HOLDER_GLN) ? gln: ''
197
205
  unless item[:pharmacode]
198
206
  item[:pharmacode] = phar
199
207
  unless data[item[:pharmacode]] # pharmacode => GTINs
200
- data[item[:ean]] = []
208
+ data[item[:ean13]] = []
201
209
  end
202
210
  end
203
- data[item[:ean]] = item
211
+ data[item[:ean13]] = item
204
212
  end
205
213
  data
206
214
  end
@@ -210,6 +218,7 @@ module Oddb2xml
210
218
  @filename = File.join(Downloads, File.basename(filename))
211
219
  @filename = File.join(SpecData, File.basename(filename)) if defined?(RSpec) and not File.exists?(@filename)
212
220
  @type = type
221
+ Oddb2xml.log("SwissmedicExtractor #{@filename} #{File.size(@filename)} bytes")
213
222
  return unless File.exists?(@filename)
214
223
  @sheet = RubyXL::Parser.parse(File.expand_path(@filename)).worksheets[0]
215
224
  end
@@ -280,8 +289,8 @@ module Oddb2xml
280
289
  unless no8.empty?
281
290
  next if no8.to_i == 0
282
291
  ean_base12 = "7680#{no8}"
283
- data[no8.intern] = {
284
- :ean => (ean_base12.ljust(12, '0') + Oddb2xml.calc_checksum(ean_base12)),
292
+ data[no8] = {
293
+ :ean13 => (ean_base12.ljust(12, '0') + Oddb2xml.calc_checksum(ean_base12)),
285
294
  :prodno => prodno ? prodno : '',
286
295
  :ith_swissmedic => row[ith] ? row[ith].value.to_s : '',
287
296
  :swissmedic_category => row[cat].value.to_s,
@@ -296,6 +305,11 @@ module Oddb2xml
296
305
  :gen_production => row[COLUMNS_JULY_2015.keys.index(:gen_production)].value.to_s,
297
306
  :insulin_category => row[COLUMNS_JULY_2015.keys.index(:insulin_category)].value.to_s,
298
307
  :drug_index => row[COLUMNS_JULY_2015.keys.index(:drug_index)].value.to_s,
308
+ :data_origin => 'swissmedic_package',
309
+ :expiry_date => row[COLUMNS_JULY_2015.keys.index(:expiry_date)].value.to_s,
310
+ :company_name => row[COLUMNS_JULY_2015.keys.index(:company)].value.to_s,
311
+ :size => row[COLUMNS_JULY_2015.keys.index(:size)].value.to_s,
312
+ :unit => row[COLUMNS_JULY_2015.keys.index(:unit)].value.to_s,
299
313
  }
300
314
  end
301
315
  end
@@ -307,14 +321,14 @@ module Oddb2xml
307
321
  def cleanup_file
308
322
  begin
309
323
  File.unlink(@filename) if File.exists?(@filename)
310
- rescue Errno::EACCES # Permission Denied on Windows
324
+ rescue Errno::EACCES # Permission Denied on Windows
311
325
  end unless defined?(RSpec)
312
326
  end
313
327
 
314
328
  end
315
329
  class MigelExtractor < Extractor
316
330
  def initialize(bin)
317
- io = StringIO.new(bin)
331
+ Oddb2xml.log("MigelExtractor #{io} #{File.size(io)} bytes")
318
332
  book = Spreadsheet.open(io, 'rb')
319
333
  @sheet = book.worksheet(0)
320
334
  end
@@ -322,19 +336,20 @@ module Oddb2xml
322
336
  data = {}
323
337
  @sheet.each_with_index do |row, i|
324
338
  next if i.zero?
325
- phar = row[1].to_i
339
+ phar = row[1]
326
340
  next if phar == 0
327
- ean = row[0].to_i
328
- ean = phar unless ean.to_s.length == 13
341
+ ean13 = row[0]
342
+ ean13 = phar unless ean13.to_s.length == 13
329
343
  data[ean] = {
330
344
  :refdata => true,
331
- :ean => ean,
332
- :pharmacode => phar.to_i,
345
+ :ean13 => ean13,
346
+ :pharmacode => phar,
333
347
  :desc_de => row[3],
334
348
  :desc_fr => row[4],
335
349
  :quantity => row[5], # quantity
336
350
  :company_name => row[6],
337
- :company_ean => row[7].to_i,
351
+ :company_ean => row[7],
352
+ :data_origin => 'migel'
338
353
  }
339
354
  end
340
355
  data
@@ -350,7 +365,8 @@ module Oddb2xml
350
365
  lang = pac.lang.to_s
351
366
  next unless lang =~ /de|fr/
352
367
  item = {}
353
- item[:refdata] = true,
368
+ item[:refdata] = true
369
+ item[:data_origin] = 'swissmedic_info'
354
370
  item[:name] = (name = pac.title) ? name : ''
355
371
  item[:owner] = (ownr = pac.authHolder) ? ownr : ''
356
372
  item[:style] = Nokogiri::HTML.fragment(pac.style).to_html(:encoding => 'UTF-8')
@@ -370,6 +386,7 @@ module Oddb2xml
370
386
 
371
387
  class EphaExtractor < Extractor
372
388
  def initialize(str)
389
+ Oddb2xml.log("EphaExtractor #{str.size} bytes")
373
390
  @io = StringIO.new(str)
374
391
  end
375
392
  def to_arry
@@ -384,6 +401,7 @@ module Oddb2xml
384
401
  row = CSV.parse_line(line.gsub('""','"'))
385
402
  action = {}
386
403
  next unless row.size > 8
404
+ action[:data_origin] = 'epha'
387
405
  action[:ixno] = ixno
388
406
  action[:title] = row[4]
389
407
  action[:atc1] = row[0]
@@ -413,6 +431,7 @@ module Oddb2xml
413
431
  row = line.chomp.split("\t")
414
432
  next if row[0] =~ /^GLN/
415
433
  data << {
434
+ :data_origin => 'medreg',
416
435
  :gln => row[0].to_s.gsub(/[^0-9]/, ''), #=> GLN Betrieb
417
436
  :name_1 => row[1].to_s, #=> Betriebsname 1
418
437
  :name_2 => row[2].to_s, #=> Betriebsname 2
@@ -431,6 +450,7 @@ module Oddb2xml
431
450
  row = line.chomp.split("\t")
432
451
  next if row[0] =~ /^GLN/
433
452
  data << {
453
+ :data_origin => 'medreg',
434
454
  :gln => row[0].to_s.gsub(/[^0-9]/, ''), #=> GLN Person
435
455
  :last_name => row[1].to_s, #=> Name
436
456
  :first_name => row[2].to_s, #=> Vorname
@@ -449,8 +469,9 @@ module Oddb2xml
449
469
  end
450
470
  class ZurroseExtractor < Extractor
451
471
  # see http://dev.ywesee.com/Bbmb/TransferDat
452
- def initialize(dat, extended = false)
472
+ def initialize(dat, extended = false, artikelstamm = false)
453
473
  @@extended = extended
474
+ @artikelstamm = artikelstamm
454
475
  FileUtils.makedirs(WorkDir)
455
476
  @@error_file ||= File.open(File.join(WorkDir, "duplicate_ean13_from_zur_rose.txt"), 'wb+:ISO-8859-14')
456
477
  @@items_without_ean13s ||= 0
@@ -470,37 +491,43 @@ module Oddb2xml
470
491
  def to_hash
471
492
  data = {}
472
493
  while line = @io.gets
473
- line = Oddb2xml.patch_some_utf8(line)
494
+ line = Oddb2xml.patch_some_utf8(line).chomp
474
495
  next if line =~ /(ad us\.* vet)|(\(vet\))/i
475
496
  if @@extended
476
497
  next unless line =~ /(\d{13})(\d{1})$/
477
498
  else
478
499
  next unless line =~ /(7680\d{9})(\d{1})$/
479
500
  end
480
- pharma_code = line[3..9].to_i
501
+ pharma_code = line[3..9]
481
502
  if $1.to_s == '0000000000000'
482
503
  @@items_without_ean13s += 1
483
- ean13 = pharma_code # dummy ean13
504
+ ean13 = '999999' + pharma_code.to_s # dummy ean13
484
505
  else
485
- ean13 = $1.to_i
506
+ ean13 = $1
486
507
  end
508
+ next if @artikelstamm && /(0{13})(\d{1})$/.match(line)
487
509
  if data[ean13]
488
- @@error_file.puts "Duplicate ean13 #{ean13} in line \nact: #{line}\norg: #{data[ean13][:line]}"
510
+ @@error_file.puts "Duplicate ean13 #{ean13} in line \nact: #{line.chomp}\norg: #{data[ean13][:line]}"
489
511
  @@items_without_ean13s -= 1
490
512
  @@duplicated_ean13s += 1
491
513
  next
492
514
  end
493
515
 
516
+ pexf = sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f)
517
+ ppub = sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f)
518
+ next if @artikelstamm && /^113/.match(line) && /^7680/.match(ean13)
519
+ next if @artikelstamm && /^113/.match(line) && ppub.eql?('0.0') && pexf.eql?('0.0')
494
520
  data[ean13] = {
495
- :line => line,
496
- :ean => ean13,
521
+ :data_origin => 'zur_rose',
522
+ :line => line.chomp,
523
+ :ean13 => ean13,
497
524
  :clag => line[73],
498
525
  :vat => line[96],
499
526
  :description => line[10..59].sub(/\s+$/, ''),
500
527
  :quantity => '',
501
528
  :pharmacode => pharma_code,
502
- :price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f),
503
- :pub_price => sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f),
529
+ :price => pexf,
530
+ :pub_price => ppub,
504
531
  :type => :nonpharma,
505
532
  :cmut => line[2],
506
533
  }
@@ -1,85 +1,84 @@
1
1
  # encoding: utf-8
2
- require 'optparse'
2
+ require 'trollop'
3
+ require 'oddb2xml/version'
3
4
 
4
5
  module Oddb2xml
5
-
6
- class Options
7
- attr_reader :parser, :opts
8
- def Options.default_opts
9
- {
10
- :fi => false,
11
- :adr => false,
12
- :address => false,
13
- :nonpharma => false,
14
- :extended => false,
15
- :compress_ext => nil,
16
- :format => :xml,
17
- :calc => false,
18
- :tag_suffix => nil,
19
- :debug => false,
20
- :ean14 => false,
21
- :skip_download=> false,
22
- :log => false,
23
- :percent => nil,
24
- }
25
- end
26
- def Options.help
27
- <<EOS
28
- #$0 ver.#{Oddb2xml::VERSION}
29
- Usage:
30
- oddb2xml [option]
31
- produced files are found under data
32
- -a, --append Additional target nonpharma
33
- -c F, --compress=F Compress format F. {tar.gz|zip}
34
- -e --extended pharma, non-pharma plus prices and non-pharma from zurrose.
35
- Products without EAN-Code will also be listed.
36
- File oddb_calc.xml will also be generated
37
- -f F, --format=F File format F, default is xml. {xml|dat}
38
- If F is given, -o option is ignored.
39
- -I x, --increment=x Increment price by x percent. Forces -f dat -p zurrose.
40
- -I x, --increment=x create additional field price_resellerpub as
41
- price_extfactory incremented by x percent (rounded to the next 0.05 francs)
42
- in oddb_article.xml. In generated zurrose_transfer.dat PRPU is set to this price
43
- Forces -f dat -p zurrose.
44
- -i, --include Include target option for ean14 for 'dat' format.
45
- 'xml' format includes always ean14 records.
46
- -o, --option Optional fachinfo output.
47
- -p, --price Price source (transfer.dat) from ZurRose
48
- -t S, --tag-suffix=S XML tag suffix S. Default is none. [A-z0-9]
49
- If S is given, it is also used as prefix of filename.
50
- -x N, --context=N context N {product|address}. product is default.
51
- --calc create only oddb_calc.xml with GTIN, name and galenic information
6
+ module Options
7
+ def self.parse(args =ARGV)
8
+ if args.is_a?(String)
9
+ args = args.split(' ')
10
+ end
52
11
 
53
- For debugging purposes
54
- --skip-download skips downloading files it the file is already under downloads.
55
- Downloaded files are saved under downloads
56
- --log log important actions
57
- -h, --help Show this help message.
12
+ @opts = Trollop::options(args) do
13
+ version "#$0 ver.#{Oddb2xml::VERSION}"
14
+ banner <<-EOS
15
+ #{File.expand_path($0)} version #{Oddb2xml::VERSION}
16
+ Usage:
17
+ oddb2xml [option]
18
+ produced files are found under data
58
19
  EOS
59
- end
60
- def initialize
61
- @parser = OptionParser.new
62
- @opts = Options.default_opts
63
- @parser.on('-a', '--append') {|v| @opts[:nonpharma] = true }
64
- @parser.on('-c v', '--compress v', /^tar\.gz|zip$/){|v| @opts[:compress_ext] = v }
65
- @parser.on('-e', '--extended') {|v| @opts[:extended] = true
66
- @opts[:nonpharma] = true
67
- @opts[:price] = :zurrose
68
- @opts[:calc] = true
69
- }
70
- @parser.on('-f v', '--format v', /^xml|dat$/) {|v| @opts[:format] = v.intern }
71
- @parser.on('--calc') {|v| @opts[:calc] = true }
72
- @parser.on('-o', '--option') {|v| @opts[:fi] = true }
73
- @parser.on('-I v', '--increment v', /^[0-9]+$/) {|v| @opts[:percent] = v ? v.to_i : 0
74
- @opts[:price] = :zurrose
75
- }
76
- @parser.on('-i', '--include') {|v| @opts[:ean14] = true }
77
- @parser.on('-t v', '--tag-suffix v', /^[A-z0-9]*$/i) {|v| @opts[:tag_suffix] = v.upcase }
78
- @parser.on('-x v', '--context v', /^addr(ess)*$/i){|v| @opts[:address] = true }
79
- @parser.on('-p', '--price') {|v| @opts[:price] = :zurrose }
80
- @parser.on('--skip-download') {|v| @opts[:skip_download] = true }
81
- @parser.on('--log') {|v| @opts[:log] = true }
82
- @parser.on_tail('-h', '--help') { puts Options.help; exit }
20
+ opt :append, "Additional target nonpharma", :default => false
21
+ opt :artikelstamm, "Create Artikelstamm Version 3 and 5 for Elexis >= 3.1"
22
+ opt :compress_ext, "format F. {tar.gz|zip}", :type => :string, :default => nil, :short => 'c'
23
+ opt :extended, "pharma, non-pharma plus prices and non-pharma from zurrose.
24
+ Products without EAN-Code will also be listed.
25
+ File oddb_calc.xml will also be generated"
26
+ opt :format, "File format F, default is xml. {xml|dat}
27
+ If F is given, -o option is ignored.", :type => :string, :default => 'xml'
28
+ opt :include, "Include target option for ean14 for 'dat' format.
29
+ 'xml' format includes always ean14 records.", :short => 'i'
30
+ opt :increment, "Increment price by x percent. Forces -f dat -p zurrose.
31
+ create additional field price_resellerpub as
32
+ price_extfactory incremented by x percent (rounded to the next 0.05 francs)
33
+ in oddb_article.xml. In generated zurrose_transfer.dat PRPU is set to this price
34
+ Forces -f dat -p zurrose.", :type => :int, :default => nil, :short => 'I'
35
+ opt :fi, "Optional fachinfo output.", :short => 'o'
36
+ opt :price, "Price source (transfer.dat) from ZurRose", :default => nil
37
+ opt :tag_suffix, "XML tag suffix S. Default is none. [A-z0-9]
38
+ If S is given, it is also used as prefix of filename.", :type => :string, :short => 't'
39
+ opt :context, "{product|address}. product is default.", :default => 'product', :type => :string, :short => 'x'
40
+ opt :calc, "create only oddb_calc.xml with GTIN, name and galenic information"
41
+
42
+ opt :skip_download, "skips downloading files it the file is already under downloads.
43
+ Downloaded files are saved under downloads"
44
+ opt :log, "log important actions", :short => :none
45
+ opt :use_ra11zip, "Use the ra11.zip (a zipped transfer.dat from Galexis)",
46
+ :default => File.exist?('ra11.zip') ? 'ra11.zip' : nil, :type => :string
47
+ end
48
+
49
+ @opts[:percent] = @opts[:increment]
50
+ if @opts[:increment]
51
+ @opts[:nonpharma] = true
52
+ @opts[:price] = :zurrose
53
+ end
54
+ @opts[:ean14] = @opts[:increment]
55
+ @opts.delete(:increment)
56
+ @opts[:nonpharma] = @opts[:append]
57
+ @opts.delete(:append)
58
+ if @opts[:extended]
59
+ @opts[:nonpharma] = true
60
+ @opts[:price] = :zurrose
61
+ @opts[:calc] = true
62
+ end
63
+ if @opts[:artikelstamm]
64
+ @opts[:extended] = true
65
+ @opts[:price] = :zurrose
66
+ end
67
+ @opts[:price] = :zurrose if @opts[:price].is_a?(TrueClass)
68
+ @opts[:price] = @opts[:price].to_sym if @opts[:price]
69
+ @opts[:ean14] = @opts[:include]
70
+ @opts[:format] = @opts[:format].to_sym if @opts[:format]
71
+ @opts.delete(:include)
72
+ @opts.delete(:help)
73
+ @opts.delete(:version)
74
+
75
+ @opts[:address] = false
76
+ @opts[:address] = true if /^addr(ess)*$/i.match(@opts[:context])
77
+ @opts.delete(:context)
78
+
79
+ @opts.delete(:price) unless @opts[:price]
80
+
81
+ @opts.each{|k,v| @opts.delete(k) if /_given$/.match(k.to_s)}
83
82
  end
84
83
  end
85
84
  end