mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 03:58:27 +02:00
parent
37cc05e44c
commit
ea305618a5
4 changed files with 29 additions and 3 deletions
|
@ -99,7 +99,7 @@ class Registrar < ActiveRecord::Base
|
||||||
# rubocop:disable Metrics/AbcSize
|
# rubocop:disable Metrics/AbcSize
|
||||||
def issue_prepayment_invoice(amount, description = nil)
|
def issue_prepayment_invoice(amount, description = nil)
|
||||||
vat_rate = if local_vat_payer?
|
vat_rate = if local_vat_payer?
|
||||||
Setting.registry_vat_prc
|
Registry.instance.vat_rate
|
||||||
else
|
else
|
||||||
if vat_no.blank?
|
if vat_no.blank?
|
||||||
self.vat_rate
|
self.vat_rate
|
||||||
|
@ -114,7 +114,6 @@ class Registrar < ActiveRecord::Base
|
||||||
payment_term: 'prepayment',
|
payment_term: 'prepayment',
|
||||||
description: description,
|
description: description,
|
||||||
currency: 'EUR',
|
currency: 'EUR',
|
||||||
vat_rate: Setting.registry_vat_prc,
|
|
||||||
vat_rate: vat_rate,
|
vat_rate: vat_rate,
|
||||||
seller_name: Setting.registry_juridical_name,
|
seller_name: Setting.registry_juridical_name,
|
||||||
seller_reg_no: Setting.registry_reg_no,
|
seller_reg_no: Setting.registry_reg_no,
|
||||||
|
|
11
app/models/registry.rb
Normal file
11
app/models/registry.rb
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class Registry
|
||||||
|
include Singleton
|
||||||
|
|
||||||
|
def vat_rate
|
||||||
|
Setting.registry_vat_prc
|
||||||
|
end
|
||||||
|
|
||||||
|
def legal_address_country
|
||||||
|
Country.new(Setting.registry_country_code)
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,7 +15,7 @@ require 'rails/all'
|
||||||
# you've limited to :test, :development, or :production.
|
# you've limited to :test, :development, or :production.
|
||||||
Bundler.require(*Rails.groups)
|
Bundler.require(*Rails.groups)
|
||||||
|
|
||||||
module Registry
|
module DomainNameRegistry
|
||||||
class Application < Rails::Application
|
class Application < Rails::Application
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
# Application configuration should go into files in config/initializers
|
# Application configuration should go into files in config/initializers
|
||||||
|
|
16
test/models/registry_test.rb
Normal file
16
test/models/registry_test.rb
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class RegistryTest < ActiveSupport::TestCase
|
||||||
|
def setup
|
||||||
|
@registry = Registry.send(:new)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_implements_singleton
|
||||||
|
assert_equal Registry.instance.object_id, Registry.instance.object_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_vat_rate
|
||||||
|
Setting.registry_vat_prc = 0.2
|
||||||
|
assert 0.2, @registry.vat_rate
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue