mirror of
https://github.com/internetee/registry.git
synced 2025-08-13 04:59:42 +02:00
Merge pull request #2717 from internetee/fix-poll-message-to-invalid-company-ident
feat: Add invalid ident notification for company register status checks
This commit is contained in:
commit
ce50664930
9 changed files with 65 additions and 32 deletions
|
@ -1,17 +0,0 @@
|
||||||
# Steps to Update company_status.rake
|
|
||||||
|
|
||||||
- [x] Modify the CSV output to include the contact type (role) information
|
|
||||||
- [x] Filter the output to include only Estonian organization type contacts
|
|
||||||
- [ ] Ensure only registrant contacts are included in the output
|
|
||||||
- [ ] Remove duplicate entries for the same organization
|
|
||||||
- [ ] Add a column to indicate if the contact is deleted due to an overdue annual statement
|
|
||||||
- [ ] Create a separate CSV file for invalid registrant contacts
|
|
||||||
- [ ] Update the existing CSV output to include only contacts that fail validation against the business registry and whitelist
|
|
||||||
- [ ] Add error handling and logging for better debugging
|
|
||||||
- [ ] Update the task description and comments to reflect the new functionality
|
|
||||||
- [ ] Add a new rake task or option to generate the separate registrant-only CSV file
|
|
||||||
- [ ] Implement validation against the business registry for Estonian organization contacts
|
|
||||||
- [ ] Implement validation against the whitelist for Estonian organization contacts
|
|
||||||
- [ ] Optimize the code for better performance, especially when dealing with large datasets
|
|
||||||
- [ ] Add unit tests for the new functionality
|
|
||||||
- [ ] Update the documentation to reflect the changes and new output format
|
|
|
@ -6,10 +6,18 @@ module Domains
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_without_email
|
def notify_without_email
|
||||||
template = I18n.t('force_delete_set_on_domain',
|
template = if reason == 'invalid_company'
|
||||||
|
I18n.t('invalid_ident',
|
||||||
|
ident: domain.registrant.ident,
|
||||||
domain_name: domain.name,
|
domain_name: domain.name,
|
||||||
outzone_date: domain.outzone_date,
|
outzone_date: domain.outzone_date,
|
||||||
purge_date: domain.purge_date)
|
purge_date: domain.purge_date)
|
||||||
|
else
|
||||||
|
I18n.t('force_delete_set_on_domain',
|
||||||
|
domain_name: domain.name,
|
||||||
|
outzone_date: domain.outzone_date,
|
||||||
|
purge_date: domain.purge_date)
|
||||||
|
end
|
||||||
|
|
||||||
return if domain.registrar&.notifications&.last&.text&.include? template
|
return if domain.registrar&.notifications&.last&.text&.include? template
|
||||||
|
|
||||||
|
@ -17,11 +25,19 @@ module Domains
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_with_email
|
def notify_with_email
|
||||||
template = I18n.t('force_delete_auto_email',
|
template = if reason == 'invalid_company'
|
||||||
|
I18n.t('invalid_ident',
|
||||||
|
ident: domain.registrant.ident,
|
||||||
|
domain_name: domain.name,
|
||||||
|
outzone_date: domain.outzone_date,
|
||||||
|
purge_date: domain.purge_date)
|
||||||
|
else
|
||||||
|
I18n.t('force_delete_auto_email',
|
||||||
domain_name: domain.name,
|
domain_name: domain.name,
|
||||||
outzone_date: domain.outzone_date,
|
outzone_date: domain.outzone_date,
|
||||||
purge_date: domain.purge_date,
|
purge_date: domain.purge_date,
|
||||||
email: email)
|
email: email)
|
||||||
|
end
|
||||||
|
|
||||||
return if domain.registrar&.notifications&.last&.text&.include? template
|
return if domain.registrar&.notifications&.last&.text&.include? template
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ module Domains
|
||||||
# Allow deletion
|
# Allow deletion
|
||||||
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)
|
||||||
|
|
||||||
puts "Try to save domain: #{domain.name} with statuses: #{statuses}"
|
|
||||||
domain.save(validate: false)
|
domain.save(validate: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -675,6 +675,7 @@ en:
|
||||||
actions: Actions
|
actions: Actions
|
||||||
contact_has_been_archived: 'Contact with code %{contact_code} has been archieved because it has been orphaned for longer than %{orphan_months} months.'
|
contact_has_been_archived: 'Contact with code %{contact_code} has been archieved because it has been orphaned for longer than %{orphan_months} months.'
|
||||||
dns_policy_violation: "Data management policy violation: DNSKEY does not match or not found in the authoritative nameservers"
|
dns_policy_violation: "Data management policy violation: DNSKEY does not match or not found in the authoritative nameservers"
|
||||||
|
invalid_ident: 'Force delete set on domain %{domain_name}. Outzone date: %{outzone_date}. Purge date: %{purge_date}. Invalid ident %{ident}'
|
||||||
|
|
||||||
number:
|
number:
|
||||||
currency:
|
currency:
|
||||||
|
|
|
@ -40,3 +40,5 @@ et:
|
||||||
taken: 'on juba lisatud'
|
taken: 'on juba lisatud'
|
||||||
ipv6:
|
ipv6:
|
||||||
taken: 'on juba lisatud'
|
taken: 'on juba lisatud'
|
||||||
|
|
||||||
|
invalid_ident: 'Jõustatud kustutamine määratud domainile %{domain_name}. Väljaandmise kuupäev: %{outzone_date}. Kustutamise kuupäev: %{purge_date}. Vigane ident %{ident}'
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace :company_status do
|
||||||
|
|
||||||
puts "*** Run 3 step. I process companies, update their information, and sort them into different files based on whether the companies are missing or removed from the business registry ***"
|
puts "*** Run 3 step. I process companies, update their information, and sort them into different files based on whether the companies are missing or removed from the business registry ***"
|
||||||
|
|
||||||
whitelisted_companies = JSON.parse(ENV['whitelist_companies']) # ["12345678", "87654321"]
|
whitelisted_companies = ENV['whitelist_companies'].present? ? JSON.parse(ENV['whitelist_companies']) : []
|
||||||
|
|
||||||
contacts_query = Contact.where(ident_type: 'org', ident_country_code: 'EE')
|
contacts_query = Contact.where(ident_type: 'org', ident_country_code: 'EE')
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,42 @@ class CompanyRegisterStatusJobTest < ActiveSupport::TestCase
|
||||||
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_companies_with_invalid_ident_should_receive_invalid_ident_notification
|
||||||
|
original_new_method = CompanyRegister::Client.method(:new)
|
||||||
|
CompanyRegister::Client.define_singleton_method(:new) do
|
||||||
|
object = original_new_method.call
|
||||||
|
def object.simple_data(registration_number:)
|
||||||
|
[Company.new('16752073', 'ACME Ltd', DELETED)]
|
||||||
|
end
|
||||||
|
object
|
||||||
|
end
|
||||||
|
|
||||||
|
@registrant_acme.update!(
|
||||||
|
company_register_status: Contact::DELETED,
|
||||||
|
checked_company_at: nil,
|
||||||
|
ident_type: 'org',
|
||||||
|
ident_country_code: 'EE',
|
||||||
|
ident: '16752073'
|
||||||
|
)
|
||||||
|
|
||||||
|
@registrant_acme.reload
|
||||||
|
|
||||||
|
CompanyRegisterStatusJob.perform_now(14, 0, 100)
|
||||||
|
|
||||||
|
@registrant_acme.reload
|
||||||
|
|
||||||
|
assert_equal Contact::DELETED, @registrant_acme.company_register_status
|
||||||
|
|
||||||
|
template = I18n.t('invalid_ident',
|
||||||
|
ident: @registrant_acme.ident,
|
||||||
|
domain_name: @registrant_acme.registrant_domains.first.name,
|
||||||
|
outzone_date: @registrant_acme.registrant_domains.first.outzone_date,
|
||||||
|
purge_date: @registrant_acme.registrant_domains.first.purge_date)
|
||||||
|
assert_equal @registrant_acme.registrant_domains.first.registrar.notifications.last.text, template
|
||||||
|
|
||||||
|
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||||
|
end
|
||||||
|
|
||||||
def test_companies_with_force_delete_and_status_R_should_be_lifted
|
def test_companies_with_force_delete_and_status_R_should_be_lifted
|
||||||
original_new_method = CompanyRegister::Client.method(:new)
|
original_new_method = CompanyRegister::Client.method(:new)
|
||||||
CompanyRegister::Client.define_singleton_method(:new) do
|
CompanyRegister::Client.define_singleton_method(:new) do
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
company_code,company_name,status
|
|
||||||
12345678,Test Company,active
|
|
|
|
@ -1,2 +0,0 @@
|
||||||
company_code,company_name,status
|
|
||||||
12345678,Test Company,active
|
|
|
Loading…
Add table
Add a link
Reference in a new issue