mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
Recurring transactions (#271)
* Implement recurring transactions support * Amount fix * Hide section when any filter is applied * Add automatic identify feature Automatic identification runs after: - CSV Import completes (TransactionImport, TradeImport, AccountImport, MintImport) - Plaid sync completes - SimpleFIN sync completes - LunchFlow sync completes - Any new provider that we create. * Fix linter and tests * Fix address review * FIX proper text sizing * Fix further linter Use circular distance to handle month-boundary wrapping * normalize to a circular representation before computing the median * Better tests validation * Added some UI info Fix pattern identification, last recurrent transaction needs to happened within the last 45 days. * Fix styling * Revert text subdued look * Match structure of the other sections * Styling * Restore positive amounts styling * Shorten label for UI styling --------- Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
58
app/controllers/recurring_transactions_controller.rb
Normal file
58
app/controllers/recurring_transactions_controller.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
class RecurringTransactionsController < ApplicationController
|
||||
layout "settings"
|
||||
|
||||
def index
|
||||
@recurring_transactions = Current.family.recurring_transactions
|
||||
.includes(:merchant)
|
||||
.order(status: :asc, next_expected_date: :asc)
|
||||
end
|
||||
|
||||
def identify
|
||||
count = RecurringTransaction.identify_patterns_for(Current.family)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
flash[:notice] = t("recurring_transactions.identified", count: count)
|
||||
redirect_to recurring_transactions_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def cleanup
|
||||
count = RecurringTransaction.cleanup_stale_for(Current.family)
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
flash[:notice] = t("recurring_transactions.cleaned_up", count: count)
|
||||
redirect_to recurring_transactions_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_status
|
||||
@recurring_transaction = Current.family.recurring_transactions.find(params[:id])
|
||||
|
||||
if @recurring_transaction.active?
|
||||
@recurring_transaction.mark_inactive!
|
||||
message = t("recurring_transactions.marked_inactive")
|
||||
else
|
||||
@recurring_transaction.mark_active!
|
||||
message = t("recurring_transactions.marked_active")
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
flash[:notice] = message
|
||||
redirect_to recurring_transactions_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@recurring_transaction = Current.family.recurring_transactions.find(params[:id])
|
||||
@recurring_transaction.destroy!
|
||||
|
||||
flash[:notice] = t("recurring_transactions.deleted")
|
||||
redirect_to recurring_transactions_path
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user