mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00:00
Recurring fixes (#454)
* Fix record violation and add toggle for recurring feature * Run only once per sync cycle ( 30 sec ) * FIX params passing * Add collapsible to recurring section * FIX preferences error catch
This commit is contained in:
@@ -5,10 +5,22 @@ class RecurringTransactionsController < ApplicationController
|
||||
@recurring_transactions = Current.family.recurring_transactions
|
||||
.includes(:merchant)
|
||||
.order(status: :asc, next_expected_date: :asc)
|
||||
@family = Current.family
|
||||
end
|
||||
|
||||
def update_settings
|
||||
Current.family.update!(recurring_settings_params)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
flash[:notice] = t("recurring_transactions.settings_updated")
|
||||
redirect_to recurring_transactions_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def identify
|
||||
count = RecurringTransaction.identify_patterns_for(Current.family)
|
||||
count = RecurringTransaction.identify_patterns_for!(Current.family)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@@ -55,4 +67,10 @@ class RecurringTransactionsController < ApplicationController
|
||||
flash[:notice] = t("recurring_transactions.deleted")
|
||||
redirect_to recurring_transactions_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def recurring_settings_params
|
||||
{ recurring_transactions_disabled: params[:recurring_transactions_disabled] == "true" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -159,6 +159,13 @@ class TransactionsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def update_preferences
|
||||
Current.user.update_transactions_preferences(preferences_params)
|
||||
head :ok
|
||||
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved
|
||||
head :unprocessable_entity
|
||||
end
|
||||
|
||||
private
|
||||
def per_page
|
||||
params[:per_page].to_i.positive? ? params[:per_page].to_i : 20
|
||||
@@ -236,4 +243,8 @@ class TransactionsController < ApplicationController
|
||||
def stored_params
|
||||
Current.session.prev_transaction_page_params
|
||||
end
|
||||
|
||||
def preferences_params
|
||||
params.require(:preferences).permit(collapsed_sections: {})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user