Skip to content
Browse files

Изменен парсинг для 1С 8.

  • Loading branch information...
1 parent fed5d9e commit a3fe96ab7ce9be73d138d1f43e5240ac9b19915f @Tyralion Tyralion committed
Showing with 11 additions and 6 deletions.
  1. +5 −2 lib/anlas_import/manager.rb
  2. +6 −4 lib/anlas_import/xml_parser.rb
View
7 lib/anlas_import/manager.rb
@@ -46,7 +46,8 @@ def processing
@has_files = true
- files.each do |xml_file|
+ # Сортируем по дате последнего доступа по-возрастанию
+ files.sort{ |a, b| ::File.new(a).mtime <=> ::File.new(b).atime }.each do |xml_file|
::AnlasImport::Worker.new(xml_file, self).parse
end # each
@@ -95,8 +96,10 @@ def create_logger
@logger = ::Logger.new(
::File.open(
::File.join(::AnlasImport::log_dir, "import.log"), ::File::WRONLY | ::File::APPEND | ::File::CREAT
- )
+ ),
+ 'weekly'
)
+ @logger
end # create_logger
View
10 lib/anlas_import/xml_parser.rb
@@ -66,7 +66,10 @@ def end_element(name)
when "БазоваяЕдиница" then grub_item("unit")
when "ЦенаЗаЕдиницу" then
- @item_price = @str if for_item_price?
+ @item_price = @str.sub(/\A\s+/, "").sub(/\s+\z/, "").gsub(/(\s){2,}/, '\\1').try(:to_f) if for_item_price?
+
+ when "ПроцентСкидки" then
+ @item_discount = @str.sub(/\A\s+/, "").sub(/\s+\z/, "").gsub(/(\s){2,}/, '\\1').try(:to_f) if for_item_price?
when "ИдТипаЦены" then
@item_price_id = @str if for_item_price?
@@ -283,19 +286,18 @@ def stop_parse_item_price
when "Опт" then
@item["supplier_wholesale_price"] = @item_price
+ @item["purchasing_price"] = @item_price * (1 - @item_discount*0.01) if @item_discount
when "Закупочная" then
@item["supplier_purchasing_price"] = @item_price
- when "Интернет розничная" then
- @item["purchasing_price"] = @item_price
-
end # case
end # if
@item_price = nil
@item_price_id = nil
+ @item_discount = nil
@start_parse_item_price = false
end # stop_parse_item_price

0 comments on commit a3fe96a

Please sign in to comment.
Something went wrong with that request. Please try again.