diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5d561bc1..ae9fd978 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,20 +1,6 @@
module ApplicationHelper
include Pagy::Frontend
- def date_format_options
- [
- [ "DD-MM-YYYY", "%d-%m-%Y" ],
- [ "DD.MM.YYYY", "%d.%m.%Y" ],
- [ "MM-DD-YYYY", "%m-%d-%Y" ],
- [ "YYYY-MM-DD", "%Y-%m-%d" ],
- [ "DD/MM/YYYY", "%d/%m/%Y" ],
- [ "YYYY/MM/DD", "%Y/%m/%d" ],
- [ "MM/DD/YYYY", "%m/%d/%Y" ],
- [ "D/MM/YYYY", "%e/%m/%Y" ],
- [ "YYYY.MM.DD", "%Y.%m.%d" ]
- ]
- end
-
def icon(key, size: "md", color: "current")
render partial: "shared/icon", locals: { key:, size:, color: }
end
diff --git a/app/models/family.rb b/app/models/family.rb
index 71926dbd..683df55b 100644
--- a/app/models/family.rb
+++ b/app/models/family.rb
@@ -1,7 +1,17 @@
class Family < ApplicationRecord
include Plaidable, Syncable
- DATE_FORMATS = [ "%m-%d-%Y", "%d.%m.%Y", "%d-%m-%Y", "%Y-%m-%d", "%d/%m/%Y", "%Y/%m/%d", "%m/%d/%Y", "%e/%m/%Y", "%Y.%m.%d" ]
+ DATE_FORMATS = [
+ [ "MM-DD-YYYY", "%m-%d-%Y" ],
+ [ "DD.MM.YYYY", "%d.%m.%Y" ],
+ [ "DD-MM-YYYY", "%d-%m-%Y" ],
+ [ "YYYY-MM-DD", "%Y-%m-%d" ],
+ [ "DD/MM/YYYY", "%d/%m/%Y" ],
+ [ "YYYY/MM/DD", "%Y/%m/%d" ],
+ [ "MM/DD/YYYY", "%m/%d/%Y" ],
+ [ "D/MM/YYYY", "%e/%m/%Y" ],
+ [ "YYYY.MM.DD", "%Y.%m.%d" ]
+ ].freeze
include Providable
@@ -21,7 +31,7 @@ class Family < ApplicationRecord
has_many :budget_categories, through: :budgets
validates :locale, inclusion: { in: I18n.available_locales.map(&:to_s) }
- validates :date_format, inclusion: { in: DATE_FORMATS }
+ validates :date_format, inclusion: { in: DATE_FORMATS.map(&:last) }
def sync_data(start_date: nil)
update!(last_synced_at: Time.current)
diff --git a/app/views/import/configurations/_mint_import.html.erb b/app/views/import/configurations/_mint_import.html.erb
index afb13156..f5ff4834 100644
--- a/app/views/import/configurations/_mint_import.html.erb
+++ b/app/views/import/configurations/_mint_import.html.erb
@@ -8,7 +8,7 @@
<%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %>
<%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true, disabled: import.complete? %>
- <%= form.select :date_format, [["DD-MM-YYYY", "%d-%m-%Y"], ["MM-DD-YYYY", "%m-%d-%Y"], ["YYYY-MM-DD", "%Y-%m-%d"], ["DD/MM/YYYY", "%d/%m/%Y"], ["YYYY/MM/DD", "%Y/%m/%d"], ["MM/DD/YYYY", "%m/%d/%Y"]], { label: true }, required: true, disabled: import.complete? %>
+ <%= form.select :date_format, Family::DATE_FORMATS, { label: t(".date_format_label")}, label: true, required: true, disabled: import.complete? %>
diff --git a/app/views/import/configurations/_trade_import.html.erb b/app/views/import/configurations/_trade_import.html.erb
index b60eb61b..278debf8 100644
--- a/app/views/import/configurations/_trade_import.html.erb
+++ b/app/views/import/configurations/_trade_import.html.erb
@@ -3,7 +3,7 @@
<%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %>
<%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true %>
- <%= form.select :date_format, [["DD-MM-YYYY", "%d-%m-%Y"], ["DD.MM.YY", "%d.%m.%y"], ["MM-DD-YYYY", "%m-%d-%Y"], ["YYYY-MM-DD", "%Y-%m-%d"], ["DD/MM/YYYY", "%d/%m/%Y"], ["YYYY/MM/DD", "%Y/%m/%d"], ["MM/DD/YYYY", "%m/%d/%Y"]], label: true, required: true %>
+ <%= form.select :date_format, Family::DATE_FORMATS, { label: t(".date_format_label")}, label: true, required: true %>
diff --git a/app/views/import/configurations/_transaction_import.html.erb b/app/views/import/configurations/_transaction_import.html.erb
index c8bc103b..fc741c85 100644
--- a/app/views/import/configurations/_transaction_import.html.erb
+++ b/app/views/import/configurations/_transaction_import.html.erb
@@ -3,7 +3,7 @@
<%= styled_form_with model: @import, url: import_configuration_path(@import), scope: :import, method: :patch, class: "space-y-2" do |form| %>
<%= form.select :date_col_label, import.csv_headers, { include_blank: "Leave empty", label: "Date" }, required: true %>
- <%= form.select :date_format, [["DD-MM-YYYY", "%d-%m-%Y"], ["DD.MM.YY", "%d.%m.%y"], ["MM-DD-YYYY", "%m-%d-%Y"], ["YYYY-MM-DD", "%Y-%m-%d"], ["DD/MM/YYYY", "%d/%m/%Y"], ["YYYY/MM/DD", "%Y/%m/%d"], ["MM/DD/YYYY", "%m/%d/%Y"]], label: true, required: true %>
+ <%= form.select :date_format, Family::DATE_FORMATS, { label: t(".date_format_label")}, label: true, required: true %>
diff --git a/app/views/onboardings/preferences.html.erb b/app/views/onboardings/preferences.html.erb
index 26b0ac1f..93eee73b 100644
--- a/app/views/onboardings/preferences.html.erb
+++ b/app/views/onboardings/preferences.html.erb
@@ -72,7 +72,7 @@
{ data: { action: "onboarding#setCurrency" } } %>
<%= family_form.select :date_format,
- date_format_options,
+ Family::DATE_FORMATS,
{ label: t(".date_format"), required: true, selected: params[:date_format] || @user.family.date_format },
{ data: { action: "onboarding#setDateFormat" } } %>
diff --git a/app/views/settings/preferences/show.html.erb b/app/views/settings/preferences/show.html.erb
index 7af910e2..666469a9 100644
--- a/app/views/settings/preferences/show.html.erb
+++ b/app/views/settings/preferences/show.html.erb
@@ -25,7 +25,7 @@
{ data: { auto_submit_form_target: "auto" } } %>
<%= family_form.select :date_format,
- date_format_options,
+ Family::DATE_FORMATS,
{ label: t(".date_format") },
{ data: { auto_submit_form_target: "auto" } } %>
diff --git a/config/locales/views/imports/en.yml b/config/locales/views/imports/en.yml
index b45ac84b..2ed7c1ff 100644
--- a/config/locales/views/imports/en.yml
+++ b/config/locales/views/imports/en.yml
@@ -8,6 +8,12 @@ en:
details.
title: Clean your data
configurations:
+ trade_import:
+ date_format_label: Date format
+ mint_import:
+ date_format_label: Date format
+ transaction_import:
+ date_format_label: Date format
show:
description: Select the columns that correspond to each field in your CSV.
title: Configure your import