mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 22:29:38 +02:00
* Prepare entry search for nested categories * Subcategory implementation * Remove caching for test stability
25 lines
843 B
Ruby
25 lines
843 B
Ruby
class TransactionsController < ApplicationController
|
|
layout :with_sidebar
|
|
|
|
def index
|
|
@q = search_params
|
|
search_query = Current.family.transactions.search(@q).includes(:entryable).reverse_chronological
|
|
@pagy, @transaction_entries = pagy(search_query, limit: params[:per_page] || "50")
|
|
|
|
@totals = {
|
|
count: search_query.select { |t| t.currency == Current.family.currency }.count,
|
|
income: search_query.income_total(Current.family.currency).abs,
|
|
expense: search_query.expense_total(Current.family.currency)
|
|
}
|
|
end
|
|
|
|
private
|
|
def search_params
|
|
params.fetch(:q, {})
|
|
.permit(
|
|
:start_date, :end_date, :search, :amount,
|
|
:amount_operator, accounts: [], account_ids: [],
|
|
categories: [], merchants: [], types: [], tags: []
|
|
)
|
|
end
|
|
end
|