Merge branch 'master' into remove-unused-cron-task

This commit is contained in:
Artur Beljajev 2018-04-13 17:55:29 +03:00
commit b1209f7078
121 changed files with 1401 additions and 814 deletions

View file

@ -9,6 +9,7 @@
#= require select2
#= require jquery.doubleScroll
#= require datepicker
#= require spell_check
#= require admin/application
#= require admin/app
#= require_tree ./admin

View file

@ -4,4 +4,5 @@
#= require jquery-ui/datepicker
#= require select2
#= require datepicker
#= require spell_check
#= require shared/general

View file

@ -6,6 +6,7 @@
#= require jquery-ui/datepicker
#= require select2
#= require datepicker
#= require spell_check
#= require shared/general
#= require registrar/autocomplete
#= require registrar/application

View file

@ -0,0 +1,12 @@
(function() {
function disableSpellCheck() {
let selector = 'input[type=text], textarea';
let textFields = document.querySelectorAll(selector);
for (let field of textFields) {
field.spellcheck = false;
}
}
disableSpellCheck();
})();

View file

@ -24,7 +24,7 @@ module Admin
@invoice = Invoice.find_by(id: params[:invoice_id])
@bank_transaction = @bank_statement.bank_transactions.build(
description: @invoice.to_s,
sum: @invoice.sum,
sum: @invoice.total,
reference_no: @invoice.reference_no,
paid_at: Time.zone.now.to_date,
currency: 'EUR'

View file

@ -19,17 +19,15 @@ module Admin
def create
@registrar = Registrar.new(registrar_params)
begin
if @registrar.valid?
@registrar.transaction do
@registrar.save!
@registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
end
flash[:notice] = t('.created')
redirect_to [:admin, @registrar]
rescue ActiveRecord::RecordInvalid
flash.now[:alert] = t('.not_created')
render 'new'
redirect_to [:admin, @registrar], notice: t('.created')
else
render :new
end
end
@ -38,21 +36,19 @@ module Admin
def update
if @registrar.update(registrar_params)
flash[:notice] = t('.updated')
redirect_to [:admin, @registrar]
redirect_to [:admin, @registrar], notice: t('.updated')
else
flash.now[:alert] = t('.not_updated')
render 'edit'
render :edit
end
end
def destroy
if @registrar.destroy
flash[:notice] = I18n.t('registrar_deleted')
redirect_to admin_registrars_path
flash[:notice] = t('.deleted')
redirect_to admin_registrars_url
else
flash.now[:alert] = I18n.t('failed_to_delete_registrar')
render 'show'
flash[:alert] = @registrar.errors.full_messages.first
redirect_to admin_registrar_url(@registrar)
end
end
@ -65,7 +61,6 @@ module Admin
def registrar_params
params.require(:registrar).permit(:name,
:reg_no,
:vat_no,
:street,
:city,
:state,
@ -74,10 +69,12 @@ module Admin
:email,
:phone,
:website,
:billing_email,
:code,
:test_registrar,
:vat_no,
:vat_rate,
:accounting_customer_code,
:billing_email,
:language)
end
end

View file

@ -55,8 +55,8 @@ class Registrar
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]
params[:q][:total_gteq].gsub!(',', '.') if params[:q][:total_gteq]
params[:q][:total_lteq].gsub!(',', '.') if params[:q][:total_lteq]
ca_cache = params[:q][:due_date_lteq]
begin

View file

@ -3,7 +3,7 @@ class Registrar
protect_from_forgery except: :back
skip_authorization_check # actually anyone can pay, no problems at all
skip_before_action :authenticate_user!, :check_ip, only: [:back]
skip_before_action :authenticate_user!, :check_ip_restriction, only: [:back]
before_action :check_bank
# to handle existing model we should

View file

@ -29,7 +29,7 @@ class BankLink
hash["VK_VERSION"] = "008"
hash["VK_SND_ID"] = ENV["payments_#{type}_seller_account"]
hash["VK_STAMP"] = invoice.number
hash["VK_AMOUNT"] = number_with_precision(invoice.sum_cache, :precision => 2, :separator => ".")
hash["VK_AMOUNT"] = number_with_precision(invoice.total, :precision => 2, :separator => ".")
hash["VK_CURR"] = invoice.currency
hash["VK_REF"] = ""
hash["VK_MSG"] = invoice.order
@ -140,7 +140,7 @@ class BankLink
def validate_amount
source = number_with_precision(BigDecimal.new(params["VK_AMOUNT"].to_s), precision: 2, separator: ".")
target = number_with_precision(invoice.sum_cache, precision: 2, separator: ".")
target = number_with_precision(invoice.total, precision: 2, separator: ".")
source == target
end

View file

@ -47,7 +47,7 @@ class BankTransaction < ActiveRecord::Base
return if invoice.binded?
return if invoice.cancelled?
return if invoice.sum != sum
return if invoice.total != sum
create_activity(registrar, invoice)
end
# rubocop: enable Metrics/PerceivedComplexity
@ -76,7 +76,7 @@ class BankTransaction < ActiveRecord::Base
return
end
if invoice.sum != sum
if invoice.total != sum
errors.add(:base, I18n.t('invoice_and_transaction_sums_do_not_match'))
return
end
@ -88,7 +88,7 @@ class BankTransaction < ActiveRecord::Base
create_account_activity(
account: registrar.cash_account,
invoice: invoice,
sum: invoice.sum_without_vat,
sum: invoice.subtotal,
currency: currency,
description: description,
activity_type: AccountActivity::ADD_CREDIT

View file

@ -3,7 +3,7 @@ class Directo < ActiveRecord::Base
belongs_to :item, polymorphic: true
def self.send_receipts
new_trans = Invoice.where(invoice_type: "DEB", in_directo: false).where(cancelled_at: nil)
new_trans = Invoice.where(in_directo: false).where(cancelled_at: nil)
total = new_trans.count
counter = 0
Rails.logger.info("[DIRECTO] Will try to send #{total} invoices")
@ -15,7 +15,7 @@ class Directo < ActiveRecord::Base
group.each do |invoice|
if invoice.account_activity.nil? || invoice.account_activity.bank_transaction.nil? ||
invoice.account_activity.bank_transaction.sum.nil? || invoice.account_activity.bank_transaction.sum != invoice.sum_cache
invoice.account_activity.bank_transaction.sum.nil? || invoice.account_activity.bank_transaction.sum != invoice.total
Rails.logger.info("[DIRECTO] Invoice #{invoice.number} has been skipped")
next
end
@ -29,12 +29,14 @@ class Directo < ActiveRecord::Base
"InvoiceDate" => invoice.created_at.strftime("%Y-%m-%dT%H:%M:%S"),
"PaymentTerm" => Setting.directo_receipt_payment_term,
"Currency" => invoice.currency,
"CustomerCode"=> invoice.buyer.accounting_customer_code
"CustomerCode"=> invoice.buyer.accounting_customer_code,
'TotalVAT' => ActionController::Base.helpers.number_with_precision(invoice.vat_amount, precision: 2, separator: '.')
){
xml.line(
"ProductID" => Setting.directo_receipt_product_name,
"Quantity" => 1,
"UnitPriceWoVAT" => ActionController::Base.helpers.number_with_precision(invoice.sum_cache/(1+invoice.vat_prc), precision: 2, separator: "."),
"UnitPriceWoVAT" => ActionController::Base.helpers.number_with_precision(invoice.subtotal, precision: 2, separator: '.'),
'VATCode' => invoice.buyer_vat_no,
"ProductName" => invoice.order
)
}

View file

@ -18,7 +18,7 @@ class Epp::Domain < Domain
after_validation :validate_contacts
def validate_contacts
return true if is_renewal || is_transfer
return true if is_transfer
ok = true
active_admins = admin_domain_contacts.select { |x| !x.marked_for_destruction? }

View file

@ -27,12 +27,18 @@ class Invoice < ActiveRecord::Base
attr_accessor :billing_email
validates :billing_email, email_format: { message: :invalid }, allow_blank: true
validates :invoice_type, :due_date, :currency, :seller_name,
:seller_iban, :buyer_name, :invoice_items, :vat_prc, presence: true
validates :due_date, :currency, :seller_name,
:seller_iban, :buyer_name, :invoice_items, presence: true
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
allow_nil: true
before_create :set_invoice_number, :check_vat
before_create :set_invoice_number
before_create :apply_default_vat_rate, unless: :vat_rate?
before_create :calculate_total, unless: :total?
before_create :apply_default_buyer_vat_no, unless: :buyer_vat_no?
before_save :check_vat
attribute :vat_rate, ::Type::VATRate.new
attr_readonly :vat_rate
def set_invoice_number
last_no = Invoice.order(number: :desc).where('number IS NOT NULL').limit(1).pluck(:number).first
@ -50,14 +56,6 @@ class Invoice < ActiveRecord::Base
false
end
def check_vat
if buyer.country_code != 'EE' && buyer.vat_no.present?
self.vat_prc = 0
end
end
before_save -> { self.sum_cache = sum }
class << self
def cancel_overdue_invoices
STDOUT << "#{Time.zone.now.utc} - Cancelling overdue invoices\n" unless Rails.env.test?
@ -106,12 +104,12 @@ class Invoice < ActiveRecord::Base
def buyer_country
Country.new(buyer_country_code)
end
# order is used for directo/banklink description
def order
"Order nr. #{number}"
end
def pdf(html)
kit = PDFKit.new(html)
kit.to_pdf
@ -152,15 +150,31 @@ class Invoice < ActiveRecord::Base
invoice_items
end
def sum_without_vat
(items.map(&:item_sum_without_vat).sum).round(2)
def subtotal
invoice_items.map(&:item_sum_without_vat).reduce(:+)
end
def vat
(sum_without_vat * vat_prc).round(2)
def vat_amount
return 0 unless vat_rate
subtotal * vat_rate / 100
end
def sum
(sum_without_vat + vat).round(2)
def total
calculate_total unless total?
read_attribute(:total)
end
private
def apply_default_vat_rate
self.vat_rate = buyer.effective_vat_rate
end
def apply_default_buyer_vat_no
self.buyer_vat_no = buyer.vat_no
end
def calculate_total
self.total = subtotal + vat_amount
end
end

View file

