mirror of
https://github.com/internetee/registry.git
synced 2025-07-31 15:06:23 +02:00
refactor: Improve company status handling logic
- Extract liquidation email logic into separate method `send_email_for_liquidation` - Add early return for bankrupt companies - Remove redundant logging for bankrupt companies - Simplify status handling conditions
This commit is contained in:
parent
bf2a038e3a
commit
b1e079340e
1 changed files with 9 additions and 5 deletions
|
@ -36,20 +36,24 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
end
|
||||
|
||||
def handle_company_statuses(contact, company_status)
|
||||
return if company_status == Contact::BANKRUPT
|
||||
|
||||
case company_status
|
||||
when Contact::REGISTERED
|
||||
lift_force_delete(contact) if check_for_force_delete(contact)
|
||||
when Contact::LIQUIDATED
|
||||
unless contact.company_register_status == Contact::LIQUIDATED
|
||||
ContactInformMailer.company_liquidation(contact: contact).deliver_now
|
||||
end
|
||||
when Contact::BANKRUPT
|
||||
Rails.logger.info("Company #{contact.ident} is bankrupt. No action needed.")
|
||||
send_email_for_liquidation(contact)
|
||||
else
|
||||
delete_process(contact)
|
||||
end
|
||||
end
|
||||
|
||||
def send_email_for_liquidation(contact)
|
||||
return if contact.company_register_status == Contact::LIQUIDATED
|
||||
|
||||
ContactInformMailer.company_liquidation(contact: contact).deliver_now
|
||||
end
|
||||
|
||||
def sampling_registrant_contact(days_interval)
|
||||
Contact.joins(:registrant_domains)
|
||||
.where(ident_type: 'org', ident_country_code: 'EE')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue