[Fix #1736] Assign the deal and person to the person who accepted them

This commit is contained in:
gregoirenovel 2018-05-31 18:15:42 +02:00
parent e7995bd1c9
commit 346b32fbd4
5 changed files with 10 additions and 10 deletions

View file

@ -10,7 +10,7 @@ module Manager
if administrateur.errors.empty? if administrateur.errors.empty?
PipedriveAcceptsDealsJob.perform_later( PipedriveAcceptsDealsJob.perform_later(
create_administrateur_params[:person_id], create_administrateur_params[:person_id],
Pipedrive::DealAdapter::PIPEDRIVE_CAMILLE_ID, current_administration.id,
create_administrateur_params[:stage_id] create_administrateur_params[:stage_id]
) )
@ -26,7 +26,7 @@ module Manager
def refuse_administrateur def refuse_administrateur
PipedriveRefusesDealsJob.perform_later( PipedriveRefusesDealsJob.perform_later(
refuse_administrateur_params[:person_id], refuse_administrateur_params[:person_id],
Pipedrive::DealAdapter::PIPEDRIVE_CAMILLE_ID current_administration.id
) )
AdministrationMailer AdministrationMailer

View file

@ -1,5 +1,5 @@
class PipedriveAcceptsDealsJob < ApplicationJob class PipedriveAcceptsDealsJob < ApplicationJob
def perform(person_id, owner_id, stage_id) def perform(person_id, administration_id, stage_id)
PipedriveService.accept_demande_from_person(person_id, owner_id, stage_id) PipedriveService.accept_demande_from_person(person_id, administration_id, stage_id)
end end
end end

View file

@ -1,5 +1,5 @@
class PipedriveRefusesDealsJob < ApplicationJob class PipedriveRefusesDealsJob < ApplicationJob
def perform(person_id, owner_id) def perform(person_id, administration_id)
PipedriveService.refuse_demande_from_person(person_id, owner_id) PipedriveService.refuse_demande_from_person(person_id, administration_id)
end end
end end

View file

@ -10,8 +10,6 @@ class Pipedrive::DealAdapter
PIPEDRIVE_LOST_STATUS = "lost" PIPEDRIVE_LOST_STATUS = "lost"
PIPEDRIVE_LOST_REASON = "refusé depuis DS" PIPEDRIVE_LOST_REASON = "refusé depuis DS"
PIPEDRIVE_CAMILLE_ID = '3189424'
def self.refuse_deal(deal_id, owner_id) def self.refuse_deal(deal_id, owner_id)
params = { params = {
user_id: owner_id, user_id: owner_id,

View file

@ -1,11 +1,13 @@
class PipedriveService 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 = 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) } 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) Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id)
end 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 = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id)
person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.refuse_deal(deal_id, owner_id) } person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.refuse_deal(deal_id, owner_id) }
Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id) Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id)