go_import 3.0.42 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/go-import +2 -1
- data/lib/go_import/errors.rb +2 -2
- data/lib/go_import/model/deal_status.rb +2 -2
- data/lib/go_import/model/{note.rb → history.rb} +17 -13
- data/lib/go_import/model/{note_classification.rb → history_classification.rb} +8 -8
- data/lib/go_import/model/rootmodel.rb +39 -41
- data/lib/go_import/serialize_helper.rb +4 -4
- data/lib/go_import/shard_helper.rb +3 -3
- data/lib/go_import.rb +13 -13
- data/sources/VISMA/.go_import/readme.txt +1 -1
- data/sources/VISMA/.go_import/runner.rb +8 -8
- data/sources/VISMA/converter.rb +15 -14
- data/sources/base-crm/.go_import/runner.rb +24 -24
- data/sources/base-crm/converter.rb +3 -3
- data/sources/base-crm/data/{notes.csv → histories.csv} +0 -0
- data/sources/csv/converter.rb +6 -6
- data/sources/excel/.go_import/runner.rb +11 -11
- data/sources/excel/converter.rb +15 -15
- data/sources/excel-basic/.go_import/runner.rb +11 -11
- data/sources/excel-basic/converter.rb +9 -9
- data/sources/lime-easy/.go_import/runner.rb +40 -40
- data/sources/lime-easy/converter.rb +22 -22
- data/sources/lime-pro-basic/.go_import/runner.rb +19 -19
- data/sources/lime-pro-basic/converter.rb +22 -22
- data/sources/salesforce/.go_import/runner.rb +10 -10
- data/sources/salesforce/converter.rb +6 -6
- data/spec/helpers/serialize_helper_spec.rb +6 -6
- data/spec/helpers/shard_helper_spec.rb +3 -3
- data/spec/history_spec.rb +150 -0
- data/spec/rootmodel_spec.rb +56 -56
- metadata +7 -7
- data/spec/note_spec.rb +0 -150
@@ -58,11 +58,11 @@ def convert_source
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
if defined?(
|
62
|
-
if excel_workbook.has_sheet?(
|
63
|
-
|
61
|
+
if defined?(HISTORY_SHEET)
|
62
|
+
if excel_workbook.has_sheet?(HISTORY_SHEET)
|
63
|
+
history_rows = excel_workbook.rows_for_sheet HISTORY_SHEET
|
64
64
|
else
|
65
|
-
puts "WARNING: can't find sheet '#{
|
65
|
+
puts "WARNING: can't find sheet '#{HISTORY_SHEET}'"
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -83,7 +83,7 @@ def convert_source
|
|
83
83
|
|
84
84
|
# Now start to read data from the excel file and add to the
|
85
85
|
# rootmodel. We begin with coworkers since they are referenced
|
86
|
-
# from everywhere (orgs, deals,
|
86
|
+
# from everywhere (orgs, deals, histories)
|
87
87
|
if defined?(coworker_rows) && !coworker_rows.nil?
|
88
88
|
puts "Trying to convert coworkers..."
|
89
89
|
coworker_rows.each do |row|
|
@@ -119,12 +119,12 @@ def convert_source
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
#
|
123
|
-
# organizations and
|
124
|
-
if defined?(
|
125
|
-
puts "Trying to convert
|
126
|
-
|
127
|
-
rootmodel.
|
122
|
+
# History must be owned by a coworker and the be added to
|
123
|
+
# organizations and histories and might refernce a person
|
124
|
+
if defined?(history_rows) && !history_rows.nil?
|
125
|
+
puts "Trying to convert histories..."
|
126
|
+
history_rows.with_progress().each do |row|
|
127
|
+
rootmodel.add_history(converter.to_history(row, rootmodel))
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
data/sources/excel/converter.rb
CHANGED
@@ -15,7 +15,7 @@ COWORKER_SHEET = "Medarbetare"
|
|
15
15
|
ORGANIZATION_SHEET = "Företag"
|
16
16
|
PERSON_SHEET = "Kontaktperson"
|
17
17
|
DEAL_SHEET = "Affär"
|
18
|
-
|
18
|
+
HISTORY_SHEET = "Anteckningar"
|
19
19
|
FILE_SHEET = "Dokument"
|
20
20
|
|
21
21
|
# Then you need to modify the script below according to the TODO
|
@@ -143,19 +143,19 @@ class Converter
|
|
143
143
|
return person
|
144
144
|
end
|
145
145
|
|
146
|
-
def
|
147
|
-
|
146
|
+
def to_history(row, rootmodel)
|
147
|
+
history = GoImport::History.new()
|
148
148
|
|
149
149
|
# *** TODO:
|
150
150
|
#
|
151
|
-
# Set
|
151
|
+
# Set history properties from the row.
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
153
|
+
history.organization = rootmodel.find_organization_by_integration_id(row['ID'])
|
154
|
+
history.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad av'])
|
155
|
+
history.text = row['Text']
|
156
|
+
history.date = row['Skapad den']
|
157
157
|
|
158
|
-
return
|
158
|
+
return history
|
159
159
|
end
|
160
160
|
|
161
161
|
def to_file(row, rootmodel)
|
@@ -173,15 +173,15 @@ class Converter
|
|
173
173
|
# HOOKS
|
174
174
|
#
|
175
175
|
# Sometimes you need to add exra information to the rootmodel, this can be done
|
176
|
-
# with hooks, below is an example of an organization hook that adds a
|
176
|
+
# with hooks, below is an example of an organization hook that adds a history to
|
177
177
|
# an organization if a field has a specific value
|
178
178
|
#def organization_hook(row, organization, rootmodel)
|
179
179
|
# if not row['fieldname'].empty?
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
# rootmodel.
|
180
|
+
# history = GoImport::History.new
|
181
|
+
# history.text = row['fieldname']
|
182
|
+
# history.organization = organization
|
183
|
+
# history.created_by = rootmodel.import_coworker
|
184
|
+
# rootmodel.add_history(history)
|
185
185
|
# end
|
186
186
|
#end
|
187
187
|
|
@@ -57,11 +57,11 @@ def convert_source
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
if defined?(
|
61
|
-
if excel_workbook.has_sheet?(
|
62
|
-
|
60
|
+
if defined?(HISTORY_SHEET)
|
61
|
+
if excel_workbook.has_sheet?(HISTORY_SHEET)
|
62
|
+
history_rows = excel_workbook.rows_for_sheet HISTORY_SHEET
|
63
63
|
else
|
64
|
-
puts "WARNING: can't find sheet '#{
|
64
|
+
puts "WARNING: can't find sheet '#{HISTORY_SHEET}'"
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -82,7 +82,7 @@ def convert_source
|
|
82
82
|
|
83
83
|
# Now start to read data from the excel file and add to the
|
84
84
|
# rootmodel. We begin with coworkers since they are referenced
|
85
|
-
# from everywhere (orgs, deals,
|
85
|
+
# from everywhere (orgs, deals, histories)
|
86
86
|
if defined?(coworker_rows) && !coworker_rows.nil?
|
87
87
|
puts "Trying to convert coworkers..."
|
88
88
|
coworker_rows.each do |row|
|
@@ -118,12 +118,12 @@ def convert_source
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
#
|
122
|
-
# organizations and
|
123
|
-
if defined?(
|
124
|
-
puts "Trying to convert
|
125
|
-
|
126
|
-
rootmodel.
|
121
|
+
# histories must be owned by a coworker and the be added to
|
122
|
+
# organizations and histories and might refernce a person
|
123
|
+
if defined?(histories_rows) && !histories_rows.nil?
|
124
|
+
puts "Trying to convert history..."
|
125
|
+
history_rows.each do |row|
|
126
|
+
rootmodel.add_history(converter.to_history(row, rootmodel))
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -14,7 +14,7 @@ EXCEL_FILE = "Exempelfil.xlsx"
|
|
14
14
|
COWORKER_SHEET = "Medarbetare"
|
15
15
|
ORGANIZATION_SHEET = "Företag"
|
16
16
|
PERSON_SHEET = "Kontaktperson"
|
17
|
-
|
17
|
+
HISTORY_SHEET = "Anteckningar"
|
18
18
|
|
19
19
|
# Then you need to modify the script below according to the TODO
|
20
20
|
# comments.
|
@@ -158,18 +158,18 @@ class Converter
|
|
158
158
|
return person
|
159
159
|
end
|
160
160
|
|
161
|
-
def
|
162
|
-
|
161
|
+
def to_history(row, rootmodel)
|
162
|
+
history = GoImport::History.new()
|
163
163
|
|
164
164
|
# *** TODO:
|
165
165
|
#
|
166
|
-
# Set
|
166
|
+
# Set history properties from the row.
|
167
167
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
168
|
+
history.organization = rootmodel.find_organization_by_integration_id(row['Kundnummer/FöretagsID'])
|
169
|
+
history.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad av medarbetare'])
|
170
|
+
history.text = row['Textanteckningar/Historik']
|
171
|
+
history.date = row['Skapad den']
|
172
172
|
|
173
|
-
return
|
173
|
+
return history
|
174
174
|
end
|
175
175
|
end
|
@@ -7,12 +7,12 @@ require_relative("../converter")
|
|
7
7
|
EXPORT_FOLDER = 'export'
|
8
8
|
COWORKER_FILE = "#{EXPORT_FOLDER}/User.txt"
|
9
9
|
ORGANIZATION_FILE = "#{EXPORT_FOLDER}/Company.txt"
|
10
|
-
|
10
|
+
ORGANIZATION_HISTORY_FILE = "#{EXPORT_FOLDER}/Company-History.txt"
|
11
11
|
ORGANIZATION_DOCUMENT_FILE = "#{EXPORT_FOLDER}/Company-Document.txt"
|
12
12
|
PERSON_FILE = "#{EXPORT_FOLDER}/Company-Person.txt"
|
13
13
|
INCLUDE_FILE = "#{EXPORT_FOLDER}/Project-Included.txt"
|
14
14
|
DEAL_FILE = "#{EXPORT_FOLDER}/Project.txt"
|
15
|
-
|
15
|
+
DEAL_HISTORY_FILE = "#{EXPORT_FOLDER}/Project-History.txt"
|
16
16
|
PROJECT_DOCUMENT_FILE = "#{EXPORT_FOLDER}/Project-Document.txt"
|
17
17
|
|
18
18
|
def convert_source
|
@@ -56,10 +56,10 @@ def convert_source
|
|
56
56
|
converter.to_person(person, row)
|
57
57
|
end
|
58
58
|
|
59
|
-
# organization
|
60
|
-
process_rows(" - Reading Organization
|
59
|
+
# organization histories
|
60
|
+
process_rows(" - Reading Organization History '#{ORGANIZATION_HISTORY_FILE}'", ORGANIZATION_HISTORY_FILE) do |row|
|
61
61
|
# adds itself if applicable
|
62
|
-
rootmodel.
|
62
|
+
rootmodel.add_history(to_organization_history(converter, row, rootmodel))
|
63
63
|
end
|
64
64
|
|
65
65
|
# Organization - Deal connection
|
@@ -77,10 +77,10 @@ def convert_source
|
|
77
77
|
rootmodel.add_deal(converter.to_deal(deal, row))
|
78
78
|
end
|
79
79
|
|
80
|
-
# deal
|
81
|
-
process_rows(" - Reading Deal
|
80
|
+
# deal histories
|
81
|
+
process_rows(" - Reading Deal Histories '#{DEAL_HISTORY_FILE}'", DEAL_HISTORY_FILE) do |row|
|
82
82
|
# adds itself if applicable
|
83
|
-
rootmodel.
|
83
|
+
rootmodel.add_history(to_deal_history(converter, row, rootmodel))
|
84
84
|
end
|
85
85
|
|
86
86
|
# documents
|
@@ -152,37 +152,37 @@ end
|
|
152
152
|
|
153
153
|
# Turns a row from the Easy exported Company-History.txt file into
|
154
154
|
# a go_import model that is used to generate xml.
|
155
|
-
def
|
155
|
+
def to_organization_history(converter, row, rootmodel)
|
156
156
|
organization = rootmodel.find_organization_by_integration_id(row['idCompany'])
|
157
157
|
coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
|
158
158
|
|
159
159
|
if organization && coworker
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
160
|
+
history = GoImport::History.new()
|
161
|
+
history.organization = organization
|
162
|
+
history.created_by = coworker
|
163
|
+
history.person = organization.find_employee_by_integration_id(row['idPerson'])
|
164
|
+
history.date = row['Date']
|
165
165
|
|
166
|
-
if converter.respond_to?(:
|
167
|
-
# we will get an
|
166
|
+
if converter.respond_to?(:get_history_classification_for_activity_on_company)
|
167
|
+
# we will get an InvalidHistoryClassificationError if we are
|
168
168
|
# setting and invalid classification. So no need to verify
|
169
169
|
# return value from converter.
|
170
170
|
classification =
|
171
|
-
converter.
|
171
|
+
converter.get_history_classification_for_activity_on_company(row['Category'])
|
172
172
|
|
173
173
|
if classification.nil?
|
174
|
-
classification = GoImport::
|
174
|
+
classification = GoImport::HistoryClassification::Comment
|
175
175
|
end
|
176
176
|
|
177
|
-
|
177
|
+
history.classification = classification
|
178
178
|
|
179
|
-
|
179
|
+
history.text = row['History']
|
180
180
|
else
|
181
|
-
|
182
|
-
|
181
|
+
history.classification = GoImport::HistoryClassification::Comment
|
182
|
+
history.text = "#{row['Category']}: #{row['History']}"
|
183
183
|
end
|
184
184
|
|
185
|
-
return
|
185
|
+
return history.text.empty? ? nil : history
|
186
186
|
end
|
187
187
|
|
188
188
|
return nil
|
@@ -257,7 +257,7 @@ end
|
|
257
257
|
|
258
258
|
# Turns a row from the Easy exported Project-History.txt file into
|
259
259
|
# a go_import model that is used to generate xml
|
260
|
-
def
|
260
|
+
def to_deal_history(converter, row, rootmodel)
|
261
261
|
# TODO: This could be improved to read a person from an
|
262
262
|
# organization connected to this deal if any, but since it is
|
263
263
|
# a many to many connection between organizations and deals
|
@@ -266,34 +266,34 @@ def to_deal_note(converter, row, rootmodel)
|
|
266
266
|
coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
|
267
267
|
|
268
268
|
if deal && coworker
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
269
|
+
history = GoImport::History.new()
|
270
|
+
history.deal = deal
|
271
|
+
history.created_by = coworker
|
272
|
+
history.date = row['Date']
|
273
273
|
# Raw history looks like this <category>: <person>: <text>
|
274
|
-
|
274
|
+
history.text = row['RawHistory']
|
275
275
|
|
276
|
-
if converter.respond_to?(:
|
277
|
-
# we will get an
|
276
|
+
if converter.respond_to?(:get_history_classification_for_activity_on_project)
|
277
|
+
# we will get an InvalidHistoryClassificationError if we are
|
278
278
|
# setting and invalid classification. So no need to verify
|
279
279
|
# return value from converter.
|
280
280
|
|
281
281
|
classification =
|
282
|
-
converter.
|
282
|
+
converter.get_history_classification_for_activity_on_project(row['Category'])
|
283
283
|
|
284
284
|
if classification.nil?
|
285
|
-
classification = GoImport::
|
285
|
+
classification = GoImport::HistoryClassification::Comment
|
286
286
|
end
|
287
287
|
|
288
|
-
|
289
|
-
|
288
|
+
history.classification = classification
|
289
|
+
history.text = row['RawHistory'].to_s.sub("#{row['Category']}:", "")
|
290
290
|
else
|
291
|
-
|
292
|
-
|
291
|
+
history.classification = GoImport::HistoryClassification::Comment
|
292
|
+
history.text = row['RawHistory']
|
293
293
|
end
|
294
294
|
|
295
295
|
|
296
|
-
return
|
296
|
+
return history.text.empty? ? nil : history
|
297
297
|
end
|
298
298
|
|
299
299
|
return nil
|
@@ -338,11 +338,11 @@ end
|
|
338
338
|
def make_sure_database_has_been_exported()
|
339
339
|
return File.exists?(COWORKER_FILE) &&
|
340
340
|
File.exists?(ORGANIZATION_FILE) &&
|
341
|
-
File.exists?(
|
341
|
+
File.exists?(ORGANIZATION_HISTORY_FILE) &&
|
342
342
|
File.exists?(ORGANIZATION_DOCUMENT_FILE) &&
|
343
343
|
File.exists?(PERSON_FILE) &&
|
344
344
|
File.exists?(INCLUDE_FILE) &&
|
345
345
|
File.exists?(DEAL_FILE) &&
|
346
|
-
File.exists?(
|
346
|
+
File.exists?(DEAL_HISTORY_FILE) &&
|
347
347
|
File.exists?(PROJECT_DOCUMENT_FILE)
|
348
348
|
end
|
@@ -296,45 +296,45 @@ class Converter
|
|
296
296
|
return deal
|
297
297
|
end
|
298
298
|
|
299
|
-
def
|
299
|
+
def get_history_classification_for_activity_on_company(activity)
|
300
300
|
# When notes are added to LIME Go this method is called for
|
301
301
|
# every note that is connected to a company in LIME Easy. The
|
302
302
|
# note's activity from LIME Easy is supplied as an argument
|
303
303
|
# and this method should return a classification for the note
|
304
304
|
# in LIME Go. The return value must be a value from the
|
305
|
-
# GoImport::
|
305
|
+
# GoImport::HistoryClassification enum. If no classification is
|
306
306
|
# return the note will get the default classification 'Comment'
|
307
307
|
|
308
308
|
# case activity
|
309
309
|
# when 'SalesCall'
|
310
|
-
# classification = GoImport::
|
310
|
+
# classification = GoImport::HistoryClassification::SalesCall
|
311
311
|
# when 'Customer Visit'
|
312
|
-
# classification = GoImport::
|
312
|
+
# classification = GoImport::HistoryClassification::ClientVisit
|
313
313
|
# when 'No answer'
|
314
|
-
# classification = GoImport::
|
314
|
+
# classification = GoImport::HistoryClassification::TriedToReach
|
315
315
|
# else
|
316
|
-
# classification = GoImport::
|
316
|
+
# classification = GoImport::HistoryClassification::Comment
|
317
317
|
# end
|
318
318
|
|
319
319
|
# return classification
|
320
320
|
end
|
321
321
|
|
322
|
-
def
|
323
|
-
# When
|
324
|
-
# every
|
325
|
-
#
|
326
|
-
# and this method should return a classification for the
|
322
|
+
def get_history_classification_for_activity_on_project(activity)
|
323
|
+
# When histories are added to LIME Go this method is called for
|
324
|
+
# every history that is connected to a project in LIME Easy. The
|
325
|
+
# histories activity from LIME Easy is supplied as an argument
|
326
|
+
# and this method should return a classification for the history
|
327
327
|
# in LIME Go. The return value must be a value from the
|
328
|
-
# GoImport::
|
329
|
-
# return the
|
328
|
+
# GoImport::HistoryClassification enum. If no classification is
|
329
|
+
# return the history will get the default classification 'Comment'
|
330
330
|
|
331
331
|
# case activity
|
332
332
|
# when 'Installation'
|
333
|
-
# classification = GoImport::
|
333
|
+
# classification = GoImport::HistoryClassification::ClientVisit
|
334
334
|
# when 'No answer'
|
335
|
-
# classification = GoImport::
|
335
|
+
# classification = GoImport::HistoryClassification::TriedToReach
|
336
336
|
# else
|
337
|
-
# classification = GoImport::
|
337
|
+
# classification = GoImport::HistoryClassification::Comment
|
338
338
|
# end
|
339
339
|
|
340
340
|
# return classification
|
@@ -345,15 +345,15 @@ class Converter
|
|
345
345
|
# HOOKS
|
346
346
|
#
|
347
347
|
# Sometimes you need to add exra information to the rootmodel, this can be done
|
348
|
-
# with hooks, below is an example of an organization hook that adds a
|
348
|
+
# with hooks, below is an example of an organization hook that adds a history to
|
349
349
|
# an organization if a field has a specific value
|
350
350
|
#def organization_hook(row, organization, rootmodel)
|
351
351
|
# if not row['fieldname'].empty?
|
352
|
-
#
|
353
|
-
#
|
354
|
-
#
|
355
|
-
#
|
356
|
-
# rootmodel.
|
352
|
+
# history = GoImport::History.new
|
353
|
+
# history.text = row['fieldname']
|
354
|
+
# history.organization = organization
|
355
|
+
# history.created_by = rootmodel.import_coworker
|
356
|
+
# rootmodel.add_history(history)
|
357
357
|
# end
|
358
358
|
#end
|
359
359
|
|
@@ -132,15 +132,15 @@ def convert_source
|
|
132
132
|
puts "Deals are not imported. To enable set IMPORT_DEALS = true in converter.rb."
|
133
133
|
end
|
134
134
|
|
135
|
-
if defined?(
|
135
|
+
if defined?(IMPORT_HISTORY) && IMPORT_HISTORY == true
|
136
136
|
con.fetch_data 'history' do |row|
|
137
|
-
|
138
|
-
#if !
|
139
|
-
rootmodel.
|
137
|
+
history = converter.to_history(init_history(row, con.get_class_by_name('history'), rootmodel), row)
|
138
|
+
#if !history.organization.nil? || !history.person.nil?
|
139
|
+
rootmodel.add_history(history)
|
140
140
|
#end
|
141
141
|
end
|
142
142
|
else
|
143
|
-
puts "
|
143
|
+
puts "History is not imported. To enable set IMPORT_HISTORY = true in converter.rb."
|
144
144
|
end
|
145
145
|
|
146
146
|
"""
|
@@ -258,27 +258,27 @@ def init_deal(row, table, rootmodel)
|
|
258
258
|
return deal
|
259
259
|
end
|
260
260
|
|
261
|
-
def
|
262
|
-
|
261
|
+
def init_history(row, table, rootmodel)
|
262
|
+
history = GoImport::History.new
|
263
263
|
|
264
|
-
|
264
|
+
history.integration_id = row['idhistory'].to_s
|
265
265
|
|
266
|
-
coworker = rootmodel.find_coworker_by_integration_id(row[
|
267
|
-
|
266
|
+
coworker = rootmodel.find_coworker_by_integration_id(row[HISTORY_COWORKER_FIELD].to_s)
|
267
|
+
history.created_by = coworker if coworker
|
268
268
|
|
269
|
-
organization = rootmodel.find_organization_by_integration_id(row[
|
270
|
-
|
269
|
+
organization = rootmodel.find_organization_by_integration_id(row[HISTORY_COMPANY_FIELD].to_s)
|
270
|
+
history.organization = organization if organization
|
271
271
|
|
272
|
-
person = rootmodel.find_person_by_integration_id(row[
|
273
|
-
|
272
|
+
person = rootmodel.find_person_by_integration_id(row[HISTORY_PERSON_FIELD].to_s)
|
273
|
+
history.person = person if person
|
274
274
|
|
275
|
-
deal = rootmodel.find_deal_by_integration_id(row[
|
276
|
-
|
275
|
+
deal = rootmodel.find_deal_by_integration_id(row[HISTORY_DEAL_FIELD].to_s)
|
276
|
+
history.deal = deal if deal
|
277
277
|
|
278
|
-
|
279
|
-
|
278
|
+
history.text = table.get_value_for_field_with_label(row, FieldLabel::historys)
|
279
|
+
history.date = table.get_value_for_field_with_label(row, FieldLabel::StartDate)
|
280
280
|
|
281
|
-
return
|
281
|
+
return history
|
282
282
|
end
|
283
283
|
|
284
284
|
|
@@ -55,11 +55,11 @@ DEAL_COMPANY_FIELD = 'company'
|
|
55
55
|
# Notes
|
56
56
|
# Set if notes should be imported and name of relationfields.
|
57
57
|
# Defaults should work well
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
IMPORT_HISTORY = true
|
59
|
+
HISTORY_COWORKER_FIELD = 'coworker'
|
60
|
+
HISTORY_COMPANY_FIELD = 'company'
|
61
|
+
HISTORY_PERSON_FIELD = 'person'
|
62
|
+
HISTORY_DEAL_FIELD = 'business'
|
63
63
|
|
64
64
|
############################################################################
|
65
65
|
|
@@ -325,7 +325,7 @@ class Converter
|
|
325
325
|
end
|
326
326
|
|
327
327
|
# Reads a row from the History table
|
328
|
-
# and ads custom fields to the go_import
|
328
|
+
# and ads custom fields to the go_import history.
|
329
329
|
|
330
330
|
# NOTE!!! You should customize this method to include
|
331
331
|
# and transform the fields you want to import to LIME Go.
|
@@ -334,26 +334,26 @@ class Converter
|
|
334
334
|
# Sometimes it's enough to uncomment some code and
|
335
335
|
# change the row name but in most cases you need to
|
336
336
|
# do some thinking of your own.
|
337
|
-
def
|
337
|
+
def to_history(history, row)
|
338
338
|
|
339
|
-
#
|
339
|
+
# history.text = row['text']
|
340
340
|
|
341
|
-
# Set the
|
342
|
-
# GoImport::
|
343
|
-
# set the
|
341
|
+
# Set the history classification. The value must be a value from the
|
342
|
+
# GoImport::HistoryClassification enum. If no classification is
|
343
|
+
# set the history will get the default classification 'Comment'
|
344
344
|
|
345
345
|
# case row['type']
|
346
346
|
# when 'Sales call'
|
347
|
-
#
|
347
|
+
# history.classification = GoImport::HistoryClassification::SalesCall
|
348
348
|
# when 'Customer Visit'
|
349
|
-
#
|
349
|
+
# history.classification = GoImport::historyClassification::ClientVisit
|
350
350
|
# when 'No answer'
|
351
|
-
#
|
351
|
+
# history.classification = GoImport::HistoryClassification::TriedToReach
|
352
352
|
# else
|
353
|
-
#
|
353
|
+
# history.classification = GoImport::HistoryClassification::Comment
|
354
354
|
# end
|
355
355
|
|
356
|
-
return
|
356
|
+
return history
|
357
357
|
end
|
358
358
|
|
359
359
|
|
@@ -380,15 +380,15 @@ class Converter
|
|
380
380
|
# HOOKS
|
381
381
|
#
|
382
382
|
# Sometimes you need to add exra information to the rootmodel, this can be done
|
383
|
-
# with hooks, below is an example of an organization hook that adds a
|
383
|
+
# with hooks, below is an example of an organization hook that adds a history to
|
384
384
|
# an organization if a field has a specific value
|
385
385
|
#def organization_hook(row, organization, rootmodel)
|
386
386
|
# if not row['fieldname'].empty?
|
387
|
-
#
|
388
|
-
#
|
389
|
-
#
|
390
|
-
#
|
391
|
-
# rootmodel.
|
387
|
+
# history = GoImport::History.new
|
388
|
+
# history.text = row['fieldname']
|
389
|
+
# history.organization = organization
|
390
|
+
# history.created_by = rootmodel.import_coworker
|
391
|
+
# rootmodel.add_history(history)
|
392
392
|
# end
|
393
393
|
#end
|
394
394
|
|
@@ -267,25 +267,25 @@ def to_deal(row, rootmodel, converter)
|
|
267
267
|
return deal
|
268
268
|
end
|
269
269
|
|
270
|
-
def
|
270
|
+
def to_history(row, rootmodel)
|
271
271
|
if row['IsDeleted'] != '0'
|
272
272
|
return nil
|
273
273
|
end
|
274
274
|
|
275
|
-
|
275
|
+
history = GoImport::History.new
|
276
276
|
|
277
|
-
|
278
|
-
|
277
|
+
history.integration_id = row['Id']
|
278
|
+
history.text = row['Title'] + ' ' + row['Body']
|
279
279
|
|
280
|
-
|
280
|
+
history.date = row['CreatedDate']
|
281
281
|
|
282
|
-
|
283
|
-
|
282
|
+
history.created_by = rootmodel.find_coworker_by_integration_id(row['CreatedById'])
|
283
|
+
history.organization = rootmodel.find_organization_by_integration_id(row['AccountId'])
|
284
284
|
|
285
285
|
# TODO: we should probably set the classification in the same was
|
286
286
|
# a a deal's status is set.
|
287
287
|
|
288
|
-
return
|
288
|
+
return history
|
289
289
|
end
|
290
290
|
|
291
291
|
def add_opportunity_stages_as_deal_status_to_model(rootmodel)
|
@@ -389,9 +389,9 @@ def convert_source
|
|
389
389
|
rootmodel.add_deal(to_deal(row, rootmodel, converter))
|
390
390
|
end
|
391
391
|
|
392
|
-
puts "Trying to import
|
392
|
+
puts "Trying to import history..."
|
393
393
|
process_rows(NOTE_FILE) do |row|
|
394
|
-
rootmodel.
|
394
|
+
rootmodel.add_history(to_history(row, rootmodel))
|
395
395
|
end
|
396
396
|
end
|
397
397
|
|
@@ -98,15 +98,15 @@ class Converter
|
|
98
98
|
# HOOKS
|
99
99
|
#
|
100
100
|
# Sometimes you need to add exra information to the rootmodel, this can be done
|
101
|
-
# with hooks, below is an example of an organization hook that adds a
|
101
|
+
# with hooks, below is an example of an organization hook that adds a history to
|
102
102
|
# an organization if a field has a specific value
|
103
103
|
#def organization_hook(row, organization, rootmodel)
|
104
104
|
# if not row['fieldname'].empty?
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# rootmodel.
|
105
|
+
# history = GoImport::History.new
|
106
|
+
# history.text = row['fieldname']
|
107
|
+
# history.organization = organization
|
108
|
+
# history.created_by = rootmodel.import_coworker
|
109
|
+
# rootmodel.add_history(history)
|
110
110
|
# end
|
111
111
|
#end
|
112
112
|
|