@ -6,7 +6,7 @@ class Registrar < ActiveRecord::Base
has_many :api_users, dependent: :restrict_with_error
has_many :messages
has_many :invoices, foreign_key: 'buyer_id'
has_many :accounts
has_many :accounts, dependent: :destroy
has_many :nameservers, through: :domains
has_many :whois_records
has_many :white_ips, dependent: :destroy
@ -17,37 +17,19 @@ class Registrar < ActiveRecord::Base
validates :name, :reference_no, :code, uniqueness: true
validates :accounting_customer_code, presence: true
validates :language, presence: true
validate :forbidden_codes
validate :forbid_special_code
validates :vat_rate, presence: true, if: 'foreign_vat_payer? && vat_no.blank?'
validates :vat_rate, absence: true, if: :home_vat_payer?
validates :vat_rate, absence: true, if: 'foreign_vat_payer? && vat_no?'
validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 },
allow_nil: true
validate :forbid_special_code
attribute :vat_rate, ::Type::VATRate.new
after_initialize :set_defaults
def forbidden_codes
return true unless ['CID'].include? code
errors.add(:code, I18n.t(:forbidden_code))
false
end
before_validation :generate_iso_11649_reference_no
def generate_iso_11649_reference_no
return if reference_no.present?
loop do
base = nil
loop do
base = SecureRandom.random_number.to_s.last(8)
break if base.to_i != 0 && base.length == 8
end
control_base = (base + '2715' + '00').to_i
reminder = control_base % 97
check_digits = 98 - reminder
check_digits = check_digits < 10 ? "0#{check_digits}" : check_digits.to_s
self.reference_no = "RF#{check_digits}#{base}"
break unless self.class.exists?(reference_no: reference_no)
end
end
validates :email, :billing_email,
email_format: { message: :invalid },
@ -76,12 +58,10 @@ class Registrar < ActiveRecord::Base
# rubocop:disable Metrics/AbcSize
def issue_prepayment_invoice(amount, description = nil)
invoices.create(
invoice_type: 'DEB',
due_date: (Time.zone.now.to_date + Setting.days_to_keep_invoices_active.days).end_of_day,
payment_term: 'prepayment',
description: description,
currency: 'EUR',
vat_prc: Setting.registry_vat_prc,
seller_name: Setting.registry_juridical_name,
seller_reg_no: Setting.registry_reg_no,
seller_iban: Setting.registry_iban,
@ -97,7 +77,7 @@ class Registrar < ActiveRecord::Base
seller_url: Setting.registry_url,
seller_email: Setting.registry_email,
seller_contact_name: Setting.registry_invoice_contact,
buyer_id: id,
buyer: self,
buyer_name: name,
buyer_reg_no: reg_no,
buyer_country_code: country_code,
@ -132,11 +112,6 @@ class Registrar < ActiveRecord::Base
cash_account.account_activities.create!(args)
end
def credit!(args)
args[:currency] = 'EUR'
cash_account.account_activities.create!(args)
end
def address
[street, city, state, zip].reject(&:blank?).compact.join(', ')
end
@ -172,9 +147,50 @@ class Registrar < ActiveRecord::Base
end
end
def effective_vat_rate
if home_vat_payer?
Registry.instance.vat_rate
else
vat_rate
end
end
private
def set_defaults
self.language = Setting.default_language unless language
end
def forbid_special_code
errors.add(:code, :forbidden) if code == 'CID'
end
def generate_iso_11649_reference_no
return if reference_no.present?
loop do
base = nil
loop do
base = SecureRandom.random_number.to_s.last(8)
break if base.to_i != 0 && base.length == 8
end
control_base = (base + '2715' + '00').to_i
reminder = control_base % 97
check_digits = 98 - reminder
check_digits = check_digits < 10 ? "0#{check_digits}" : check_digits.to_s
self.reference_no = "RF#{check_digits}#{base}"
break unless self.class.exists?(reference_no: reference_no)
end
end
def home_vat_payer?
country == Registry.instance.legal_address_country
end
def foreign_vat_payer?
!home_vat_payer?
end
end

11
app/models/registry.rb Normal file
View file

@ -0,0 +1,11 @@
class Registry
include Singleton
def vat_rate
Setting.registry_vat_prc.to_d * 100
end
def legal_address_country
Country.new(Setting.registry_country_code)
end
end

View file

@ -0,0 +1,11 @@
module Type
class VATRate < ActiveRecord::Type::Decimal
def type_cast_from_database(value)
super * 100 if value
end
def type_cast_for_database(value)
super / 100.0 if value
end
end
end

View file

@ -41,7 +41,7 @@
%dt= t(:currency)
%dd= @bank_transaction.currency
%dt= t(:reference_no)
%dt= BankTransaction.human_attribute_name :reference_no
%dd= @bank_transaction.reference_no
%dt= t(:paid_at)

View file

@ -37,7 +37,7 @@
= f.email_field :bcc, class: 'form-control'
.form-group
.col-md-12
= f.label :body, t(:html_body)
= f.label :body, t('admin.mail_templates.html_body')
= liquid_help
.col-md-12
= f.text_area(:body, class: 'form-control', size: '15x15')
@ -48,7 +48,7 @@
.col-md-12
= f.text_area(:text_body, class: 'form-control', size: '15x15')
%hr
%hr
.row
.col-md-12.text-right
= button_tag(t(:save), class: 'btn btn-primary')

View file

@ -1,3 +1,3 @@
= render 'shared/title', name: t(:new_mail_template)
= render 'shared/title', name: t('admin.mail_templates.new_mail_template')
= render 'form', mail_template: @mail_template

View file

@ -0,0 +1,20 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Registrar.human_attribute_name :vat_no %></dt>
<dd><%= registrar.vat_no %></dd>
<dt><%= Registrar.human_attribute_name :vat_rate %></dt>
<dd><%= number_to_percentage(registrar.vat_rate, precision: 1) %></dd>
<dt><%= Registrar.human_attribute_name :accounting_customer_code %></dt>
<dd><%= registrar.accounting_customer_code %></dd>
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
<dd><%= registrar.billing_email %></dd>
</dl>
</div>
</div>

View file

@ -0,0 +1,24 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= t(:country) %></dt>
<dd><%= @registrar.country %></dd>
<dt><%= t(:address) %></dt>
<dd><%= @registrar.address %></dd>
<dt><%= t(:contact_phone) %></dt>
<dd><%= @registrar.phone %></dd>
<dt><%= t(:contact_email) %></dt>
<dd><%= @registrar.email %></dd>
<dt><%= Registrar.human_attribute_name :billing_email %></dt>
<dd><%= @registrar.billing_email %></dd>
</dl>
</div>
</div>

View file

@ -0,0 +1,27 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt><%= Registrar.human_attribute_name :name %></dt>
<dd><%= registrar.name %></dd>
<dt><%= Registrar.human_attribute_name :reg_no %></dt>
<dd><%= registrar.reg_no %></dd>
<dt><%= Registrar.human_attribute_name :reference_no %></dt>
<dd><%= registrar.reference_no %></dd>
<dt><%= Registrar.human_attribute_name :code %></dt>
<dd><%= registrar.code %></dd>
<dt><%= Registrar.human_attribute_name :balance %></dt>
<dd><%= registrar.balance %></dd>
<dt><%= Registrar.human_attribute_name :website %></dt>
<dd><%= registrar.website %></dd>
</dl>
</div>
</div>

View file

@ -1,5 +1,6 @@
<%= form_for([:admin, @registrar], html: { class: 'form-horizontal' }) do |f| %>
<%= render 'shared/full_errors', object: @registrar %>
<%= render 'form_errors', target: @registrar %>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default">
@ -133,7 +134,9 @@
<%= f.label :code %>
</div>
<div class="col-md-7">
<%= f.text_field :code, required: f.object.new_record?, class: 'form-control', disabled: !f.object.new_record? %>
<%= f.text_field :code, required: f.object.new_record?,
disabled: f.object.persisted?,
class: 'form-control' %>
</div>
</div>

View file

@ -0,0 +1,28 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-6"><%= ApiUser.human_attribute_name :username %></th>
<th class="col-xs-6"><%= ApiUser.human_attribute_name :active %></th>
</tr>
</thead>
<tbody>
<% registrar.api_users.each do |user| %>
<tr>
<td><%= link_to(user, [:admin, user]) %></td>
<td><%= user.active %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="panel-footer text-right">
<%= link_to t('.new_btn'), new_admin_registrar_api_user_path(registrar),
class: 'btn btn-default btn-xs' %>
</div>
</div>

View file

@ -0,0 +1,38 @@
<div class="panel panel-default">
<div class="panel-heading">
<%= t '.header' %>
</div>
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-4"><%= WhiteIp.human_attribute_name :ipv4 %></th>
<th class="col-xs-6"><%= WhiteIp.human_attribute_name :ipv6 %></th>
<th class="col-xs-2"><%= WhiteIp.human_attribute_name :interfaces %></th>
</tr>
</thead>
<tbody>
<% registrar.white_ips.each do |white_ip| %>
<tr>
<td>
<% if white_ip.ipv4.present? %>
<%= link_to(white_ip.ipv4, [:admin, registrar, white_ip]) %>
<% end %>
</td>
<td>
<% if white_ip.ipv6.present? %>
<%= link_to(white_ip.ipv6, [:admin, registrar, white_ip]) %>
<% end %>
</td>
<td><%= white_ip.interfaces.join(', ').upcase %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="panel-footer text-right">
<%= link_to t('.new_btn'), new_admin_registrar_white_ip_path(registrar),
class: 'btn btn-default btn-xs' %>
</div>
</div>

View file

@ -1,5 +1,10 @@
<% content_for :actions do %>
<%= link_to(t(:back_to_registrar), [:admin, @registrar], class: 'btn btn-default') %>
<% end %>
<%= render 'shared/title', name: "#{t(:edit)}: #{@registrar.name}" %>
<ol class="breadcrumb">
<li><%= link_to t('admin.registrars.index.header'), admin_registrars_path %></li>
<li><%= link_to @registrar.name, admin_registrar_path(@registrar) %></li>
</ol>
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<%= render 'form' %>

View file

@ -17,6 +17,19 @@
</div>
</div>
<div class="form-group">
<div class="col-md-4 control-label">
<%= f.label :vat_rate %>
</div>
<div class="col-md-3">
<div class="input-group">
<%= f.number_field :vat_rate, min: 0, max: 99.9, step: 0.1,
class: 'form-control' %>
<div class="input-group-addon">%</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-4 control-label">
<%= f.label :accounting_customer_code %>

View file

@ -1,7 +1,15 @@
<% content_for :actions do %>
<%= link_to(t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary') %>
<% end %>
<%= render 'shared/title', name: t(:registrars) %>
<div class="page-header">
<div class="row">
<div class="col-sm-10">
<h1><%= t '.header' %></h1>
</div>
<div class="col-sm-2 text-right">
<%= link_to t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary' %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
@ -12,10 +20,10 @@
<%= sort_link(@q, 'name') %>
</th>
<th class="col-xs-4">
<%= sort_link(@q, 'reg_no', t(:reg_no)) %>
<%= sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no)) %>
</th>
<th class="col-xs-4">
<%= t(:credit_balance) %>
<%= Registrar.human_attribute_name :balance %>
</th>
<th class="col-xs-4">
<%= t(:test_registrar) %>

