mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Invoice filtering in registrar
This commit is contained in:
parent
1f2f483e34
commit
23098add74
13 changed files with 83 additions and 7 deletions
3
Gemfile
3
Gemfile
|
@ -75,6 +75,9 @@ gem 'activerecord-import', '~> 0.7.0' # for inserting dummy data
|
||||||
# for generating pdf
|
# for generating pdf
|
||||||
gem 'pdfkit', '~> 0.6.2'
|
gem 'pdfkit', '~> 0.6.2'
|
||||||
|
|
||||||
|
# for datepicker
|
||||||
|
gem 'jquery-ui-rails', '~> 5.0.3'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# dev tools
|
# dev tools
|
||||||
gem 'spring', '~> 1.3.3'
|
gem 'spring', '~> 1.3.3'
|
||||||
|
|
|
@ -235,6 +235,8 @@ GEM
|
||||||
rails-dom-testing (~> 1.0)
|
rails-dom-testing (~> 1.0)
|
||||||
railties (>= 4.2.0)
|
railties (>= 4.2.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
|
jquery-ui-rails (5.0.3)
|
||||||
|
railties (>= 3.2.16)
|
||||||
jquery-validation-rails (1.13.1)
|
jquery-validation-rails (1.13.1)
|
||||||
railties (>= 3.2, < 5.0)
|
railties (>= 3.2, < 5.0)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
|
@ -520,6 +522,7 @@ DEPENDENCIES
|
||||||
iso8601 (~> 0.8.2)
|
iso8601 (~> 0.8.2)
|
||||||
jbuilder (~> 2.2.6)
|
jbuilder (~> 2.2.6)
|
||||||
jquery-rails (~> 4.0.3)
|
jquery-rails (~> 4.0.3)
|
||||||
|
jquery-ui-rails (~> 5.0.3)
|
||||||
jquery-validation-rails (~> 1.13.1)
|
jquery-validation-rails (~> 1.13.1)
|
||||||
kaminari (~> 0.16.3)
|
kaminari (~> 0.16.3)
|
||||||
launchy (~> 2.4.3)
|
launchy (~> 2.4.3)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#= require jquery.nested_attributes
|
#= require jquery.nested_attributes
|
||||||
#= require selectize
|
#= require selectize
|
||||||
#= require shared/jquery.validate.bootstrap
|
#= require shared/jquery.validate.bootstrap
|
||||||
|
#= require jquery-ui/datepicker
|
||||||
#= require shared/general
|
#= require shared/general
|
||||||
#= require admin/application
|
#= require admin/application
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
#= require bootstrap-sprockets
|
#= require bootstrap-sprockets
|
||||||
#= require jquery.nested_attributes
|
#= require jquery.nested_attributes
|
||||||
#= require shared/jquery.validate.bootstrap
|
#= require shared/jquery.validate.bootstrap
|
||||||
|
#= require jquery-ui/datepicker
|
||||||
#= require shared/general
|
#= require shared/general
|
||||||
#= require registrar/application
|
#= require registrar/application
|
||||||
|
|
|
@ -9,3 +9,13 @@
|
||||||
$('#flash').find('div').addClass('bg-danger')
|
$('#flash').find('div').addClass('bg-danger')
|
||||||
$('#flash').find('div').html(msg)
|
$('#flash').find('div').html(msg)
|
||||||
$('#flash').show()
|
$('#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 'shared/general-manifest'
|
||||||
//= require 'registrar/registrar-bootstrap'
|
//= require 'registrar/registrar-bootstrap'
|
||||||
|
//= require 'jquery-ui/datepicker'
|
||||||
@import shared/fonts
|
@import shared/fonts
|
||||||
@import shared/general
|
@import shared/general
|
||||||
@import nprogress
|
@import nprogress
|
||||||
|
|
|
@ -4,6 +4,7 @@ class Registrar::InvoicesController < RegistrarController
|
||||||
before_action :set_invoice, only: [:show, :forward, :download_pdf]
|
before_action :set_invoice, only: [:show, :forward, :download_pdf]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
params[:q] ||= {}
|
||||||
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
||||||
@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?
|
||||||
|
|
|
@ -32,6 +32,8 @@ class Invoice < ActiveRecord::Base
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before_save -> { self.sum_cache = sum }
|
||||||
|
|
||||||
def binded?
|
def binded?
|
||||||
account_activity.present?
|
account_activity.present?
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,43 @@
|
||||||
currency: current_user.registrar.cash_account.currency)
|
currency: current_user.registrar.cash_account.currency)
|
||||||
|
|
||||||
%h1= t(:invoices)
|
%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
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
@ -30,11 +67,14 @@
|
||||||
- else
|
- else
|
||||||
%td{class: 'text-danger'}= t(:unpaid)
|
%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
|
%td= x.sum
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= paginate @invoices
|
= paginate @invoices
|
||||||
|
|
||||||
|
:coffee
|
||||||
|
$(".js-reset-form").on "click", (e) ->
|
||||||
|
e.preventDefault();
|
||||||
|
window.location = "#{registrar_invoices_path}"
|
||||||
|
|
||||||
|
|
|
@ -740,3 +740,9 @@ en:
|
||||||
cannot_cancel_paid_invoice: 'Cannot cancel paid invoice'
|
cannot_cancel_paid_invoice: 'Cannot cancel paid invoice'
|
||||||
cannot_cancel_cancelled_invoice: 'Cannot cancel cancelled invoice'
|
cannot_cancel_cancelled_invoice: 'Cannot cancel cancelled invoice'
|
||||||
cannot_bind_cancelled_invoice: 'Cannot bind cancelled invoice'
|
cannot_bind_cancelled_invoice: 'Cannot bind cancelled invoice'
|
||||||
|
minimum_invoice_no: 'Miminum invoice no'
|
||||||
|
maximum_invoice_no: 'Maximum invoice no'
|
||||||
|
due_date_after: 'Due date after'
|
||||||
|
due_date_before: 'Due date before'
|
||||||
|
minimum_total: 'Minimum total'
|
||||||
|
maximum_total: 'Maximum total'
|
||||||
|
|
6
db/migrate/20150428075052_add_sum_cache_to_invoice.rb
Normal file
6
db/migrate/20150428075052_add_sum_cache_to_invoice.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class AddSumCacheToInvoice < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :invoices, :sum_cache, :decimal
|
||||||
|
Invoice.all.each(&:save)
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150427073517) do
|
ActiveRecord::Schema.define(version: 20150428075052) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -368,6 +368,7 @@ ActiveRecord::Schema.define(version: 20150427073517) do
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
t.integer "number"
|
t.integer "number"
|
||||||
t.datetime "cancelled_at"
|
t.datetime "cancelled_at"
|
||||||
|
t.decimal "sum_cache"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree
|
add_index "invoices", ["buyer_id"], name: "index_invoices_on_buyer_id", using: :btree
|
||||||
|
|
|
@ -72,7 +72,8 @@ describe Invoice do
|
||||||
|
|
||||||
it 'should cancel overdue invoices' do
|
it 'should cancel overdue invoices' do
|
||||||
Fabricate(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 1.days)
|
Fabricate(:invoice, created_at: Time.zone.now - 35.days, due_date: Time.zone.now - 1.days)
|
||||||
Invoice.cancel_overdue_invoices.should == 1
|
Invoice.cancel_overdue_invoices
|
||||||
|
Invoice.where(cancelled_at: nil).count.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# it 'should have one version' do
|
# it 'should have one version' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue