mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 20:19:34 +02:00
Merge branch 'master' into 2413-force-delete-lift-bug
This commit is contained in:
commit
7328ea24c3
69 changed files with 2082 additions and 818 deletions
2
.github/workflows/ruby.yml
vendored
2
.github/workflows/ruby.yml
vendored
|
@ -6,7 +6,7 @@ jobs:
|
||||||
test:
|
test:
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:12
|
image: postgres:14
|
||||||
ports: ["5432:5432"]
|
ports: ["5432:5432"]
|
||||||
env:
|
env:
|
||||||
POSTGRES_PASSWORD: password
|
POSTGRES_PASSWORD: password
|
||||||
|
|
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -1,3 +1,21 @@
|
||||||
|
08.09.2022
|
||||||
|
* Fixed template error for multi-year registered domains in force delete process [#2435](https://github.com/internetee/registry/issues/2435)
|
||||||
|
|
||||||
|
02.09.2022
|
||||||
|
* Update invoice status on payment order payments [#2427](https://github.com/internetee/registry/pull/2427)
|
||||||
|
|
||||||
|
01.09.2022
|
||||||
|
* Monthly invoice payment status fix [#2428](https://github.com/internetee/registry/issues/2428)
|
||||||
|
|
||||||
|
31.08.2022
|
||||||
|
* new fully automated process for registrar monthly invoices [#2424](https://github.com/internetee/registry/pull/2424)
|
||||||
|
|
||||||
|
25.08.2022
|
||||||
|
* Contact creation fix to not require postal addresses in Registrar portal [#2421](https://github.com/internetee/registry/pull/2421)
|
||||||
|
|
||||||
|
23.08.2022
|
||||||
|
* REPP update to fix search by registrant in Registrar portal [#2425](https://github.com/internetee/registry/pull/2425)
|
||||||
|
|
||||||
21.07.2022
|
21.07.2022
|
||||||
* Removed deprecated statuses_before_force_delete field [#2363](https://github.com/internetee/registry/issues/2363)
|
* Removed deprecated statuses_before_force_delete field [#2363](https://github.com/internetee/registry/issues/2363)
|
||||||
|
|
||||||
|
|
4
Gemfile
4
Gemfile
|
@ -17,11 +17,11 @@ gem 'figaro', '~> 1.2'
|
||||||
|
|
||||||
# model related
|
# model related
|
||||||
gem 'paper_trail', '~> 12.1'
|
gem 'paper_trail', '~> 12.1'
|
||||||
gem 'pg', '1.4.2'
|
gem 'pg', '1.4.3'
|
||||||
# 1.8 is for Rails < 5.0
|
# 1.8 is for Rails < 5.0
|
||||||
gem 'ransack', '~> 2.6.0'
|
gem 'ransack', '~> 2.6.0'
|
||||||
gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence
|
gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence
|
||||||
gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696
|
gem 'validates_email_format_of', '1.7.2' # validates email against RFC 2822 and RFC 3696
|
||||||
|
|
||||||
# 0.7.3 is the latest for Rails 4.2, however, it is absent on Rubygems server
|
# 0.7.3 is the latest for Rails 4.2, however, it is absent on Rubygems server
|
||||||
# https://github.com/huacnlee/rails-settings-cached/issues/165
|
# https://github.com/huacnlee/rails-settings-cached/issues/165
|
||||||
|
|
20
Gemfile.lock
20
Gemfile.lock
|
@ -18,10 +18,10 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/internetee/e_invoice.git
|
remote: https://github.com/internetee/e_invoice.git
|
||||||
revision: 312cac173935f434e449d1714f3497bfee9f8995
|
revision: 9f850465697a2448a31ebddb83c1be5a5a9be3d2
|
||||||
branch: master
|
branch: master
|
||||||
specs:
|
specs:
|
||||||
e_invoice (0.1.0)
|
e_invoice (0.1.3)
|
||||||
builder (~> 3.2)
|
builder (~> 3.2)
|
||||||
nokogiri
|
nokogiri
|
||||||
savon
|
savon
|
||||||
|
@ -259,7 +259,7 @@ GEM
|
||||||
httpi (2.4.5)
|
httpi (2.4.5)
|
||||||
rack
|
rack
|
||||||
socksify
|
socksify
|
||||||
i18n (1.10.0)
|
i18n (1.12.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
i18n_data (0.13.0)
|
i18n_data (0.13.0)
|
||||||
isikukood (0.1.2)
|
isikukood (0.1.2)
|
||||||
|
@ -291,7 +291,7 @@ GEM
|
||||||
kaminari-core (1.2.1)
|
kaminari-core (1.2.1)
|
||||||
libxml-ruby (3.2.1)
|
libxml-ruby (3.2.1)
|
||||||
logger (1.4.3)
|
logger (1.4.3)
|
||||||
loofah (2.16.0)
|
loofah (2.18.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
mail (2.7.1)
|
mail (2.7.1)
|
||||||
|
@ -353,7 +353,7 @@ GEM
|
||||||
activerecord (>= 5.2)
|
activerecord (>= 5.2)
|
||||||
request_store (~> 1.1)
|
request_store (~> 1.1)
|
||||||
pdfkit (0.8.5)
|
pdfkit (0.8.5)
|
||||||
pg (1.4.2)
|
pg (1.4.3)
|
||||||
pg_query (2.1.2)
|
pg_query (2.1.2)
|
||||||
google-protobuf (>= 3.17.1)
|
google-protobuf (>= 3.17.1)
|
||||||
pghero (2.8.1)
|
pghero (2.8.1)
|
||||||
|
@ -399,7 +399,7 @@ GEM
|
||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
rails-html-sanitizer (1.4.2)
|
rails-html-sanitizer (1.4.3)
|
||||||
loofah (~> 2.3)
|
loofah (~> 2.3)
|
||||||
railties (6.1.4.1)
|
railties (6.1.4.1)
|
||||||
actionpack (= 6.1.4.1)
|
actionpack (= 6.1.4.1)
|
||||||
|
@ -499,7 +499,7 @@ GEM
|
||||||
validate_url (1.0.15)
|
validate_url (1.0.15)
|
||||||
activemodel (>= 3.0.0)
|
activemodel (>= 3.0.0)
|
||||||
public_suffix
|
public_suffix
|
||||||
validates_email_format_of (1.6.3)
|
validates_email_format_of (1.7.2)
|
||||||
i18n
|
i18n
|
||||||
warden (1.2.9)
|
warden (1.2.9)
|
||||||
rack (>= 2.0.9)
|
rack (>= 2.0.9)
|
||||||
|
@ -576,7 +576,7 @@ DEPENDENCIES
|
||||||
omniauth-tara!
|
omniauth-tara!
|
||||||
paper_trail (~> 12.1)
|
paper_trail (~> 12.1)
|
||||||
pdfkit
|
pdfkit
|
||||||
pg (= 1.4.2)
|
pg (= 1.4.3)
|
||||||
pg_query (>= 0.9.0)
|
pg_query (>= 0.9.0)
|
||||||
pghero
|
pghero
|
||||||
pry (= 0.14.1)
|
pry (= 0.14.1)
|
||||||
|
@ -596,11 +596,11 @@ DEPENDENCIES
|
||||||
spy
|
spy
|
||||||
truemail (~> 2.4)
|
truemail (~> 2.4)
|
||||||
uglifier
|
uglifier
|
||||||
validates_email_format_of (= 1.6.3)
|
validates_email_format_of (= 1.7.2)
|
||||||
webdrivers
|
webdrivers
|
||||||
webmock
|
webmock
|
||||||
whenever (= 1.0.0)
|
whenever (= 1.0.0)
|
||||||
wkhtmltopdf-binary (~> 0.12.5.1)
|
wkhtmltopdf-binary (~> 0.12.5.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.3.16
|
2.3.21
|
||||||
|
|
|
@ -81,18 +81,24 @@ module Admin
|
||||||
payment_order.update(notes: 'Cancelled')
|
payment_order.update(notes: 'Cancelled')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/MethodLength
|
||||||
def filter_by_status
|
def filter_by_status
|
||||||
case params[:status]
|
case params[:status]
|
||||||
when 'Paid'
|
when 'Paid'
|
||||||
Invoice.includes(:account_activity, :buyer).where.not(account_activity: { id: nil })
|
Invoice.includes(:account_activity, :buyer).where.not(account_activity: { id: nil })
|
||||||
when 'Unpaid'
|
when 'Unpaid'
|
||||||
Invoice.includes(:account_activity, :buyer).where(account_activity: { id: nil })
|
Invoice.includes(:account_activity, :buyer).where(account_activity: { id: nil },
|
||||||
|
cancelled_at: nil,
|
||||||
|
monthly_invoice: false)
|
||||||
when 'Cancelled'
|
when 'Cancelled'
|
||||||
Invoice.includes(:account_activity, :buyer).where.not(cancelled_at: nil)
|
Invoice.includes(:account_activity, :buyer).where.not(cancelled_at: nil)
|
||||||
|
when 'Monthly'
|
||||||
|
Invoice.where(monthly_invoice: true, cancelled_at: nil)
|
||||||
else
|
else
|
||||||
Invoice.includes(:account_activity, :buyer)
|
Invoice.includes(:account_activity, :buyer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
def filter_by_receipt_date(invoices)
|
def filter_by_receipt_date(invoices)
|
||||||
date_from_param = params[:q][:receipt_date_gteq] if params[:q][:receipt_date_gteq].present?
|
date_from_param = params[:q][:receipt_date_gteq] if params[:q][:receipt_date_gteq].present?
|
||||||
|
|
|
@ -3,7 +3,6 @@ module EisBilling
|
||||||
protect_from_forgery with: :null_session
|
protect_from_forgery with: :null_session
|
||||||
skip_authorization_check # Temporary solution
|
skip_authorization_check # Temporary solution
|
||||||
# skip_before_action :verify_authenticity_token # Temporary solution
|
# skip_before_action :verify_authenticity_token # Temporary solution
|
||||||
before_action :persistent
|
|
||||||
before_action :authorized
|
before_action :authorized
|
||||||
|
|
||||||
INITIATOR = 'billing'.freeze
|
INITIATOR = 'billing'.freeze
|
||||||
|
@ -49,11 +48,5 @@ module EisBilling
|
||||||
def logger
|
def logger
|
||||||
Rails.logger
|
Rails.logger
|
||||||
end
|
end
|
||||||
|
|
||||||
def persistent
|
|
||||||
return true if Feature.billing_system_integrated?
|
|
||||||
|
|
||||||
render json: { message: "We don't work yet!" }, status: :unauthorized
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,16 @@
|
||||||
module EisBilling
|
module EisBilling
|
||||||
class LhvConnectTransactionsController < EisBilling::BaseController
|
class LhvConnectTransactionsController < EisBilling::BaseController
|
||||||
def create
|
def create
|
||||||
|
if params['_json'].nil? || params['_json'].empty?
|
||||||
|
render json: { message: 'MISSING PARAMS' }, status: :unprocessable_entity
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
bank_statement = BankStatement.create(bank_code: Setting.registry_bank_code,
|
||||||
|
iban: Setting.registry_iban)
|
||||||
|
|
||||||
params['_json'].each do |incoming_transaction|
|
params['_json'].each do |incoming_transaction|
|
||||||
process_transactions(incoming_transaction)
|
process_transactions(incoming_transaction, bank_statement)
|
||||||
end
|
end
|
||||||
|
|
||||||
render status: :ok, json: { message: 'RECEIVED', params: params }
|
render status: :ok, json: { message: 'RECEIVED', params: params }
|
||||||
|
@ -10,19 +18,13 @@ module EisBilling
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def process_transactions(incoming_transaction)
|
def process_transactions(incoming_transaction, bank_statement)
|
||||||
logger.info 'Got incoming transactions'
|
logger.info 'Got incoming transactions'
|
||||||
logger.info incoming_transaction
|
logger.info incoming_transaction
|
||||||
|
|
||||||
bank_statement = BankStatement.new(bank_code: Setting.registry_bank_code,
|
|
||||||
iban: Setting.registry_iban)
|
|
||||||
bank_statement_transaction(bank_statement: bank_statement, incoming_transaction: incoming_transaction)
|
|
||||||
end
|
|
||||||
|
|
||||||
def bank_statement_transaction(bank_statement:, incoming_transaction:)
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
bank_statement.save!
|
transaction = bank_statement.bank_transactions
|
||||||
transaction = create_transaction(incoming_transaction: incoming_transaction, bank_statement: bank_statement)
|
.create!(transaction_attributes(incoming_transaction))
|
||||||
|
|
||||||
next if transaction.registrar.blank?
|
next if transaction.registrar.blank?
|
||||||
|
|
||||||
|
@ -32,17 +34,21 @@ module EisBilling
|
||||||
|
|
||||||
def create_invoice_if_missing(transaction)
|
def create_invoice_if_missing(transaction)
|
||||||
Invoice.create_from_transaction!(transaction) unless transaction.autobindable?
|
Invoice.create_from_transaction!(transaction) unless transaction.autobindable?
|
||||||
transaction.autobind_invoice
|
invoice = transaction.autobind_invoice
|
||||||
|
return unless invoice.paid?
|
||||||
|
|
||||||
|
EisBilling::SendInvoiceStatus.send_info(invoice_number: invoice.number,
|
||||||
|
status: 'paid')
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_transaction(incoming_transaction:, bank_statement:)
|
def transaction_attributes(incoming_transaction)
|
||||||
transaction_attributes = { sum: incoming_transaction['amount'],
|
{
|
||||||
|
sum: incoming_transaction['amount'],
|
||||||
currency: incoming_transaction['currency'],
|
currency: incoming_transaction['currency'],
|
||||||
paid_at: incoming_transaction['date'],
|
paid_at: incoming_transaction['date'],
|
||||||
reference_no: incoming_transaction['payment_reference_number'],
|
reference_no: incoming_transaction['payment_reference_number'],
|
||||||
description: incoming_transaction['payment_description'] }
|
description: incoming_transaction['payment_description'],
|
||||||
|
}
|
||||||
bank_statement.bank_transactions.create!(transaction_attributes)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,9 @@ module EisBilling
|
||||||
def update
|
def update
|
||||||
payment_status = define_payment_status(params[:payment_state])
|
payment_status = define_payment_status(params[:payment_state])
|
||||||
invoice = Invoice.find_by(number: params[:order_reference])
|
invoice = Invoice.find_by(number: params[:order_reference])
|
||||||
|
|
||||||
|
return if invoice.paid?
|
||||||
|
|
||||||
bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time])
|
bank = create_bank_transfer(invoice: invoice, sum: params[:standing_amount], paid_at: params[:transaction_time])
|
||||||
create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status)
|
create_payment_order(invoice: invoice, everypay_response: params, payment_status: payment_status)
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ module Repp
|
||||||
data = current_user.as_json(only: %i[id username roles])
|
data = current_user.as_json(only: %i[id username roles])
|
||||||
data[:registrar_name] = registrar.name
|
data[:registrar_name] = registrar.name
|
||||||
data[:legaldoc_mandatory] = registrar.legaldoc_mandatory?
|
data[:legaldoc_mandatory] = registrar.legaldoc_mandatory?
|
||||||
|
data[:address_processing] = Contact.address_processing?
|
||||||
data[:abilities] = Ability.new(current_user).permissions
|
data[:abilities] = Ability.new(current_user).permissions
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
|
@ -193,7 +193,7 @@ module Repp
|
||||||
def contact_create_params(required: true)
|
def contact_create_params(required: true)
|
||||||
create_params = %i[name email phone]
|
create_params = %i[name email phone]
|
||||||
contact_params.require(create_params) if required
|
contact_params.require(create_params) if required
|
||||||
contact_params.slice(*create_params)
|
contact_params.slice(:id, *create_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def contact_ident_params(required: true)
|
def contact_ident_params(required: true)
|
||||||
|
@ -211,7 +211,7 @@ module Repp
|
||||||
end
|
end
|
||||||
|
|
||||||
def contact_params
|
def contact_params
|
||||||
params.require(:contact).permit(:name, :email, :phone, :legal_document,
|
params.require(:contact).permit(:id, :name, :email, :phone, :legal_document,
|
||||||
legal_document: %i[body type],
|
legal_document: %i[body type],
|
||||||
ident: [%i[ident ident_type ident_country_code]],
|
ident: [%i[ident ident_type ident_country_code]],
|
||||||
addr: [%i[country_code city street zip state]])
|
addr: [%i[country_code city street zip state]])
|
||||||
|
|
|
@ -12,14 +12,14 @@ module Repp
|
||||||
desc 'Get all existing domains'
|
desc 'Get all existing domains'
|
||||||
def index
|
def index
|
||||||
authorize! :info, Epp::Domain
|
authorize! :info, Epp::Domain
|
||||||
records = current_user.registrar.domains
|
records = current_user.registrar.domains.includes(:registrar, :registrant)
|
||||||
q = records.ransack(PartialSearchFormatter.format(search_params))
|
q = records.ransack(PartialSearchFormatter.format(search_params))
|
||||||
q.sorts = ['valid_to asc', 'created_at desc'] if q.sorts.empty?
|
q.sorts = ['valid_to asc', 'created_at desc'] if q.sorts.empty?
|
||||||
# use distinct: false here due to ransack bug:
|
# use distinct: false here due to ransack bug:
|
||||||
# https://github.com/activerecord-hackery/ransack/issues/429
|
# https://github.com/activerecord-hackery/ransack/issues/429
|
||||||
domains = q.result(distinct: false)
|
domains = q.result(distinct: false)
|
||||||
|
|
||||||
limited_domains = domains.limit(limit).offset(offset).includes(:registrar, :registrant)
|
limited_domains = domains.limit(limit).offset(offset)
|
||||||
|
|
||||||
render_success(data: { new_domain: records.any? ? serialized_domains([records.last]) : [],
|
render_success(data: { new_domain: records.any? ? serialized_domains([records.last]) : [],
|
||||||
domains: serialized_domains(limited_domains.to_a.uniq),
|
domains: serialized_domains(limited_domains.to_a.uniq),
|
||||||
|
@ -238,7 +238,7 @@ module Repp
|
||||||
|
|
||||||
def index_params
|
def index_params
|
||||||
params.permit(:limit, :offset, :details, :simple, :q,
|
params.permit(:limit, :offset, :details, :simple, :q,
|
||||||
q: %i[s name_matches registrant_id_eq contacts_ident_eq
|
q: %i[s name_matches registrant_code_eq contacts_ident_eq
|
||||||
nameservers_hostname_eq valid_to_gteq valid_to_lteq
|
nameservers_hostname_eq valid_to_gteq valid_to_lteq
|
||||||
statuses_contains_array] + [s: []])
|
statuses_contains_array] + [s: []])
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,6 +97,7 @@ module Repp
|
||||||
account_activity_id_not_null
|
account_activity_id_not_null
|
||||||
account_activity_id_null cancelled_at_null
|
account_activity_id_null cancelled_at_null
|
||||||
cancelled_at_not_null number_gteq number_lteq
|
cancelled_at_not_null number_gteq number_lteq
|
||||||
|
monthly_invoice_true monthly_invoice_false
|
||||||
total_gteq total_lteq s] + [s: []])
|
total_gteq total_lteq s] + [s: []])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Domains
|
||||||
outzone_date: domain.outzone_date,
|
outzone_date: domain.outzone_date,
|
||||||
purge_date: domain.purge_date)
|
purge_date: domain.purge_date)
|
||||||
|
|
||||||
return if domain.registrar.notifications.last.text.include? template
|
return if domain.registrar&.notifications&.last&.text&.include? template
|
||||||
|
|
||||||
domain.registrar.notifications.create!(text: template)
|
domain.registrar.notifications.create!(text: template)
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ module Domains
|
||||||
purge_date: domain.purge_date,
|
purge_date: domain.purge_date,
|
||||||
email: email)
|
email: email)
|
||||||
|
|
||||||
return if domain.registrar.notifications.last.text.include? template
|
return if domain.registrar&.notifications&.last&.text&.include? template
|
||||||
|
|
||||||
domain.registrar.notifications.create!(text: template)
|
domain.registrar.notifications.create!(text: template)
|
||||||
end
|
end
|
||||||
|
|
10
app/jobs/delete_monthly_invoices_job.rb
Normal file
10
app/jobs/delete_monthly_invoices_job.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
class DeleteMonthlyInvoicesJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform
|
||||||
|
@month = Time.zone.now - 1.month
|
||||||
|
invoices = Invoice.where(monthly_invoice: true, issue_date: @month.end_of_month.to_date,
|
||||||
|
in_directo: false, e_invoice_sent_at: nil)
|
||||||
|
invoices.delete_all
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,60 +1,31 @@
|
||||||
class DirectoInvoiceForwardJob < ApplicationJob
|
class DirectoInvoiceForwardJob < ApplicationJob
|
||||||
def perform(monthly: false, dry: false)
|
def perform(monthly: false, dry: false)
|
||||||
@dry = dry
|
data = nil
|
||||||
(@month = Time.zone.now - 1.month) if monthly
|
|
||||||
|
|
||||||
@client = new_directo_client
|
if monthly
|
||||||
monthly ? send_monthly_invoices : send_receipts
|
@month = Time.zone.now - 1.month
|
||||||
|
data = collect_monthly_data
|
||||||
|
else
|
||||||
|
data = collect_receipts_data
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_directo_client
|
EisBilling::SendDataToDirecto.send_request(object_data: data, monthly: monthly, dry: dry)
|
||||||
DirectoApi::Client.new(ENV['directo_invoice_url'], Setting.directo_sales_agent,
|
|
||||||
Setting.directo_receipt_payment_term)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_receipts
|
def collect_receipts_data
|
||||||
unsent_invoices = Invoice.where(in_directo: false).non_cancelled
|
unsent_invoices = Invoice.where(in_directo: false).non_cancelled
|
||||||
|
collected_data = []
|
||||||
|
|
||||||
Rails.logger.info("[DIRECTO] Trying to send #{unsent_invoices.count} prepayment invoices")
|
|
||||||
unsent_invoices.each do |invoice|
|
unsent_invoices.each do |invoice|
|
||||||
unless valid_invoice_conditions?(invoice)
|
unless valid_invoice_conditions?(invoice)
|
||||||
Rails.logger.info "[DIRECTO] Invoice #{invoice.number} has been skipped"
|
Rails.logger.info "[DIRECTO] Invoice #{invoice.number} has been skipped"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
@client.invoices.add_with_schema(invoice: invoice.as_directo_json, schema: 'prepayment')
|
collected_data << invoice.as_directo_json
|
||||||
end
|
end
|
||||||
|
|
||||||
sync_with_directo
|
collected_data
|
||||||
end
|
|
||||||
|
|
||||||
def send_monthly_invoices
|
|
||||||
Registrar.where.not(test_registrar: true).find_each do |registrar|
|
|
||||||
next unless registrar.cash_account
|
|
||||||
|
|
||||||
@client = new_directo_client
|
|
||||||
send_invoice_for_registrar(registrar)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def send_invoice_for_registrar(registrar)
|
|
||||||
summary = registrar.monthly_summary(month: @month)
|
|
||||||
@client.invoices.add_with_schema(invoice: summary, schema: 'summary') unless summary.nil?
|
|
||||||
|
|
||||||
sync_with_directo if @client.invoices.count.positive?
|
|
||||||
end
|
|
||||||
|
|
||||||
def assign_monthly_numbers
|
|
||||||
raise 'Directo Counter is going to be out of period!' if directo_counter_exceedable?(@client.invoices.count)
|
|
||||||
|
|
||||||
min_directo = Setting.directo_monthly_number_min.presence.try(:to_i)
|
|
||||||
directo_number = [Setting.directo_monthly_number_last.presence.try(:to_i),
|
|
||||||
min_directo].compact.max || 0
|
|
||||||
|
|
||||||
@client.invoices.each do |inv|
|
|
||||||
directo_number += 1
|
|
||||||
inv.number = directo_number
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_invoice_conditions?(invoice)
|
def valid_invoice_conditions?(invoice)
|
||||||
|
@ -68,29 +39,17 @@ class DirectoInvoiceForwardJob < ApplicationJob
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync_with_directo
|
def collect_monthly_data
|
||||||
assign_monthly_numbers if @month
|
registrars_data = []
|
||||||
|
|
||||||
Rails.logger.info("[Directo] - attempting to send following XML:\n #{@client.invoices.as_xml}")
|
Registrar.where.not(test_registrar: true).find_each do |registrar|
|
||||||
return if @dry
|
registrars_data << {
|
||||||
|
registrar: registrar,
|
||||||
res = @client.invoices.deliver(ssl_verify: false)
|
registrar_summery: registrar.monthly_summary(month: @month),
|
||||||
process_directo_response(res.body, @client.invoices.as_xml)
|
}
|
||||||
rescue SocketError, Errno::ECONNREFUSED, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
|
||||||
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
|
||||||
Rails.logger.info('[Directo] Failed to communicate via API')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_directo_response(xml, req)
|
registrars_data
|
||||||
Rails.logger.info "[Directo] - Responded with body: #{xml}"
|
|
||||||
Nokogiri::XML(xml).css('Result').each do |res|
|
|
||||||
if @month
|
|
||||||
mark_invoice_as_sent(res: res, req: req)
|
|
||||||
else
|
|
||||||
inv = Invoice.find_by(number: res.attributes['docid'].value.to_i)
|
|
||||||
mark_invoice_as_sent(invoice: inv, res: res, req: req)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_invoice_as_sent(invoice: nil, res:, req:)
|
def mark_invoice_as_sent(invoice: nil, res:, req:)
|
||||||
|
|
125
app/jobs/directo_invoice_forward_legacy_job.rb
Normal file
125
app/jobs/directo_invoice_forward_legacy_job.rb
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
class DirectoInvoiceForwardLegacyJob < ApplicationJob
|
||||||
|
def perform(monthly: false, dry: false)
|
||||||
|
@dry = dry
|
||||||
|
(@month = Time.zone.now - 1.month) if monthly
|
||||||
|
|
||||||
|
@client = new_directo_client
|
||||||
|
monthly ? send_monthly_invoices : send_receipts
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_directo_client
|
||||||
|
DirectoApi::Client.new(ENV['directo_invoice_url'], Setting.directo_sales_agent,
|
||||||
|
Setting.directo_receipt_payment_term)
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_receipts
|
||||||
|
unsent_invoices = Invoice.where(in_directo: false).non_cancelled
|
||||||
|
|
||||||
|
Rails.logger.info("[DIRECTO] Trying to send #{unsent_invoices.count} prepayment invoices")
|
||||||
|
unsent_invoices.each do |invoice|
|
||||||
|
unless valid_invoice_conditions?(invoice)
|
||||||
|
Rails.logger.info "[DIRECTO] Invoice #{invoice.number} has been skipped"
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
@client.invoices.add_with_schema(invoice: invoice.as_directo_json, schema: 'prepayment')
|
||||||
|
end
|
||||||
|
|
||||||
|
sync_with_directo
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_monthly_invoices
|
||||||
|
Registrar.where.not(test_registrar: true).find_each do |registrar|
|
||||||
|
next unless registrar.cash_account
|
||||||
|
|
||||||
|
@client = new_directo_client
|
||||||
|
send_invoice_for_registrar(registrar)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_invoice_for_registrar(registrar)
|
||||||
|
summary = registrar.monthly_summary(month: @month)
|
||||||
|
@client.invoices.add_with_schema(invoice: summary, schema: 'summary') unless summary.nil?
|
||||||
|
|
||||||
|
sync_with_directo if @client.invoices.count.positive?
|
||||||
|
end
|
||||||
|
|
||||||
|
def assign_monthly_numbers
|
||||||
|
raise 'Directo Counter is going to be out of period!' if directo_counter_exceedable?(@client.invoices.count)
|
||||||
|
|
||||||
|
min_directo = Setting.directo_monthly_number_min.presence.try(:to_i)
|
||||||
|
directo_number = [Setting.directo_monthly_number_last.presence.try(:to_i),
|
||||||
|
min_directo].compact.max || 0
|
||||||
|
|
||||||
|
@client.invoices.each do |inv|
|
||||||
|
directo_number += 1
|
||||||
|
inv.number = directo_number
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def valid_invoice_conditions?(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.total
|
||||||
|
return false
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
def sync_with_directo
|
||||||
|
assign_monthly_numbers if @month
|
||||||
|
|
||||||
|
Rails.logger.info("[Directo] - attempting to send following XML:\n #{@client.invoices.as_xml}")
|
||||||
|
return if @dry
|
||||||
|
|
||||||
|
res = @client.invoices.deliver(ssl_verify: false)
|
||||||
|
process_directo_response(res.body, @client.invoices.as_xml)
|
||||||
|
rescue SocketError, Errno::ECONNREFUSED, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
||||||
|
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
||||||
|
Rails.logger.info('[Directo] Failed to communicate via API')
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_directo_response(xml, req)
|
||||||
|
Rails.logger.info "[Directo] - Responded with body: #{xml}"
|
||||||
|
Nokogiri::XML(xml).css('Result').each do |res|
|
||||||
|
if @month
|
||||||
|
mark_invoice_as_sent(res: res, req: req)
|
||||||
|
else
|
||||||
|
inv = Invoice.find_by(number: res.attributes['docid'].value.to_i)
|
||||||
|
mark_invoice_as_sent(invoice: inv, res: res, req: req)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def mark_invoice_as_sent(invoice: nil, res:, req:)
|
||||||
|
directo_record = Directo.new(response: res.as_json.to_h,
|
||||||
|
request: req, invoice_number: res.attributes['docid'].value.to_i)
|
||||||
|
if invoice
|
||||||
|
directo_record.item = invoice
|
||||||
|
invoice.update(in_directo: true)
|
||||||
|
else
|
||||||
|
update_directo_number(num: directo_record.invoice_number)
|
||||||
|
end
|
||||||
|
|
||||||
|
directo_record.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_directo_number(num:)
|
||||||
|
return unless num.to_i > Setting.directo_monthly_number_last.to_i
|
||||||
|
|
||||||
|
Setting.directo_monthly_number_last = num.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
def directo_counter_exceedable?(invoice_count)
|
||||||
|
min_directo = Setting.directo_monthly_number_min.presence.try(:to_i)
|
||||||
|
max_directo = Setting.directo_monthly_number_max.presence.try(:to_i)
|
||||||
|
last_directo = [Setting.directo_monthly_number_last.presence.try(:to_i),
|
||||||
|
min_directo].compact.max || 0
|
||||||
|
|
||||||
|
return true if max_directo && max_directo < (last_directo + invoice_count)
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,84 +0,0 @@
|
||||||
class DirectoInvoiceForwardTwoJob < ApplicationJob
|
|
||||||
def perform(monthly: false, dry: false)
|
|
||||||
data = nil
|
|
||||||
|
|
||||||
if monthly
|
|
||||||
@month = Time.zone.now - 1.month
|
|
||||||
data = collect_monthly_data
|
|
||||||
else
|
|
||||||
data = collect_receipts_data
|
|
||||||
end
|
|
||||||
|
|
||||||
EisBilling::SendDataToDirecto.send_request(object_data: data, monthly: monthly, dry: dry)
|
|
||||||
end
|
|
||||||
|
|
||||||
def collect_receipts_data
|
|
||||||
unsent_invoices = Invoice.where(in_directo: false).non_cancelled
|
|
||||||
collected_data = []
|
|
||||||
|
|
||||||
unsent_invoices.each do |invoice|
|
|
||||||
unless valid_invoice_conditions?(invoice)
|
|
||||||
Rails.logger.info "[DIRECTO] Invoice #{invoice.number} has been skipped"
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
collected_data << invoice.as_directo_json
|
|
||||||
end
|
|
||||||
|
|
||||||
collected_data
|
|
||||||
end
|
|
||||||
|
|
||||||
def valid_invoice_conditions?(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.total
|
|
||||||
return false
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def collect_monthly_data
|
|
||||||
registrars_data = []
|
|
||||||
|
|
||||||
Registrar.where.not(test_registrar: true).find_each do |registrar|
|
|
||||||
registrars_data << {
|
|
||||||
registrar: registrar,
|
|
||||||
registrar_summery: registrar.monthly_summary(month: @month),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
registrars_data
|
|
||||||
end
|
|
||||||
|
|
||||||
def mark_invoice_as_sent(invoice: nil, res:, req:)
|
|
||||||
directo_record = Directo.new(response: res.as_json.to_h,
|
|
||||||
request: req, invoice_number: res.attributes['docid'].value.to_i)
|
|
||||||
if invoice
|
|
||||||
directo_record.item = invoice
|
|
||||||
invoice.update(in_directo: true)
|
|
||||||
else
|
|
||||||
update_directo_number(num: directo_record.invoice_number)
|
|
||||||
end
|
|
||||||
|
|
||||||
directo_record.save!
|
|
||||||
end
|
|
||||||
|
|
||||||
def update_directo_number(num:)
|
|
||||||
return unless num.to_i > Setting.directo_monthly_number_last.to_i
|
|
||||||
|
|
||||||
Setting.directo_monthly_number_last = num.to_i
|
|
||||||
end
|
|
||||||
|
|
||||||
def directo_counter_exceedable?(invoice_count)
|
|
||||||
min_directo = Setting.directo_monthly_number_min.presence.try(:to_i)
|
|
||||||
max_directo = Setting.directo_monthly_number_max.presence.try(:to_i)
|
|
||||||
last_directo = [Setting.directo_monthly_number_last.presence.try(:to_i),
|
|
||||||
min_directo].compact.max || 0
|
|
||||||
|
|
||||||
return true if max_directo && max_directo < (last_directo + invoice_count)
|
|
||||||
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -6,7 +6,8 @@ class SendEInvoiceJob < ApplicationJob
|
||||||
invoice = Invoice.find_by(id: invoice_id)
|
invoice = Invoice.find_by(id: invoice_id)
|
||||||
return unless need_to_process_invoice?(invoice: invoice, payable: payable)
|
return unless need_to_process_invoice?(invoice: invoice, payable: payable)
|
||||||
|
|
||||||
process(invoice: invoice, payable: payable)
|
send_invoice_to_eis_billing(invoice: invoice, payable: payable)
|
||||||
|
invoice.update(e_invoice_sent_at: Time.zone.now)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
log_error(invoice: invoice, error: e)
|
log_error(invoice: invoice, error: e)
|
||||||
raise e
|
raise e
|
||||||
|
@ -22,16 +23,9 @@ class SendEInvoiceJob < ApplicationJob
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(invoice:, payable:)
|
def send_invoice_to_eis_billing(invoice:, payable:)
|
||||||
invoice.to_e_invoice(payable: payable).deliver unless Rails.env.development?
|
result = EisBilling::SendEInvoice.send_request(invoice: invoice, payable: payable)
|
||||||
invoice.update(e_invoice_sent_at: Time.zone.now)
|
logger.info result.body
|
||||||
log_success(invoice)
|
|
||||||
end
|
|
||||||
|
|
||||||
def log_success(invoice)
|
|
||||||
id = invoice.try(:id) || invoice
|
|
||||||
message = "E-Invoice for an invoice with ID # #{id} was sent successfully"
|
|
||||||
logger.info message
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_error(invoice:, error:)
|
def log_error(invoice:, error:)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class SendEInvoiceTwoJob < ApplicationJob
|
class SendEInvoiceLegacyJob < ApplicationJob
|
||||||
discard_on HTTPClient::TimeoutError
|
discard_on HTTPClient::TimeoutError
|
||||||
|
|
||||||
def perform(invoice_id, payable: true)
|
def perform(invoice_id, payable: true)
|
||||||
|
@ -6,8 +6,7 @@ class SendEInvoiceTwoJob < ApplicationJob
|
||||||
invoice = Invoice.find_by(id: invoice_id)
|
invoice = Invoice.find_by(id: invoice_id)
|
||||||
return unless need_to_process_invoice?(invoice: invoice, payable: payable)
|
return unless need_to_process_invoice?(invoice: invoice, payable: payable)
|
||||||
|
|
||||||
send_invoice_to_eis_billing(invoice: invoice, payable: payable)
|
process(invoice: invoice, payable: payable)
|
||||||
invoice.update(e_invoice_sent_at: Time.zone.now)
|
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
log_error(invoice: invoice, error: e)
|
log_error(invoice: invoice, error: e)
|
||||||
raise e
|
raise e
|
||||||
|
@ -17,15 +16,23 @@ class SendEInvoiceTwoJob < ApplicationJob
|
||||||
|
|
||||||
def need_to_process_invoice?(invoice:, payable:)
|
def need_to_process_invoice?(invoice:, payable:)
|
||||||
logger.info "Checking if need to process e-invoice #{invoice}, payable: #{payable}"
|
logger.info "Checking if need to process e-invoice #{invoice}, payable: #{payable}"
|
||||||
|
unprocessable = invoice.do_not_send_e_invoice? && (invoice.monthly_invoice ? true : payable)
|
||||||
return false if invoice.blank?
|
return false if invoice.blank?
|
||||||
return false if invoice.do_not_send_e_invoice? && payable
|
return false if unprocessable
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_invoice_to_eis_billing(invoice:, payable:)
|
def process(invoice:, payable:)
|
||||||
result = EisBilling::SendEInvoice.send_request(invoice: invoice, payable: payable)
|
invoice.to_e_invoice(payable: payable).deliver unless Rails.env.development?
|
||||||
logger.info result.body
|
invoice.update(e_invoice_sent_at: Time.zone.now)
|
||||||
|
log_success(invoice)
|
||||||
|
end
|
||||||
|
|
||||||
|
def log_success(invoice)
|
||||||
|
id = invoice.try(:id) || invoice
|
||||||
|
message = "E-Invoice for an invoice with ID # #{id} was sent successfully"
|
||||||
|
logger.info message
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_error(invoice:, error:)
|
def log_error(invoice:, error:)
|
147
app/jobs/send_monthly_invoices_job.rb
Normal file
147
app/jobs/send_monthly_invoices_job.rb
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
class SendMonthlyInvoicesJob < ApplicationJob # rubocop:disable Metrics/ClassLength
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(dry: false)
|
||||||
|
@dry = dry
|
||||||
|
@month = Time.zone.now - 1.month
|
||||||
|
@directo_client = new_directo_client
|
||||||
|
@min_directo_num = Setting.directo_monthly_number_min.presence.try(:to_i)
|
||||||
|
@max_directo_num = Setting.directo_monthly_number_max.presence.try(:to_i)
|
||||||
|
|
||||||
|
send_monthly_invoices
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_directo_client
|
||||||
|
DirectoApi::Client.new(ENV['directo_invoice_url'], Setting.directo_sales_agent,
|
||||||
|
Setting.directo_receipt_payment_term)
|
||||||
|
end
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/MethodLength
|
||||||
|
def send_monthly_invoices
|
||||||
|
Registrar.with_cash_accounts.find_each do |registrar|
|
||||||
|
summary = registrar.monthly_summary(month: @month)
|
||||||
|
next if summary.nil?
|
||||||
|
|
||||||
|
invoice = registrar.monthly_invoice(month: @month) || create_invoice(summary, registrar)
|
||||||
|
next if invoice.nil? || @dry
|
||||||
|
|
||||||
|
send_email_to_registrar(invoice: invoice, registrar: registrar)
|
||||||
|
send_e_invoice(invoice.id)
|
||||||
|
next if invoice.in_directo
|
||||||
|
|
||||||
|
Rails.logger.info("[DIRECTO] Trying to send monthly invoice #{invoice.number}")
|
||||||
|
@directo_client = new_directo_client
|
||||||
|
directo_invoices = @directo_client.invoices.add_with_schema(invoice: summary,
|
||||||
|
schema: 'summary')
|
||||||
|
next unless directo_invoices.size.positive?
|
||||||
|
|
||||||
|
directo_invoices.last.number = invoice.number
|
||||||
|
sync_with_directo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
|
def send_email_to_registrar(invoice:, registrar:)
|
||||||
|
InvoiceMailer.invoice_email(invoice: invoice,
|
||||||
|
recipient: registrar.billing_email)
|
||||||
|
.deliver_now
|
||||||
|
end
|
||||||
|
|
||||||
|
def send_e_invoice(invoice_id)
|
||||||
|
SendEInvoiceLegacyJob.set(wait: 1.minute).perform_later(invoice_id, payable: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_invoice(summary, registrar)
|
||||||
|
invoice = registrar.init_monthly_invoice(normalize(summary))
|
||||||
|
invoice.number = assign_monthly_number
|
||||||
|
return unless invoice.save!
|
||||||
|
|
||||||
|
update_monthly_invoice_number(num: invoice.number)
|
||||||
|
invoice
|
||||||
|
end
|
||||||
|
|
||||||
|
def sync_with_directo
|
||||||
|
invoices_xml = @directo_client.invoices.as_xml
|
||||||
|
|
||||||
|
Rails.logger.info("[Directo] - attempting to send following XML:\n #{invoices_xml}")
|
||||||
|
|
||||||
|
res = @directo_client.invoices.deliver(ssl_verify: false)
|
||||||
|
process_directo_response(res.body, invoices_xml)
|
||||||
|
rescue SocketError, Errno::ECONNREFUSED, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
||||||
|
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
|
||||||
|
Rails.logger.info('[Directo] Failed to communicate via API')
|
||||||
|
end
|
||||||
|
|
||||||
|
def assign_monthly_number
|
||||||
|
last_directo_num = [Setting.directo_monthly_number_last.presence.try(:to_i),
|
||||||
|
@min_directo_num].compact.max || 0
|
||||||
|
raise 'Directo Counter is out of period!' if directo_counter_exceedable?(1, last_directo_num)
|
||||||
|
|
||||||
|
last_directo_num + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def directo_counter_exceedable?(invoices_count, last_directo_num)
|
||||||
|
return true if @max_directo_num && @max_directo_num < (last_directo_num + invoices_count)
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_directo_response(body, req)
|
||||||
|
Rails.logger.info "[Directo] - Responded with body: #{body}"
|
||||||
|
Nokogiri::XML(body).css('Result').each do |res|
|
||||||
|
inv = Invoice.find_by(number: res.attributes['docid'].value.to_i)
|
||||||
|
mark_invoice_as_sent_to_directo(res: res, req: req, invoice: inv)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def mark_invoice_as_sent_to_directo(res:, req:, invoice: nil)
|
||||||
|
directo_record = Directo.new(response: res.as_json.to_h,
|
||||||
|
request: req, invoice_number: res.attributes['docid'].value.to_i)
|
||||||
|
directo_record.item = invoice
|
||||||
|
invoice.update(in_directo: true)
|
||||||
|
|
||||||
|
directo_record.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_monthly_invoice_number(num:)
|
||||||
|
return unless num.to_i > Setting.directo_monthly_number_last.to_i
|
||||||
|
|
||||||
|
Setting.directo_monthly_number_last = num.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# rubocop:disable Metrics/MethodLength
|
||||||
|
def normalize(summary, lines: [])
|
||||||
|
sum = summary.dup
|
||||||
|
line_map = Hash.new 0
|
||||||
|
sum['invoice_lines'].each { |l| line_map[l] += 1 }
|
||||||
|
|
||||||
|
line_map.each_key do |count|
|
||||||
|
count['quantity'] = line_map[count] unless count['unit'].nil?
|
||||||
|
regex = /Domeenide ettemaks|Domains prepayment/
|
||||||
|
count['quantity'] = -1 if count['description'].match?(regex)
|
||||||
|
lines << count
|
||||||
|
end
|
||||||
|
|
||||||
|
sum['invoice_lines'] = summarize_lines(lines)
|
||||||
|
sum
|
||||||
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
|
def summarize_lines(invoice_lines, lines: [])
|
||||||
|
line_map = Hash.new 0
|
||||||
|
invoice_lines.each do |l|
|
||||||
|
hash = l.with_indifferent_access.except(:start_date, :end_date)
|
||||||
|
line_map[hash] += 1
|
||||||
|
end
|
||||||
|
|
||||||
|
line_map.each_key do |count|
|
||||||
|
count['price'] = (line_map[count] * count['price'].to_f).round(3) unless count['price'].nil?
|
||||||
|
lines << count
|
||||||
|
end
|
||||||
|
|
||||||
|
lines
|
||||||
|
end
|
||||||
|
end
|
|
@ -4,6 +4,7 @@ class InvoiceMailer < ApplicationMailer
|
||||||
|
|
||||||
subject = default_i18n_subject(invoice_number: invoice.number)
|
subject = default_i18n_subject(invoice_number: invoice.number)
|
||||||
subject << I18n.t('invoice.already_paid') if paid
|
subject << I18n.t('invoice.already_paid') if paid
|
||||||
|
subject << I18n.t('invoice.monthly_invoice') if invoice.monthly_invoice
|
||||||
attachments["invoice-#{invoice.number}.pdf"] = invoice.as_pdf
|
attachments["invoice-#{invoice.number}.pdf"] = invoice.as_pdf
|
||||||
mail(to: recipient, subject: subject)
|
mail(to: recipient, subject: subject)
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,10 +33,10 @@ class BankTransaction < ApplicationRecord
|
||||||
return unless autobindable?
|
return unless autobindable?
|
||||||
|
|
||||||
channel = manual ? 'admin_payment' : 'system_payment'
|
channel = manual ? 'admin_payment' : 'system_payment'
|
||||||
create_internal_payment_record(channel: channel, invoice: invoice, registrar: registrar)
|
create_internal_payment_record(invoice: invoice, registrar: registrar, channel: channel)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_internal_payment_record(channel: nil, invoice:, registrar:)
|
def create_internal_payment_record(invoice:, registrar:, channel: nil)
|
||||||
if channel.nil?
|
if channel.nil?
|
||||||
create_activity(invoice.buyer, invoice)
|
create_activity(invoice.buyer, invoice)
|
||||||
return
|
return
|
||||||
|
@ -47,9 +47,12 @@ class BankTransaction < ApplicationRecord
|
||||||
|
|
||||||
if create_activity(registrar, invoice)
|
if create_activity(registrar, invoice)
|
||||||
payment_order.paid!
|
payment_order.paid!
|
||||||
|
EisBilling::SendInvoiceStatus.send_info(invoice_number: invoice.number,
|
||||||
|
status: 'paid')
|
||||||
else
|
else
|
||||||
payment_order.update(notes: 'Failed to create activity', status: 'failed')
|
payment_order.update(notes: 'Failed to create activity', status: 'failed')
|
||||||
end
|
end
|
||||||
|
invoice
|
||||||
end
|
end
|
||||||
|
|
||||||
def bind_invoice(invoice_no, manual: false)
|
def bind_invoice(invoice_no, manual: false)
|
||||||
|
@ -62,8 +65,8 @@ class BankTransaction < ApplicationRecord
|
||||||
validate_invoice_data(invoice)
|
validate_invoice_data(invoice)
|
||||||
return if errors.any?
|
return if errors.any?
|
||||||
|
|
||||||
create_internal_payment_record(channel: (manual ? 'admin_payment' : nil), invoice: invoice,
|
create_internal_payment_record(invoice: invoice, registrar: invoice.buyer,
|
||||||
registrar: invoice.buyer)
|
channel: (manual ? 'admin_payment' : nil))
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_invoice_data(invoice)
|
def validate_invoice_data(invoice)
|
||||||
|
|
|
@ -4,13 +4,8 @@ module Billing
|
||||||
MULTI_REGEXP = /(\d{2,20})/
|
MULTI_REGEXP = /(\d{2,20})/
|
||||||
|
|
||||||
def self.generate
|
def self.generate
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
result = EisBilling::GetReferenceNumber.send_request
|
result = EisBilling::GetReferenceNumber.send_request
|
||||||
JSON.parse(result.body)['reference_number']
|
JSON.parse(result.body)['reference_number']
|
||||||
else
|
|
||||||
base = Base.generate
|
|
||||||
"#{base}#{base.check_digit}"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.valid?(ref)
|
def self.valid?(ref)
|
||||||
|
|
|
@ -34,7 +34,13 @@ module Domain::ForceDelete
|
||||||
reason = explicit&.downcase
|
reason = explicit&.downcase
|
||||||
return reason if %w[invalid_email invalid_phone].include?(reason)
|
return reason if %w[invalid_email invalid_phone].include?(reason)
|
||||||
|
|
||||||
registrant.org? ? 'legal_person' : 'private_person'
|
if contact_emails_verification_failed.present?
|
||||||
|
'invalid_email'
|
||||||
|
elsif registrant.org?
|
||||||
|
'legal_person'
|
||||||
|
else
|
||||||
|
'private_person'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def force_delete_scheduled?
|
def force_delete_scheduled?
|
||||||
|
|
|
@ -5,6 +5,10 @@ module EmailVerifable
|
||||||
scope :recently_not_validated, -> { where.not(id: ValidationEvent.validated_ids_by(name)) }
|
scope :recently_not_validated, -> { where.not(id: ValidationEvent.validated_ids_by(name)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def email_verification_failed?
|
||||||
|
need_to_start_force_delete?
|
||||||
|
end
|
||||||
|
|
||||||
def validate_email_data(level:, count:)
|
def validate_email_data(level:, count:)
|
||||||
validation_events.order(created_at: :desc).limit(count).all? do |event|
|
validation_events.order(created_at: :desc).limit(count).all? do |event|
|
||||||
event.check_level == level.to_s && event.failed?
|
event.check_level == level.to_s && event.failed?
|
||||||
|
|
|
@ -1,22 +1,27 @@
|
||||||
module Registrar::BookKeeping
|
module Registrar::BookKeeping # rubocop:disable Metrics/ModuleLength
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
DOMAIN_TO_PRODUCT = { 'ee': '01EE', 'com.ee': '02COM', 'pri.ee': '03PRI',
|
DOMAIN_TO_PRODUCT = { 'ee': '01EE', 'com.ee': '02COM', 'pri.ee': '03PRI',
|
||||||
'fie.ee': '04FIE', 'med.ee': '05MED' }.freeze
|
'fie.ee': '04FIE', 'med.ee': '05MED' }.freeze
|
||||||
|
|
||||||
|
included do
|
||||||
|
scope :with_cash_accounts, (lambda do
|
||||||
|
joins(:accounts).where('accounts.account_type = ? AND test_registrar != ?',
|
||||||
|
Account::CASH,
|
||||||
|
true)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
def monthly_summary(month:)
|
def monthly_summary(month:)
|
||||||
activities = monthly_activites(month)
|
activities = monthly_activites(month)
|
||||||
return unless activities.any?
|
return unless activities.any?
|
||||||
|
|
||||||
invoice = {
|
invoice = {
|
||||||
'number': 1,
|
'number': 1, 'customer': compose_directo_customer,
|
||||||
'customer': compose_directo_customer,
|
|
||||||
'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency,
|
'language': language == 'en' ? 'ENG' : '', 'currency': activities.first.currency,
|
||||||
'date': month.end_of_month.strftime('%Y-%m-%d')
|
'date': month.end_of_month.strftime('%Y-%m-%d')
|
||||||
}.as_json
|
}.as_json
|
||||||
|
|
||||||
invoice['invoice_lines'] = prepare_invoice_lines(month: month, activities: activities)
|
invoice['invoice_lines'] = prepare_invoice_lines(month: month, activities: activities)
|
||||||
|
|
||||||
invoice
|
invoice
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,20 +60,25 @@ module Registrar::BookKeeping
|
||||||
.where(activity_type: [AccountActivity::CREATE, AccountActivity::RENEW])
|
.where(activity_type: [AccountActivity::CREATE, AccountActivity::RENEW])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def monthly_invoice(month:)
|
||||||
|
invoices.where(monthly_invoice: true, issue_date: month.end_of_month.to_date,
|
||||||
|
cancelled_at: nil).first
|
||||||
|
end
|
||||||
|
|
||||||
def new_monthly_invoice_line(activity:, duration: nil)
|
def new_monthly_invoice_line(activity:, duration: nil)
|
||||||
price = load_price(activity)
|
price = load_price(activity)
|
||||||
line = {
|
line = {
|
||||||
'product_id': DOMAIN_TO_PRODUCT[price.zone_name.to_sym],
|
'product_id': DOMAIN_TO_PRODUCT[price.zone_name.to_sym],
|
||||||
'quantity': 1,
|
'quantity': 1,
|
||||||
'unit': language == 'en' ? 'pc' : 'tk',
|
'unit': language == 'en' ? 'pc' : 'tk',
|
||||||
}
|
}.with_indifferent_access
|
||||||
|
|
||||||
finalize_invoice_line(line, price: price, duration: duration, activity: activity)
|
finalize_invoice_line(line, price: price, duration: duration, activity: activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize_invoice_line(line, price:, activity:, duration:)
|
def finalize_invoice_line(line, price:, activity:, duration:)
|
||||||
yearly = price.duration.in_years.to_i >= 1
|
yearly = price.duration.in_years.to_i >= 1
|
||||||
line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i) : price.price.amount
|
line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i).to_f : price.price.amount.to_f
|
||||||
line['description'] = description_in_language(price: price, yearly: yearly)
|
line['description'] = description_in_language(price: price, yearly: yearly)
|
||||||
|
|
||||||
add_product_timeframe(line: line, activity: activity, duration: duration) if duration.present? && (duration > 1)
|
add_product_timeframe(line: line, activity: activity, duration: duration) if duration.present? && (duration > 1)
|
||||||
|
@ -79,15 +89,16 @@ module Registrar::BookKeeping
|
||||||
def add_product_timeframe(line:, activity:, duration:)
|
def add_product_timeframe(line:, activity:, duration:)
|
||||||
create_time = activity.created_at
|
create_time = activity.created_at
|
||||||
line['start_date'] = (create_time + (duration - 1).year).end_of_month.strftime('%Y-%m-%d')
|
line['start_date'] = (create_time + (duration - 1).year).end_of_month.strftime('%Y-%m-%d')
|
||||||
line['end_date'] = (create_time + (duration - 1).year + 1).end_of_month.strftime('%Y-%m-%d')
|
line['end_date'] = (create_time + duration.year).end_of_month.strftime('%Y-%m-%d')
|
||||||
end
|
end
|
||||||
|
|
||||||
def description_in_language(price:, yearly:)
|
def description_in_language(price:, yearly:)
|
||||||
timeframe_string = yearly ? 'yearly' : 'monthly'
|
timeframe_string = yearly ? 'yearly' : 'monthly'
|
||||||
locale_string = "registrar.invoice_#{timeframe_string}_product_description"
|
locale_string = "registrar.invoice_#{timeframe_string}_product_description"
|
||||||
|
length = yearly ? price.duration.in_years.to_i : price.duration.in_months.to_i
|
||||||
|
|
||||||
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
I18n.with_locale(language == 'en' ? 'en' : 'et') do
|
||||||
I18n.t(locale_string, tld: ".#{price.zone_name}", length: price.duration.in_years.to_i)
|
I18n.t(locale_string, tld: ".#{price.zone_name}", length: length)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@ class Contact < ApplicationRecord
|
||||||
alias_attribute :kind, :ident_type
|
alias_attribute :kind, :ident_type
|
||||||
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail
|
alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail
|
||||||
|
|
||||||
|
scope :email_verification_failed, lambda {
|
||||||
|
joins('LEFT JOIN email_address_verifications emv ON contacts.email = emv.email')
|
||||||
|
.where('success = false and verified_at IS NOT NULL')
|
||||||
|
}
|
||||||
|
|
||||||
scope :with_different_company_name, (lambda do |company|
|
scope :with_different_company_name, (lambda do |company|
|
||||||
where("ident = ? AND ident_country_code = 'EE' AND name != ?",
|
where("ident = ? AND ident_country_code = 'EE' AND name != ?",
|
||||||
company.registration_number,
|
company.registration_number,
|
||||||
|
|
|
@ -725,6 +725,10 @@ class Domain < ApplicationRecord
|
||||||
DNS::DomainName.new(name)
|
DNS::DomainName.new(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def contact_emails_verification_failed
|
||||||
|
contacts.select(&:email_verification_failed?)&.map(&:email)&.uniq
|
||||||
|
end
|
||||||
|
|
||||||
def as_csv_row
|
def as_csv_row
|
||||||
[
|
[
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -32,11 +32,14 @@ class Invoice < ApplicationRecord
|
||||||
# rubocop:enable Layout/LineLength
|
# rubocop:enable Layout/LineLength
|
||||||
# rubocop:enable Style/MultilineBlockLayout
|
# rubocop:enable Style/MultilineBlockLayout
|
||||||
validates :due_date, :currency, :seller_name,
|
validates :due_date, :currency, :seller_name,
|
||||||
:seller_iban, :buyer_name, :items, presence: true
|
:seller_iban, :buyer_name, presence: true
|
||||||
|
validates :items, presence: true, unless: -> { monthly_invoice }
|
||||||
|
|
||||||
before_create :set_invoice_number
|
before_create :set_invoice_number
|
||||||
before_create :calculate_total, unless: :total?
|
before_create :calculate_total, unless: :total?
|
||||||
before_create :apply_default_buyer_vat_no, unless: :buyer_vat_no?
|
before_create :apply_default_buyer_vat_no, unless: :buyer_vat_no?
|
||||||
|
skip_callback :create, :before, :set_invoice_number, if: -> { monthly_invoice }
|
||||||
|
skip_callback :create, :before, :calculate_total, if: -> { monthly_invoice }
|
||||||
|
|
||||||
attribute :vat_rate, ::Type::VatRate.new
|
attribute :vat_rate, ::Type::VatRate.new
|
||||||
|
|
||||||
|
@ -59,39 +62,13 @@ class Invoice < ApplicationRecord
|
||||||
throw(:abort)
|
throw(:abort)
|
||||||
end
|
end
|
||||||
|
|
||||||
def invoice_number_from_billing
|
def set_invoice_number
|
||||||
result = EisBilling::GetInvoiceNumber.send_invoice
|
result = EisBilling::GetInvoiceNumber.send_invoice
|
||||||
validate_invoice_number(result)
|
validate_invoice_number(result)
|
||||||
|
|
||||||
self.number = JSON.parse(result.body)['invoice_number'].to_i
|
self.number = JSON.parse(result.body)['invoice_number'].to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_invoice_number_legacy
|
|
||||||
last_no = Invoice.all
|
|
||||||
.where(number: Setting.invoice_number_min.to_i...Setting.invoice_number_max.to_i)
|
|
||||||
.order(number: :desc)
|
|
||||||
.limit(1)
|
|
||||||
.pick(:number)
|
|
||||||
|
|
||||||
if last_no && last_no >= Setting.invoice_number_min.to_i
|
|
||||||
self.number = last_no + 1
|
|
||||||
else
|
|
||||||
self.number = Setting.invoice_number_min.to_i
|
|
||||||
end
|
|
||||||
|
|
||||||
return if number <= Setting.invoice_number_max.to_i
|
|
||||||
|
|
||||||
billing_out_of_range_issue
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_invoice_number
|
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_number_from_billing
|
|
||||||
else
|
|
||||||
generate_invoice_number_legacy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
I18n.t('invoice_no', no: number)
|
I18n.t('invoice_no', no: number)
|
||||||
end
|
end
|
||||||
|
@ -118,7 +95,7 @@ class Invoice < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def subtotal
|
def subtotal
|
||||||
items.map(&:item_sum_without_vat).reduce(:+)
|
items.map(&:item_sum_without_vat).reduce(:+) || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def vat_amount
|
def vat_amount
|
||||||
|
@ -131,8 +108,12 @@ class Invoice < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def each(&block)
|
def each(&block)
|
||||||
|
if monthly_invoice
|
||||||
|
metadata['items'].map { |el| OpenStruct.new(el) }.each(&block)
|
||||||
|
else
|
||||||
items.each(&block)
|
items.each(&block)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def as_pdf
|
def as_pdf
|
||||||
generator = PdfGenerator.new(self)
|
generator = PdfGenerator.new(self)
|
||||||
|
|
|
@ -41,22 +41,16 @@ class Invoice
|
||||||
|
|
||||||
e_invoice_invoice_items = []
|
e_invoice_invoice_items = []
|
||||||
invoice.each do |invoice_item|
|
invoice.each do |invoice_item|
|
||||||
e_invoice_invoice_item = EInvoice::InvoiceItem.new.tap do |i|
|
e_invoice_invoice_item = generate_invoice_item(invoice, invoice_item)
|
||||||
i.description = invoice_item.description
|
|
||||||
i.price = invoice_item.price
|
|
||||||
i.quantity = invoice_item.quantity
|
|
||||||
i.unit = invoice_item.unit
|
|
||||||
i.subtotal = invoice_item.subtotal
|
|
||||||
i.vat_rate = invoice_item.vat_rate
|
|
||||||
i.vat_amount = invoice_item.vat_amount
|
|
||||||
i.total = invoice_item.total
|
|
||||||
end
|
|
||||||
e_invoice_invoice_items << e_invoice_invoice_item
|
e_invoice_invoice_items << e_invoice_invoice_item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
e_invoice_name_item = e_invoice_invoice_items.shift if invoice.monthly_invoice
|
||||||
|
|
||||||
e_invoice_invoice = EInvoice::Invoice.new.tap do |i|
|
e_invoice_invoice = EInvoice::Invoice.new.tap do |i|
|
||||||
i.seller = seller
|
i.seller = seller
|
||||||
i.buyer = buyer
|
i.buyer = buyer
|
||||||
|
i.name = e_invoice_name_item&.description
|
||||||
i.items = e_invoice_invoice_items
|
i.items = e_invoice_invoice_items
|
||||||
i.number = invoice.number
|
i.number = invoice.number
|
||||||
i.date = invoice.issue_date
|
i.date = invoice.issue_date
|
||||||
|
@ -72,9 +66,33 @@ class Invoice
|
||||||
i.currency = invoice.currency
|
i.currency = invoice.currency
|
||||||
i.delivery_channel = %i[internet_bank portal]
|
i.delivery_channel = %i[internet_bank portal]
|
||||||
i.payable = payable
|
i.payable = payable
|
||||||
|
i.monthly_invoice = invoice.monthly_invoice
|
||||||
end
|
end
|
||||||
|
|
||||||
EInvoice::EInvoice.new(date: Time.zone.today, invoice: e_invoice_invoice)
|
EInvoice::EInvoice.new(date: Time.zone.today, invoice: e_invoice_invoice)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def generate_invoice_item(invoice, item)
|
||||||
|
EInvoice::InvoiceItem.new.tap do |i|
|
||||||
|
i.description = item.description
|
||||||
|
i.unit = item.unit
|
||||||
|
i.price = item.price
|
||||||
|
i.quantity = item.quantity
|
||||||
|
if invoice.monthly_invoice && item.price && item.quantity
|
||||||
|
i.product_id = item.product_id
|
||||||
|
i.vat_rate = invoice.vat_rate
|
||||||
|
i.subtotal = (item.price * item.quantity).round(3)
|
||||||
|
i.vat_amount = i.subtotal * (i.vat_rate / 100)
|
||||||
|
i.total = i.subtotal + i.vat_amount
|
||||||
|
else
|
||||||
|
i.subtotal = item.subtotal
|
||||||
|
i.vat_rate = item.vat_rate
|
||||||
|
i.vat_amount = item.vat_amount
|
||||||
|
i.total = item.total
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,8 @@ class Invoice
|
||||||
private
|
private
|
||||||
|
|
||||||
def invoice_html
|
def invoice_html
|
||||||
ApplicationController.render(template: 'invoice/pdf', assigns: { invoice: invoice })
|
template = invoice.monthly_invoice ? 'invoice/monthly_pdf' : 'invoice/pdf'
|
||||||
|
ApplicationController.render(template: template, assigns: { invoice: invoice })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Registrar < ApplicationRecord
|
class Registrar < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
||||||
include Versions # version/registrar_version.rb
|
include Versions # version/registrar_version.rb
|
||||||
include Registrar::BookKeeping
|
include Registrar::BookKeeping
|
||||||
include EmailVerifable
|
include EmailVerifable
|
||||||
|
@ -56,9 +56,48 @@ class Registrar < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_prepayment_invoice(amount, description = nil, payable: true)
|
# rubocop:disable Metrics/MethodLength
|
||||||
vat_rate = ::Invoice::VatRateCalculator.new(registrar: self).calculate
|
def init_monthly_invoice(summary)
|
||||||
|
Invoice.new(
|
||||||
|
issue_date: summary['date'].to_date,
|
||||||
|
due_date: summary['date'].to_date,
|
||||||
|
currency: 'EUR',
|
||||||
|
description: I18n.t('invoice.monthly_invoice_description'),
|
||||||
|
seller_name: Setting.registry_juridical_name,
|
||||||
|
seller_reg_no: Setting.registry_reg_no,
|
||||||
|
seller_iban: Setting.registry_iban,
|
||||||
|
seller_bank: Setting.registry_bank,
|
||||||
|
seller_swift: Setting.registry_swift,
|
||||||
|
seller_vat_no: Setting.registry_vat_no,
|
||||||
|
seller_country_code: Setting.registry_country_code,
|
||||||
|
seller_state: Setting.registry_state,
|
||||||
|
seller_street: Setting.registry_street,
|
||||||
|
seller_city: Setting.registry_city,
|
||||||
|
seller_zip: Setting.registry_zip,
|
||||||
|
seller_phone: Setting.registry_phone,
|
||||||
|
seller_url: Setting.registry_url,
|
||||||
|
seller_email: Setting.registry_email,
|
||||||
|
seller_contact_name: Setting.registry_invoice_contact,
|
||||||
|
buyer: self,
|
||||||
|
buyer_name: name,
|
||||||
|
buyer_reg_no: reg_no,
|
||||||
|
buyer_country_code: address_country_code,
|
||||||
|
buyer_state: address_state,
|
||||||
|
buyer_street: address_street,
|
||||||
|
buyer_city: address_city,
|
||||||
|
buyer_zip: address_zip,
|
||||||
|
buyer_phone: phone,
|
||||||
|
buyer_url: website,
|
||||||
|
buyer_email: email,
|
||||||
|
reference_no: reference_no,
|
||||||
|
vat_rate: calculate_vat_rate,
|
||||||
|
monthly_invoice: true,
|
||||||
|
metadata: { items: summary['invoice_lines'] },
|
||||||
|
total: 0
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def issue_prepayment_invoice(amount, description = nil, payable: true)
|
||||||
invoice = invoices.create!(
|
invoice = invoices.create!(
|
||||||
issue_date: Time.zone.today,
|
issue_date: Time.zone.today,
|
||||||
due_date: (Time.zone.now + Setting.days_to_keep_invoices_active.days).to_date,
|
due_date: (Time.zone.now + Setting.days_to_keep_invoices_active.days).to_date,
|
||||||
|
@ -91,7 +130,7 @@ class Registrar < ApplicationRecord
|
||||||
buyer_url: website,
|
buyer_url: website,
|
||||||
buyer_email: email,
|
buyer_email: email,
|
||||||
reference_no: reference_no,
|
reference_no: reference_no,
|
||||||
vat_rate: vat_rate,
|
vat_rate: calculate_vat_rate,
|
||||||
items_attributes: [
|
items_attributes: [
|
||||||
{
|
{
|
||||||
description: 'prepayment',
|
description: 'prepayment',
|
||||||
|
@ -107,23 +146,17 @@ class Registrar < ApplicationRecord
|
||||||
.deliver_later(wait: 1.minute)
|
.deliver_later(wait: 1.minute)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
add_invoice_instance = EisBilling::AddDeposits.new(invoice)
|
add_invoice_instance = EisBilling::AddDeposits.new(invoice)
|
||||||
result = add_invoice_instance.send_invoice
|
result = add_invoice_instance.send_invoice
|
||||||
|
|
||||||
link = JSON.parse(result.body)['everypay_link']
|
link = JSON.parse(result.body)['everypay_link']
|
||||||
|
|
||||||
invoice.update(payment_link: link)
|
invoice.update(payment_link: link)
|
||||||
end
|
|
||||||
|
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
SendEInvoiceTwoJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
|
||||||
else
|
|
||||||
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable)
|
||||||
end
|
|
||||||
|
|
||||||
invoice
|
invoice
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
||||||
def cash_account
|
def cash_account
|
||||||
accounts.find_by(account_type: Account::CASH)
|
accounts.find_by(account_type: Account::CASH)
|
||||||
|
@ -265,4 +298,8 @@ class Registrar < ApplicationRecord
|
||||||
def vat_liable_in_foreign_country?
|
def vat_liable_in_foreign_country?
|
||||||
!vat_liable_locally?
|
!vat_liable_locally?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def calculate_vat_rate
|
||||||
|
::Invoice::VatRateCalculator.new(registrar: self).calculate
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,6 +52,10 @@ class DomainPresenter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def contact_emails_verification_failed
|
||||||
|
domain.contact_emails_verification_failed.join(', ')
|
||||||
|
end
|
||||||
|
|
||||||
def remove_registry_lock_btn
|
def remove_registry_lock_btn
|
||||||
return unless domain.locked_by_registrant?
|
return unless domain.locked_by_registrant?
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ module EisBilling
|
||||||
data[:custom_field1] = invoice.description
|
data[:custom_field1] = invoice.description
|
||||||
data[:custom_field2] = INITIATOR
|
data[:custom_field2] = INITIATOR
|
||||||
data[:invoice_number] = invoice.number
|
data[:invoice_number] = invoice.number
|
||||||
|
data[:reference_number] = invoice.reference_no
|
||||||
|
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label t(:status) %>
|
<%= f.label t(:status) %>
|
||||||
<%= select_tag :status, options_for_select(%w(Paid Unpaid Cancelled),params[:status]),
|
<%= select_tag :status, options_for_select(%w(Paid Unpaid Cancelled Monthly),params[:status]),
|
||||||
{ multiple: false, include_blank: true, selected: params[:status], class: 'form-control selectize'} %>
|
{ multiple: false, include_blank: true, selected: params[:status], class: 'form-control selectize'} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
%td= l invoice.receipt_date
|
%td= l invoice.receipt_date
|
||||||
- elsif invoice.cancelled?
|
- elsif invoice.cancelled?
|
||||||
%td.text-grey= t(:cancelled)
|
%td.text-grey= t(:cancelled)
|
||||||
|
- elsif invoice.monthly_invoice
|
||||||
|
%td= l invoice.issue_date
|
||||||
- else
|
- else
|
||||||
%td.text-danger= t(:unpaid)
|
%td.text-danger= t(:unpaid)
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
= @invoice
|
= @invoice
|
||||||
.col-sm-8
|
.col-sm-8
|
||||||
%h1.text-right.text-center-xs
|
%h1.text-right.text-center-xs
|
||||||
|
- unless @invoice.monthly_invoice
|
||||||
- if @invoice.unpaid?
|
- if @invoice.unpaid?
|
||||||
= link_to(t(:payment_received), new_admin_bank_statement_path(invoice_id: @invoice.id), class: 'btn btn-default')
|
= link_to(t(:payment_received), new_admin_bank_statement_path(invoice_id: @invoice.id), class: 'btn btn-default')
|
||||||
|
|
||||||
- if @invoice.paid? and !@invoice.cancelled?
|
- if @invoice.paid? && !@invoice.cancelled?
|
||||||
= link_to(t(:cancel_payment), cancel_paid_admin_invoices_path(invoice_id: @invoice.id), method: 'post', data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning')
|
= link_to(t(:cancel_payment), cancel_paid_admin_invoices_path(invoice_id: @invoice.id), method: 'post', data: { confirm: t(:are_you_sure) }, class: 'btn btn-warning')
|
||||||
|
|
||||||
= link_to(t('.download_btn'), download_admin_invoice_path(@invoice), class: 'btn btn-default')
|
= link_to(t('.download_btn'), download_admin_invoice_path(@invoice), class: 'btn btn-default')
|
||||||
|
@ -24,6 +25,9 @@
|
||||||
.col-md-6= render 'registrar/invoices/partials/seller'
|
.col-md-6= render 'registrar/invoices/partials/seller'
|
||||||
.col-md-6= render 'registrar/invoices/partials/buyer'
|
.col-md-6= render 'registrar/invoices/partials/buyer'
|
||||||
.row
|
.row
|
||||||
|
- if @invoice.monthly_invoice
|
||||||
|
.col-md-12= render 'registrar/invoices/partials/monthly_invoice_items'
|
||||||
|
- else
|
||||||
.col-md-12= render 'registrar/invoices/partials/items'
|
.col-md-12= render 'registrar/invoices/partials/items'
|
||||||
.row
|
.row
|
||||||
.col-md-12= render 'registrar/invoices/partials/payment_orders'
|
.col-md-12= render 'registrar/invoices/partials/payment_orders'
|
||||||
|
|
277
app/views/invoice/monthly_pdf.haml
Normal file
277
app/views/invoice/monthly_pdf.haml
Normal file
|
@ -0,0 +1,277 @@
|
||||||
|
%html{lang: I18n.locale.to_s}
|
||||||
|
%head
|
||||||
|
%meta{charset: "utf-8"}
|
||||||
|
:css
|
||||||
|
.container {
|
||||||
|
margin: auto;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-md-12 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-md-6 {
|
||||||
|
width: 49%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-xs-4 {
|
||||||
|
width: 33%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-xs-2 {
|
||||||
|
width: 16%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-md-3 {
|
||||||
|
width: 24%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left {
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
dt {
|
||||||
|
float: left;
|
||||||
|
width: 100px;
|
||||||
|
clear: left;
|
||||||
|
text-align: right;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 1.42857;
|
||||||
|
}
|
||||||
|
|
||||||
|
dd {
|
||||||
|
margin-left: 120px;
|
||||||
|
line-height: 1.42857;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
text-align: left;
|
||||||
|
border: 0px;
|
||||||
|
border-top: 1px solid #DDD;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead th {
|
||||||
|
border-bottom: 2px solid #DDD;
|
||||||
|
border-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
border-top: 1px solid #DDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-border {
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr {
|
||||||
|
height: 1px;
|
||||||
|
border: 0;
|
||||||
|
color: #DDD;
|
||||||
|
background-color: #DDD;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pull-down {
|
||||||
|
margin-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header {
|
||||||
|
position: relative;
|
||||||
|
min-height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 106px;
|
||||||
|
height: 102px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header-content {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
width: 99%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
%body
|
||||||
|
.container
|
||||||
|
#header.row
|
||||||
|
.col-sm-6.left
|
||||||
|
#header-content
|
||||||
|
%h1
|
||||||
|
= @invoice
|
||||||
|
.col-sm-6.right
|
||||||
|
%img{src: "#{Rails.root}/public/eis-logo-black-et.png"}
|
||||||
|
.clear
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-6.left
|
||||||
|
%h4
|
||||||
|
Details
|
||||||
|
%hr
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t(:issue_date)
|
||||||
|
%dd= l @invoice.issue_date
|
||||||
|
|
||||||
|
- if @invoice.cancelled?
|
||||||
|
%dt= Invoice.human_attribute_name :cancelled_at
|
||||||
|
%dd= l @invoice.cancelled_at
|
||||||
|
|
||||||
|
%dt= t(:due_date)
|
||||||
|
- if @invoice.cancelled?
|
||||||
|
%dd= t(:cancelled)
|
||||||
|
- else
|
||||||
|
%dd= l @invoice.due_date
|
||||||
|
|
||||||
|
%dt= t(:issuer)
|
||||||
|
%dd= @invoice.seller_contact_name
|
||||||
|
|
||||||
|
- if @invoice.description.present?
|
||||||
|
%dt= t(:description)
|
||||||
|
%dd=@invoice.description
|
||||||
|
|
||||||
|
%dt= Invoice.human_attribute_name :reference_no
|
||||||
|
%dd= @invoice.reference_no
|
||||||
|
|
||||||
|
.col-md-6.right
|
||||||
|
%h4= t(:client)
|
||||||
|
%hr
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt= t(:name)
|
||||||
|
%dd= @invoice.buyer_name
|
||||||
|
|
||||||
|
%dt= t(:reg_no)
|
||||||
|
%dd= @invoice.buyer_reg_no
|
||||||
|
|
||||||
|
- if @invoice.buyer_address.present?
|
||||||
|
%dt= Invoice.human_attribute_name :address
|
||||||
|
%dd= @invoice.buyer_address
|
||||||
|
|
||||||
|
- if @invoice.buyer_country.present?
|
||||||
|
%dt= t(:country)
|
||||||
|
%dd= @invoice.buyer_country
|
||||||
|
|
||||||
|
- if @invoice.buyer_phone.present?
|
||||||
|
%dt= t(:phone)
|
||||||
|
%dd= @invoice.buyer_phone
|
||||||
|
|
||||||
|
- if @invoice.buyer_url.present?
|
||||||
|
%dt= t(:url)
|
||||||
|
%dd= @invoice.buyer_url
|
||||||
|
|
||||||
|
- if @invoice.buyer_email.present?
|
||||||
|
%dt= t(:email)
|
||||||
|
%dd= @invoice.buyer_email
|
||||||
|
|
||||||
|
.clear
|
||||||
|
.row.pull-down
|
||||||
|
.col-md-12
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{class: 'col-xs-1'}= t(:code)
|
||||||
|
%th{class: 'col-xs-1'}= InvoiceItem.human_attribute_name :quantity
|
||||||
|
%th{class: 'col-xs-1'}= t(:unit)
|
||||||
|
%th{class: 'col-xs-5'}= t(:description)
|
||||||
|
%th{class: 'col-xs-2'}= t(:price)
|
||||||
|
%th{class: 'col-xs-2'}= t(:total)
|
||||||
|
%tbody
|
||||||
|
- @invoice.each do |invoice_item|
|
||||||
|
%tr
|
||||||
|
%td= invoice_item.product_id
|
||||||
|
%td= invoice_item.quantity
|
||||||
|
%td= invoice_item.unit
|
||||||
|
%td= invoice_item.description
|
||||||
|
- if invoice_item.price && invoice_item.quantity
|
||||||
|
%td= currency(invoice_item.price)
|
||||||
|
%td= "#{currency((invoice_item.price * invoice_item.quantity).round(3))} #{@invoice.currency}"
|
||||||
|
- else
|
||||||
|
%td= ''
|
||||||
|
%td= ''
|
||||||
|
%tfoot
|
||||||
|
%tr
|
||||||
|
%th{colspan: 4}
|
||||||
|
%th= Invoice.human_attribute_name :subtotal
|
||||||
|
%td= number_to_currency(0)
|
||||||
|
%tr
|
||||||
|
%th.no-border{colspan: 4}
|
||||||
|
%th= "VAT #{number_to_percentage(@invoice.vat_rate, precision: 1)}"
|
||||||
|
%td= number_to_currency(0)
|
||||||
|
%tr
|
||||||
|
%th.no-border{colspan: 4}
|
||||||
|
%th= t(:total)
|
||||||
|
%td= number_to_currency(0)
|
||||||
|
|
||||||
|
#footer
|
||||||
|
%hr
|
||||||
|
.row
|
||||||
|
.col-md-3.left
|
||||||
|
= @invoice.seller_name
|
||||||
|
%br
|
||||||
|
= @invoice.seller_address
|
||||||
|
%br
|
||||||
|
= @invoice.seller_country
|
||||||
|
%br
|
||||||
|
= "#{t('reg_no')} #{@invoice.seller_reg_no}"
|
||||||
|
%br
|
||||||
|
= "#{Registrar.human_attribute_name :vat_no} #{@invoice.seller_vat_no}"
|
||||||
|
|
||||||
|
.col-md-3.left
|
||||||
|
= @invoice.seller_phone
|
||||||
|
%br
|
||||||
|
= @invoice.seller_email
|
||||||
|
%br
|
||||||
|
= @invoice.seller_url
|
||||||
|
|
||||||
|
.col-md-3.text-right.left
|
||||||
|
= t(:bank)
|
||||||
|
%br
|
||||||
|
= t(:iban)
|
||||||
|
%br
|
||||||
|
= t(:swift)
|
||||||
|
|
||||||
|
.col-md-3.left
|
||||||
|
= @invoice.seller_bank
|
||||||
|
%br
|
||||||
|
= @invoice.seller_iban
|
||||||
|
%br
|
||||||
|
= @invoice.seller_swift
|
|
@ -0,0 +1,45 @@
|
||||||
|
<p>Lugupeetud domeeni <%= @domain.name %> registreerija/halduskontakt</p>
|
||||||
|
|
||||||
|
<p>Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et domeeni <%= @domain.name %> kontaktandmed on puudulikud - eposti aadress <%= @domain.contact_emails_verification_failed %>.</p>
|
||||||
|
|
||||||
|
<p>Et see olukord on vastuolus .ee <a href='https://www.internet.ee/domains/ee-domain-regulation'>domeenireeglitega</a> algatas EIS <%= @delete_period_length %> päeva pikkuse kustutusmenetluse. Menetluse käigus on domeen <%= @expire_warning_period %> esimest päeva internetis kättesaadav.</p>
|
||||||
|
|
||||||
|
<p>Andmete parandamiseks pöörduge palun oma registripidaja <%= @registrar.name %> poole või isiklike ja oma ettevõtte andmete puhul <a href="https://registrant.internet.ee/">registreerija portaali</a>.</p>
|
||||||
|
|
||||||
|
<p>Kui kontaktandmed ei ole <%= @delete_period_length %> päeva jooksul parandatud, läheb domeen <%= @domain.name %> <%= @domain.force_delete_date %> domeenioksjonile <a href="https://auction.internet.ee">.ee oksjonikeskkonda</a>. Juhul kui domeenile <%= @domain.name %> ei tehta oksjonil 24h möödudes pakkumist, domeen vabaneb ja on registreerimiseks vabalt kättesaadav kõigile huvilistele. Muude võimalike oksjoni tulemuste kohta loe <a href="https://www.internet.ee/domeenid/domeenide-oksjonikeskkonna-kasutajatingimused#3-oksjonikeskkonna-enampakkumisel-osalemise-tingimused">siit</a>.</p>
|
||||||
|
|
||||||
|
<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
|
||||||
|
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||||
|
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Dear registrant/administrative contact of .ee domain,</p>
|
||||||
|
|
||||||
|
<p>Estonian Internet Foundation has learned that contact data of the domain <%= @domain.name %> s invalid - email(s) <%= @domain.contact_emails_verification_failed %>.</p>
|
||||||
|
|
||||||
|
<p>Since this is a violation of <a href='https://www.internet.ee/domains/ee-domain-regulation'>Estonian domain regulations</a>, <%= @delete_period_length %>-day deletion process has started for the <%= @domain.name %> domain. For the first <%= @expire_warning_period %> days the domain will remain available on the Internet during the deletion process.</p>
|
||||||
|
|
||||||
|
<p>Please, contact your registrar <%= @registrar.name %> with updated contact data, or in case of your personal or business data use <a href="https://registrant.internet.ee/">.ee portal for registrants</a></p>
|
||||||
|
|
||||||
|
<p>If the data is not fixed within <%= @delete_period_length %> days, the domain <%= @domain.name %> will go to domain auction on <%= @domain.force_delete_date %> in the <a href="https://auction.internet.ee">.ee auction environment</a>. If no offer is made for the domain <%= @domain.name %> at auction within 24 hours, the domain will be released and made freely available for registration to anyone interested on a first-come, first-served basis. Read more about other potential auction results <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">here</a>.</p>
|
||||||
|
|
||||||
|
<p>Should you have additional questions, please contact your registrar:</p>
|
||||||
|
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||||
|
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Уважаемый регистрант/административный контакт домена .ee</p>
|
||||||
|
|
||||||
|
<p>Целевому учреждению Eesti Internet (EIS) стало известно, что контактные данные домена <%= @registrant.reg_no %> неверны - электронная почта <%= @domain.contact_emails_verification_failed %>.</p>
|
||||||
|
|
||||||
|
<p>Так как это является нарушением <a href='https://www.internet.ee/domains/ee-domain-regulation'>Правил домена .ee</a>, <%= @delete_period_length %>-дневный процесс удаления начат для доменного имени <%= @domain.name %>. В течение первых <%= @expire_warning_period %> дней домен будет доступен в интернете.</p>
|
||||||
|
|
||||||
|
<p>Для уточнения контактных данных, пожалуйста, свяжитесь с регистратором <%= @registrar.name %>, либо воспользуйтесь <a href="https://registrant.internet.ee/">порталом для регистрантов</a></p>
|
||||||
|
|
||||||
|
<p>Если контактные данные не будут исправлены в течение <%= @delete_period_length %> дней, домен <%= @domain.name %> отправится <%= @domain.force_delete_date %> на доменный аукцион в <a href="https://auction.internet.ee">аукционной среде.ee</a>. Если в течение 24 часов в отношении домена <%= @domain.name %> е поступит предложений, домен освободится и станет доступным для всех желающих по принципу «кто раньше». О других возможных результатах аукциона читайте <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">здесь</a>.</p>
|
||||||
|
|
||||||
|
<p>В случае возникновения дополнительных вопросов свяжитесь, пожалуйста, со своим регистратором:
|
||||||
|
<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %></p>
|
||||||
|
|
||||||
|
<%= render 'mailers/shared/signatures/signature.ru.html' %>
|
|
@ -0,0 +1,45 @@
|
||||||
|
<p>Lugupeetud domeeni <%= @domain.name %> registreerija/halduskontakt</p>
|
||||||
|
|
||||||
|
<p>Eesti Interneti Sihtasutusele (EIS) on saanud teatavaks, et domeeni <%= @domain.name %> kontaktandmed on puudulikud - eposti aadress <%= @domain.contact_emails_verification_failed %></p>
|
||||||
|
|
||||||
|
<p>Et see olukord on vastuolus .ee <a href='https://www.internet.ee/domains/ee-domain-regulation'>domeenireeglitega</a> algatas EIS <%= @delete_period_length %> päeva pikkuse kustutusmenetluse. Menetluse käigus on domeen <%= @expire_warning_period %> esimest päeva internetis kättesaadav.</p>
|
||||||
|
|
||||||
|
<p>Andmete parandamiseks pöörduge palun oma registripidaja <%= @registrar.name %> poole või isiklike ja oma ettevõtte andmete puhul <a href="https://registrant.internet.ee/">registreerija portaali</a>.</p>
|
||||||
|
|
||||||
|
<p>Kui kontaktandmed ei ole <%= @delete_period_length %> päeva jooksul parandatud, läheb domeen <%= @domain.name %> <%= @domain.force_delete_date %> domeenioksjonile <a href="https://auction.internet.ee">.ee oksjonikeskkonda</a>. Juhul kui domeenile <%= @domain.name %> ei tehta oksjonil 24h möödudes pakkumist, domeen vabaneb ja on registreerimiseks vabalt kättesaadav kõigile huvilistele. Muude võimalike oksjoni tulemuste kohta loe <a href="https://www.internet.ee/domeenid/domeenide-oksjonikeskkonna-kasutajatingimused#3-oksjonikeskkonna-enampakkumisel-osalemise-tingimused">siit</a>.</p>
|
||||||
|
|
||||||
|
<p>Lisaküsimuste korral võtke palun ühendust oma registripidajaga:</p>
|
||||||
|
<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrar %>
|
||||||
|
<%= render 'mailers/shared/signatures/signature.et.html' %>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Dear registrant/administrative contact of .ee domain,</p>
|
||||||
|
|
||||||
|
<p>Estonian Internet Foundation has learned that contact data of the domain <%= @domain.name %> s invalid - email(s) <%= @domain.contact_emails_verification_failed %>.</p>
|
||||||
|
|
||||||
|
<p>Since this is a violation of <a href='https://www.internet.ee/domains/ee-domain-regulation'>Estonian domain regulations</a>, <%= @delete_period_length %>-day deletion process has started for the <%= @domain.name %> domain. For the first <%= @expire_warning_period %> days the domain will remain available on the Internet during the deletion process.</p>
|
||||||
|
|
||||||
|
<p>Please, contact your registrar <%= @registrar.name %> with updated contact data, or in case of your personal or business data use <a href="https://registrant.internet.ee/">.ee portal for registrants</a></p>
|
||||||
|
|
||||||
|
<p>If the data is not fixed within <%= @delete_period_length %> days, the domain <%= @domain.name %> will go to domain auction on <%= @domain.force_delete_date %> in the <a href="https://auction.internet.ee">.ee auction environment</a>. If no offer is made for the domain <%= @domain.name %> at auction within 24 hours, the domain will be released and made freely available for registration to anyone interested on a first-come, first-served basis. Read more about other potential auction results <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">here</a>.</p>
|
||||||
|
|
||||||
|
<p>Should you have additional questions, please contact your registrar:</p>
|
||||||
|
<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrar %>
|
||||||
|
<%= render 'mailers/shared/signatures/signature.en.html' %>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<p>Уважаемый регистрант/административный контакт домена .ee</p>
|
||||||
|
|
||||||
|
<p>Целевому учреждению Eesti Internet (EIS) стало известно, что контактные данные домена <%= @registrant.reg_no %> неверны - электронная почта <%= @domain.contact_emails_verification_failed %>.</p>
|
||||||
|
|
||||||
|
<p>Так как это является нарушением <a href='https://www.internet.ee/domains/ee-domain-regulation'>Правил домена .ee</a>, <%= @delete_period_length %>-дневный процесс удаления начат для доменного имени <%= @domain.name %>. В течение первых <%= @expire_warning_period %> дней домен будет доступен в интернете.</p>
|
||||||
|
|
||||||
|
<p>Для уточнения контактных данных, пожалуйста, свяжитесь с регистратором <%= @registrar.name %>, либо воспользуйтесь <a href="https://registrant.internet.ee/">порталом для регистрантов</a></p>
|
||||||
|
|
||||||
|
<p>Если контактные данные не будут исправлены в течение <%= @delete_period_length %> дней, домен <%= @domain.name %> отправится <%= @domain.force_delete_date %> на доменный аукцион в <a href="https://auction.internet.ee">аукционной среде.ee</a>. Если в течение 24 часов в отношении домена <%= @domain.name %> е поступит предложений, домен освободится и станет доступным для всех желающих по принципу «кто раньше». О других возможных результатах аукциона читайте <a href="https://www.internet.ee/domains/auction-environment-user-agreement#3-terms-and-conditions-for-participation-in-the-auction-of-the-auction-environment">здесь</a>.</p>
|
||||||
|
|
||||||
|
<p>В случае возникновения дополнительных вопросов свяжитесь, пожалуйста, со своим регистратором:
|
||||||
|
<%= render 'mailers/shared/registrar/registrar.ru.html', registrar: @registrar %></p>
|
||||||
|
|
||||||
|
<%= render 'mailers/shared/signatures/signature.ru.html' %>
|
|
@ -19,6 +19,8 @@
|
||||||
%dd= l @invoice.receipt_date
|
%dd= l @invoice.receipt_date
|
||||||
- elsif @invoice.cancelled?
|
- elsif @invoice.cancelled?
|
||||||
%dd.text-grey= t(:cancelled)
|
%dd.text-grey= t(:cancelled)
|
||||||
|
- elsif @invoice.monthly_invoice
|
||||||
|
%dd= l @invoice.issue_date
|
||||||
- else
|
- else
|
||||||
%dd{class: 'text-danger'}= t(:unpaid)
|
%dd{class: 'text-danger'}= t(:unpaid)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
%h4= t(:items)
|
||||||
|
%hr
|
||||||
|
.table-responsive
|
||||||
|
%table.table.table-hover.table-condensed
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{class: 'col-xs-1'}= t(:code)
|
||||||
|
%th{class: 'col-xs-1'}= InvoiceItem.human_attribute_name :quantity
|
||||||
|
%th{class: 'col-xs-1'}= t(:unit)
|
||||||
|
%th{class: 'col-xs-5'}= t(:description)
|
||||||
|
%th{class: 'col-xs-2'}= t(:price)
|
||||||
|
%th{class: 'col-xs-2'}= t(:total)
|
||||||
|
%tbody
|
||||||
|
- @invoice.each do |invoice_item|
|
||||||
|
%tr
|
||||||
|
%td= invoice_item.product_id
|
||||||
|
%td= invoice_item.quantity
|
||||||
|
%td= invoice_item.unit
|
||||||
|
%td= invoice_item.description
|
||||||
|
- if invoice_item.price && invoice_item.quantity
|
||||||
|
%td= currency(invoice_item.price)
|
||||||
|
%td= "#{currency((invoice_item.price * invoice_item.quantity).round(3))} #{@invoice.currency}"
|
||||||
|
- else
|
||||||
|
%td= ''
|
||||||
|
%td= ''
|
||||||
|
%tfoot
|
||||||
|
%tr
|
||||||
|
%th{colspan: 4}
|
||||||
|
%th= Invoice.human_attribute_name :subtotal
|
||||||
|
%td= number_to_currency(0)
|
||||||
|
%tr
|
||||||
|
%th.no-border{colspan: 4}
|
||||||
|
%th= "VAT #{number_to_percentage(@invoice.vat_rate, precision: 1)}"
|
||||||
|
%td= number_to_currency(0)
|
||||||
|
%tr
|
||||||
|
%th.no-border{colspan: 4}
|
||||||
|
%th= t(:total)
|
||||||
|
%td= number_to_currency(0)
|
|
@ -13,6 +13,9 @@
|
||||||
.col-md-6= render 'registrar/invoices/partials/seller'
|
.col-md-6= render 'registrar/invoices/partials/seller'
|
||||||
.col-md-6= render 'registrar/invoices/partials/buyer'
|
.col-md-6= render 'registrar/invoices/partials/buyer'
|
||||||
.row
|
.row
|
||||||
|
- if @invoice.monthly_invoice
|
||||||
|
.col-md-12= render 'registrar/invoices/partials/monthly_invoice_items'
|
||||||
|
- else
|
||||||
.col-md-12= render 'registrar/invoices/partials/items'
|
.col-md-12= render 'registrar/invoices/partials/items'
|
||||||
|
|
||||||
- if @invoice.payable?
|
- if @invoice.payable?
|
||||||
|
|
|
@ -484,6 +484,8 @@ en:
|
||||||
invoice:
|
invoice:
|
||||||
title: 'Invoice'
|
title: 'Invoice'
|
||||||
already_paid: " (already paid)"
|
already_paid: " (already paid)"
|
||||||
|
monthly_invoice: " (monthly invoice)"
|
||||||
|
monthly_invoice_description: 'Monthly invoice'
|
||||||
bank_statements: 'Bank statements'
|
bank_statements: 'Bank statements'
|
||||||
back_to_bank_statements: 'Back to bank statements'
|
back_to_bank_statements: 'Back to bank statements'
|
||||||
back_to_bank_statement: 'Back to bank statement'
|
back_to_bank_statement: 'Back to bank statement'
|
||||||
|
|
|
@ -9,3 +9,5 @@ et:
|
||||||
invoice:
|
invoice:
|
||||||
title: 'Arve'
|
title: 'Arve'
|
||||||
already_paid: " (juba makstud)"
|
already_paid: " (juba makstud)"
|
||||||
|
monthly_invoice: " (kuuaruanne)"
|
||||||
|
monthly_invoice_description: 'Kuuaruanne'
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddMonthlyInvoiceTypeColumns < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
add_column :invoices, :monthly_invoice, :boolean, default: false
|
||||||
|
add_column :invoices, :metadata, :jsonb
|
||||||
|
end
|
||||||
|
end
|
339
db/structure.sql
339
db/structure.sql
|
@ -955,14 +955,14 @@ CREATE TABLE public.domains (
|
||||||
pending_json jsonb,
|
pending_json jsonb,
|
||||||
force_delete_date date,
|
force_delete_date date,
|
||||||
statuses character varying[],
|
statuses character varying[],
|
||||||
|
status_notes public.hstore,
|
||||||
upid integer,
|
upid integer,
|
||||||
up_date timestamp without time zone,
|
up_date timestamp without time zone,
|
||||||
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
uuid uuid DEFAULT public.gen_random_uuid() NOT NULL,
|
||||||
locked_by_registrant_at timestamp without time zone,
|
locked_by_registrant_at timestamp without time zone,
|
||||||
force_delete_start timestamp without time zone,
|
force_delete_start timestamp without time zone,
|
||||||
force_delete_data public.hstore,
|
force_delete_data public.hstore,
|
||||||
json_statuses_history jsonb,
|
json_statuses_history jsonb
|
||||||
status_notes public.hstore
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -985,6 +985,98 @@ CREATE SEQUENCE public.domains_id_seq
|
||||||
ALTER SEQUENCE public.domains_id_seq OWNED BY public.domains.id;
|
ALTER SEQUENCE public.domains_id_seq OWNED BY public.domains.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_address_verifications; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.email_address_verifications (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
email public.citext NOT NULL,
|
||||||
|
verified_at timestamp without time zone,
|
||||||
|
success boolean DEFAULT false NOT NULL,
|
||||||
|
domain public.citext NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_address_verifications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.email_address_verifications_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_address_verifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.email_address_verifications_id_seq OWNED BY public.email_address_verifications.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_validations; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.email_addresses_validations (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
email character varying NOT NULL,
|
||||||
|
validated_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_validations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.email_addresses_validations_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_validations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.email_addresses_validations_id_seq OWNED BY public.email_addresses_validations.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_verifications; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.email_addresses_verifications (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
email character varying NOT NULL,
|
||||||
|
validated_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_verifications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.email_addresses_verifications_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_verifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.email_addresses_verifications_id_seq OWNED BY public.email_addresses_verifications.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: epp_sessions; Type: TABLE; Schema: public; Owner: -
|
-- Name: epp_sessions; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1104,6 +1196,8 @@ CREATE TABLE public.invoices (
|
||||||
issue_date date NOT NULL,
|
issue_date date NOT NULL,
|
||||||
e_invoice_sent_at timestamp without time zone,
|
e_invoice_sent_at timestamp without time zone,
|
||||||
payment_link character varying,
|
payment_link character varying,
|
||||||
|
monthly_invoice boolean DEFAULT false,
|
||||||
|
metadata jsonb,
|
||||||
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
|
CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2190,6 +2284,74 @@ CREATE SEQUENCE public.payment_orders_id_seq
|
||||||
ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id;
|
ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.pghero_query_stats (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
database text,
|
||||||
|
"user" text,
|
||||||
|
query text,
|
||||||
|
query_hash bigint,
|
||||||
|
total_time double precision,
|
||||||
|
calls bigint,
|
||||||
|
captured_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.pghero_query_stats_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.pghero_space_stats (
|
||||||
|
id bigint NOT NULL,
|
||||||
|
database text,
|
||||||
|
schema text,
|
||||||
|
relation text,
|
||||||
|
size bigint,
|
||||||
|
captured_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.pghero_space_stats_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: prices; Type: TABLE; Schema: public; Owner: -
|
-- Name: prices; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -2228,6 +2390,48 @@ CREATE SEQUENCE public.prices_id_seq
|
||||||
ALTER SEQUENCE public.prices_id_seq OWNED BY public.prices.id;
|
ALTER SEQUENCE public.prices_id_seq OWNED BY public.prices.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: que_jobs; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.que_jobs (
|
||||||
|
priority smallint DEFAULT 100 NOT NULL,
|
||||||
|
run_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
job_id bigint NOT NULL,
|
||||||
|
job_class text NOT NULL,
|
||||||
|
args json DEFAULT '[]'::json NOT NULL,
|
||||||
|
error_count integer DEFAULT 0 NOT NULL,
|
||||||
|
last_error text,
|
||||||
|
queue text DEFAULT ''::text NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: TABLE que_jobs; Type: COMMENT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
COMMENT ON TABLE public.que_jobs IS '3';
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: que_jobs_job_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE public.que_jobs_job_id_seq
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: que_jobs_job_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE public.que_jobs_job_id_seq OWNED BY public.que_jobs.job_id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -
|
-- Name: registrant_verifications; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -2508,8 +2712,7 @@ CREATE TABLE public.validation_events (
|
||||||
validation_eventable_type character varying,
|
validation_eventable_type character varying,
|
||||||
validation_eventable_id bigint,
|
validation_eventable_id bigint,
|
||||||
created_at timestamp(6) without time zone NOT NULL,
|
created_at timestamp(6) without time zone NOT NULL,
|
||||||
updated_at timestamp(6) without time zone NOT NULL,
|
updated_at timestamp(6) without time zone NOT NULL
|
||||||
event_type public.validation_type
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -2813,6 +3016,27 @@ ALTER TABLE ONLY public.domain_transfers ALTER COLUMN id SET DEFAULT nextval('pu
|
||||||
ALTER TABLE ONLY public.domains ALTER COLUMN id SET DEFAULT nextval('public.domains_id_seq'::regclass);
|
ALTER TABLE ONLY public.domains ALTER COLUMN id SET DEFAULT nextval('public.domains_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_address_verifications id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.email_address_verifications ALTER COLUMN id SET DEFAULT nextval('public.email_address_verifications_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_validations id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.email_addresses_validations ALTER COLUMN id SET DEFAULT nextval('public.email_addresses_validations_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_verifications id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.email_addresses_verifications ALTER COLUMN id SET DEFAULT nextval('public.email_addresses_verifications_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: epp_sessions id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: epp_sessions id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3030,6 +3254,20 @@ ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('publi
|
||||||
ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass);
|
ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: prices id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: prices id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3037,6 +3275,13 @@ ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('publ
|
||||||
ALTER TABLE ONLY public.prices ALTER COLUMN id SET DEFAULT nextval('public.prices_id_seq'::regclass);
|
ALTER TABLE ONLY public.prices ALTER COLUMN id SET DEFAULT nextval('public.prices_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: que_jobs job_id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.que_jobs ALTER COLUMN job_id SET DEFAULT nextval('public.que_jobs_job_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: registrant_verifications id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: registrant_verifications id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3274,6 +3519,30 @@ ALTER TABLE ONLY public.domains
|
||||||
ADD CONSTRAINT domains_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT domains_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_address_verifications email_address_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.email_address_verifications
|
||||||
|
ADD CONSTRAINT email_address_verifications_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_validations email_addresses_validations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.email_addresses_validations
|
||||||
|
ADD CONSTRAINT email_addresses_validations_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: email_addresses_verifications email_addresses_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.email_addresses_verifications
|
||||||
|
ADD CONSTRAINT email_addresses_verifications_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: epp_sessions epp_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: epp_sessions epp_sessions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3522,6 +3791,22 @@ ALTER TABLE ONLY public.payment_orders
|
||||||
ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_query_stats
|
||||||
|
ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.pghero_space_stats
|
||||||
|
ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3530,6 +3815,14 @@ ALTER TABLE ONLY public.prices
|
||||||
ADD CONSTRAINT prices_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT prices_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: que_jobs que_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.que_jobs
|
||||||
|
ADD CONSTRAINT que_jobs_pkey PRIMARY KEY (queue, priority, run_at, job_id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: registrant_verifications registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: registrant_verifications registrant_verifications_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3941,6 +4234,13 @@ CREATE INDEX index_domains_on_registrar_id ON public.domains USING btree (regist
|
||||||
CREATE INDEX index_domains_on_statuses ON public.domains USING gin (statuses);
|
CREATE INDEX index_domains_on_statuses ON public.domains USING gin (statuses);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_email_address_verifications_on_domain; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_email_address_verifications_on_domain ON public.email_address_verifications USING btree (domain);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_epp_sessions_on_updated_at; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -4277,6 +4577,20 @@ CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING b
|
||||||
CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id);
|
CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -4333,13 +4647,6 @@ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_
|
||||||
CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data);
|
CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data);
|
||||||
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Name: index_validation_events_on_event_type; Type: INDEX; Schema: public; Owner: -
|
|
||||||
--
|
|
||||||
|
|
||||||
CREATE INDEX index_validation_events_on_event_type ON public.validation_events USING btree (event_type);
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -5085,9 +5392,11 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20210708131814'),
|
('20210708131814'),
|
||||||
('20210729131100'),
|
('20210729131100'),
|
||||||
('20210729134625'),
|
('20210729134625'),
|
||||||
('20210827185249'),
|
('20211028122103'),
|
||||||
('20211029073644'),
|
('20211028125245'),
|
||||||
|
('20211029082225'),
|
||||||
('20211124071418'),
|
('20211124071418'),
|
||||||
|
('20211124084308'),
|
||||||
('20211125181033'),
|
('20211125181033'),
|
||||||
('20211125184334'),
|
('20211125184334'),
|
||||||
('20211126085139'),
|
('20211126085139'),
|
||||||
|
@ -5096,6 +5405,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20220113201642'),
|
('20220113201642'),
|
||||||
('20220113220809'),
|
('20220113220809'),
|
||||||
('20220124105717'),
|
('20220124105717'),
|
||||||
|
('20220216113112'),
|
||||||
('20220228093211'),
|
('20220228093211'),
|
||||||
('20220316140727'),
|
('20220316140727'),
|
||||||
('20220406085500'),
|
('20220406085500'),
|
||||||
|
@ -5104,6 +5414,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20220413084536'),
|
('20220413084536'),
|
||||||
('20220413084748'),
|
('20220413084748'),
|
||||||
('20220504090512'),
|
('20220504090512'),
|
||||||
('20220524130709');
|
('20220524130709'),
|
||||||
|
('20220818075833');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ module Serializers
|
||||||
created_at: obj.created_at, updated_at: obj.updated_at,
|
created_at: obj.created_at, updated_at: obj.updated_at,
|
||||||
due_date: obj.due_date, currency: obj.currency,
|
due_date: obj.due_date, currency: obj.currency,
|
||||||
seller: seller, buyer: buyer, items: items,
|
seller: seller, buyer: buyer, items: items,
|
||||||
recipient: obj.buyer.billing_email
|
recipient: obj.buyer.billing_email,
|
||||||
|
monthly_invoice: obj.monthly_invoice
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,6 +55,9 @@ module Serializers
|
||||||
end
|
end
|
||||||
|
|
||||||
def items
|
def items
|
||||||
|
if invoice.monthly_invoice
|
||||||
|
invoice.metadata['items']
|
||||||
|
else
|
||||||
invoice.items.map do |item|
|
invoice.items.map do |item|
|
||||||
{ description: item.description, unit: item.unit,
|
{ description: item.description, unit: item.unit,
|
||||||
quantity: item.quantity, price: item.price,
|
quantity: item.quantity, price: item.price,
|
||||||
|
@ -61,6 +65,7 @@ module Serializers
|
||||||
vat_amount: item.vat_amount, total: item.total }
|
vat_amount: item.vat_amount, total: item.total }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def simple_object
|
def simple_object
|
||||||
{
|
{
|
||||||
|
@ -75,6 +80,7 @@ module Serializers
|
||||||
due_date: invoice.due_date,
|
due_date: invoice.due_date,
|
||||||
total: invoice.total,
|
total: invoice.total,
|
||||||
recipient: invoice.buyer.billing_email,
|
recipient: invoice.buyer.billing_email,
|
||||||
|
monthly_invoice: invoice.monthly_invoice,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/MethodLength
|
# rubocop:enable Metrics/MethodLength
|
||||||
|
|
|
@ -24,7 +24,6 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_new_invoice
|
def test_create_new_invoice
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
|
@ -48,7 +47,6 @@ class AdminAreaInvoicesIntegrationTest < ApplicationIntegrationTest
|
||||||
|
|
||||||
assert_equal page.status_code, 200
|
assert_equal page.status_code, 200
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_visit_list_of_invoices_pages
|
def test_visit_list_of_invoices_pages
|
||||||
visit admin_invoices_path
|
visit admin_invoices_path
|
||||||
|
|
|
@ -10,7 +10,6 @@ class DirectoResponseTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_created_directo_instance
|
def test_should_created_directo_instance
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
directo_response_from_billing = {
|
directo_response_from_billing = {
|
||||||
response: @response_xml,
|
response: @response_xml,
|
||||||
month: true
|
month: true
|
||||||
|
@ -21,10 +20,8 @@ class DirectoResponseTest < ApplicationIntegrationTest
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_should_update_related_invoice
|
def test_should_update_related_invoice
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
directo_response_from_billing = {
|
directo_response_from_billing = {
|
||||||
response: @response_xml
|
response: @response_xml
|
||||||
}
|
}
|
||||||
|
@ -39,5 +36,4 @@ class DirectoResponseTest < ApplicationIntegrationTest
|
||||||
@invoice.reload
|
@invoice.reload
|
||||||
assert @invoice.in_directo
|
assert @invoice.in_directo
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,36 +8,34 @@ class LhvConnectTransactionsIntegrationTest < ApplicationIntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_saved_transaction_data
|
def test_should_saved_transaction_data
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
test_transaction_1 = OpenStruct.new(amount: 0.1,
|
test_transaction_1 = OpenStruct.new(amount: 0.1,
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
date: Time.zone.today,
|
date: Time.zone.today,
|
||||||
payment_reference_number: '2199812',
|
payment_reference_number: '2199812',
|
||||||
payment_description: "description 2199812")
|
payment_description: 'description 2199812')
|
||||||
|
|
||||||
test_transaction_2 = OpenStruct.new(amount: 0.1,
|
test_transaction_2 = OpenStruct.new(amount: 0.1,
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
date: Time.zone.today,
|
date: Time.zone.today,
|
||||||
payment_reference_number: '2199813',
|
payment_reference_number: '2199813',
|
||||||
payment_description: "description 2199813")
|
payment_description: 'description 2199813')
|
||||||
|
|
||||||
test_transaction_3 = OpenStruct.new(amount: 0.1,
|
test_transaction_3 = OpenStruct.new(amount: 0.1,
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
date: Time.zone.today,
|
date: Time.zone.today,
|
||||||
payment_reference_number: '2199814',
|
payment_reference_number: '2199814',
|
||||||
payment_description: "description 2199814")
|
payment_description: 'description 2199814')
|
||||||
|
|
||||||
lhv_transactions = []
|
lhv_transactions = []
|
||||||
lhv_transactions << test_transaction_1
|
lhv_transactions << test_transaction_1
|
||||||
lhv_transactions << test_transaction_2
|
lhv_transactions << test_transaction_2
|
||||||
lhv_transactions << test_transaction_3
|
lhv_transactions << test_transaction_3
|
||||||
|
|
||||||
assert_difference 'BankStatement.count', 3 do
|
assert_difference 'BankStatement.count', 1 do
|
||||||
assert_difference 'BankTransaction.count', 3 do
|
assert_difference 'BankTransaction.count', 3 do
|
||||||
post eis_billing_lhv_connect_transactions_path, params: { "_json" => JSON.parse(lhv_transactions.to_json) },
|
post eis_billing_lhv_connect_transactions_path, params: { '_json' => JSON.parse(lhv_transactions.to_json) },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
32
test/integration/eis_billing/payment_status_test.rb
Normal file
32
test/integration/eis_billing/payment_status_test.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class PaymentStatusTest < ApplicationIntegrationTest
|
||||||
|
setup do
|
||||||
|
sign_in users(:api_bestnames)
|
||||||
|
@invoice = invoices(:one)
|
||||||
|
@unpaid = invoices(:unpaid)
|
||||||
|
@registrar = registrars(:bestnames)
|
||||||
|
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def shoudl_update_buyer_balance
|
||||||
|
assert @invoice.paid?
|
||||||
|
assert_equal @invoice.buyer.balance.to_f, 100.0
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
payment_state: 'settled',
|
||||||
|
order_reference: @unpaid.number,
|
||||||
|
standing_amount: @unpaid.total,
|
||||||
|
transaction_time: Time.zone.now,
|
||||||
|
}
|
||||||
|
|
||||||
|
put eis_billing_payment_status_path, params: payload
|
||||||
|
|
||||||
|
@invoice.reload
|
||||||
|
@invoice.buyer.reload
|
||||||
|
@registrar.reload
|
||||||
|
|
||||||
|
assert @invoice.paid?
|
||||||
|
assert_equal @invoice.buyer.balance.to_f, 100.0
|
||||||
|
end
|
||||||
|
end
|
|
@ -12,6 +12,18 @@ class ReppV1InvoicesAddCreditTest < ActionDispatch::IntegrationTest
|
||||||
eis_response = OpenStruct.new(body: '{"everypay_link":"https://link.test"}')
|
eis_response = OpenStruct.new(body: '{"everypay_link":"https://link.test"}')
|
||||||
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
Spy.on_instance_method(EisBilling::AddDeposits, :send_invoice).and_return(eis_response)
|
||||||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||||
|
|
||||||
|
invoice = Invoice.last
|
||||||
|
msg = {
|
||||||
|
invoice_number: invoice.number + 3
|
||||||
|
}
|
||||||
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
||||||
|
.to_return(status: 200, body: msg.to_json, headers: {})
|
||||||
|
|
||||||
|
msg2 = {
|
||||||
|
message: 'success'
|
||||||
|
}
|
||||||
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").to_return(status: 200, body: msg2.to_json, headers: {})
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
|
@ -28,13 +40,11 @@ class ReppV1InvoicesAddCreditTest < ActionDispatch::IntegrationTest
|
||||||
Setting.registry_vat_prc = 0.1
|
Setting.registry_vat_prc = 0.1
|
||||||
ENV['billing_system_integrated'] = 'true'
|
ENV['billing_system_integrated'] = 'true'
|
||||||
|
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||||
.to_return(status: 200, body: '', headers: {})
|
.to_return(status: 200, body: '', headers: {})
|
||||||
end
|
|
||||||
|
|
||||||
post '/repp/v1/invoices/add_credit', headers: @auth_headers,
|
post '/repp/v1/invoices/add_credit', headers: @auth_headers,
|
||||||
params: request_body
|
params: request_body
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
class DirectoInvoiceForwardLegacyJobTest < ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
@invoice = invoices(:one)
|
@invoice = invoices(:one)
|
||||||
@user = registrars(:bestnames)
|
@user = registrars(:bestnames)
|
||||||
|
@ -8,9 +8,9 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
Setting.directo_monthly_number_min = 309901
|
Setting.directo_monthly_number_min = 309_901
|
||||||
Setting.directo_monthly_number_max = 309999
|
Setting.directo_monthly_number_max = 309_999
|
||||||
Setting.directo_monthly_number_last = 309901
|
Setting.directo_monthly_number_last = 309_901
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_directo_json_sends_customer_as_hash
|
def test_directo_json_sends_customer_as_hash
|
||||||
|
@ -38,7 +38,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
end.to_return(status: 200, body: response)
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: false, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: false, dry: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_not_empty @invoice.directo_records.first.request
|
assert_not_empty @invoice.directo_records.first.request
|
||||||
|
@ -49,10 +49,10 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
price = billing_prices(:create_one_year)
|
price = billing_prices(:create_one_year)
|
||||||
activity.update!(activity_type: 'create', price: price)
|
activity.update!(activity_type: 'create', price: price)
|
||||||
|
|
||||||
Setting.directo_monthly_number_max = 30991
|
Setting.directo_monthly_number_max = 30_991
|
||||||
|
|
||||||
assert_raises 'RuntimeError' do
|
assert_raises 'RuntimeError' do
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
end.to_return(status: 200, body: response)
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
assert_difference 'Setting.directo_monthly_number_last' do
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
end.to_return(status: 200, body: response)
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
assert_difference 'Setting.directo_monthly_number_last' do
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
end.to_return(status: 200, body: response)
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
assert_difference 'Setting.directo_monthly_number_last' do
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
end.to_return(status: 200, body: response)
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
assert_difference 'Setting.directo_monthly_number_last' do
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ class DirectoInvoiceForwardJobTest < ActiveSupport::TestCase
|
||||||
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'goodnames')
|
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'goodnames')
|
||||||
end.to_return(status: 200, body: response)
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
DirectoInvoiceForwardJob.perform_now(monthly: true, dry: false)
|
DirectoInvoiceForwardLegacyJob.perform_now(monthly: true, dry: false)
|
||||||
|
|
||||||
assert_requested first_registrar_stub
|
assert_requested first_registrar_stub
|
||||||
assert_requested second_registrar_stub
|
assert_requested second_registrar_stub
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class SendEInvoiceJobTest < ActiveJob::TestCase
|
class SendEInvoiceLegacyJobTest < ActiveJob::TestCase
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||||
EInvoice::Providers::TestProvider.deliveries.clear
|
EInvoice::Providers::TestProvider.deliveries.clear
|
||||||
|
|
||||||
|
msg = { message: 'success' }
|
||||||
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||||
|
.to_return(status: 200, body: msg.to_json, headers: {})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_if_invoice_is_sent
|
def test_if_invoice_is_sent
|
||||||
|
@ -15,7 +19,7 @@ class SendEInvoiceJobTest < ActiveJob::TestCase
|
||||||
|
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
perform_enqueued_jobs do
|
perform_enqueued_jobs do
|
||||||
SendEInvoiceJob.perform_now(@invoice.id, payable: true)
|
SendEInvoiceLegacyJob.perform_now(@invoice.id, payable: true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@invoice.reload
|
@invoice.reload
|
279
test/jobs/send_monthly_invoices_job_test.rb
Normal file
279
test/jobs/send_monthly_invoices_job_test.rb
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class SendMonthlyInvoicesJobTest < ActiveSupport::TestCase
|
||||||
|
include ActionMailer::TestHelper
|
||||||
|
|
||||||
|
setup do
|
||||||
|
@user = registrars(:bestnames)
|
||||||
|
@date = Time.zone.parse('2010-08-06')
|
||||||
|
travel_to @date
|
||||||
|
ActionMailer::Base.deliveries.clear
|
||||||
|
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||||
|
EInvoice::Providers::TestProvider.deliveries.clear
|
||||||
|
|
||||||
|
response = { message: 'sucess' }
|
||||||
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice")
|
||||||
|
.to_return(status: 200, body: response.to_json, headers: {})
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
Setting.directo_monthly_number_min = 309_901
|
||||||
|
Setting.directo_monthly_number_max = 309_999
|
||||||
|
Setting.directo_monthly_number_last = 309_901
|
||||||
|
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||||
|
EInvoice::Providers::TestProvider.deliveries.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_fails_if_directo_bounds_exceedable
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_year)
|
||||||
|
activity.update!(activity_type: 'create', price: price)
|
||||||
|
|
||||||
|
Setting.directo_monthly_number_max = 30_991
|
||||||
|
|
||||||
|
assert_no_difference 'Directo.count' do
|
||||||
|
assert_raises 'RuntimeError' do
|
||||||
|
SendMonthlyInvoicesJob.perform_now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_nil Invoice.find_by_monthly_invoice(true)
|
||||||
|
assert_emails 0
|
||||||
|
assert_equal 0, EInvoice::Providers::TestProvider.deliveries.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_summary_is_not_delivered_if_dry
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_year)
|
||||||
|
activity.update!(activity_type: 'create', price: price)
|
||||||
|
@user.update(language: 'et')
|
||||||
|
|
||||||
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
|
assert_no_difference 'Directo.count' do
|
||||||
|
SendMonthlyInvoicesJob.perform_now(dry: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
invoice = Invoice.last
|
||||||
|
assert_equal 309_902, invoice.number
|
||||||
|
refute invoice.in_directo
|
||||||
|
assert invoice.e_invoice_sent_at.blank?
|
||||||
|
|
||||||
|
assert_emails 0
|
||||||
|
assert_equal 0, EInvoice::Providers::TestProvider.deliveries.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_summary_is_delivered_if_invoice_already_exists
|
||||||
|
@monthly_invoice = invoices(:one)
|
||||||
|
@monthly_invoice.update(number: 309_902, monthly_invoice: true,
|
||||||
|
issue_date: @date.last_month.end_of_month,
|
||||||
|
due_date: @date.last_month.end_of_month,
|
||||||
|
metadata: metadata,
|
||||||
|
in_directo: false,
|
||||||
|
e_invoice_sent_at: nil)
|
||||||
|
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_year)
|
||||||
|
activity.update!(activity_type: 'create', price: price)
|
||||||
|
@user.update(language: 'et')
|
||||||
|
|
||||||
|
response = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<results>
|
||||||
|
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
|
||||||
|
</results>
|
||||||
|
XML
|
||||||
|
|
||||||
|
stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||||
|
body = CGI.unescape(request.body)
|
||||||
|
|
||||||
|
(body.include? '.test registreerimine: 1 aasta(t)') &&
|
||||||
|
(body.include? 'Domeenide ettemaks') &&
|
||||||
|
(body.include? '309902')
|
||||||
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
|
assert_no_difference 'Setting.directo_monthly_number_last' do
|
||||||
|
assert_difference('Directo.count', 1) do
|
||||||
|
SendMonthlyInvoicesJob.perform_now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
|
||||||
|
invoice = Invoice.last
|
||||||
|
assert_equal 309_902, invoice.number
|
||||||
|
assert invoice.in_directo
|
||||||
|
assert_not invoice.e_invoice_sent_at.blank?
|
||||||
|
|
||||||
|
assert_emails 1
|
||||||
|
email = ActionMailer::Base.deliveries.last
|
||||||
|
assert_equal ['billing@bestnames.test'], email.to
|
||||||
|
assert_equal 'Invoice no. 309902 (monthly invoice)', email.subject
|
||||||
|
assert email.attachments['invoice-309902.pdf']
|
||||||
|
|
||||||
|
# assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_summary_is_delivered_in_estonian
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_month)
|
||||||
|
activity.update!(activity_type: 'create', price: price)
|
||||||
|
@user.update(language: 'et')
|
||||||
|
|
||||||
|
response = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<results>
|
||||||
|
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
|
||||||
|
</results>
|
||||||
|
XML
|
||||||
|
|
||||||
|
stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||||
|
body = CGI.unescape(request.body)
|
||||||
|
|
||||||
|
(body.include? '.test registreerimine: 3 kuu(d)') &&
|
||||||
|
(body.include? 'Domeenide ettemaks') &&
|
||||||
|
(body.include? '309902')
|
||||||
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
|
assert_difference('Directo.count', 1) do
|
||||||
|
SendMonthlyInvoicesJob.perform_now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
|
||||||
|
invoice = Invoice.last
|
||||||
|
assert_equal 309_902, invoice.number
|
||||||
|
assert invoice.in_directo
|
||||||
|
assert_not invoice.e_invoice_sent_at.blank?
|
||||||
|
|
||||||
|
assert_emails 1
|
||||||
|
email = ActionMailer::Base.deliveries.last
|
||||||
|
assert_equal ['billing@bestnames.test'], email.to
|
||||||
|
assert_equal 'Invoice no. 309902 (monthly invoice)', email.subject
|
||||||
|
assert email.attachments['invoice-309902.pdf']
|
||||||
|
|
||||||
|
# assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_multi_year_purchases_have_duration_assigned
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_year)
|
||||||
|
price.update(duration: 3.years)
|
||||||
|
activity.update(activity_type: 'create', price: price)
|
||||||
|
|
||||||
|
response = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<results>
|
||||||
|
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
|
||||||
|
</results>
|
||||||
|
XML
|
||||||
|
|
||||||
|
stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||||
|
body = CGI.unescape(request.body)
|
||||||
|
(body.include? 'StartDate') && (body.include? 'EndDate')
|
||||||
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
|
SendMonthlyInvoicesJob.perform_now
|
||||||
|
end
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
|
||||||
|
invoice = Invoice.last
|
||||||
|
assert_equal 309_902, invoice.number
|
||||||
|
assert invoice.in_directo
|
||||||
|
assert_not invoice.e_invoice_sent_at.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_monthly_duration_products_are_present_in_summary
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_month)
|
||||||
|
activity.update(activity_type: 'create', price: price)
|
||||||
|
|
||||||
|
response = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<results>
|
||||||
|
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
|
||||||
|
</results>
|
||||||
|
XML
|
||||||
|
|
||||||
|
stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||||
|
body = CGI.unescape(request.body)
|
||||||
|
body.include? 'month(s)'
|
||||||
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
|
assert_difference 'Setting.directo_monthly_number_last' do
|
||||||
|
SendMonthlyInvoicesJob.perform_now
|
||||||
|
end
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
|
||||||
|
invoice = Invoice.last
|
||||||
|
assert_equal 309_902, invoice.number
|
||||||
|
assert invoice.in_directo
|
||||||
|
assert_not invoice.e_invoice_sent_at.blank?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_sends_each_monthly_invoice_separately
|
||||||
|
WebMock.reset!
|
||||||
|
|
||||||
|
activity = account_activities(:one)
|
||||||
|
price = billing_prices(:create_one_year)
|
||||||
|
price.update(duration: 3.years)
|
||||||
|
activity.update(activity_type: 'create', price: price)
|
||||||
|
|
||||||
|
# Creating account activity for second action
|
||||||
|
another_activity = activity.dup
|
||||||
|
another_activity.account = accounts(:two)
|
||||||
|
|
||||||
|
AccountActivity.skip_callback(:create, :after, :update_balance)
|
||||||
|
another_activity.created_at = Time.zone.parse('2010-07-05 10:00')
|
||||||
|
another_activity.save
|
||||||
|
AccountActivity.set_callback(:create, :after, :update_balance)
|
||||||
|
|
||||||
|
response = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<results>
|
||||||
|
<Result Type="0" Desc="OK" docid="309902" doctype="ARVE" submit="Invoices"/>
|
||||||
|
</results>
|
||||||
|
XML
|
||||||
|
|
||||||
|
first_registrar_stub = stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||||
|
body = CGI.unescape(request.body)
|
||||||
|
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'bestnames')
|
||||||
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
|
second_registrar_stub = stub_request(:post, ENV['directo_invoice_url']).with do |request|
|
||||||
|
body = CGI.unescape(request.body)
|
||||||
|
(body.include? 'StartDate') && (body.include? 'EndDate') && (body.include? 'goodnames')
|
||||||
|
end.to_return(status: 200, body: response)
|
||||||
|
|
||||||
|
assert_difference('Invoice.count', 2) do
|
||||||
|
assert_difference('Directo.count', 2) do
|
||||||
|
SendMonthlyInvoicesJob.perform_now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
perform_enqueued_jobs
|
||||||
|
|
||||||
|
assert_requested first_registrar_stub
|
||||||
|
assert_requested second_registrar_stub
|
||||||
|
|
||||||
|
assert_emails 2
|
||||||
|
assert_equal 2, EInvoice::Providers::TestProvider.deliveries.count
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def metadata
|
||||||
|
{
|
||||||
|
"items" => [
|
||||||
|
{ "description" => "Domeenide registreerimine - Juuli 2010" },
|
||||||
|
{ "product_id" => nil, "quantity" => 1, "unit" => "tk", "price" => 10.0, "description" => ".test registreerimine: 1 aasta(t)" },
|
||||||
|
{ "product_id" => "ETTEM06", "description" => "Domeenide ettemaks", "quantity" => -1, "price" => 10.0, "unit" => "tk" },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
|
@ -73,4 +73,21 @@ class DomainDeleteMailerTest < ActionMailer::TestCase
|
||||||
' / Domain shop.test is in deletion process' \
|
' / Domain shop.test is in deletion process' \
|
||||||
' / Домен shop.test в процессе удаления', email.subject
|
' / Домен shop.test в процессе удаления', email.subject
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_forced_invalid_email
|
||||||
|
@domain.update(template_name: 'invalid_email')
|
||||||
|
@domain.reload
|
||||||
|
|
||||||
|
email = DomainDeleteMailer.forced(domain: @domain,
|
||||||
|
registrar: @domain.registrar,
|
||||||
|
registrant: @domain.registrant,
|
||||||
|
template_name: @domain.template_name).deliver_now
|
||||||
|
|
||||||
|
assert_emails 1
|
||||||
|
assert_equal ['legal@registry.test'], email.from
|
||||||
|
assert @domain.force_delete_contact_emails.sort == email.to.sort
|
||||||
|
assert_equal 'Domeen shop.test on kustutusmenetluses' \
|
||||||
|
' / Domain shop.test is in deletion process' \
|
||||||
|
' / Домен shop.test в процессе удаления', email.subject
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,12 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
@registrar = registrars(:bestnames)
|
@registrar = registrars(:bestnames)
|
||||||
@invoice = invoices(:one)
|
@invoice = invoices(:one)
|
||||||
|
|
||||||
|
response_message = {
|
||||||
|
message: 'got it'
|
||||||
|
}
|
||||||
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_status')
|
||||||
|
.to_return(status: 200, body: response_message.to_json, headers: {})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_matches_against_invoice_nubmber_and_reference_number
|
def test_matches_against_invoice_nubmber_and_reference_number
|
||||||
|
@ -16,10 +22,9 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_binds_if_this_sum_invoice_already_present
|
def test_binds_if_this_sum_invoice_already_present
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||||
another_invoice = @invoice.dup
|
another_invoice = @invoice.dup
|
||||||
another_invoice.save(validate: false)
|
another_invoice.save(validate: false)
|
||||||
|
@ -42,18 +47,15 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
transaction.autobind_invoice
|
transaction.autobind_invoice
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_binds_if_this_sum_cancelled_invoice_already_present
|
def test_binds_if_this_sum_cancelled_invoice_already_present
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||||
another_invoice = @invoice.dup
|
another_invoice = @invoice.dup
|
||||||
another_invoice.save(validate: false)
|
another_invoice.save(validate: false)
|
||||||
|
|
||||||
|
|
||||||
another_item = @invoice.items.first.dup
|
another_item = @invoice.items.first.dup
|
||||||
another_item.invoice = another_invoice
|
another_item.invoice = another_invoice
|
||||||
|
|
||||||
|
@ -68,13 +70,11 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
transaction.autobind_invoice
|
transaction.autobind_invoice
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_marks_the_first_one_as_paid_if_same_sum
|
def test_marks_the_first_one_as_paid_if_same_sum
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||||
another_invoice = @invoice.dup
|
another_invoice = @invoice.dup
|
||||||
another_invoice.save(validate: false)
|
another_invoice.save(validate: false)
|
||||||
|
@ -97,7 +97,6 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
assert(@invoice.paid?)
|
assert(@invoice.paid?)
|
||||||
assert_not(another_invoice.paid?)
|
assert_not(another_invoice.paid?)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_matches_against_invoice_nubmber_and_reference_number_in_description
|
def test_matches_against_invoice_nubmber_and_reference_number_in_description
|
||||||
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
create_payable_invoice(number: '2222', total: 10, reference_no: '1234567')
|
||||||
|
@ -192,7 +191,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
def test_parsed_ref_no_returns_nil_if_ref_not_found
|
def test_parsed_ref_no_returns_nil_if_ref_not_found
|
||||||
statement = BankTransaction.new
|
statement = BankTransaction.new
|
||||||
statement.description = "all invalid 12 123 55 77777 --"
|
statement.description = 'all invalid 12 123 55 77777 --'
|
||||||
assert_nil statement.parsed_ref_number
|
assert_nil statement.parsed_ref_number
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -208,6 +207,7 @@ class BankTransactionTest < ActiveSupport::TestCase
|
||||||
transaction.bind_invoice('2222')
|
transaction.bind_invoice('2222')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_payable_invoice(attributes)
|
def create_payable_invoice(attributes)
|
||||||
|
|
|
@ -7,12 +7,10 @@ class ReferenceNoTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_generated_reference_number_conforms_to_format
|
def test_generated_reference_number_conforms_to_format
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator")
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator")
|
||||||
.to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
.to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
||||||
|
|
||||||
reference_no = Billing::ReferenceNo.generate
|
reference_no = Billing::ReferenceNo.generate
|
||||||
assert_match Billing::ReferenceNo::REGEXP, reference_no
|
assert_match Billing::ReferenceNo::REGEXP, reference_no
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,53 +1,4 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class FeatureTest < ActiveSupport::TestCase
|
class FeatureTest < ActiveSupport::TestCase
|
||||||
# setup do
|
|
||||||
# @domain = domains(:shop)
|
|
||||||
# @domain.apply_registry_lock(extensions_prohibited: false)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def test_if_obj_and_extensions_prohibited_enabled
|
|
||||||
# ENV['obj_and_extensions_prohibited'] = 'true'
|
|
||||||
#
|
|
||||||
# assert Feature.obj_and_extensions_statuses_enabled?
|
|
||||||
#
|
|
||||||
# statuses = DomainStatus.admin_statuses
|
|
||||||
# assert statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def test_if_obj_and_extensions_prohibited_is_nil
|
|
||||||
# ENV['obj_and_extensions_prohibited'] = nil
|
|
||||||
#
|
|
||||||
# assert_not Feature.obj_and_extensions_statuses_enabled?
|
|
||||||
#
|
|
||||||
# statuses = DomainStatus.admin_statuses
|
|
||||||
# assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def test_if_obj_and_extensions_prohibited_is_false
|
|
||||||
# ENV['obj_and_extensions_prohibited'] = 'false'
|
|
||||||
#
|
|
||||||
# assert_not Feature.obj_and_extensions_statuses_enabled?
|
|
||||||
#
|
|
||||||
# statuses = DomainStatus.admin_statuses
|
|
||||||
# assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def test_if_enable_lock_domain_with_new_statuses_is_nil
|
|
||||||
# ENV['enable_lock_domain_with_new_statuses'] = nil
|
|
||||||
#
|
|
||||||
# assert_not Feature.enable_lock_domain_with_new_statuses?
|
|
||||||
#
|
|
||||||
# assert_equal @domain.statuses, ["serverObjUpdateProhibited", "serverDeleteProhibited", "serverTransferProhibited"]
|
|
||||||
# assert @domain.locked_by_registrant?
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def test_if_enable_lock_domain_with_new_statuses_is_false
|
|
||||||
# ENV['enable_lock_domain_with_new_statuses'] = 'false'
|
|
||||||
#
|
|
||||||
# assert_not Feature.enable_lock_domain_with_new_statuses?
|
|
||||||
#
|
|
||||||
# assert_equal @domain.statuses, ["serverObjUpdateProhibited", "serverDeleteProhibited", "serverTransferProhibited"]
|
|
||||||
# assert @domain.locked_by_registrant?
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,7 +118,6 @@ class InvoiceTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_invoice_with_bank_transaction_total
|
def test_creates_invoice_with_bank_transaction_total
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
registrar = registrars(:bestnames)
|
registrar = registrars(:bestnames)
|
||||||
transaction = bank_transactions(:one).dup
|
transaction = bank_transactions(:one).dup
|
||||||
transaction.reference_no = registrar.reference_no
|
transaction.reference_no = registrar.reference_no
|
||||||
|
@ -156,10 +155,8 @@ class InvoiceTest < ActiveSupport::TestCase
|
||||||
invoice = Invoice.create_from_transaction!(transaction)
|
invoice = Invoice.create_from_transaction!(transaction)
|
||||||
assert_equal 0.99, invoice.total
|
assert_equal 0.99, invoice.total
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_emails_invoice_after_creating_topup_invoice
|
def test_emails_invoice_after_creating_topup_invoice
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
@ -182,5 +179,4 @@ class InvoiceTest < ActiveSupport::TestCase
|
||||||
Invoice.create_from_transaction!(transaction)
|
Invoice.create_from_transaction!(transaction)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -145,7 +145,6 @@ class RegistrarTest < ActiveJob::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_new_invoice
|
def test_issues_new_invoice
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
|
@ -167,10 +166,8 @@ class RegistrarTest < ActiveJob::TestCase
|
||||||
assert_equal Date.parse('2010-07-05'), invoice.issue_date
|
assert_equal Date.parse('2010-07-05'), invoice.issue_date
|
||||||
assert_equal Date.parse('2010-07-15'), invoice.due_date
|
assert_equal Date.parse('2010-07-15'), invoice.due_date
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_issues_e_invoice_along_with_invoice
|
def test_issues_e_invoice_along_with_invoice
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
|
@ -183,17 +180,12 @@ class RegistrarTest < ActiveJob::TestCase
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
||||||
to_return(status: 200, body: "", headers: {})
|
to_return(status: 200, body: "", headers: {})
|
||||||
end
|
|
||||||
|
|
||||||
EInvoice::Providers::TestProvider.deliveries.clear
|
EInvoice::Providers::TestProvider.deliveries.clear
|
||||||
|
|
||||||
perform_enqueued_jobs do
|
perform_enqueued_jobs do
|
||||||
@registrar.issue_prepayment_invoice(100)
|
@registrar.issue_prepayment_invoice(100)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Feature.billing_system_integrated?
|
|
||||||
assert_equal 1, EInvoice::Providers::TestProvider.deliveries.count
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_without_address_street
|
def test_invalid_without_address_street
|
||||||
|
|
|
@ -7,6 +7,9 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
||||||
|
|
||||||
@invoice = invoices(:one)
|
@invoice = invoices(:one)
|
||||||
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
Spy.on_instance_method(EisBilling::BaseController, :authorized).and_return(true)
|
||||||
|
response_message = { message: 'got it' }
|
||||||
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_status')
|
||||||
|
.to_return(status: 200, body: response_message.to_json, headers: {})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_update_bank_statement
|
def test_update_bank_statement
|
||||||
|
@ -55,7 +58,6 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_can_bind_statement_transactions
|
def test_can_bind_statement_transactions
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator")
|
||||||
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
|
@ -88,7 +90,6 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase
|
||||||
|
|
||||||
assert_text 'Invoices were fully binded'
|
assert_text 'Invoices were fully binded'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def create_bank_statement
|
def create_bank_statement
|
||||||
visit admin_bank_statements_path
|
visit admin_bank_statements_path
|
||||||
|
|
|
@ -14,7 +14,6 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_new_registrar
|
def test_creates_new_registrar
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/reference_number_generator").
|
||||||
to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
to_return(status: 200, body: "{\"reference_number\":\"12332\"}", headers: {})
|
||||||
|
|
||||||
|
@ -38,7 +37,6 @@ class AdminRegistrarsSystemTest < ApplicationSystemTestCase
|
||||||
assert_text 'Registrar has been successfully created'
|
assert_text 'Registrar has been successfully created'
|
||||||
assert_text 'Acme Ltd'
|
assert_text 'Acme Ltd'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_updates_registrar
|
def test_updates_registrar
|
||||||
assert_not_equal 'New name', @registrar.name
|
assert_not_equal 'New name', @registrar.name
|
||||||
|
|
|
@ -15,7 +15,6 @@ class BalanceTopUpTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_new_invoice
|
def test_creates_new_invoice
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
|
@ -42,5 +41,4 @@ class BalanceTopUpTest < ApplicationSystemTestCase
|
||||||
assert_equal BigDecimal('28.05'), invoice.total
|
assert_equal BigDecimal('28.05'), invoice.total
|
||||||
assert_text 'Please pay the following invoice'
|
assert_text 'Please pay the following invoice'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,6 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_create_new_invoice_with_positive_amount
|
def test_create_new_invoice_with_positive_amount
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
|
@ -42,10 +41,8 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
||||||
assert_text 'Subtotal 200,00 €'
|
assert_text 'Subtotal 200,00 €'
|
||||||
assert_text 'Pay invoice'
|
assert_text 'Pay invoice'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_create_new_invoice_with_comma_in_number
|
def test_create_new_invoice_with_comma_in_number
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
|
@ -70,7 +67,6 @@ class NewInvoiceTest < ApplicationSystemTestCase
|
||||||
assert_text 'Subtotal 200,00 €'
|
assert_text 'Subtotal 200,00 €'
|
||||||
assert_text 'Pay invoice'
|
assert_text 'Pay invoice'
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_create_new_invoice_fails_when_amount_is_0
|
def test_create_new_invoice_fails_when_amount_is_0
|
||||||
visit registrar_invoices_path
|
visit registrar_invoices_path
|
||||||
|
|
|
@ -16,6 +16,12 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
@account_activity = account_activities(:one)
|
@account_activity = account_activities(:one)
|
||||||
@account = accounts(:cash)
|
@account = accounts(:cash)
|
||||||
|
|
||||||
|
response_message = {
|
||||||
|
message: 'got it'
|
||||||
|
}
|
||||||
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_status')
|
||||||
|
.to_return(status: 200, body: response_message.to_json, headers: {})
|
||||||
|
|
||||||
Setting.registry_iban = beneficiary_iban
|
Setting.registry_iban = beneficiary_iban
|
||||||
|
|
||||||
Lhv::ConnectApi.class_eval do
|
Lhv::ConnectApi.class_eval do
|
||||||
|
@ -63,7 +69,8 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
def test_cannot_create_new_invoice_if_transaction_binded_to_paid_invoice
|
def test_cannot_create_new_invoice_if_transaction_binded_to_paid_invoice
|
||||||
assert_not @invoice.paid?
|
assert_not @invoice.paid?
|
||||||
|
|
||||||
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 1.day, creator_str: 'AdminUser')
|
@account_activity.update(activity_type: 'add_credit', bank_transaction: nil,
|
||||||
|
created_at: Time.zone.today - 1.day, creator_str: 'AdminUser')
|
||||||
@invoice.update(account_activity: @account_activity, total: @payment_amount)
|
@invoice.update(account_activity: @account_activity, total: @payment_amount)
|
||||||
assert @invoice.paid?
|
assert @invoice.paid?
|
||||||
|
|
||||||
|
@ -77,26 +84,26 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_if_invoice_is_overdue_than_48_hours
|
def test_if_invoice_is_overdue_than_48_hours
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
|
|
||||||
Spy.on_instance_method(SendEInvoiceTwoJob, :perform_now).and_return(true)
|
Spy.on_instance_method(SendEInvoiceJob, :perform_now).and_return(true)
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||||
to_return(status: 200, body: "", headers: {})
|
.to_return(status: 200, body: '', headers: {})
|
||||||
|
|
||||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
stub_request(:put, 'https://registry:3000/eis_billing/e_invoice_response')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator')
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
assert_not @invoice.paid?
|
assert_not @invoice.paid?
|
||||||
|
|
||||||
@account_activity.update(activity_type: "add_credit", bank_transaction: nil, created_at: Time.zone.today - 3.days, creator_str: 'AdminUser')
|
@account_activity.update(activity_type: 'add_credit', bank_transaction: nil,
|
||||||
|
created_at: Time.zone.today - 3.days, creator_str: 'AdminUser')
|
||||||
@invoice.update(account_activity: @account_activity, total: @payment_amount)
|
@invoice.update(account_activity: @account_activity, total: @payment_amount)
|
||||||
assert @invoice.paid?
|
assert @invoice.paid?
|
||||||
|
|
||||||
|
@ -106,7 +113,6 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_doubles_are_valid
|
def test_doubles_are_valid
|
||||||
assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages)
|
assert Lhv::ConnectApi.method_defined?(:credit_debit_notification_messages)
|
||||||
|
@ -162,21 +168,22 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_credits_registrar_athout_invoice_beforehand
|
def test_credits_registrar_athout_invoice_beforehand
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}")
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}")
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator')
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
Spy.on_instance_method(SendEInvoiceTwoJob, :perform_now).and_return(true)
|
Spy.on_instance_method(SendEInvoiceJob, :perform_now).and_return(true)
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||||
to_return(status: 200, body: "", headers: {})
|
.to_return(status: 200, body: '', headers: {})
|
||||||
|
|
||||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
stub_request(:put, 'https://registry:3000/eis_billing/e_invoice_response')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
.to_return(status: 200,
|
||||||
|
body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}",
|
||||||
|
headers: {})
|
||||||
|
|
||||||
registrar = registrars(:bestnames)
|
registrar = registrars(:bestnames)
|
||||||
|
|
||||||
|
@ -188,7 +195,6 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
run_task
|
run_task
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_topup_creates_invoice_with_total_of_transactioned_amount
|
def test_topup_creates_invoice_with_total_of_transactioned_amount
|
||||||
registrar = registrars(:bestnames)
|
registrar = registrars(:bestnames)
|
||||||
|
@ -198,19 +204,20 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_topup_creates_invoice_and_send_it_as_paid
|
def test_topup_creates_invoice_and_send_it_as_paid
|
||||||
if Feature.billing_system_integrated?
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/e_invoice/e_invoice')
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/e_invoice/e_invoice").
|
.to_return(status: 200, body: '', headers: {})
|
||||||
to_return(status: 200, body: "", headers: {})
|
|
||||||
|
|
||||||
invoice_n = Invoice.order(number: :desc).last.number
|
invoice_n = Invoice.order(number: :desc).last.number
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
.to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}", headers: {})
|
||||||
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, 'https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator')
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
.to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
stub_request(:put, "https://registry:3000/eis_billing/e_invoice_response").
|
stub_request(:put, 'https://registry:3000/eis_billing/e_invoice_response')
|
||||||
to_return(status: 200, body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now-10.minutes}\"}", headers: {})
|
.to_return(status: 200,
|
||||||
|
body: "{\"invoice_number\":\"#{invoice_n + 3}\"}, {\"date\":\"#{Time.zone.now - 10.minutes}\"}",
|
||||||
|
headers: {})
|
||||||
|
|
||||||
registrar = registrars(:bestnames)
|
registrar = registrars(:bestnames)
|
||||||
@invoice.payment_orders.destroy_all
|
@invoice.payment_orders.destroy_all
|
||||||
|
@ -227,12 +234,11 @@ class ProcessPaymentsTaskTest < ActiveJob::TestCase
|
||||||
pdf_source = Invoice::PdfGenerator.new(invoice)
|
pdf_source = Invoice::PdfGenerator.new(invoice)
|
||||||
pdf_source.send(:invoice_html).include?('Receipt date')
|
pdf_source.send(:invoice_html).include?('Receipt date')
|
||||||
|
|
||||||
email= ActionMailer::Base.deliveries.last
|
email = ActionMailer::Base.deliveries.last
|
||||||
assert email.subject.include?('already paid')
|
assert email.subject.include?('already paid')
|
||||||
|
|
||||||
assert_equal 0.1, registrar.invoices.last.total
|
assert_equal 0.1, registrar.invoices.last.total
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_output
|
def test_output
|
||||||
assert_output "Transactions processed: 1\n" do
|
assert_output "Transactions processed: 1\n" do
|
||||||
|
|
|
@ -21,7 +21,6 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_issues_invoice_when_auto_reload_is_enabled_and_threshold_reached
|
def test_issues_invoice_when_auto_reload_is_enabled_and_threshold_reached
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
|
@ -45,7 +44,6 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
||||||
invoice = registrar.invoices.last
|
invoice = registrar.invoices.last
|
||||||
assert_equal Time.zone.today, invoice.e_invoice_sent_at.to_date
|
assert_equal Time.zone.today, invoice.e_invoice_sent_at.to_date
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_skips_issuing_invoice_when_threshold_is_not_reached
|
def test_skips_issuing_invoice_when_threshold_is_not_reached
|
||||||
registrar = registrar_with_auto_reload_enabled_and_threshold_not_reached
|
registrar = registrar_with_auto_reload_enabled_and_threshold_not_reached
|
||||||
|
@ -66,7 +64,6 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_marks_registrar_as_pending_balance_reload
|
def test_marks_registrar_as_pending_balance_reload
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
|
@ -87,10 +84,8 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert registrar.settings['balance_auto_reload']['pending']
|
assert registrar.settings['balance_auto_reload']['pending']
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def test_output
|
def test_output
|
||||||
if Feature.billing_system_integrated?
|
|
||||||
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
stub_request(:post, "https://eis_billing_system:3000/api/v1/invoice_generator/invoice_generator").
|
||||||
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
to_return(status: 200, body: "{\"everypay_link\":\"http://link.test\"}", headers: {})
|
||||||
|
|
||||||
|
@ -112,7 +107,6 @@ class ReloadBalanceTaskTest < ActiveSupport::TestCase
|
||||||
run_task
|
run_task
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue