mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 09:43:36 +02:00
Add account activity to registrar
This commit is contained in:
parent
f2f2e42608
commit
32073ca862
15 changed files with 117 additions and 32 deletions
21
app/controllers/registrar/account_activities_controller.rb
Normal file
21
app/controllers/registrar/account_activities_controller.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
class Registrar::AccountActivitiesController < RegistrarController
|
||||
load_and_authorize_resource
|
||||
|
||||
# before_action :set_invoice, only: [:show]
|
||||
|
||||
def index
|
||||
account = current_user.registrar.cash_account
|
||||
@q = account.activities.search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@account_activities = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_invoice
|
||||
@invoice = Invoice.find(params[:id])
|
||||
end
|
||||
end
|
|
@ -4,7 +4,10 @@ class Registrar::InvoicesController < RegistrarController
|
|||
before_action :set_invoice, only: [:show]
|
||||
|
||||
def index
|
||||
@invoices = current_user.registrar.invoices.includes(:invoice_items).order(id: :desc)
|
||||
invoices = current_user.registrar.invoices.includes(:invoice_items, :account_activity)
|
||||
@q = invoices.search(params[:q])
|
||||
@q.sorts = 'id desc' if @q.sorts.empty?
|
||||
@invoices = @q.result.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -47,6 +47,7 @@ class Ability
|
|||
|
||||
def registrar
|
||||
can :manage, Invoice
|
||||
can :read, AccountActivity
|
||||
can :view, :registrar_dashboard
|
||||
can :delete, :registrar_poll
|
||||
can :manage, :registrar_xml_console
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
class Account < ActiveRecord::Base
|
||||
belongs_to :registrar
|
||||
has_many :account_activities
|
||||
|
||||
CASH = 'cash'
|
||||
|
||||
def activities
|
||||
account_activities
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,7 +37,8 @@ class BankTransaction < ActiveRecord::Base
|
|||
account: registrar.cash_account,
|
||||
invoice: invoice,
|
||||
sum: sum,
|
||||
currency: currency
|
||||
currency: currency,
|
||||
description: description
|
||||
)
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
|
|
|
@ -13,9 +13,8 @@ class Invoice < ActiveRecord::Base
|
|||
account_activity.present?
|
||||
end
|
||||
|
||||
def paid_at
|
||||
# TODO: Cache this?
|
||||
account_activity.try(:bank_transaction).try(:paid_at)
|
||||
def receipt_date
|
||||
account_activity.try(:created_at)
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
34
app/views/registrar/account_activities/index.haml
Normal file
34
app/views/registrar/account_activities/index.haml
Normal file
|
@ -0,0 +1,34 @@
|
|||
.row
|
||||
.col-sm-6
|
||||
%h1.text-center-xs
|
||||
= t('account_activity')
|
||||
.col-sm-6
|
||||
%h1.text-right.text-center-xs
|
||||
= link_to(t('back_to_billing'), registrar_invoices_path, class: 'btn btn-default')
|
||||
|
||||
%hr
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-5'}= t('description')
|
||||
%th{class: 'col-xs-3'}= t('receipt_date')
|
||||
%th{class: 'col-xs-2'}= t('invoice')
|
||||
%th{class: 'col-xs-2'}= t('sum')
|
||||
%tbody
|
||||
- @account_activities.each do |x|
|
||||
%tr
|
||||
%td= x.description.present? ? x.description : '-'
|
||||
%td= l(x.created_at)
|
||||
- if x.invoice
|
||||
%td= link_to(x.invoice, [:registrar, x.invoice])
|
||||
- else
|
||||
%td \-
|
||||
- c = x.sum > 0.0 ? 'text-success' : 'text-danger'
|
||||
- s = x.sum > 0.0 ? "+#{x.sum} #{x.currency}" : "#{x.sum} #{x.currency}"
|
||||
%td{class: c}= s
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @account_activities
|
|
@ -1,4 +1,11 @@
|
|||
%h1= t(:add_deposit)
|
||||
.row
|
||||
.col-sm-6
|
||||
%h1.text-center-xs
|
||||
= t(:add_deposit)
|
||||
.col-sm-6
|
||||
%h1.text-right.text-center-xs
|
||||
= link_to(t('back_to_billing'), registrar_invoices_path, class: 'btn btn-default')
|
||||
|
||||
%hr
|
||||
= form_for([:registrar, @deposit], method: :post) do |f|
|
||||
.row
|
||||
|
@ -18,5 +25,3 @@
|
|||
.row
|
||||
.col-md-12.text-right
|
||||
= button_tag(t(:add), class: 'btn btn-primary')
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
= t('your_account')
|
||||
.col-sm-6
|
||||
%h1.text-right.text-center-xs
|
||||
= link_to(t('account_activity'), registrar_account_activities_path, class: 'btn btn-default')
|
||||
= link_to(t('add_deposit'), new_registrar_deposit_path, class: 'btn btn-default')
|
||||
|
||||
%hr
|
||||
|
@ -11,21 +12,26 @@
|
|||
|
||||
%h1= t('invoices')
|
||||
%hr
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-3'}= t('invoice')
|
||||
%th{class: 'col-xs-3'}= t('paid_at')
|
||||
%th{class: 'col-xs-3'}= t('due_date')
|
||||
%th{class: 'col-xs-3'}= t('total')
|
||||
%tbody
|
||||
- @invoices.each do |x|
|
||||
%tr
|
||||
%td= link_to(t('invoice_no', no: x.id), [:registrar, x])
|
||||
- if x.paid_at
|
||||
%td= l(x.paid_at)
|
||||
- else
|
||||
%td{class: 'text-danger'}= t('unpaid')
|
||||
%td= l(x.due_date)
|
||||
%td= x.sum
|
||||
.row
|
||||
.col-md-12
|
||||
.table-responsive
|
||||
%table.table.table-hover.table-condensed
|
||||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-3'}= t('invoice')
|
||||
%th{class: 'col-xs-3'}= t('receipt_date')
|
||||
%th{class: 'col-xs-3'}= t('due_date')
|
||||
%th{class: 'col-xs-3'}= t('total')
|
||||
%tbody
|
||||
- @invoices.each do |x|
|
||||
%tr
|
||||
%td= link_to(t('invoice_no', no: x.id), [:registrar, x])
|
||||
- if x.receipt_date
|
||||
%td= l(x.receipt_date)
|
||||
- else
|
||||
%td{class: 'text-danger'}= t('unpaid')
|
||||
%td= l(x.due_date)
|
||||
%td= x.sum
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @invoices
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
%dt= t('due_date')
|
||||
%dd= l(@invoice.due_date)
|
||||
|
||||
%dt= t('paid_at')
|
||||
- if @invoice.paid_at
|
||||
%dd= l(@invoice.paid_at)
|
||||
%dt= t('receipt_date')
|
||||
- if @invoice.binded?
|
||||
%dd= l(@invoice.receipt_date)
|
||||
- else
|
||||
%dd{class: 'text-danger'}= t('unpaid')
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
= t('invoice_no', no: @invoice.id)
|
||||
.col-sm-6
|
||||
%h1.text-right.text-center-xs
|
||||
= link_to(t('back_to_billing'), registrar_invoices_path, class: 'btn btn-default')
|
||||
= link_to(t('back'), :back, class: 'btn btn-default')
|
||||
%hr
|
||||
.row
|
||||
.col-md-6= render 'registrar/invoices/partials/details'
|
||||
|
|
|
@ -652,7 +652,7 @@ en:
|
|||
prepayment: 'Prepayment'
|
||||
vat: 'VAT (%{vat_prc}%)'
|
||||
unpaid: 'Unpaid'
|
||||
your_current_account_balance_is: 'Your current account balance is %{balance} %{currency]'
|
||||
your_current_account_balance_is: 'Your current account balance is %{balance} %{currency}'
|
||||
billing: 'Billing'
|
||||
your_account: 'Your account'
|
||||
pay_by_bank_link: 'Pay by bank link'
|
||||
|
@ -711,3 +711,5 @@ en:
|
|||
domain_tech_contact_help:
|
||||
<b>The domain name server</b>
|
||||
is a computer that saves and forwards via a general-access data communications network such data that is connected with the domain name and corresponding IP addresses. Your IT helpdesk or Internet service provider will have the necessary information about the domain name servers.
|
||||
account_activity: 'Account activity'
|
||||
receipt_date: 'Receipt date'
|
||||
|
|
|
@ -22,6 +22,7 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :invoices
|
||||
resources :deposits
|
||||
resources :account_activities
|
||||
|
||||
devise_scope :user do
|
||||
get 'login' => 'sessions#login'
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddDescriptionToAccountActivity < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :account_activities, :description, :string
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150416080828) do
|
||||
ActiveRecord::Schema.define(version: 20150416092026) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -24,6 +24,7 @@ ActiveRecord::Schema.define(version: 20150416080828) do
|
|||
t.integer "bank_transaction_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "description"
|
||||
end
|
||||
|
||||
create_table "accounts", force: :cascade do |t|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue