diff --git a/app/jobs/company_register_status_job.rb b/app/jobs/company_register_status_job.rb
index c79acb14ec..695b2af21a 100644
--- a/app/jobs/company_register_status_job.rb
+++ b/app/jobs/company_register_status_job.rb
@@ -10,6 +10,8 @@ def perform(days_interval = 14, spam_time_delay = 0.2, batch_size = 100, force_d
company_status = contact.return_company_status
contact.update!(company_register_status: company_status, checked_company_at: Time.zone.now)
+ ContactInformMailer.company_liquidation(contact: contact).deliver_now if company_status == Contact::LIQUIDATED
+
next unless [Contact::BANKRUPT, Contact::DELETED, nil].include? company_status
if force_delete
diff --git a/app/mailers/contact_inform_mailer.rb b/app/mailers/contact_inform_mailer.rb
index bf5037cbfa..cb04037686 100644
--- a/app/mailers/contact_inform_mailer.rb
+++ b/app/mailers/contact_inform_mailer.rb
@@ -19,6 +19,13 @@ def notify_nameserver(contact:, domain:, nameserver:)
mail(to: contact.email, subject: subject)
end
+ def company_liquidation(contact:)
+ @registrant = contact
+
+ subject = "Kas soovite oma .ee domeeni säilitada? / Do you wish to preserve your .ee registration?"
+ mail(to: contact.email, subject: subject)
+ end
+
private
def address_processing
diff --git a/app/views/mailers/contact_inform_mailer/company_liquidation.html.erb b/app/views/mailers/contact_inform_mailer/company_liquidation.html.erb
new file mode 100644
index 0000000000..cf86dad6b4
--- /dev/null
+++ b/app/views/mailers/contact_inform_mailer/company_liquidation.html.erb
@@ -0,0 +1,36 @@
+
Lugupeetud ettevõtte <%= @registrant.name %> esindaja,
+
+Eesti Interneti Sihtasutusele (EIS) on äriregistri vahendusel teatavaks saanud, et ettevõtte <%= @registrant.name %> äriregistrikoodiga <%= @registrant.ident %> suhtes käib likvideerimismenetlus. Tuletame teile meelde, et tulenevalt .ee domeenireeglitest peab domeeni registreerijaks olema eksisteeriv era- või juriidiline isik. Seega käivitame ettevõtte likvideerimise järel sellele kuuluvate registreeringute kustutusmenetluse. Kustutusmenetluse tulemusena eemaldatakse .ee domeeninimi registrist ning vabaneb kõigile soovijatele taaskord registreerimiseks.
+Kui soovite ettevõttele kuuluvaid registreeritud domeene ka edaspidi kasutada, soovitame teil ette valmistada registreeringute üleandmine uuele omanikule enne praeguse omaniku likvideerimist. Lähemalt leiate selle kohta infot meie kodulehelt.
+
+.ee domeeni registris kuuluvad ettevõttele <%= @registrant.ident %> järgmised registreeringud:
+
+ <% @registrant.domains.each do |domain| %>
+ - <%= domain.name %>
+ <% end %>
+
+
+Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrant.registrar %>
+
+<%= render 'mailers/shared/signatures/signature.et.html' %>
+
+
+
+Dear representative of <%= @registrant.name %>,
+
+The Estonian Internet Foundation (EIS) has found through the Estonian business register that the company <%= @registrant.name %> with the business registry code <%= @registrant.ident %> is in liquidation proceedings. Please note that according to the .ee domain regulation, the registrant of the domain must be an existing private or legal entity. Therefore, the registry will start the registration deletion procedure once the liquidation of the company has been finalized. After the registration deletion procedure, the domain name will be open to register again for everyone.
+If you want to continue to use the registered domains belonging to your company, we recommend you to prepare the transfer of the registrations to the new owner before the liquidation of the current owner will be finalized. Learn more on our website.
+
+The following registrations belong to the company <%= @registrant.ident %> in the .ee domain register:
+
+ <% @registrant.domains.each do |domain| %>
+ - <%= domain.name %>
+ <% end %>
+
+
+Should you have additional questions, please contact your registrar:
+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrant.registrar %>
+
+<%= render 'mailers/shared/signatures/signature.en.html' %>
+
diff --git a/app/views/mailers/contact_inform_mailer/company_liquidation.text.erb b/app/views/mailers/contact_inform_mailer/company_liquidation.text.erb
new file mode 100644
index 0000000000..9bcaeffa66
--- /dev/null
+++ b/app/views/mailers/contact_inform_mailer/company_liquidation.text.erb
@@ -0,0 +1,35 @@
+Lugupeetud ettevõtte <%= @registrant.name %> esindaja
+
+Eesti Interneti Sihtasutusele (EIS) on äriregistri vahendusel teatavaks saanud, et ettevõtte <%= @registrant.name %> äriregistrikoodiga <%= @registrant.ident %> suhtes käib likvideerimismenetlus. Tuletame teile meelde, et tulenevalt .ee domeenireeglitest peab domeeni registreerijaks olema eksisteeriv era- või juriidiline isik. Seega käivitame ettevõtte likvideerimise järel sellele kuuluvate registreeringute kustutusmenetluse. Kustutusmenetluse tulemusena eemaldatakse .ee domeeninimi registrist ning vabaneb kõigile soovijatele taaskord registreerimiseks.
+Kui soovite ettevõttele kuuluvaid registreeritud domeene ka edaspidi kasutada, soovitame teil ette valmistada registreeringute üleandmine uuele omanikule enne praeguse omaniku likvideerimist. Lähemalt leiate selle kohta infot meie kodulehelt.
+
+.ee domeeni registris kuuluvad ettevõttele <%= @registrant.ident %> järgmised registreeringud:
+
+ <% @registrant.domains.each do |domain| %>
+ <%= domain.name %>
+ <% end %>
+
+
+Lisaküsimuste korral võtke palun ühendust oma registripidajaga:
+<%= render 'mailers/shared/registrar/registrar.et.html', registrar: @registrant.registrar %>
+
+<%= render 'mailers/shared/signatures/signature.et.html' %>
+
+---
+
+Dear representative of <%= @registrant.name %>,
+
+The Estonian Internet Foundation (EIS) has found through the Estonian business register that the company <%= @registrant.name %> with the business registry code <%= @registrant.ident %> is in liquidation proceedings. Please note that according to the .ee domain regulation, the registrant of the domain must be an existing private or legal entity. Therefore, the registry will start the registration deletion procedure once the liquidation of the company has been finalized. After the registration deletion procedure, the domain name will be open to register again for everyone.
+If you want to continue to use the registered domains belonging to your company, we recommend you to prepare the transfer of the registrations to the new owner before the liquidation of the current owner will be finalized. Learn more on our website.
+
+The following registrations belong to the company <%= @registrant.ident %> in the .ee domain register:
+
+ <% @registrant.domains.each do |domain| %>
+ <%= domain.name %>
+ <% end %>
+
+Should you have additional questions, please contact your registrar:
+<%= render 'mailers/shared/registrar/registrar.en.html', registrar: @registrant.registrar %>
+
+<%= render 'mailers/shared/signatures/signature.en.html' %>
+
diff --git a/test/jobs/company_register_status_job_test.rb b/test/jobs/company_register_status_job_test.rb
index 985f35efda..7d136fcbf6 100644
--- a/test/jobs/company_register_status_job_test.rb
+++ b/test/jobs/company_register_status_job_test.rb
@@ -292,4 +292,37 @@ def object.company_details(registration_number:)
assert_equal @registrant_acme.registrar.notifications.count, 2
end
+
+ def test_should_inform_contact_if_his_company_in_liquadation
+ original_new_method = CompanyRegister::Client.method(:new)
+ CompanyRegister::Client.define_singleton_method(:new) do
+ object = original_new_method.call
+ def object.company_details(registration_number:)
+ [Company.new('1234567', 'ACME Ltd', LIQUIDATED)]
+ end
+ object
+ end
+
+ ActionMailer::Base.deliveries.clear
+ assert_emails 0
+
+ interval_days = 5
+ current_time = Time.zone.now
+
+ @registrant_acme.update!(company_register_status: Contact::REGISTERED, checked_company_at: current_time - interval_days.days)
+ @registrant_acme.reload && @registrant_jack.reload
+
+ CompanyRegisterStatusJob.perform_now(interval_days, 0, 100, true)
+
+ @registrant_acme.reload && @registrant_jack.reload
+
+ assert_equal Contact::LIQUIDATED, @registrant_acme.company_register_status
+ assert_equal current_time.to_date, @registrant_acme.checked_company_at.to_date
+
+ mail = ActionMailer::Base.deliveries.first
+ mail_html = Nokogiri::HTML(mail.html_part.body.decoded)
+ text = mail_html.css('p')[1].text
+
+ assert_equal text, "Eesti Interneti Sihtasutusele (EIS) on äriregistri vahendusel teatavaks saanud, et ettevõtte #{@registrant_jack.name} äriregistrikoodiga #{@registrant_jack.ident} suhtes käib likvideerimismenetlus. Tuletame teile meelde, et tulenevalt .ee domeenireeglitest peab domeeni registreerijaks olema eksisteeriv era- või juriidiline isik. Seega käivitame ettevõtte likvideerimise järel sellele kuuluvate registreeringute kustutusmenetluse. Kustutusmenetluse tulemusena eemaldatakse .ee domeeninimi registrist ning vabaneb kõigile soovijatele taaskord registreerimiseks."
+ end
end
\ No newline at end of file
diff --git a/test/mailers/contact_inform_mailer_test.rb b/test/mailers/contact_inform_mailer_test.rb
new file mode 100644
index 0000000000..37e6578925
--- /dev/null
+++ b/test/mailers/contact_inform_mailer_test.rb
@@ -0,0 +1,19 @@
+require 'test_helper'
+
+class ContactInformMailerTest < ActionMailer::TestCase
+ setup do
+ @contact = contacts(:john)
+ end
+
+ def test_liquidation_email
+ assert_equal 'john-001', @contact.code
+ assert_equal 'john@inbox.test', @contact.email
+
+ email = ContactInformMailer.company_liquidation(contact: @contact).deliver_now
+
+ assert_emails 1
+
+ assert_equal %w[john@inbox.test], email.to
+ assert_equal 'Kas soovite oma .ee domeeni säilitada? / Do you wish to preserve your .ee registration?', email.subject
+ end
+end
diff --git a/test/mailers/contact_mailer_test.rb b/test/mailers/contact_mailer_test.rb
index a0310748f0..b168b2cbbb 100644
--- a/test/mailers/contact_mailer_test.rb
+++ b/test/mailers/contact_mailer_test.rb
@@ -18,4 +18,4 @@ def test_delivers_email_changed_email
assert_equal 'Teie domeenide kontakt epostiaadress on muutunud' \
' / Contact e-mail addresses of your domains have changed [john-001]', email.subject
end
-end
\ No newline at end of file
+end