SU2-26 | Убрал лишние записи в jsonb
This commit is contained in:
@@ -2,6 +2,8 @@ module ReportParsers
|
||||
class Form11Parser < BaseParser
|
||||
SHEET_NAME = 'Бухгалтерский баланс'
|
||||
FORM_CODE = '1.1'
|
||||
# Add line codes or names that should be skipped during parsing.
|
||||
IGNORED_KEYS = [2].freeze
|
||||
|
||||
def call
|
||||
return {} unless sheet_exists?(SHEET_NAME)
|
||||
@@ -27,6 +29,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)
|
||||
@@ -124,5 +127,14 @@ module ReportParsers
|
||||
year = period_text[/\d{4}/].to_i
|
||||
yearly_file.update!(year: year) if year.positive?
|
||||
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