move-to-go 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/bin/move-to-go +210 -0
  3. data/lib/move-to-go/can_become_immutable.rb +29 -0
  4. data/lib/move-to-go/csv_helper.rb +47 -0
  5. data/lib/move-to-go/email_helper.rb +14 -0
  6. data/lib/move-to-go/errors.rb +31 -0
  7. data/lib/move-to-go/excel_helper.rb +10 -0
  8. data/lib/move-to-go/global_phone.json +6571 -0
  9. data/lib/move-to-go/model/address.rb +63 -0
  10. data/lib/move-to-go/model/class_settings.rb +50 -0
  11. data/lib/move-to-go/model/clientvisit.rb +10 -0
  12. data/lib/move-to-go/model/comment.rb +10 -0
  13. data/lib/move-to-go/model/coworker.rb +82 -0
  14. data/lib/move-to-go/model/coworker_reference.rb +33 -0
  15. data/lib/move-to-go/model/customfield.rb +87 -0
  16. data/lib/move-to-go/model/deal.rb +216 -0
  17. data/lib/move-to-go/model/deal_class_settings.rb +97 -0
  18. data/lib/move-to-go/model/deal_state.rb +15 -0
  19. data/lib/move-to-go/model/deal_status.rb +23 -0
  20. data/lib/move-to-go/model/deal_status_reference.rb +47 -0
  21. data/lib/move-to-go/model/deal_status_setting.rb +49 -0
  22. data/lib/move-to-go/model/documents.rb +76 -0
  23. data/lib/move-to-go/model/file.rb +193 -0
  24. data/lib/move-to-go/model/history.rb +148 -0
  25. data/lib/move-to-go/model/history_classification.rb +26 -0
  26. data/lib/move-to-go/model/link.rb +82 -0
  27. data/lib/move-to-go/model/organization.rb +250 -0
  28. data/lib/move-to-go/model/person.rb +164 -0
  29. data/lib/move-to-go/model/referencetosource.rb +58 -0
  30. data/lib/move-to-go/model/relation.rb +23 -0
  31. data/lib/move-to-go/model/rootmodel.rb +663 -0
  32. data/lib/move-to-go/model/salescall.rb +10 -0
  33. data/lib/move-to-go/model/settings.rb +61 -0
  34. data/lib/move-to-go/model/tag.rb +35 -0
  35. data/lib/move-to-go/model/talkedto.rb +10 -0
  36. data/lib/move-to-go/model/triedtoreach.rb +10 -0
  37. data/lib/move-to-go/model_helpers.rb +97 -0
  38. data/lib/move-to-go/phone_helper.rb +75 -0
  39. data/lib/move-to-go/roo_helper.rb +82 -0
  40. data/lib/move-to-go/serialize_helper.rb +199 -0
  41. data/lib/move-to-go/shard_helper.rb +96 -0
  42. data/lib/move-to-go/source.rb +108 -0
  43. data/lib/move-to-go/templating.rb +52 -0
  44. data/lib/move-to-go.rb +20 -0
  45. data/sources/VISMA/.gitignore +14 -0
  46. data/sources/VISMA/.move-to-go/readme.txt +1 -0
  47. data/sources/VISMA/.move-to-go/runner.rb +89 -0
  48. data/sources/VISMA/Database/KONTAKT.DBF +0 -0
  49. data/sources/VISMA/Database/KUND.DBF +0 -0
  50. data/sources/VISMA/Gemfile +5 -0
  51. data/sources/VISMA/converter.rb +120 -0
  52. data/sources/base-crm/.move-to-go/runner.rb +235 -0
  53. data/sources/base-crm/Gemfile +5 -0
  54. data/sources/base-crm/README.md +9 -0
  55. data/sources/base-crm/converter.rb +56 -0
  56. data/sources/base-crm/data/contacts.csv +13 -0
  57. data/sources/base-crm/data/coworkers.csv +3 -0
  58. data/sources/base-crm/data/deals.csv +5 -0
  59. data/sources/base-crm/data/histories.csv +6 -0
  60. data/sources/base-crm/data/leads.csv +4 -0
  61. data/sources/base-crm/data/tasks.csv +5 -0
  62. data/sources/csv/.gitignore +14 -0
  63. data/sources/csv/.move-to-go/readme.txt +1 -0
  64. data/sources/csv/.move-to-go/runner.rb +65 -0
  65. data/sources/csv/Gemfile +5 -0
  66. data/sources/csv/converter.rb +218 -0
  67. data/sources/csv/data/coworkers.csv +2 -0
  68. data/sources/csv/data/deals.csv +2 -0
  69. data/sources/csv/data/organizations.csv +2 -0
  70. data/sources/csv/data/persons.csv +2 -0
  71. data/sources/custom/.gitignore +14 -0
  72. data/sources/custom/.move-to-go/readme.txt +1 -0
  73. data/sources/custom/.move-to-go/runner.rb +30 -0
  74. data/sources/custom/Gemfile +4 -0
  75. data/sources/custom/converter.rb +45 -0
  76. data/sources/excel/.gitignore +14 -0
  77. data/sources/excel/.move-to-go/readme.txt +3 -0
  78. data/sources/excel/.move-to-go/runner.rb +140 -0
  79. data/sources/excel/Gemfile +7 -0
  80. data/sources/excel/converter.rb +188 -0
  81. data/sources/excel/files/avtal.docx +0 -0
  82. data/sources/excel/files/more/avtal.docx +0 -0
  83. data/sources/excel/files/more/offert-2.pdf +0 -0
  84. data/sources/excel/files/offert-2.docx +0 -0
  85. data/sources/excel/files/offert.docx +0 -0
  86. data/sources/excel/sample-data.xlsx +0 -0
  87. data/sources/excel-basic/.gitignore +14 -0
  88. data/sources/excel-basic/.move-to-go/readme.txt +3 -0
  89. data/sources/excel-basic/.move-to-go/runner.rb +139 -0
  90. data/sources/excel-basic/Exempelfil.xlsx +0 -0
  91. data/sources/excel-basic/Gemfile +6 -0
  92. data/sources/excel-basic/converter.rb +175 -0
  93. data/sources/excel-basic/files/avtal.docx +0 -0
  94. data/sources/excel-basic/files/more/avtal.docx +0 -0
  95. data/sources/excel-basic/files/more/offert-2.pdf +0 -0
  96. data/sources/excel-basic/files/offert-2.docx +0 -0
  97. data/sources/excel-basic/files/offert.docx +0 -0
  98. data/sources/lime-crm-basic/.gitignore +14 -0
  99. data/sources/lime-crm-basic/.move-to-go/readme.txt +1 -0
  100. data/sources/lime-crm-basic/.move-to-go/runner.rb +524 -0
  101. data/sources/lime-crm-basic/Gemfile +6 -0
  102. data/sources/lime-crm-basic/converter.rb +396 -0
  103. data/sources/lime-easy/.gitignore +14 -0
  104. data/sources/lime-easy/.move-to-go/readme.txt +1 -0
  105. data/sources/lime-easy/.move-to-go/runner.rb +348 -0
  106. data/sources/lime-easy/Export/readme.txt +6 -0
  107. data/sources/lime-easy/Gemfile +5 -0
  108. data/sources/lime-easy/converter.rb +362 -0
  109. data/sources/salesforce/.gitignore +14 -0
  110. data/sources/salesforce/.move-to-go/readme.txt +1 -0
  111. data/sources/salesforce/.move-to-go/runner.rb +404 -0
  112. data/sources/salesforce/Gemfile +6 -0
  113. data/sources/salesforce/Gemfile.lock +48 -0
  114. data/sources/salesforce/converter.rb +113 -0
  115. data/sources/salesforce/export/readme.txt +3 -0
  116. data/spec/address_spec.rb +49 -0
  117. data/spec/class_settings_spec.rb +37 -0
  118. data/spec/coworker_spec.rb +94 -0
  119. data/spec/custom_field_spec.rb +22 -0
  120. data/spec/deal_class_settings_spec.rb +116 -0
  121. data/spec/deal_spec.rb +232 -0
  122. data/spec/deal_status_reference_spec.rb +17 -0
  123. data/spec/documents_spec.rb +64 -0
  124. data/spec/file_spec.rb +178 -0
  125. data/spec/helpers/csv_helper_spec.rb +45 -0
  126. data/spec/helpers/email_helper_spec.rb +37 -0
  127. data/spec/helpers/phone_helper_spec.rb +119 -0
  128. data/spec/helpers/roo_helper_spec.rb +10 -0
  129. data/spec/helpers/serialize_helper_spec.rb +253 -0
  130. data/spec/helpers/shard_helper_spec.rb +141 -0
  131. data/spec/helpers/xsd_validate_spec.rb +57 -0
  132. data/spec/history_spec.rb +150 -0
  133. data/spec/link_spec.rb +107 -0
  134. data/spec/organization_spec.rb +221 -0
  135. data/spec/person_spec.rb +129 -0
  136. data/spec/rootmodel_spec.rb +993 -0
  137. data/spec/spec_helper.rb +30 -0
  138. metadata +362 -0
