Transaction History

<%= link_to "Last 7 Days", transaction_history_client_portal_property_accounts_path(from_date: 7.days.ago.to_date), class: "btn btn-outline-primary btn-sm" %> <%= link_to "This Month", transaction_history_client_portal_property_accounts_path( from_date: Date.current.beginning_of_month, to_date: Date.current.end_of_month ), class: "btn btn-outline-primary btn-sm" %> <%= link_to "Last 3 Months", transaction_history_client_portal_property_accounts_path(from_date: 3.months.ago.to_date), class: "btn btn-outline-primary btn-sm" %> <%= link_to "Clear Filters", transaction_history_client_portal_property_accounts_path, class: "btn btn-outline-danger btn-sm" %>
<%= form_with url: transaction_history_client_portal_property_accounts_path, method: :get, local: true do %>
<%= select_tag :property_account_id, options_from_collection_for_select( @property_accounts, :id, :property_number, params[:property_account_id] ), include_blank: "All Properties", class: "form-select" %>
<%= date_field_tag :from_date, params[:from_date], class: "form-control", placeholder: "From" %>
<%= date_field_tag :to_date, params[:to_date], class: "form-control", placeholder: "To" %>
<%= text_field_tag :q, params[:q], placeholder: "Search title / ref", class: "form-control" %>
<%= submit_tag "Filter",data: {turbo: false}, class: "btn btn-primary w-100" %>
<% end %>
Total Transactions
<%= @transactions.count %>
Total Amount Paid
<%= number_to_currency(@transactions.where(credit: true).sum(:amount)) %>
Current Balance
<%= number_to_currency(@total_balance) %>
<%= render partial: "transactions_table", locals: { transactions: @transactions } %>
<% if @pagy.pages > 1 %>
<%= pagy_bootstrap_nav(@pagy) %>
<% end %>