491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
# File 'lib/oddb2xml/extractor.rb', line 491
def to_hash
data = {}
while line = @io.gets
line = Oddb2xml.patch_some_utf8(line).chomp
next if line =~ /(ad us\.* vet)|(\(vet\))/i
if @@extended
next unless line =~ /(\d{13})(\d{1})$/
else
next unless line =~ /(7680\d{9})(\d{1})$/
end
pharma_code = line[3..9]
if $1.to_s == '0000000000000'
@@items_without_ean13s += 1
ean13 = '999999' + pharma_code.to_s else
ean13 = $1
end
next if @artikelstamm && /(0{13})(\d{1})$/.match(line)
if data[ean13]
@@error_file.puts "Duplicate ean13 #{ean13} in line \nact: #{line.chomp}\norg: #{data[ean13][:line]}"
@@items_without_ean13s -= 1
@@duplicated_ean13s += 1
next
end
pexf = sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f)
ppub = sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f)
next if @artikelstamm && /^113/.match(line) && /^7680/.match(ean13)
next if @artikelstamm && /^113/.match(line) && ppub.eql?('0.0') && pexf.eql?('0.0')
data[ean13] = {
:data_origin => 'zur_rose',
:line => line.chomp,
:ean13 => ean13,
:clag => line[73],
:vat => line[96],
:description => line[10..59].sub(/\s+$/, ''),
:quantity => '',
:pharmacode => pharma_code,
:price => pexf,
:pub_price => ppub,
:type => :nonpharma,
:cmut => line[2],
}
@@zur_rose_items += 1
end if @io
if defined?(@@extended) and @@extended
@@error_file.puts get_error_msg
end
@@error_file.close
@@error_file = nil
data
end
|