mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
Add rows_to_skip config for transaction import
This commit is contained in:
@@ -42,6 +42,7 @@ class Import::ConfigurationsController < ApplicationController
|
||||
:signage_convention,
|
||||
:amount_type_strategy,
|
||||
:amount_type_inflow_value,
|
||||
:rows_to_skip
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,6 +36,7 @@ class Import < ApplicationRecord
|
||||
validates :col_sep, inclusion: { in: SEPARATORS.map(&:last) }
|
||||
validates :signage_convention, inclusion: { in: SIGNAGE_CONVENTIONS }, allow_nil: true
|
||||
validates :number_format, presence: true, inclusion: { in: NUMBER_FORMATS.keys }
|
||||
validates :rows_to_skip, numericality: { greater_than_or_equal_to: 0 }
|
||||
|
||||
has_many :rows, dependent: :destroy
|
||||
has_many :mappings, dependent: :destroy
|
||||
@@ -248,7 +249,14 @@ class Import < ApplicationRecord
|
||||
end
|
||||
|
||||
def parsed_csv
|
||||
@parsed_csv ||= self.class.parse_csv_str(raw_file_str, col_sep: col_sep)
|
||||
return @parsed_csv if defined?(@parsed_csv)
|
||||
|
||||
csv_content = raw_file_str || ""
|
||||
if rows_to_skip.to_i > 0
|
||||
csv_content = csv_content.lines.drop(rows_to_skip).join
|
||||
end
|
||||
|
||||
@parsed_csv = self.class.parse_csv_str(csv_content, col_sep: col_sep)
|
||||
end
|
||||
|
||||
def sanitize_number(value)
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
<% end %>
|
||||
|
||||
<%# Optional Fields %>
|
||||
<%= form.number_field :rows_to_skip,
|
||||
{ label: "Skip first n rows", min: 0, step: 1, value: 0 } %>
|
||||
|
||||
<% unless import.account.present? %>
|
||||
<%= form.select :account_col_label,
|
||||
import.csv_headers,
|
||||
|
||||
5
db/migrate/20251226205942_add_rows_to_skip_to_imports.rb
Normal file
5
db/migrate/20251226205942_add_rows_to_skip_to_imports.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddRowsToSkipToImports < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
add_column :imports, :rows_to_skip, :integer, default: 0, null: false
|
||||
end
|
||||
end
|
||||
3
db/schema.rb
generated
3
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_12_15_100443) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_12_26_205942) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
@@ -538,6 +538,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_12_15_100443) do
|
||||
t.string "exchange_operating_mic_col_label"
|
||||
t.string "amount_type_strategy", default: "signed_amount"
|
||||
t.string "amount_type_inflow_value"
|
||||
t.integer "rows_to_skip", default: 0, null: false
|
||||
t.index ["family_id"], name: "index_imports_on_family_id"
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user