View file

@ -1,2 +1,9 @@
<%= render 'shared/title', name: t(:new_registrar) %>
<ol class="breadcrumb">
<li><%= link_to t('admin.registrars.index.header'), admin_registrars_path %></li>
</ol>
<div class="page-header">
<h1><%= t '.header' %></h1>
</div>
<%= render 'form' %>

View file

@ -1,218 +1,50 @@
<% registrar = RegistrarPresenter.new(registrar: @registrar, view: self) %>
<% content_for :actions do %>
<%= link_to(t(:edit), edit_admin_registrar_path(@registrar), class: 'btn btn-primary') %>
<%= link_to(t(:delete), admin_registrar_path(@registrar), method: :delete, data: { confirm: t(:are_you_sure) }, class: 'btn btn-danger') %>
<% end %>
<% content_for :page_name do %>
<%= @registrar.name %>
<% if @registrar.test_registrar? %>
<span style="color: #c9302c;">(test)</span>
<% end %>
<% end %>
<%= render 'shared/title', name: @registrar.name %>
<% if @registrar.errors.any? %>
<% @registrar.errors.each do |attr, err| %>
<%= err %>
<br/>
<% end %>
<% end %>
<% if @registrar.errors.any? %>
<hr/>
<% end %>
<ol class="breadcrumb">
<li><%= link_to t('admin.registrars.index.header'), admin_registrars_path %></li>
</ol>
<div class="page-header">
<div class="row">
<div class="col-md-6">
<h1>
<%= @registrar.name %>
<% if @registrar.test_registrar? %>
<span class="text-danger"> (test)</span>
<% end %>
</h1>
</div>
<div class="col-md-6 text-right">
<%= link_to t('.edit_btn'), edit_admin_registrar_path(@registrar),
class: 'btn btn-primary' %>
<%= link_to t('.delete_btn'), admin_registrar_path(@registrar),
method: :delete,
data: { confirm: t('.delete_btn_confirm') },
class: 'btn btn-default' %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<%= t(:general) %>
</h3>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>
<%= t(:name) %>
</dt>
<dd>
<%= @registrar.name %>
</dd>
<dt>
<%= t(:reg_no) %>
</dt>
<dd>
<%= @registrar.reg_no %>
</dd>
<dt>
<%= t(:vat_no) %>
</dt>
<dd>
<%= @registrar.vat_no %>
</dd>
<dt>
<%= t(:reference_no) %>
</dt>
<dd>
<%= @registrar.reference_no %>
</dd>
<dt>
<%= t(:id) %>
</dt>
<dd>
<%= @registrar.code %>
</dd>
<dt>
<%= t(:credit_balance) %>
</dt>
<dd>
<%= @registrar.balance %>
</dd>
<dt>
<%= Registrar.human_attribute_name :website %>
</dt>
<dd>
<%= @registrar.website %>
</dd>
<dt>
<%= Registrar.human_attribute_name :accounting_customer_code %>
</dt>
<dd>
<%= @registrar.accounting_customer_code %>
</dd>
</dl>
</div>
</div>
<%= render 'details', registrar: @registrar %>
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<%= t(:contact) %>
</h3>
</div>
<div class="panel-body">
<dl class="dl-horizontal">
<dt>
<%= t(:country) %>
</dt>
<dd>
<%= @registrar.country %>
</dd>
<dt>
<%= t(:address) %>
</dt>
<dd>
<%= @registrar.address %>
</dd>
<dt>
<%= t(:contact_phone) %>
</dt>
<dd>
<%= @registrar.phone %>
</dd>
<dt>
<%= t(:contact_email) %>
</dt>
<dd>
<%= @registrar.email %>
</dd>
<dt>
<%= t(:billing_email) %>
</dt>
<dd>
<%= @registrar.billing_email %>
</dd>
</dl>
</div>
</div>
<%= render 'admin/registrars/show/preferences', registrar: registrar %>
<%= render 'contacts', registrar: @registrar %>
<%= render 'billing', registrar: @registrar %>
<%= render 'preferences', registrar: registrar %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default" id="epp-users">
<div class="panel-heading clearfix">
<div class="pull-left">
<%= t('.api_users') %>
</div>
<div class="pull-right">
<%= link_to(t('.new_api_use_btn'), new_admin_registrar_api_user_path(@registrar), class: 'btn btn-default btn-xs') %>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-6">
<%= t(:username) %>
</th>
<th class="col-xs-6">
<%= t('.active') %>
</th>
</tr>
</thead>
<tbody>
<% @registrar.api_users.each do |x| %>
<tr>
<td>
<%= link_to(x, [:admin, x]) %>
</td>
<td>
<%= x.active %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= render 'users', registrar: @registrar %>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default" id="epp-users">
<div class="panel-heading clearfix">
<div class="pull-left">
<%= t(:white_ips) %>
</div>
<div class="pull-right">
<%= link_to(t(:create_new_white_ip), new_admin_registrar_white_ip_path(@registrar), class: 'btn btn-default btn-xs') %>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered table-condensed">
<thead>
<tr>
<th class="col-xs-4">
<%= t(:ipv4) %>
</th>
<th class="col-xs-6">
<%= t(:ipv6) %>
</th>
<th class="col-xs-2">
<%= t(:interfaces) %>
</th>
</tr>
</thead>
<tbody>
<% @registrar.white_ips.each do |x| %>
<tr>
<td>
<% if x.ipv4.present? %>
<%= link_to(x.ipv4, [:admin, @registrar, x]) %>
<% end %>
</td>
<td>
<% if x.ipv6.present? %>
<%= link_to(x.ipv6, [:admin, @registrar, x]) %>
<% end %>
</td>
<td>
<%= x.interfaces.join(', ').upcase %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<%= render 'white_ips', registrar: @registrar %>
</div>
</div>

View file

@ -1,5 +1,5 @@
- content_for :actions do
= link_to(t(:back_to_registrar), admin_registrar_path(@registrar), class: 'btn btn-default')
= render 'shared/title', name: t(:create_new_white_ip)
= render 'shared/title', name: t('.header')
= render 'form'

View file

@ -14,11 +14,11 @@
%dt= t(:registrar_name)
%dd= link_to(@registrar, [:admin, @registrar])
%dt= t(:ipv4)
%dt= WhiteIp.human_attribute_name :ipv4
%dd= @white_ip.ipv4
%dt= t(:ipv6)
%dt= WhiteIp.human_attribute_name :ipv6
%dd= @white_ip.ipv6
%dt= t(:interfaces)
%dt= WhiteIp.human_attribute_name :interfaces
%dd= @white_ip.interfaces.join(', ').upcase

View file

@ -10,7 +10,7 @@
%th{class: 'col-xs-6'}
= sort_link(@q, 'name')
%th{class: 'col-xs-6'}
= sort_link(@q, 'reg_no', t(:reg_no))
= sort_link(@q, 'reg_no', Registrar.human_attribute_name(:reg_no))
%tbody
- @registrars.each do |x|
%tr

View file

@ -16,10 +16,10 @@
%dt= t(:name)
%dd= @registrar.name
%dt= t(:reg_no)
%dt= Registrar.human_attribute_name :reg_no
%dd= @registrar.reg_no
%dt= t(:vat_no)
%dt= Registrar.human_attribute_name :vat_no
%dd= @registrar.vat_no
%dt= t(:id)

View file

@ -33,11 +33,11 @@
.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'
= f.search_field :total_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'
= f.search_field :total_lteq, class: 'form-control', placeholder: t(:maximum_total), autocomplete: 'off'
.col-md-3{style: 'padding-top: 25px;'}
%button.btn.btn-default
&nbsp;
@ -67,7 +67,7 @@
%td{class: 'text-danger'}= t(:unpaid)
%td= l(x.due_date, format: :date_long)
%td= currency(x.sum)
%td= currency(x.total)
.row
.col-md-12
= paginate @invoices

View file

@ -32,5 +32,5 @@
%dt= t(:description)
%dd=@invoice.description
%dt= t(:reference_no)
%dt= Invoice.human_attribute_name :reference_no
%dd= @invoice.reference_no

View file

@ -20,13 +20,13 @@
%tfoot
%tr
%th{colspan: 3}
%th= t(:total_without_vat)
%td= currency(@invoice.sum_without_vat)
%th= Invoice.human_attribute_name :subtotal
%td= number_to_currency @invoice.subtotal
%tr
%th.no-border{colspan: 3}
%th= t('vat', vat_prc: (@invoice.vat_prc * 100).round)
%td= currency(@invoice.vat)
%th= "VAT #{number_to_percentage(@invoice.vat_rate, precision: 1)}"
%td= number_to_currency @invoice.vat_amount
%tr
%th.no-border{colspan: 3}
%th= t(:total)
%td= currency(@invoice.sum)
%td= number_to_currency @invoice.total

View file

@ -4,7 +4,7 @@
%dt= t(:name)
%dd= @invoice.seller_name
%dt= t(:reg_no)
%dt= Registrar.human_attribute_name :reg_no
%dd= @invoice.seller_reg_no
%dt= t(:iban)
@ -16,7 +16,7 @@
%dt= t(:swift)
%dd= @invoice.seller_swift
%dt= t(:vat_no)
%dt= Registrar.human_attribute_name :vat_no
%dd= @invoice.seller_vat_no
%dt= t(:address)

View file

@ -182,7 +182,7 @@
%dt= t(:description)
%dd=@invoice.description
%dt= t(:reference_no)
%dt= Invoice.human_attribute_name :reference_no
%dd= @invoice.reference_no
.col-md-6.right
@ -238,16 +238,16 @@
%tfoot
%tr
%th{colspan: 3}
%th= t(:total_without_vat)
%td= "#{currency(@invoice.sum_without_vat)} #{@invoice.currency}"
%th= Invoice.human_attribute_name :subtotal
%td= number_to_currency @invoice.subtotal
%tr
%th.no-border{colspan: 3}
%th= t('vat', vat_prc: (@invoice.vat_prc * 100).round)
%td= "#{currency(@invoice.vat)} #{@invoice.currency}"
%th= "VAT #{number_to_percentage(@invoice.vat_rate, precision: 1)}"
%td= number_to_currency @invoice.vat_amount
%tr
%th.no-border{colspan: 3}
%th= t(:total)
%td= "#{currency(@invoice.sum)} #{@invoice.currency}"
%td= number_to_currency @invoice.total
#footer
%hr
@ -261,7 +261,7 @@
%br
= "#{t('reg_no')} #{@invoice.seller_reg_no}"
%br
= "#{t('vat_no')} #{@invoice.seller_vat_no}"
= "#{Registrar.human_attribute_name :vat_no} #{@invoice.seller_vat_no}"
.col-md-3.left
= @invoice.seller_phone

View file

@ -7,7 +7,6 @@
<div class="col-md-5">
<%= text_field_tag :old_hostname, params[:old_hostname], autofocus: true,
required: true,
spellcheck: false,
class: 'form-control' %>
</div>
</div>
@ -19,7 +18,6 @@
<div class="col-md-5">
<%= text_field_tag :new_hostname, params[:new_hostname], required: true,
spellcheck: false,
class: 'form-control' %>
</div>
</div>
@ -30,7 +28,7 @@
</div>
<div class="col-md-3">
<%= text_area_tag :ipv4, params[:ipv4], spellcheck: false, class: 'form-control' %>
<%= text_area_tag :ipv4, params[:ipv4], class: 'form-control' %>
</div>
</div>
@ -40,7 +38,7 @@
</div>
<div class="col-md-3">
<%= text_area_tag :ipv6, params[:ipv6], spellcheck: false, class: 'form-control' %>
<%= text_area_tag :ipv6, params[:ipv6], class: 'form-control' %>
<span class="help-block"><%= t '.ip_hint' %></span>
</div>
</div>