diff --git a/app/controllers/manager/demandes_controller.rb b/app/controllers/manager/demandes_controller.rb index 09690f077..932cfd8d6 100644 --- a/app/controllers/manager/demandes_controller.rb +++ b/app/controllers/manager/demandes_controller.rb @@ -10,7 +10,7 @@ module Manager if administrateur.errors.empty? PipedriveAcceptsDealsJob.perform_later( create_administrateur_params[:person_id], - Pipedrive::DealAdapter::PIPEDRIVE_CAMILLE_ID, + current_administration.id, create_administrateur_params[:stage_id] ) @@ -26,7 +26,7 @@ module Manager def refuse_administrateur PipedriveRefusesDealsJob.perform_later( refuse_administrateur_params[:person_id], - Pipedrive::DealAdapter::PIPEDRIVE_CAMILLE_ID + current_administration.id ) AdministrationMailer diff --git a/app/jobs/pipedrive_accepts_deals_job.rb b/app/jobs/pipedrive_accepts_deals_job.rb index 84a4e96d5..05ce05a1c 100644 --- a/app/jobs/pipedrive_accepts_deals_job.rb +++ b/app/jobs/pipedrive_accepts_deals_job.rb @@ -1,5 +1,5 @@ class PipedriveAcceptsDealsJob < ApplicationJob - def perform(person_id, owner_id, stage_id) - PipedriveService.accept_demande_from_person(person_id, owner_id, stage_id) + def perform(person_id, administration_id, stage_id) + PipedriveService.accept_demande_from_person(person_id, administration_id, stage_id) end end diff --git a/app/jobs/pipedrive_refuses_deals_job.rb b/app/jobs/pipedrive_refuses_deals_job.rb index 61c157efb..610a4cd51 100644 --- a/app/jobs/pipedrive_refuses_deals_job.rb +++ b/app/jobs/pipedrive_refuses_deals_job.rb @@ -1,5 +1,5 @@ class PipedriveRefusesDealsJob < ApplicationJob - def perform(person_id, owner_id) - PipedriveService.refuse_demande_from_person(person_id, owner_id) + def perform(person_id, administration_id) + PipedriveService.refuse_demande_from_person(person_id, administration_id) end end diff --git a/app/lib/pipedrive/deal_adapter.rb b/app/lib/pipedrive/deal_adapter.rb index 1d7f969ca..68f9725c9 100644 --- a/app/lib/pipedrive/deal_adapter.rb +++ b/app/lib/pipedrive/deal_adapter.rb @@ -10,8 +10,6 @@ class Pipedrive::DealAdapter PIPEDRIVE_LOST_STATUS = "lost" PIPEDRIVE_LOST_REASON = "refusé depuis DS" - PIPEDRIVE_CAMILLE_ID = '3189424' - def self.refuse_deal(deal_id, owner_id) params = { user_id: owner_id, diff --git a/app/services/pipedrive_service.rb b/app/services/pipedrive_service.rb index f7b7c0875..df46dca6b 100644 --- a/app/services/pipedrive_service.rb +++ b/app/services/pipedrive_service.rb @@ -1,11 +1,13 @@ class PipedriveService - def self.accept_demande_from_person(person_id, owner_id, stage_id) + def self.accept_demande_from_person(person_id, administration_id, stage_id) + owner_id = BizDev.pipedrive_id(administration_id) person_deals_ids = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id) person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.update_deal_owner_and_stage(deal_id, owner_id, stage_id) } Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id) end - def self.refuse_demande_from_person(person_id, owner_id) + def self.refuse_demande_from_person(person_id, administration_id) + owner_id = BizDev.pipedrive_id(administration_id) person_deals_ids = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id) person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.refuse_deal(deal_id, owner_id) } Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id) diff --git a/lib/tasks/2018_06_05_resend_attestations.rb b/lib/tasks/2018_06_05_resend_attestations.rb index 37f56b0b6..5c6527727 100644 --- a/lib/tasks/2018_06_05_resend_attestations.rb +++ b/lib/tasks/2018_06_05_resend_attestations.rb @@ -1,4 +1,4 @@ -namespace :'2018_06_05_resend_attestation' do +namespace :'2018_06_05_resend_attestations' do task set: :environment do procedure = Procedure.find(4247) dossiers = procedure.dossiers.includes(:attestation).where(state: 'accepte').select do |d| diff --git a/lib/tasks/2018_06_05_send_new_attestations.rake b/lib/tasks/2018_06_05_send_new_attestations.rake index da3be3539..b9af48a26 100644 --- a/lib/tasks/2018_06_05_send_new_attestations.rake +++ b/lib/tasks/2018_06_05_send_new_attestations.rake @@ -29,7 +29,7 @@ namespace :'2018_06_05_send_new_attestation' do 41103 ] - dossiers = ids.map { |id| Dossier.Dossier.find_by(id: id) }.compact + dossiers = ids.map { |id| Dossier.find_by(id: id) }.compact dossiers.each do |dossier| attestation = dossier.attestation