diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index caf1e3a95..a4ba97310 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -81,18 +81,24 @@ module Admin payment_order.update(notes: 'Cancelled') end + # rubocop:disable Metrics/MethodLength def filter_by_status case params[:status] when 'Paid' Invoice.includes(:account_activity, :buyer).where.not(account_activity: { id: nil }) when 'Unpaid' - Invoice.includes(:account_activity, :buyer).where(account_activity: { id: nil }) + Invoice.includes(:account_activity, :buyer).where(account_activity: { id: nil }, + cancelled_at: nil, + monthly_invoice: false) when 'Cancelled' Invoice.includes(:account_activity, :buyer).where.not(cancelled_at: nil) + when 'Monthly' + Invoice.where(monthly_invoice: true, cancelled_at: nil) else Invoice.includes(:account_activity, :buyer) end end + # rubocop:enable Metrics/MethodLength def filter_by_receipt_date(invoices) date_from_param = params[:q][:receipt_date_gteq] if params[:q][:receipt_date_gteq].present? diff --git a/app/controllers/repp/v1/invoices_controller.rb b/app/controllers/repp/v1/invoices_controller.rb index 204aba096..2d4340b3e 100644 --- a/app/controllers/repp/v1/invoices_controller.rb +++ b/app/controllers/repp/v1/invoices_controller.rb @@ -97,6 +97,7 @@ module Repp account_activity_id_not_null account_activity_id_null cancelled_at_null cancelled_at_not_null number_gteq number_lteq + monthly_invoice_true monthly_invoice_false total_gteq total_lteq s] + [s: []]) end diff --git a/app/views/admin/invoices/_search_form.html.erb b/app/views/admin/invoices/_search_form.html.erb index 7739387b2..91ccf4421 100644 --- a/app/views/admin/invoices/_search_form.html.erb +++ b/app/views/admin/invoices/_search_form.html.erb @@ -12,7 +12,7 @@