@@ -0,0 +1,56 @@
1
+
2
+ class Converter
3
+
4
+ def configure(rootmodel)
5
+ # add custom field to your model here. Custom fields can be
6
+ # added to organization, deal and person. Valid types are
7
+ # :String and :Link. If no type is specified :String is used
8
+ # as default.
9
+ rootmodel.settings.with_organization do |organization|
10
+
11
+ end
12
+
13
+ rootmodel.settings.with_deal do |deal|
14
+ deal.add_status({:label => "Prospecting", :integration_id => "Prospecting"})
15
+ deal.add_status({:label => "Qualified", :integration_id => "Qualified"})
16
+ deal.add_status({:label => "Won", :integration_id => "Won",
17
+ :assessment => MoveToGo::DealState::PositiveEndState })
18
+ deal.add_status({:label => "Lost", :integration_id => "Lost",
19
+ :assessment => MoveToGo::DealState::NegativeEndState })
20
+ end
21
+ end
22
+
23
+ def to_organization(row, rootmodel)
24
+
25
+ organization = MoveToGo::Organization.new
26
+ # All built in fields are automagically mapped. Add your custom stuff here...
27
+
28
+ return organization
29
+ end
30
+
31
+ def to_organization_from_lead(row, rootmodel)
32
+ organization = MoveToGo::Organization.new
33
+ # All built in fields are automagically mapped. Add your custom stuff here...
34
+ return organization
35
+ end
36
+
37
+ def to_coworker(row)
38
+ coworker = MoveToGo::Coworker.new
39
+ # All built in fields are automagically mapped. Add your custom stuff here...
40
+ return coworker
41
+ end
42
+
43
+ def to_person(row, rootmodel)
44
+ person = MoveToGo::Person.new
45
+ # All built in fields are automagically mapped. Add your custom stuff here...
46
+ return person
47
+ end
48
+
49
+ def to_deal(row, rootmodel)
50
+ deal = MoveToGo::Deal.new
51
+ # All built in fields are automagically mapped. Add your custom stuff here...
52
+ deal.status = rootmodel.settings.deal.find_status_by_label row['stage_name']
53
+ return deal
54
+ end
55
+
56
+ end
@@ -0,0 +1,13 @@
1
+ first_name,last_name,is_organisation,name,organisation_name,owner,tags,email,address,mobile,phone,customer_status,prospect_status,custom Name#1,custom First name#1,city,country,created_at,creator,description,facebook,fax,id,industry,last_activity_date,linkedin,linkedin_display,private,region,skype,title,twitter,updated_at,website,zip
2
+ Håka,Lind,false,Håka Lind,AD Company,Kalle Kula,"",hakan.lind@ad.com,gatan 2,+46701234123,"",current,,,,Göteborg,Sweden,2015-08-12T09:59:32Z,Kalle Kula,,,,98153928,,,,,false,"",,"Service Manager production system, IT coordinator",,2015-10-02T09:19:17Z,,56130
3
+ ,,true,itteknik,,Kalle Kula,from iPhone,,vägen 23,,,current,,,,Malmö,Sverige,2015-11-25T15:17:20Z,Kalle Kula,,,,108910004,,,,,false,,,,,2015-11-25T15:17:21Z,,34250
4
+ Anna,Berg,false,Anna Berg,itteknik,Kalle Kula,"Flexibla Kontoret,Hantverksappen,vvs",info@roret.se,Brunnvägen 1,070-1110000,"",current,,,,Stockholm,Sweden,2016-02-15T07:41:56Z,Kalle Kula,,,,117069853,,,,,false,"",,"Ekonomi, Admin",,2016-02-15T07:41:56Z,,57450
5
+ Anna,Ståhl,false,Anna Ståhl,AB Bors Rör,Kalle Kula,from iPhone,,,076-800 10 00,,,,,,,,2015-08-19T08:49:26Z,Kalle Kula,,,,98708109,,,,,false,,,,,2015-08-19T08:49:26Z,,
6
+ ,,true,AB Bors Rör,,Kalle Kula,"flexibla kontoret,vvs","","","","",,,,,"","",2015-09-17T12:01:44Z,Kalle Kula,,,,101402913,,,,,false,"",,,,2015-11-09T13:45:58Z,,""
7
+ ,,true,AB Familjen,,Kalle Kula,from iPhone,,,,,,,,,Åre,Sweden,2015-08-19T06:26:58Z,Kalle Kula,,,,98702143,,,,,false,Jämtlands Län,,,,2015-08-21T07:29:44Z,,
8
+ ,,true,AB Laholms,,Kalle Kula,from iPhone,,,,,,,,,,,2015-08-19T06:21:27Z,Kalle Kula,,,,98702035,,,,,false,,,,,2015-08-19T06:21:27Z,,
9
+ ,,true,AD Company,,Kalle Kula,from iPhone,,gatan 2,,,current,,,,Lund,,2015-10-12T14:38:43Z,Kalle Kula,,,,104062513,,,,,false,,,,,2015-11-19T10:40:39Z,,553 00
10
+ ,,true,AB Affär,,Kalle Kula,"",,,,,current,,,,Lund,Sweden,2015-08-18T21:59:33Z,Kalle Kula,,,,98677167,Digital sinage mm,,,,false,,,,,2015-08-18T21:59:33Z,,
11
+ ,,true,AB Affären,,Kalle Kula,"",,,,,,,,,,,2014-09-05T07:45:04Z,Kalle Kula,,,,69769303,Redovisnings konsult,,,,false,,,,,2014-09-05T15:33:17Z,,
12
+ ,,true,Ahlgrens Bilar,,Kalle Kula,"from iPhone,flexibla kontoret,Flexibla/Hantverksappen",,,,,,,,,,,2015-08-19T06:37:39Z,Kalle Kula,,,,98702525,,,,,false,,,,,2015-08-19T06:37:39Z,,
13
+ Alex,Alexandersson,false,Alex Alexandersson,Ahlgrens Bilar,Kalle Kula,from iPhone,Alex.Alexandersson@ahlgrens.se,,0707 840000,,,,,,,,2015-08-19T09:30:24Z,Kalle Kula,,,,98710895,,,,,false,,,,,2015-08-19T09:30:24Z,,
@@ -0,0 +1,3 @@
1
+ first_name,last_name,email
2
+ Kalle,Kula,Kalle@kula.se
3
+ Kalle,Gula,Kalle@gula.se
@@ -0,0 +1,5 @@
1
+ id,name,scope,pipeline_name,pipeline_id,stage_name,stage_id,owner,tags,main_contact_id,main_contact,company_id,company,added_at,added_on,created_at,creator,currency,forecasted_deal_value,hot,last_activity_date,last_stage_change_at,loss_reason,source,updated_at
2
+ 10926776,"avtal, ca 40st",300000,Sales Pipeline,60134,Prospecting,432286,Kalle Kula,"",117069853,Anna Berg,108910004,"itteknik",2015-10-05 08:28:00 UTC,2015-10-05,2015-10-05T08:29:47Z,Kalle Kula,SEK,,true,2015-10-05T08:29:47Z,2015-10-05T08:28:47Z,"",Butiken1,2015-10-05T08:29:47Z
3
+ 11973819,Deal2,100000,Sales Pipeline,60134,Qualified,432290,Kalle Kula,"ftp,filserver,service avtal",98708109,Anna Ståhl,101402913,AB Bors Rör,2015-11-19 10:38:00 UTC,2015-11-19,2015-11-19T10:39:51Z,Kalle Kula,SEK,,true,2015-11-19T10:39:51Z,2015-11-19T10:38:51Z,"",Henrik Henriksson konsult,2015-11-19T10:39:51Z
4
+ 4636237,Deal1,4500,Sales Pipeline,60134,Won,432287,Kalle Kula,cloud,98153928,Håka Lind,104062513,AD Company,2014-09-02 09:40:00 UTC,2014-09-02,2014-09-03T09:41:05Z,Kalle Kula,SEK,,true,2015-02-18T07:39:45Z,2015-02-18T07:39:45Z,"",konsollen,2015-02-18T07:39:45Z
5
+ 4653104,Deal3,2300,Sales Pipeline,60134,Won,432287,Kalle Kula,"",98710895,Alex Alexandersson,98702525,Ahlgrens Bilar,2014-09-04 07:53:00 UTC,2014-09-04,2014-09-04T07:54:31Z,Kalle Kula,SEK,,false,2014-09-04T07:55:07Z,2014-09-04T07:53:00Z,"",Hyresavtal,2014-09-04T07:54:31Z
@@ -0,0 +1,6 @@
1
+ content,owner,noteable_id,noteable_type,noteable_name,created_at,id,noteable_company_name,noteable_first_name,noteable_last_name,updated_at
2
+ Uppdatering av underhållsavtal på befintlig,Kalle Kula,10926776,Deal,Sannarp,2014-09-03T08:49:07Z,22606121,,,,2014-09-03T08:49:07Z
3
+ "Mailat offert, Återkommer...",Kalle Kula,10926776,Deal,Sannarp,2014-09-03T08:50:01Z,22606134,,,,2014-09-03T08:50:01Z
4
+ "Kund mailar och...",Kalle Kula,11973819,Deal,Sannarp,2014-09-03T08:50:28Z,22606143,,,,2014-09-03T08:50:28Z
5
+ "Kört igång...",Kalle Kula,98702525,SalesAccount,,2014-09-03T08:56:28Z,22606290,"",Peder,Johansson,2014-09-03T08:56:28Z
6
+ "Påminnelse ,1, 2...",Kalle Kula,108910004,SalesAccount,,2014-09-03T08:58:13Z,22606323,"",Peder,Johansson,2014-09-03T08:58:13Z
@@ -0,0 +1,4 @@
1
+ first_name,last_name,company_name,owner,city,country,created_at,creator,description,email,facebook,fax,id,industry,linkedin,mobile,phone,region,skype,status,street,tags,title,twitter,updated_at,website,zip
2
+ Robin,Hood,Reklam1 AB,Kalle Kula,Lund,Sweden,2014-09-04T09:42:33Z,Kalle Kula,,,,,16685740,tillverkning,,0733-11 11 11,,,,Working,,reklam,Försäljnings- och marknadschef,,2014-09-04T09:42:33Z,,
3
+ Tony,Tonfisk,Hantverkare2,Kalle Kula,Borås,,2014-09-04T14:36:01Z,Kalle Kula,"Ringde, intresse finns",tony@tonfisk.se,,,16694927,Magasin/katalog,,0701121212,,,,Unqualified,gatan 11,,Ansvarig,,2014-09-10T14:44:29Z,,
4
+ Thomas,Tomasso,"Bregott fabriken",Kalle Kula,Jönköping,Sweden,2015-06-30T12:47:04Z,Kalle Kula,,thomas.tomasso@bregott.se,,,35451881,,,07088000 00,090505050,,,Working,gatan 12,,Delägare,,2015-06-30T12:47:04Z,,553 17
@@ -0,0 +1,5 @@
1
+ content,owner,send_time,done_at,created_at,date,id,remind,taskable_company_name,taskable_first_name,taskable_id,taskable_last_name,taskable_name,taskable_type,updated_at
2
+ "Ring kund ang uppföljning,Kalle Kula,2014-09-04T06:15:00Z,2014-09-04T06:59:32Z,2014-09-03T08:59:53Z,,7338118,true,"""",Petter,69512473,Johansson,,SalesAccount,2014-09-04T06:59:32Z"
3
+ "Ring boka ny utb!,Kalle Kula,2014-09-08T07:45:00Z,,2014-09-04T07:00:36Z,,7402212,true,"""",Petter,69512473,Johansson,,SalesAccount,2014-09-07T14:45:04Z"
4
+ "Ring boka möte för fördjupat samarbete,Kalle Kula,2014-09-08T08:00:00Z,,2014-09-04T07:25:17Z,,7402869,true,"""",Anna,69512622,Andersson,,SalesAccount,2014-09-04T07:25:17Z"
5
+ "Boka nytt möte,Kalle Kula,2014-09-08T10:45:00Z,,2014-09-04T07:18:36Z,,7402562,true,"""",Cyrus,69512640,TheVirus,,SalesAccount,2014-09-07T14:44:51Z"
@@ -0,0 +1,14 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+ # Ignore built gems
10
+ /*.gem
11
+ # Ignore all logfiles and tempfiles.
12
+ /tmp
13
+ /spec/tmp
14
+ pkg
@@ -0,0 +1 @@
1
+ This source converts a csv file to LIME Go.
@@ -0,0 +1,65 @@
1
+
2
+ require 'move-to-go'
3
+ require_relative("../converter")
4
+
5
+ # COWORKER_FILE and other file names should be defined ../converter.rb
6
+
7
+ def process_rows(file_name, source_encoding)
8
+ data = File.read(file_name, :encoding => source_encoding)
9
+ rows = MoveToGo::CsvHelper::text_to_hashes(data)
10
+ rows.each do |row|
11
+ yield row
12
+ end
13
+ end
14
+
15
+ def convert_source
16
+ puts "Trying to convert CSV source to LIME Go..."
17
+
18
+ converter = Converter.new
19
+
20
+ # A rootmodel is used to represent all entitite/models that is
21
+ # exported
22
+ rootmodel = MoveToGo::RootModel.new
23
+
24
+ converter.configure(rootmodel)
25
+ source_encoding = defined?(SOURCE_ENCODING) ? SOURCE_ENCODING : 'ISO-8859-1'
26
+
27
+ # coworkers
28
+ # start with these since they are referenced
29
+ # from everywhere....
30
+ if defined?(COWORKER_FILE) && !COWORKER_FILE.nil? && !COWORKER_FILE.empty?
31
+ process_rows(COWORKER_FILE, source_encoding) do |row|
32
+ rootmodel.add_coworker(converter.to_coworker(row))
33
+ end
34
+ end
35
+
36
+ # organizations
37
+ if defined?(ORGANIZATION_FILE) && !ORGANIZATION_FILE.nil? && !ORGANIZATION_FILE.empty?
38
+ process_rows(ORGANIZATION_FILE, source_encoding) do |row|
39
+ organization = converter.to_organization(row, rootmodel)
40
+ rootmodel.add_organization(organization)
41
+ converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
42
+ end
43
+ end
44
+
45
+ # persons
46
+ # depends on organizations
47
+ if defined?(PERSON_FILE) && !PERSON_FILE.nil? && !PERSON_FILE.empty?
48
+ process_rows(PERSON_FILE, source_encoding) do |row|
49
+ # adds it self to the employer
50
+ converter.to_person(row, rootmodel)
51
+ end
52
+ end
53
+
54
+ # deals
55
+ # deals can reference coworkers (responsible), organizations
56
+ # and persons (contact)
57
+ if defined?(DEAL_FILE) && !DEAL_FILE.nil? && !DEAL_FILE.empty?
58
+ process_rows(DEAL_FILE, source_encoding) do |row|
59
+ rootmodel.add_deal(converter.to_deal(row, rootmodel))
60
+ end
61
+ end
62
+
63
+ return rootmodel
64
+ end
65
+
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'thor'
4
+ gem 'move-to-go'
5
+ gem 'rspec'
@@ -0,0 +1,218 @@
1
+ require 'move-to-go'
2
+
3
+ # This converter will convert one or more CVS files into a LIME Go XML
4
+ # file.
5
+
6
+ # You need to customize this script to suit your CVS file(s).
7
+
8
+ # First we set the file names of your CVS files. If you dont need to
9
+ # import all kind of objects, just leave the filename empty or remove
10
+ # the line.
11
+ COWORKER_FILE = "data/coworkers.csv"
12
+ ORGANIZATION_FILE = "data/organizations.csv"
13
+ PERSON_FILE = "data/persons.csv"
14
+ DEAL_FILE = "data/deals.csv"
15
+ # Ie if you dont want to import deals, set DEAL_FILE = ""
16
+
17
+ # Default encoding for files are 'ISO-8859-1' (aka latin1)
18
+ # If the file is in any other encoding this must be specified with
19
+ # SOURCE_ENCODING set to correct value
20
+ # Ruby can handle lots of encodings, but common ones are:
21
+ # SOURCE_ENCODING = "UTF-8"
22
+ # SOURCE_ENCODING = "bom|UTF-8"
23
+ # SOURCE_ENCODING = "UTF-16"
24
+
25
+ # If you are importing files then you must set the FILES_FOLDER
26
+ # constant. FILES_FOLDER should point to the folder where the files
27
+ # are stored. FILES_FOLDER can be relative to the project directory
28
+ # or absolute. Note that you need to escape \ with a \ so in order to
29
+ # write \ use \\.
30
+ FILES_FOLDER = "./files"
31
+
32
+ # If you are importing files with an absolute path (eg
33
+ # m:\documents\readme.doc) then you probably wont have files at that
34
+ # location on the computer where "move-to-go run" is executed. Set
35
+ # FILES_FOLDER_AT_CUSTOMER to the folder where documents are stored at
36
+ # the customers site. Ie, in this example m:\documents.
37
+ # Note that you need to escape \ with a \ so in order to write \ use
38
+ # \\.
39
+ FILES_FOLDER_AT_CUSTOMER = "m:\\documents\\"
40
+
41
+ class Converter
42
+ # Configure your root model, add custom fields and deal statuses.
43
+ def configure(rootmodel)
44
+ # add custom field to your model here. Custom fields can be
45
+ # added to organization, deal and person. Valid types are
46
+ # :String and :Link. If no type is specified :String is used
47
+ # as default.
48
+ rootmodel.settings.with_organization do |organization|
49
+ organization.set_custom_field( { :integrationid => 'external_url', :title => 'Link to external system', :type => :Link } )
50
+ end
51
+
52
+ rootmodel.settings.with_deal do |deal|
53
+ deal.add_status({:label => "1. Kvalificering", :integration_id => "qualification"})
54
+ deal.add_status({:label => "Vunnen", :integration_id => "won",
55
+ :assessment => MoveToGo::DealState::PositiveEndState })
56
+ deal.add_status({:label => "Lost", :integration_id => "Lost",
57
+ :assessment => MoveToGo::DealState::NegativeEndState })
58
+ end
59
+ end
60
+
61
+ # Turns a row from the organization csv file into a
62
+ # MoveToGo::Organization.
63
+ # Use rootmodel to locate other related stuff such coworker
64
+ def to_organization(row, rootmodel)
65
+ organization = MoveToGo::Organization.new
66
+ # Integrationid is typically the id in the system that
67
+ # we are getting the csv from. Must be set to be able
68
+ # to import the same file more than once without
69
+ # creating duplicates
70
+ organization.integration_id = row['id']
71
+ organization.name = row['name']
72
+
73
+ # Just setting all basic properties to show whats available
74
+ # Remove or fix...
75
+ organization.organization_number = 'a number' # needs clean up, should have helpers for that in lib. Swedish format.
76
+ organization.email = 'email to organizaiton, not the person'
77
+ organization.web_site = 'www.whatever.com'
78
+ organization.central_phone_number = '0000' # needs clean up, should have helpers for that in lib. Default swedish format, convert to global format
79
+
80
+ # Addresses consists of several parts in Go.
81
+ # Lots of other systems have the address all in one
82
+ # line, to be able to match when importing it is
83
+ # way better to split the addresses
84
+ organization.with_visit_address do |address|
85
+ address.street = 'visit street'
86
+ address.zip_code = 'visit zip'
87
+ address.city = 'visit city'
88
+ end
89
+
90
+ # Another example of setting address using
91
+ # helper to split '226 48 LUND' into zip and city
92
+ organization.with_postal_address do |address|
93
+ address.street = 'postal street'
94
+ address.parse_zip_and_address_se '226 48 LUND'
95
+ end
96
+
97
+ # Responsible coworker is set by first locating
98
+ # it in the root model and then setting a reference
99
+ # to him/her
100
+ # We need to be able handle missing coworkers here
101
+ coworker = rootmodel.find_coworker_by_integration_id row['responsible_id']
102
+ organization.responsible_coworker = coworker.to_reference
103
+
104
+ # Set tags for the organization. All organizations will get
105
+ # the tag "import" automagically
106
+ organization.set_tag("Guldkund")
107
+
108
+ # When imported from web based ERP or similair that
109
+ # client will continue to use it can be useful to be
110
+ # able to link from Go to the same record in the ERP
111
+ # FOr instance Lime links
112
+ organization.set_custom_value("external_url", "http://something.com?key=#{row['id']}")
113
+
114
+ return organization
115
+ end
116
+
117
+ # Turns a row from the coworker csv file into a MoveToGo::Coworker.
118
+ def to_coworker(row)
119
+ coworker = MoveToGo::Coworker.new
120
+ coworker.integration_id = row['id']
121
+ coworker.first_name = row['first_name']
122
+ coworker.last_name = row['last_name']
123
+
124
+ # Other optional attributes
125
+ coworker.email = 't@e.com'
126
+ coworker.direct_phone_number = '+46121212'
127
+ coworker.mobile_phone_number = '+46324234'
128
+ coworker.home_phone_number = '+46234234'
129
+
130
+ # Tags and custom fields are set the same
131
+ # way as on organizations
132
+
133
+ return coworker
134
+ end
135
+
136
+ # Turns a row from the person csv file into a MoveToGo::Person.
137
+ #
138
+ # You MUST add the new person to an existing organization. Use the
139
+ # rootmodel to find the organization and then add the person with
140
+ # organization.add_employee
141
+ def to_person(row, rootmodel)
142
+ person = MoveToGo::Person.new
143
+ person.integration_id = row['id']
144
+ # Note that Go has separate first and last names
145
+ # Some splitting might be necessary
146
+ person.first_name = row['first_name']
147
+ person.last_name = row['last_name']
148
+ # other optional attributes
149
+ person.direct_phone_number = '+4611111'
150
+ person.fax_phone_number = '+4623234234234'
151
+ person.mobile_phone_number = '+462321212'
152
+ person.email = 'x@y.com'
153
+ person.alternative_email = 'y@x.com'
154
+ person.with_postal_address do |address|
155
+ address.street = 'postal street'
156
+ address.parse_zip_and_address_se '226 48 LUND'
157
+ end
158
+
159
+ # Tags and custom fields are set the same
160
+ # way as on organizations
161
+
162
+ # set employer connection
163
+ employer_id = row['employer_id']
164
+ employer = rootmodel.find_organization_by_integration_id employer_id
165
+ employer.add_employee person
166
+ end
167
+
168
+ # Turns a row form the deal csv file into a MoveToGo::Deal. Use
169
+ # the rootmodel to find objects that should be linked to the new
170
+ # deal.
171
+ def to_deal(row, rootmodel)
172
+ deal = MoveToGo::Deal.new
173
+ deal.integration_id = row['id']
174
+ deal.name = row['name']
175
+ # should be integer, same currency should be used in
176
+ # the system
177
+ deal.value = row['value']
178
+
179
+ # find stuff connected to deal
180
+ responsible = rootmodel.find_coworker_by_integration_id row['responsible_id']
181
+ organization = rootmodel.find_organization_by_integration_id row['customer_id']
182
+ person = organization.find_employee_by_integration_id row['customer_contact_id']
183
+ # connect the deal by references
184
+ deal.responsible_coworker = responsible.to_reference
185
+ deal.customer = organization.to_reference
186
+ deal.customer_contact = person.to_reference
187
+
188
+ # other optional attributes
189
+ deal.probability = 50 # should be between 0 - 100
190
+ deal.order_date = '2014-01-05' # Format ?
191
+
192
+ # status, set this by either label, id or integration_id (use
193
+ # appropriate method to find status)
194
+ deal.status = rootmodel.settings.deal.find_status_by_label row['status']
195
+
196
+ # or set by existing status, search by label, integration_id
197
+ # (if string) or id (if integer).
198
+ # deal.status = "Won"
199
+
200
+ return deal
201
+ end
202
+
203
+ # HOOKS
204
+ #
205
+ # Sometimes you need to add exra information to the rootmodel, this can be done
206
+ # with hooks, below is an example of an organization hook that adds a history to
207
+ # an organization if a field has a specific value
208
+ #def organization_hook(row, organization, rootmodel)
209
+ # if not row['fieldname'].empty?
210
+ # comment = MoveToGo::Comment.new
211
+ # comment.text = row['fieldname']
212
+ # comment.organization = organization
213
+ # comment.created_by = rootmodel.migrator_coworker
214
+ # rootmodel.add_comment(comment)
215
+ # end
216
+ #end
217
+
218
+ end
@@ -0,0 +1,2 @@
1
+ id;first_name;last_name
2
+ 666;Evil;Elvis
@@ -0,0 +1,2 @@
1
+ id;name;value;responsible_id;customer_id;customer_contact_id;status
2
+ 333;Feta affären;10000;666;6;123;Vunnen
@@ -0,0 +1,2 @@
1
+ id;name;responsible_id
2
+ 6;Alfs Mjukvaruutveckling;666
@@ -0,0 +1,2 @@
1
+ id;employer_id;first_name;last_name
2
+ 123;6;Rune;Rebellion
@@ -0,0 +1,14 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+ # Ignore built gems
10
+ /*.gem
11
+ # Ignore all logfiles and tempfiles.
12
+ /tmp
13
+ /spec/tmp
14
+ pkg
@@ -0,0 +1 @@
1
+ This source is a basic template that you can usse if you want to write your own custom source.
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'move-to-go'
4
+ require_relative("../converter")
5
+
6
+ def convert_source
7
+ puts "Trying to convert a custom source to LIME Go..."
8
+
9
+ converter = Converter.new
10
+
11
+ if !converter.respond_to?(:to_go)
12
+ puts "The converter must have a method called to_go that returns an instance of MoveToGo::RootModel."
13
+ raise "The converter must have a method called to_go that returns an instance of MoveToGo::RootModel."
14
+ end
15
+
16
+ rootmodel = converter.to_go
17
+
18
+ if rootmodel.nil?
19
+ puts "The returned rootmodel is nil. You must return a MoveToGo::RootModel."
20
+ raise "The returned rootmodel is nil. You must return a MoveToGo::RootModel."
21
+ end
22
+
23
+ if !rootmodel.is_a?(MoveToGo::RootModel)
24
+ puts "The returned object is not an instance of MoveToGo::RootModel."
25
+ raise "The returned object is not an instance of MoveToGo::RootModel."
26
+ end
27
+
28
+ return rootmodel
29
+ end
30
+
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rspec'
4
+ gem 'move-to-go'
@@ -0,0 +1,45 @@
1
+ # encoding: UTF-8
2
+ require 'move-to-go'
3
+
4
+ # This Converter will convert a generic source to a XML file that can
5
+ # be imported into LIME Go.
6
+ #
7
+ # You MUST customzie this script to read a source and return a
8
+ # RootModel.
9
+ #
10
+ # Reference documentation for move-to-go can be found at
11
+ # https://rubygems.org/gems/move-to-go (click Documentation)
12
+ #
13
+ # Generate the xml-file that should be sent to LIME Go with the
14
+ # command:
15
+ # move-to-go run
16
+ #
17
+ # Good luck.
18
+
19
+ # If you are importing files then you must set the FILES_FOLDER
20
+ # constant. FILES_FOLDER should point to the folder where the files
21
+ # are stored. FILES_FOLDER can be relative to the project directory
22
+ # or absolute. Note that you need to escape \ with a \ so in order to
23
+ # write \ use \\.
24
+ FILES_FOLDER = "./files"
25
+
26
+ # If you are importing files with an absolute path (eg
27
+ # m:\documents\readme.doc) then you probably wont have files at that
28
+ # location on the computer where "move-to-go run" is executed. Set
29
+ # FILES_FOLDER_AT_CUSTOMER to the folder where documents are stored at
30
+ # the customers site. Ie, in this example m:\documents.
31
+ # Note that you need to escape \ with a \ so in order to write \ use
32
+ # \\.
33
+ FILES_FOLDER_AT_CUSTOMER = "m:\\documents\\"
34
+
35
+ class Converter
36
+ def to_go()
37
+ rootmodel = MoveToGo::RootModel.new
38
+
39
+ # *** TODO:
40
+ #
41
+ # Configure the model and then add coworkers, organizations, etc
42
+
43
+ return rootmodel
44
+ end
45
+ end
@@ -0,0 +1,14 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ # Ignore bundler config
8
+ /.bundle
9
+ # Ignore built gems
10
+ /*.gem
11
+ # Ignore all logfiles and tempfiles.
12
+ /tmp
13
+ /spec/tmp
14
+ pkg
@@ -0,0 +1,3 @@
1
+ The Excel source lets you import a custom excelfile into LIME Go.
2
+
3
+ You have to write some code to customize the script to suit your excelfile. If your customer doesnt have a specific format yet maybe you can use the Excel Basic source instead?