SU2-26 | Убрал лишние записи в jsonb
This commit is contained in:
@@ -2,6 +2,8 @@ module ReportParsers
|
||||
class Form12Parser < BaseParser
|
||||
SHEET_NAME = 'Отчет о финансовых результатах'
|
||||
FORM_CODE = '1.2'
|
||||
# Add line codes or names that should be skipped during parsing.
|
||||
IGNORED_KEYS = [2].freeze
|
||||
|
||||
def call
|
||||
return {} unless sheet_exists?(SHEET_NAME)
|
||||
@@ -25,6 +27,7 @@ module ReportParsers
|
||||
all_rows = (header_row + 1).upto(sheet.last_row).filter_map do |row|
|
||||
line_name = read_cell(sheet, row, columns[:name_column])
|
||||
line_code = read_cell(sheet, row, columns[:code_column]).to_s.strip.presence
|
||||
next if ignored_row?(line_name, line_code)
|
||||
|
||||
values = columns[:value_columns].each_with_object({}) do |col, hash|
|
||||
value = read_cell(sheet, row, col)
|
||||
@@ -110,5 +113,14 @@ module ReportParsers
|
||||
value_columns: value_columns
|
||||
}
|
||||
end
|
||||
|
||||
def ignored_row?(line_name, line_code)
|
||||
keys = [line_code, line_name].compact.map { |value| normalize_label(value) }
|
||||
keys.any? { |key| ignored_keys.include?(key) }
|
||||
end
|
||||
|
||||
def ignored_keys
|
||||
@ignored_keys ||= IGNORED_KEYS.map { |value| normalize_label(value) }.to_set
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user