mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 09:46:09 +02:00
refactored
This commit is contained in:
parent
dce074e326
commit
4770411cda
1 changed files with 7 additions and 11 deletions
|
@ -84,21 +84,17 @@ module Admin
|
||||||
Invoice.includes(:account_activity, :buyer).where.not(account_activity: { id: nil })
|
Invoice.includes(:account_activity, :buyer).where.not(account_activity: { id: nil })
|
||||||
when 'Unpaid'
|
when 'Unpaid'
|
||||||
Invoice.includes(:account_activity, :buyer).where(account_activity: { id: nil })
|
Invoice.includes(:account_activity, :buyer).where(account_activity: { id: nil })
|
||||||
when 'Cancelled' then Invoice.includes(:account_activity, :buyer).where.not(cancelled_at: nil)
|
when 'Cancelled'
|
||||||
else Invoice.includes(:account_activity, :buyer)
|
Invoice.includes(:account_activity, :buyer).where.not(cancelled_at: nil)
|
||||||
|
else
|
||||||
|
Invoice.includes(:account_activity, :buyer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_by_receipt_date(invoices)
|
def filter_by_receipt_date(invoices)
|
||||||
if params[:q][:receipt_date_gteq].present?
|
date_from = Time.zone.parse(params[:q][:receipt_date_gteq]) || -Float::INFINITY
|
||||||
date_from = Time.zone.parse(params[:q][:receipt_date_gteq])
|
date_until = Time.zone.parse(params[:q][:receipt_date_lteq]) || Float::INFINITY
|
||||||
invoices = invoices.where(account_activity: { created_at: date_from..Float::INFINITY })
|
invoices.where(account_activity: { created_at: date_from..date_until })
|
||||||
end
|
|
||||||
|
|
||||||
return invoices if params[:q][:receipt_date_lteq].blank?
|
|
||||||
|
|
||||||
date_until = Time.zone.parse(params[:q][:receipt_date_lteq])
|
|
||||||
invoices.where(account_activity: { created_at: -Float::INFINITY..date_until })
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue