1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-21 22:29:38 +02:00
Maybe/app/controllers/transactions_controller.rb
Zach Gollwitzer 77def1db40
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled
Nested Categories (#1561)
* Prepare entry search for nested categories

* Subcategory implementation

* Remove caching for test stability
2024-12-20 11:37:26 -05:00

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