Compare commits
No commits in common. "b31848744ff47570e9a4fb9e09ff141207898178" and "971b9d703193da7863767ea1db468c3d8445830f" have entirely different histories.
b31848744f
...
971b9d7031
4 changed files with 20 additions and 8 deletions
|
@ -35,15 +35,16 @@ module FoodsoftArticleImport
|
|||
# @param file [File, Tempfile]
|
||||
# @option opts [String] type file format (required) (see {.file_formats})
|
||||
# @return [File, Roo::Spreadsheet] file with encoding set if needed
|
||||
def self.parse(file, custom_file_path: nil, type: nil, &blk)
|
||||
def self.parse(file, custom_file_path: nil, type: nil, **opts, &blk)
|
||||
custom_file_path ||= nil
|
||||
type ||= 'bnn'
|
||||
|
||||
parser = file_formats[type]
|
||||
if block_given?
|
||||
parser.parse(file, custom_file_path: custom_file_path, &blk)
|
||||
parser.parse(file, custom_file_path: custom_file_path, **opts, &blk)
|
||||
else
|
||||
data = []
|
||||
parser.parse(file, custom_file_path: custom_file_path) { |a| data << a }
|
||||
parser.parse(file, custom_file_path: custom_file_path, **opts) { |a| data << a }
|
||||
data
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,9 +28,9 @@ module FoodsoftArticleImport
|
|||
RES_PARSE_UNIT_LIST.map { |r| /#{r}\s*$/ } +
|
||||
RES_PARSE_UNIT_LIST.map { |r| /-#{r}/ }
|
||||
|
||||
def self.parse(file, custom_file_path: nil)
|
||||
def self.parse(file, custom_file_path: nil, **opts)
|
||||
custom_file_path ||= nil
|
||||
opts = OPTIONS.dup
|
||||
opts = OPTIONS.merge(opts)
|
||||
opts[:liberal_parsing] = true
|
||||
opts[:col_sep] = ','
|
||||
ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)
|
||||
|
|
|
@ -71,11 +71,22 @@ module FoodsoftArticleImport
|
|||
# TODO: Complete deposit list....
|
||||
article.merge!(deposit: translate(:deposit, row[26])) if translate(:deposit, row[26])
|
||||
|
||||
# get scale prices if exists
|
||||
# article.merge!(:scale_quantity => row[40], :scale_price => row[41]) unless row[40].nil? or row[41].nil?
|
||||
unless row[37].nil? && row[65].nil? && row[66].nil?
|
||||
scale_factor = row[66].gsub(',', '.').to_f
|
||||
price = row[37].gsub(',', '.').to_f
|
||||
price_per = (scale_factor * price).to_s.gsub('.', ',')
|
||||
article.merge!(:price_per => price_per)
|
||||
article.merge!(:unit_symbol => row[65] )
|
||||
end
|
||||
|
||||
|
||||
if !row[62].nil?
|
||||
# consider special prices
|
||||
article[:note] = "Sonderpreis: #{article[:price]} von #{row[62]} bis #{row[63]}"
|
||||
yield article, :special, i
|
||||
|
||||
|
||||
# Check now for article status, we only consider outlisted articles right now
|
||||
# N=neu, A=Änderung, X=ausgelistet, R=Restbestand,
|
||||
# V=vorübergehend ausgelistet, W=wiedergelistet
|
||||
|
|
|
@ -17,9 +17,9 @@ module FoodsoftArticleImport
|
|||
|
||||
# Parses Foodsoft file
|
||||
# the yielded article is a simple hash
|
||||
def self.parse(file, custom_file_path: nil)
|
||||
def self.parse(file, custom_file_path: nil, **opts)
|
||||
custom_file_path ||= nil
|
||||
opts = OPTIONS.dup
|
||||
opts = OPTIONS.merge(opts)
|
||||
|
||||
ss = FoodsoftArticleImport.open_spreadsheet(file, **opts)
|
||||
|
||||
|
|
Loading…
Reference in a new issue