mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Invoice filtering in registrar
This commit is contained in:
parent
1f2f483e34
commit
23098add74
13 changed files with 83 additions and 7 deletions
|
@ -9,6 +9,7 @@
|
|||
#= require jquery.nested_attributes
|
||||
#= require selectize
|
||||
#= require shared/jquery.validate.bootstrap
|
||||
#= require jquery-ui/datepicker
|
||||
#= require shared/general
|
||||
#= require admin/application
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
#= require bootstrap-sprockets
|
||||
#= require jquery.nested_attributes
|
||||
#= require shared/jquery.validate.bootstrap
|
||||
#= require jquery-ui/datepicker
|
||||
#= require shared/general
|
||||
#= require registrar/application
|
||||
|
|
|
@ -9,3 +9,13 @@
|
|||
$('#flash').find('div').addClass('bg-danger')
|
||||
$('#flash').find('div').html(msg)
|
||||
$('#flash').show()
|
||||
|
||||
$(document).on 'ready page:load', ->
|
||||
today = new Date()
|
||||
tomorrow = new Date(today)
|
||||
tomorrow.setDate(today.getDate() + 1)
|
||||
|
||||
$('.datepicker').datepicker(
|
||||
dateFormat: "yy-mm-dd",
|
||||
maxDate: tomorrow
|
||||
);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//= require 'shared/general-manifest'
|
||||
//= require 'registrar/registrar-bootstrap'
|
||||
//= require 'jquery-ui/datepicker'
|
||||
@import shared/fonts
|
||||
@import shared/general
|
||||
@import nprogress
|
||||
|
|
|
@ -4,6 +4,7 @@ class Registrar::InvoicesController < RegistrarController
|
|||
before_action :set_invoice, only: [:show, :forward, :download_pdf]
|
||||
|
||||
def index
|
||||
params[:q] ||= {}
|
||||
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
||||
@q = invoices.search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
|
|
|
@ -32,6 +32,8 @@ class Invoice < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
before_save -> { self.sum_cache = sum }
|
||||
|
||||
def binded?
|
||||
account_activity.present?
|
||||
end
|
||||
|
|
|
@ -8,6 +8,43 @@
|
|||
currency: current_user.registrar.cash_account.currency)
|
||||
|
||||
%h1= t(:invoices)
|
||||
.row
|
||||
.col-md-12
|
||||
%hr
|
||||
= search_form_for @q, url: [:registrar, :invoices], html: { style: 'margin-bottom: 0;' } do |f|
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:minimum_invoice_no)
|
||||
= f.search_field :number_gteq, class: 'form-control', placeholder: t(:minimum_invoice_no), autocomplete: 'off'
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:maximum_invoice_no)
|
||||
= f.search_field :number_lteq, class: 'form-control', placeholder: t(:maximum_invoice_no), autocomplete: 'off'
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:due_date_after)
|
||||
= f.search_field :due_date_gt, value: params[:q][:due_date_gt], class: 'form-control datepicker', placeholder: t(:due_date_after), autocomplete: 'off'
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:due_date_before)
|
||||
= f.search_field :due_date_lt, value: params[:q][:due_date_lt], class: 'form-control datepicker', placeholder: t(:due_date_before), autocomplete: 'off'
|
||||
.row
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:minimum_total)
|
||||
= f.search_field :sum_cache_gteq, class: 'form-control', placeholder: t(:minimum_total), autocomplete: 'off'
|
||||
.col-md-3
|
||||
.form-group
|
||||
= f.label t(:maximum_total)
|
||||
= f.search_field :sum_cache_lteq, class: 'form-control', placeholder: t(:maximum_total), autocomplete: 'off'
|
||||
.col-md-3{style: 'padding-top: 25px;'}
|
||||
%button.btn.btn-primary
|
||||
|
||||
%span.glyphicon.glyphicon-search
|
||||
|
||||
%button.btn.btn-default.js-reset-form
|
||||
= t(:clear_fields)
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
|
@ -30,11 +67,14 @@
|
|||
- else
|
||||
%td{class: 'text-danger'}= t(:unpaid)
|
||||
|
||||
- if x.cancelled?
|
||||
%td.text-grey= t('cancelled')
|
||||
- else
|
||||
%td= l(x.due_date)
|
||||
%td= l(x.due_date)
|
||||
%td= x.sum
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @invoices
|
||||
|
||||
:coffee
|
||||
$(".js-reset-form").on "click", (e) ->
|
||||
e.preventDefault();
|
||||
window.location = "#{registrar_invoices_path}"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue