sf_migrate 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/import.rb +38 -15
- metadata +4 -4
data/lib/import.rb
CHANGED
@@ -604,14 +604,14 @@ module SalesforceMigration
|
|
604
604
|
end
|
605
605
|
|
606
606
|
# Associate an object with selected ids
|
607
|
-
def associate_module_by_ids!(
|
607
|
+
def associate_module_by_ids!(object, type, list_of_ids, assign_to_user = false, reverse_association = false)
|
608
608
|
if list_of_ids.is_a?(Array)
|
609
609
|
list_of_ids.each do |record_id|
|
610
610
|
sugar_object = find_sugarcrm_object(type, 'sf_id', record_id)
|
611
611
|
if reverse_association
|
612
|
-
sugar_object.associate!
|
612
|
+
sugar_object.associate! object if sugar_object
|
613
613
|
else
|
614
|
-
|
614
|
+
object.associate! sugar_object if sugar_object
|
615
615
|
end
|
616
616
|
assign_user_as_owner_to_record(object, sugar_object) if assign_to_user
|
617
617
|
end
|
@@ -640,9 +640,9 @@ module SalesforceMigration
|
|
640
640
|
return if found_records.blank?
|
641
641
|
|
642
642
|
if %(contract email settlement_bank_account).include? type
|
643
|
-
associate_module_by_ids!(
|
643
|
+
associate_module_by_ids!(object, type, found_records, true, false)
|
644
644
|
else
|
645
|
-
associate_module_by_ids!(
|
645
|
+
associate_module_by_ids!(object, type, found_records, false, false)
|
646
646
|
end
|
647
647
|
end
|
648
648
|
|
@@ -689,7 +689,7 @@ module SalesforceMigration
|
|
689
689
|
def assign_user_as_owner_to_record(id_object, object_to_assign)
|
690
690
|
return unless id_object and object_to_assign
|
691
691
|
|
692
|
-
salesforce_id = (id_object.sf_agent_id
|
692
|
+
salesforce_id = (defined? id_object.sf_agent_id) ? id_object.sf_agent_id : id_object.sf_id
|
693
693
|
|
694
694
|
user = find_sugarcrm_object('users', 'salesforce_id', salesforce_id)
|
695
695
|
|
@@ -742,7 +742,7 @@ module SalesforceMigration
|
|
742
742
|
def create_security_group_iso(iso)
|
743
743
|
@logger.info("Creating SecurityGroup #{iso.name}")
|
744
744
|
security_group = SugarCRM::SecurityGroup.new(:name => iso.name) unless find_sugarcrm_object('security_group','name', iso.name)
|
745
|
-
security_group.save!
|
745
|
+
security_group.save! if security_group
|
746
746
|
end
|
747
747
|
|
748
748
|
# Assign all records, to their ISO's SecurityGroup
|
@@ -800,10 +800,12 @@ module SalesforceMigration
|
|
800
800
|
security_group = find_sugarcrm_object('security_group','name', iso.name)
|
801
801
|
|
802
802
|
if security_group
|
803
|
-
|
803
|
+
@logger.info("Puting ISO #{iso.name} into its ISO group")
|
804
804
|
iso.associate! security_group
|
805
805
|
role.associate! security_group
|
806
806
|
|
807
|
+
user = SugarCRM::User.find_by_last_name(iso.name)
|
808
|
+
|
807
809
|
if user.nil?
|
808
810
|
@logger.error("ISO (#{iso.name}) doesn't have a user record")
|
809
811
|
else
|
@@ -823,6 +825,13 @@ module SalesforceMigration
|
|
823
825
|
security_group = find_sugarcrm_object('security_group','name', agent.emp_iso.first.name) unless agent.emp_iso.empty?
|
824
826
|
role = SugarCRM::ACLRole.find_by_name('agents')
|
825
827
|
if security_group
|
828
|
+
|
829
|
+
@logger.info("Puting Agent #{agent.name} in Security Group #{security_group.name}")
|
830
|
+
agent.associate! security_group
|
831
|
+
role.associate! security_group
|
832
|
+
|
833
|
+
put_email_objects_into_iso_group(security_group, 'agent', agent)
|
834
|
+
|
826
835
|
user = SugarCRM::User.find_by_last_name(agent.name)
|
827
836
|
|
828
837
|
if user.nil?
|
@@ -830,11 +839,6 @@ module SalesforceMigration
|
|
830
839
|
else
|
831
840
|
user.associate! security_group
|
832
841
|
end
|
833
|
-
|
834
|
-
@logger.info("Puting Agent #{agent.name} in Security Group #{security_group.name}")
|
835
|
-
agent.associate! security_group
|
836
|
-
role.associate! security_group
|
837
|
-
put_email_objects_into_iso_group(security_group, 'agent', agent)
|
838
842
|
else
|
839
843
|
@logger.error("Couldn't find a ISO SecurityGroup for Agent - #{agent.emp_iso.first.name}")
|
840
844
|
end
|
@@ -856,9 +860,11 @@ module SalesforceMigration
|
|
856
860
|
if security_group
|
857
861
|
@logger.info("Puting merchant #{merchant.name} into ISO group")
|
858
862
|
merchant.associate! security_group
|
859
|
-
|
863
|
+
|
860
864
|
put_email_objects_into_iso_group(security_group, 'merchant', merchant)
|
861
865
|
put_payment_methods_objects_into_iso_group(security_group, merchant)
|
866
|
+
put_bank_accounts_into_iso_group(security_group, merchant)
|
867
|
+
put_contracts_into_iso_group(security_group, merchant)
|
862
868
|
else
|
863
869
|
@logger.error("Couldn't find a ISO SecurityGroup for Merchant - #{merchant.name}")
|
864
870
|
end
|
@@ -866,7 +872,24 @@ module SalesforceMigration
|
|
866
872
|
end
|
867
873
|
end
|
868
874
|
end
|
869
|
-
|
875
|
+
|
876
|
+
def put_contracts_into_iso_group(security_group, merchant)
|
877
|
+
return unless security_group and merchant
|
878
|
+
|
879
|
+
@logger.info("Putting Contracts for #{merchant.name} into ISO group")
|
880
|
+
|
881
|
+
case @action
|
882
|
+
when "initial_run"
|
883
|
+
contracts_for_merchant_id = find_related_records(@contracts, 'sf_account_id', merchant.sf_id)
|
884
|
+
when "update"
|
885
|
+
contracts_for_merchant_id = find_related_records('contract', 'sf_account_id', merchant.sf_id)
|
886
|
+
end
|
887
|
+
|
888
|
+
return if contracts_for_merchant_id.blank?
|
889
|
+
|
890
|
+
associate_module_by_ids!(security_group, 'contract', contracts_for_merchant_id, false, true)
|
891
|
+
end
|
892
|
+
|
870
893
|
def put_bank_accounts_into_iso_group(security_group, merchant)
|
871
894
|
return unless security_group and merchant
|
872
895
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sf_migrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Emil Petkov
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2014-02-
|
19
|
+
date: 2014-02-04 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: sugarcrm_emp
|