mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 09:57:23 +02:00
Make date until inclusive in invoice search, registrar #2666
This commit is contained in:
parent
00cfbbdc7f
commit
812daff1e5
2 changed files with 25 additions and 9 deletions
|
@ -22,8 +22,7 @@ $(document).on 'page:change', ->
|
||||||
tomorrow.setDate(today.getDate() + 1)
|
tomorrow.setDate(today.getDate() + 1)
|
||||||
|
|
||||||
$('.datepicker').datepicker(
|
$('.datepicker').datepicker(
|
||||||
dateFormat: "yy-mm-dd",
|
dateFormat: "yy-mm-dd"
|
||||||
maxDate: tomorrow
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if $('.js-combobox').length
|
if $('.js-combobox').length
|
||||||
|
|
|
@ -6,15 +6,15 @@ class Registrar::InvoicesController < RegistrarController
|
||||||
def index
|
def index
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
||||||
params[:q][:sum_cache_gteq].gsub!(',', '.') if params[:q][:sum_cache_gteq]
|
|
||||||
params[:q][:sum_cache_lteq].gsub!(',', '.') if params[:q][:sum_cache_lteq]
|
normalize_search_parameters do
|
||||||
@q = invoices.search(params[:q])
|
@q = invoices.search(params[:q])
|
||||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||||
@invoices = @q.result.page(params[:page])
|
@invoices = @q.result.page(params[:page])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show; end
|
||||||
end
|
|
||||||
|
|
||||||
def forward
|
def forward
|
||||||
@invoice.billing_email = @invoice.buyer.billing_email
|
@invoice.billing_email = @invoice.buyer.billing_email
|
||||||
|
@ -51,4 +51,21 @@ class Registrar::InvoicesController < RegistrarController
|
||||||
def set_invoice
|
def set_invoice
|
||||||
@invoice = Invoice.find(params[:id])
|
@invoice = Invoice.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize_search_parameters
|
||||||
|
params[:q][:sum_cache_gteq].gsub!(',', '.') if params[:q][:sum_cache_gteq]
|
||||||
|
params[:q][:sum_cache_lteq].gsub!(',', '.') if params[:q][:sum_cache_lteq]
|
||||||
|
|
||||||
|
ca_cache = params[:q][:due_date_lteq]
|
||||||
|
begin
|
||||||
|
end_time = params[:q][:due_date_lteq].try(:to_date)
|
||||||
|
params[:q][:due_date_lteq] = end_time.try(:end_of_day)
|
||||||
|
rescue
|
||||||
|
logger.warn('Invalid date')
|
||||||
|
end
|
||||||
|
|
||||||
|
yield
|
||||||
|
|
||||||
|
params[:q][:due_date_lteq] = ca_cache
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue