mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 18:56:05 +02:00
Merge pull request #61 from internetee/107279984-credit_balance
107279984 credit balance
This commit is contained in:
commit
8e79e67d9d
6 changed files with 49 additions and 5 deletions
|
@ -12,11 +12,27 @@ class Admin::AccountActivitiesController < AdminController
|
||||||
logger.warn('Invalid date')
|
logger.warn('Invalid date')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
balance_params = params[:q].deep_dup
|
||||||
|
|
||||||
|
if balance_params[:created_at_gteq]
|
||||||
|
balance_params.delete('created_at_gteq')
|
||||||
|
end
|
||||||
|
|
||||||
@q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q])
|
@q = AccountActivity.includes(:invoice, account: :registrar).search(params[:q])
|
||||||
|
@b = AccountActivity.search(balance_params)
|
||||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||||
|
|
||||||
|
@account_activities = @q.result.page(params[:page]).per(params[:results_per_page])
|
||||||
|
sort = @account_activities.orders.map(&:to_sql).join(",")
|
||||||
|
|
||||||
|
if params[:page] && params[:page].to_i > 1
|
||||||
|
@sum = @q.result.reorder(sort).limit(@account_activities.offset_value) + @b.result.where.not(id: @q.result.map(&:id))
|
||||||
|
else
|
||||||
|
@sum = @b.result.where.not(id: @q.result.map(&:id))
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { @account_activities = @q.result.page(params[:page]) }
|
format.html
|
||||||
format.csv do
|
format.csv do
|
||||||
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
send_data @q.result.to_csv, filename: "account_activities_#{Time.zone.now.to_formatted_s(:number)}.csv"
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Admin::RegistrarsController < AdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = Registrar.ordered.search(params[:q])
|
@q = Registrar.joins(:accounts).ordered.search(params[:q])
|
||||||
@registrars = @q.result.page(params[:page])
|
@registrars = @q.result.page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,24 @@
|
||||||
.form-group
|
.form-group
|
||||||
= f.label t(:receipt_date_until)
|
= f.label t(:receipt_date_until)
|
||||||
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:receipt_date_until), autocomplete: 'off'
|
= f.search_field :created_at_lteq, value: params[:q][:created_at_lteq], class: 'form-control datepicker', placeholder: t(:receipt_date_until), autocomplete: 'off'
|
||||||
.col-md-6{style: 'padding-top: 25px;'}
|
.col-md-3
|
||||||
|
.form-group
|
||||||
|
= label_tag t(:results_per_page)
|
||||||
|
= text_field_tag :results_per_page, params[:results_per_page], class: 'form-control', placeholder: t(:results_per_page)
|
||||||
|
.col-md-3{style: 'padding-top: 25px;'}
|
||||||
%button.btn.btn-default.search
|
%button.btn.btn-default.search
|
||||||
|
|
||||||
%span.glyphicon.glyphicon-search
|
%span.glyphicon.glyphicon-search
|
||||||
|
|
||||||
%button.btn.btn-default.js-reset-form
|
%button.btn.btn-default.js-reset-form
|
||||||
= t(:clear_fields)
|
= t(:clear_fields)
|
||||||
|
.row
|
||||||
|
.col-md-3
|
||||||
|
.col-md-3
|
||||||
|
.col-md-2
|
||||||
|
.col-md-4{class: 'text-right'}
|
||||||
|
= t(:starting_balance) + " #{@sum.to_a.map(&:sum).sum.to_f} EUR"
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
@ -55,6 +66,7 @@
|
||||||
%th{class: 'col-xs-2'}
|
%th{class: 'col-xs-2'}
|
||||||
= sort_link(@q, 'sum')
|
= sort_link(@q, 'sum')
|
||||||
%tbody
|
%tbody
|
||||||
|
-total = @sum.to_a.map(&:sum).sum.to_f
|
||||||
- @account_activities.each do |x|
|
- @account_activities.each do |x|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar))
|
%td= link_to(x.account.registrar.try(:code), admin_registrar_path(x.account.registrar))
|
||||||
|
@ -63,7 +75,15 @@
|
||||||
%td= l(x.created_at)
|
%td= l(x.created_at)
|
||||||
- c = x.sum > 0.0 ? 'text-success' : 'text-danger'
|
- c = x.sum > 0.0 ? 'text-success' : 'text-danger'
|
||||||
- s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}"
|
- s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}"
|
||||||
|
-total += x.sum
|
||||||
%td{class: c}= s
|
%td{class: c}= s
|
||||||
|
- if @account_activities.count > 0
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%td
|
||||||
|
%td
|
||||||
|
%td{class: 'text-right'}= t(:total)
|
||||||
|
%td{class: total > 0 ? 'text-success' : 'text-danger'}= total > 0 ? "+#{total} EUR" : "#{total} EUR"
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= paginate @account_activities
|
= paginate @account_activities
|
||||||
|
|
|
@ -8,15 +8,18 @@
|
||||||
%table.table.table-hover.table-bordered.table-condensed
|
%table.table.table-hover.table-bordered.table-condensed
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th{class: 'col-xs-6'}
|
%th{class: 'col-xs-4'}
|
||||||
= sort_link(@q, 'name')
|
= sort_link(@q, 'name')
|
||||||
%th{class: 'col-xs-6'}
|
%th{class: 'col-xs-4'}
|
||||||
= sort_link(@q, 'reg_no', t(:reg_no))
|
= sort_link(@q, 'reg_no', t(:reg_no))
|
||||||
|
%th{class: 'col-xs-4'}
|
||||||
|
= t(:credit_balance)
|
||||||
%tbody
|
%tbody
|
||||||
- @registrars.each do |x|
|
- @registrars.each do |x|
|
||||||
%tr
|
%tr
|
||||||
%td= link_to(x, [:admin, x])
|
%td= link_to(x, [:admin, x])
|
||||||
%td= x.reg_no
|
%td= x.reg_no
|
||||||
|
%td= "#{x.balance}"
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
= paginate @registrars
|
= paginate @registrars
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
%dt= t(:id)
|
%dt= t(:id)
|
||||||
%dd= @registrar.code
|
%dd= @registrar.code
|
||||||
|
|
||||||
|
%dt= t(:credit_balance)
|
||||||
|
%dd= @registrar.balance
|
||||||
|
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
|
|
|
@ -352,6 +352,8 @@ en:
|
||||||
status: 'Status'
|
status: 'Status'
|
||||||
eedirekt: 'EEDirekt'
|
eedirekt: 'EEDirekt'
|
||||||
contact: 'Contact'
|
contact: 'Contact'
|
||||||
|
credit_balance: 'Credit balance'
|
||||||
|
starting_balance: 'Starting balance'
|
||||||
|
|
||||||
domain_transfer_requested: 'Domain transfer requested!'
|
domain_transfer_requested: 'Domain transfer requested!'
|
||||||
domain_transfer_approved: 'Domain transfer approved!'
|
domain_transfer_approved: 'Domain transfer approved!'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue