mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
24 lines
777 B
Ruby
24 lines
777 B
Ruby
class Registrar::AccountActivitiesController < RegistrarController
|
|
load_and_authorize_resource
|
|
|
|
def index
|
|
params[:q] ||= {}
|
|
account = current_user.registrar.cash_account
|
|
|
|
ca_cache = params[:q][:created_at_lteq]
|
|
begin
|
|
end_time = params[:q][:created_at_lteq].try(:to_date)
|
|
params[:q][:created_at_lteq] = end_time.try(:end_of_day)
|
|
rescue; end
|
|
|
|
@q = account.activities.includes(:invoice).search(params[:q])
|
|
@q.sorts = 'id desc' if @q.sorts.empty?
|
|
|
|
respond_to do |format|
|
|
format.html { @account_activities = @q.result.page(params[:page]) }
|
|
format.csv { send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv" }
|
|
end
|
|
|
|
params[:q][:created_at_lteq] = ca_cache
|
|
end
|
|
end
|