Skip to content

Commit

Permalink
Merge pull request #2693 from internetee/business-registry-check-for-…
Browse files Browse the repository at this point in the history
…company-existing-2

Business registry check for company existing 2
  • Loading branch information
vohmar authored Nov 8, 2024
2 parents 4ed6e90 + 0a08d77 commit 8be92f0
Show file tree
Hide file tree
Showing 32 changed files with 1,546 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
.DS_Store
/node_modules
/import
ettevotja_rekvisiidid__lihtandmed.csv.zip
27 changes: 22 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
FROM internetee/ruby:3.0-buster

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
postgresql-client \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# # RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
# RUN apt-get update && apt-get install -y --no-install-recommends \
# git \
# postgresql-client \
# && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN apt-get remove -y google-chrome-stable
RUN apt-get purge -y google-chrome-stable
RUN apt-get autoremove -y && apt-get clean

ENV CHROME_VERSION="128.0.6613.137"

RUN wget -q "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip" \
&& unzip chrome-linux64.zip -d /opt/ \
&& rm chrome-linux64.zip

RUN wget -q "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" \
&& unzip chromedriver-linux64.zip -d /opt/ \
&& mv /opt/chromedriver-linux64/chromedriver /usr/local/bin/ \
&& rm -rf chromedriver-linux64.zip /opt/chromedriver-linux64

RUN mkdir -p /opt/webapps/app/tmp/pids
WORKDIR /opt/webapps/app
COPY Gemfile Gemfile.lock ./
# ADD vendor/gems/omniauth-tara ./vendor/gems/omniauth-tara
RUN gem install bundler && bundle install --jobs 20 --retry 5

ENV PATH="/opt/chrome-linux64:${PATH}"

EXPOSE 3000
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ gem 'redis'
gem 'sidekiq', '~> 7.0'

gem 'company_register', github: 'internetee/company_register',
branch: 'master'
branch: '4-check-for-company-existence'
gem 'domain_name'
gem 'e_invoice', github: 'internetee/e_invoice', branch: :master
gem 'haml', '~> 6.0'
Expand Down
69 changes: 39 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/internetee/company_register.git
revision: 4181b2fff9080e2d87d15612561131f9e3fdfb4c
branch: master
revision: 6465d5c49478b9de5a5fa009cb6b8123b3956dd1
branch: 4-check-for-company-existence
specs:
company_register (0.1.0)
activesupport
Expand Down Expand Up @@ -139,14 +139,15 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
aes_key_wrap (1.1.0)
airbrake (11.0.3)
airbrake-ruby (~> 5.1)
airbrake-ruby (5.2.0)
rbtree3 (~> 0.5)
akami (1.3.1)
akami (1.3.3)
base64
gyoku (>= 0.4.0)
nokogiri
apipie-rails (0.6.0)
Expand All @@ -167,14 +168,16 @@ GEM
aws-sigv4 (~> 1.1)
aws-sigv4 (1.2.4)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
bcrypt (3.1.16)
bigdecimal (3.1.8)
bindata (2.4.14)
bootsnap (1.17.1)
msgpack (~> 1.2)
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
builder (3.2.4)
builder (3.3.0)
cancancan (3.3.0)
capybara (3.35.3)
addressable
Expand All @@ -194,7 +197,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
countries (4.0.1)
i18n_data (~> 0.13.0)
Expand Down Expand Up @@ -246,8 +249,9 @@ GEM
grpc (1.60.0-x86_64-linux)
google-protobuf (~> 3.25)
googleapis-common-protos-types (~> 1.0)
gyoku (1.3.1)
gyoku (1.4.0)
builder (>= 2.1.2)
rexml (~> 3.0)
haml (6.0.0)
temple (>= 0.8.2)
thor
Expand All @@ -259,10 +263,12 @@ GEM
http-cookie (1.0.3)
domain_name (~> 0.5)
httpclient (2.8.3)
httpi (2.4.5)
rack
socksify
i18n (1.14.5)
httpi (4.0.4)
base64
mutex_m
nkf
rack (>= 2.0, < 4)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
i18n_data (0.13.0)
isikukood (0.1.2)
Expand Down Expand Up @@ -310,8 +316,8 @@ GEM
nokogiri (~> 1)
rake
mini_mime (1.1.5)
mini_portile2 (2.8.6)
minitest (5.18.1)
mini_portile2 (2.8.7)
minitest (5.25.1)
minitest-stub_any_instance (1.0.3)
monetize (1.9.4)
money (~> 6.12)
Expand All @@ -326,6 +332,7 @@ GEM
net-ftp (0.3.7)
net-protocol
time
mutex_m (0.2.0)
net-protocol (0.1.3)
timeout
net-smtp (0.3.3)
Expand All @@ -336,12 +343,14 @@ GEM
newrelic_rpm (= 8.1.0)
newrelic_rpm (8.1.0)
nio4r (2.5.9)
nokogiri (1.16.5)
nkf (0.2.0)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.5-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
nori (2.6.0)
nori (2.7.1)
bigdecimal
omniauth (2.1.0)
hashie (>= 3.4.6)
rack (>= 2.2.3)
Expand Down Expand Up @@ -373,11 +382,11 @@ GEM
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.0)
puma (5.6.9)
public_suffix (6.0.1)
puma (5.6.8)
nio4r (~> 2.0)
racc (1.7.3)
rack (2.2.8.1)
racc (1.8.1)
rack (2.2.9)
rack-oauth2 (1.21.3)
activesupport
attr_required
Expand Down Expand Up @@ -449,14 +458,15 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
savon (2.12.1)
savon (2.15.1)
akami (~> 1.2)
builder (>= 2.1.2)
gyoku (~> 1.2)
httpi (~> 2.3)
httpi (>= 4, < 5)
mail (~> 2.5)
nokogiri (>= 1.8.1)
nori (~> 2.4)
wasabi (~> 3.4)
wasabi (>= 3.7, < 6)
select2-rails (4.0.13)
selectize-rails (0.12.6)
selenium-webdriver (3.142.7)
Expand All @@ -474,7 +484,6 @@ GEM
simplecov-html (0.10.2)
simpleidn (0.2.3)
sixarm_ruby_unaccent (1.2.0)
socksify (1.7.1)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -515,10 +524,10 @@ GEM
simpleidn
warden (1.2.9)
rack (>= 2.0.9)
wasabi (3.6.1)
wasabi (5.0.3)
addressable
httpi (~> 2.0)
nokogiri (>= 1.4.2)
faraday (>= 1.9, < 3)
nokogiri (>= 1.13.9)
webfinger (1.2.0)
activesupport
httpclient (>= 2.4)
Expand All @@ -534,7 +543,7 @@ GEM
wkhtmltopdf-binary (0.12.6.6)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.13)
zeitwerk (2.6.18)

PLATFORMS
ruby
Expand Down Expand Up @@ -611,4 +620,4 @@ DEPENDENCIES
wkhtmltopdf-binary (~> 0.12.6.1)

BUNDLED WITH
2.5.15
2.5.19
17 changes: 17 additions & 0 deletions ai/sop/update_company_status_rake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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
11 changes: 11 additions & 0 deletions app/interactions/actions/contact_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def call
maybe_attach_legal_doc
validate_ident
maybe_change_email
maybe_company_is_relevant
commit
validate_contact
end
Expand Down Expand Up @@ -77,6 +78,16 @@ def validate_ident_birthday
@error = true
end

def maybe_company_is_relevant
return true unless contact.org?

company_status = contact.return_company_status
return if [Contact::REGISTERED, Contact::LIQUIDATED].include? company_status

contact.add_epp_error('2003', nil, 'ident', I18n.t('errors.messages.company_not_registered'))
@error = true
end

def maybe_attach_legal_doc
::Actions::BaseAction.attach_legal_doc_to_new(contact, legal_document, domain: false)
end
Expand Down
2 changes: 2 additions & 0 deletions app/interactions/domains/force_delete/post_set_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def execute

# Allow deletion
statuses.delete(DomainStatus::CLIENT_DELETE_PROHIBITED)

puts "Try to save domain: #{domain.name} with statuses: #{statuses}"
domain.save(validate: false)
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/interactions/domains/force_delete/set_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def force_delete_fast_track
expire_warning_period_days +
redemption_grace_period_days
domain.force_delete_start = Time.zone.today + 1.day

domain.status_notes[DomainStatus::FORCE_DELETE] = "Company no: #{domain.registrant.ident}" if reason == 'invalid_company'
end

def force_delete_soft
Expand Down
Loading

0 comments on commit 8be92f0

Please sign in to comment.