SU2-32 | фикс для дублей
This commit is contained in:
@@ -87,11 +87,12 @@ class ReportParser
|
|||||||
form_data = parsed_forms.fetch(form_code, {})[year] || {}
|
form_data = parsed_forms.fetch(form_code, {})[year] || {}
|
||||||
source_rows = form_data[:rows] || form_data['rows'] || []
|
source_rows = form_data[:rows] || form_data['rows'] || []
|
||||||
rows_by_code = index_rows_by_code(source_rows)
|
rows_by_code = index_rows_by_code(source_rows)
|
||||||
|
form_codes = report_codes_for_form(form_code, codes)
|
||||||
|
|
||||||
hash[form_code] = {
|
hash[form_code] = {
|
||||||
form_code: form_code,
|
form_code: form_code,
|
||||||
sheet_name: form_data[:sheet_name] || form_data['sheet_name'] || config.fetch(:sheet_name),
|
sheet_name: form_data[:sheet_name] || form_data['sheet_name'] || config.fetch(:sheet_name),
|
||||||
rows: codes.map do |report_code|
|
rows: form_codes.map do |report_code|
|
||||||
source_row = rows_by_code[report_code.code]
|
source_row = rows_by_code[report_code.code]
|
||||||
source_value = source_row && (source_row[:value] || source_row['value'])
|
source_value = source_row && (source_row[:value] || source_row['value'])
|
||||||
|
|
||||||
@@ -177,6 +178,24 @@ class ReportParser
|
|||||||
@report_codes ||= ReportCode.order(:code).select(:code, :name).to_a
|
@report_codes ||= ReportCode.order(:code).select(:code, :name).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def report_codes_for_form(form_code, codes)
|
||||||
|
codes.select { |report_code| report_code_belongs_to_form?(report_code.code, form_code) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def report_code_belongs_to_form?(code, form_code)
|
||||||
|
normalized_code = normalize_code(code)
|
||||||
|
return false if normalized_code.blank?
|
||||||
|
|
||||||
|
case form_code
|
||||||
|
when '1.1' then normalized_code.start_with?('1')
|
||||||
|
when '1.2' then normalized_code.start_with?('2')
|
||||||
|
when '1.3' then normalized_code.start_with?('3')
|
||||||
|
when '1.4' then normalized_code.start_with?('4')
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cleanup_duplicate_statements(year, keeper_id)
|
def cleanup_duplicate_statements(year, keeper_id)
|
||||||
FinancialStatement
|
FinancialStatement
|
||||||
.joins(:yearly_file)
|
.joins(:yearly_file)
|
||||||
|
|||||||
Reference in New Issue
Block a user