From 1ab66e68df65a16a49a76f828bf10eab721403dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergei=20Ts=C3=B5ganov?= Date: Thu, 1 Sep 2022 09:21:44 +0300 Subject: [PATCH 1/2] Added monthly status to invoices --- app/controllers/admin/invoices_controller.rb | 6 +++++- app/controllers/repp/v1/invoices_controller.rb | 1 + app/views/admin/invoices/_search_form.html.erb | 2 +- app/views/admin/invoices/index.haml | 2 ++ app/views/registrar/invoices/partials/_details.haml | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index caf1e3a95..b939ca893 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -86,9 +86,13 @@ module Admin 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 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 @@
<%= f.label t(:status) %> - <%= select_tag :status, options_for_select(%w(Paid Unpaid Cancelled),params[:status]), + <%= select_tag :status, options_for_select(%w(Paid Unpaid Cancelled Monthly),params[:status]), { multiple: false, include_blank: true, selected: params[:status], class: 'form-control selectize'} %>
diff --git a/app/views/admin/invoices/index.haml b/app/views/admin/invoices/index.haml index 046772d68..8b8fe12c3 100644 --- a/app/views/admin/invoices/index.haml +++ b/app/views/admin/invoices/index.haml @@ -31,6 +31,8 @@ %td= l invoice.receipt_date - elsif invoice.cancelled? %td.text-grey= t(:cancelled) + - elsif invoice.monthly_invoice + %td= l invoice.issue_date - else %td.text-danger= t(:unpaid) diff --git a/app/views/registrar/invoices/partials/_details.haml b/app/views/registrar/invoices/partials/_details.haml index c5e6193a4..acc0e6589 100644 --- a/app/views/registrar/invoices/partials/_details.haml +++ b/app/views/registrar/invoices/partials/_details.haml @@ -19,6 +19,8 @@ %dd= l @invoice.receipt_date - elsif @invoice.cancelled? %dd.text-grey= t(:cancelled) + - elsif @invoice.monthly_invoice + %dd= l @invoice.issue_date - else %dd{class: 'text-danger'}= t(:unpaid) From 7e394e5522dbdd4f7a80d617333e81bed242347c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergei=20Ts=C3=B5ganov?= Date: Thu, 1 Sep 2022 09:32:44 +0300 Subject: [PATCH 2/2] Fixed codeclimate issue --- app/controllers/admin/invoices_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/admin/invoices_controller.rb b/app/controllers/admin/invoices_controller.rb index b939ca893..a4ba97310 100644 --- a/app/controllers/admin/invoices_controller.rb +++ b/app/controllers/admin/invoices_controller.rb @@ -81,6 +81,7 @@ module Admin payment_order.update(notes: 'Cancelled') end + # rubocop:disable Metrics/MethodLength def filter_by_status case params[:status] when 'Paid' @@ -97,6 +98,7 @@ module Admin 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?