move-to-go 5.1.0 → 5.2.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.
@@ -0,0 +1,172 @@
1
+ module MoveToGo
2
+ class Todo < CanBecomeImmutable
3
+ include SerializeHelper
4
+ ##
5
+ # :attr_accessor: id
6
+ immutable_accessor :id
7
+ ##
8
+ # :attr_accessor: integration_id
9
+ immutable_accessor :integration_id
10
+
11
+ attr_reader :text
12
+ attr_reader :date_start, :date_start_has_time, :date_checked
13
+ attr_reader :organization, :created_by, :assigned_coworker, :person, :deal
14
+
15
+ def initialize(opt = nil)
16
+ if !opt.nil?
17
+ serialize_variables.each do |myattr|
18
+ val = opt[myattr[:id]]
19
+ instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
20
+ end
21
+ end
22
+ end
23
+
24
+ def serialize_variables
25
+ [ :id, :text, :integration_id ].map {
26
+ |p| {
27
+ :id => p,
28
+ :type => :string
29
+ }
30
+ } +
31
+ [
32
+ { :id => :date_start, :type => :datetime },
33
+ { :id => :date_start_has_time, :type => :bool },
34
+ { :id => :date_checked, :type => :datetime },
35
+ { :id => :created_by_reference, :type => :coworker_reference, :element_name => :created_by },
36
+ { :id => :assigned_coworker_reference, :type => :coworker_reference, :element_name => :assigned_coworker },
37
+ { :id => :organization_reference, :type => :organization_reference, :element_name => :organization },
38
+ { :id => :deal_reference, :type => :deal_reference, :element_name => :deal },
39
+ { :id => :person_reference, :type => :person_reference, :element_name => :person }
40
+ ]
41
+ end
42
+
43
+ def get_import_rows
44
+ (serialize_variables + [
45
+ { :id => :organization, :type => :organization_reference},
46
+ { :id => :person, :type => :person_reference}
47
+ ]).map do |p|
48
+ map_to_row p
49
+ end
50
+ end
51
+
52
+ def serialize_name
53
+ "Todo"
54
+ end
55
+
56
+ def organization=(org)
57
+ raise_if_immutable
58
+ @organization_reference = OrganizationReference.from_organization(org)
59
+
60
+ if org.is_a?(Organization)
61
+ @organization = org
62
+ end
63
+ end
64
+
65
+ def created_by=(coworker)
66
+ raise_if_immutable
67
+ @created_by_reference = CoworkerReference.from_coworker(coworker)
68
+
69
+ if coworker.is_a?(Coworker)
70
+ @created_by = coworker
71
+ end
72
+ end
73
+
74
+ def assigned_coworker=(coworker)
75
+ raise_if_immutable
76
+ @assigned_coworker_reference = CoworkerReference.from_coworker(coworker)
77
+
78
+ if coworker.is_a?(Coworker)
79
+ @assigned_coworker = coworker
80
+ end
81
+ end
82
+
83
+ def person=(person)
84
+ raise_if_immutable
85
+ @person_reference = PersonReference.from_person(person)
86
+
87
+ if person.is_a?(Person)
88
+ @person = person
89
+ end
90
+ end
91
+
92
+ def deal=(deal)
93
+ raise_if_immutable
94
+ @deal_reference = DealReference.from_deal(deal)
95
+
96
+ if deal.is_a?(Deal)
97
+ @deal = deal
98
+ end
99
+ end
100
+
101
+ def text=(text)
102
+ raise_if_immutable
103
+ @text = text
104
+
105
+ if @text.nil?
106
+ return
107
+ end
108
+
109
+ if @text.length == 0
110
+ return
111
+ end
112
+
113
+ @text.strip!
114
+
115
+ # remove form feeds
116
+ @text.gsub!("\f", "")
117
+
118
+ # remove vertical spaces
119
+ @text.gsub!("\v", "")
120
+
121
+ # remove backspace
122
+ @text.gsub!("\b", "")
123
+ end
124
+
125
+ def date_start=(datetime)
126
+ begin
127
+ @date_start = DateTime.parse(datetime)
128
+ rescue
129
+ puts "\nParsed datetime '#{datetime}' but got error"
130
+ raise
131
+ end
132
+ end
133
+
134
+ def date_start_has_time=(bool)
135
+ @date_start_has_time = bool
136
+ end
137
+
138
+ def date_checked=(datetime)
139
+ @date_checked = DateTime.parse(datetime) if datetime != ""
140
+ end
141
+
142
+ def validate
143
+ error = String.new
144
+
145
+ if (@text.nil? || @text.empty?)
146
+ error = "Text is required for todo\n"
147
+ end
148
+
149
+ if @created_by.nil?
150
+ error = "#{error}Created_by is required for todo\n"
151
+ end
152
+
153
+ if @assigned_coworker_reference.nil?
154
+ error = "#{error}Assigned_coworker is required for todo\n"
155
+ end
156
+
157
+ if @date_start.nil?
158
+ error = "#{error}Date_start is required for todo\n"
159
+ end
160
+
161
+ if @date_start_has_time.nil?
162
+ error = "#{error}Date_start_has_time is required for todo\n"
163
+ end
164
+
165
+ if @organization.nil?
166
+ error = "#{error}Organization is required for todo\n"
167
+ end
168
+
169
+ return error
170
+ end
171
+ end
172
+ end
@@ -1,4 +1,7 @@
1
1
  require "csv"
2
+ require "roo"
3
+ include Roo::Formatters::Base
4
+
2
5
  module MoveToGo
3
6
  # @example transform xlsx file into rows
4
7
  # organizations_path = File.join(File.dirname(__FILE__), 'organizations.xlsx') # same path as this file
@@ -70,7 +73,7 @@ module MoveToGo
70
73
  when :date, :datetime
71
74
  onecell.to_s
72
75
  when :time
73
- Roo::Base.integer_to_timestring(onecell)
76
+ integer_to_timestring(onecell)
74
77
  when :formula
75
78
  onecell.to_s
76
79
  when :link
@@ -119,6 +119,20 @@ module MoveToGo
119
119
  :type => p[:type],
120
120
  :models => SerializeHelper.get_import_rows(:history)
121
121
  }
122
+ when :todos then
123
+ {
124
+ :id => p[:id].to_s,
125
+ :name => symbol_to_name(p[:id]),
126
+ :type => p[:type],
127
+ :models => SerializeHelper.get_import_rows(:todo)
128
+ }
129
+ when :meetings then
130
+ {
131
+ :id => p[:id].to_s,
132
+ :name => symbol_to_name(p[:id]),
133
+ :type => p[:type],
134
+ :models => SerializeHelper.get_import_rows(:meeting)
135
+ }
122
136
  when :tags then
123
137
  {
124
138
  :id => p[:id].to_s,
@@ -173,6 +187,10 @@ module MoveToGo
173
187
  ReferenceToSource.new
174
188
  when :history then
175
189
  History.new
190
+ when :todo then
191
+ Todo.new
192
+ when :meeting then
193
+ Meeting.new
176
194
  when :address then
177
195
  Address.new
178
196
  when :organization then
@@ -19,6 +19,8 @@ module MoveToGo
19
19
  model.organizations.each{|key, org| add_organization(org)}
20
20
  model.deals.each{|key, deal| add_deal(deal)}
21
21
  model.histories.each{|key, history| add_history(history)}
22
+ model.todos.each{|key, todo| add_todo(todo)}
23
+ model.meetings.each{|key, meeting| add_meeting(meeting)}
22
24
  add_documents(model.documents)
23
25
 
24
26
  return_value = @shards
@@ -40,6 +42,20 @@ module MoveToGo
40
42
  @current_shard_count += 1
41
43
  end
42
44
 
45
+ private
46
+ def add_todo(todo)
47
+ check_or_create_new_chard()
48
+ @current_shard.add_todo(todo)
49
+ @current_shard_count += 1
50
+ end
51
+
52
+ private
53
+ def add_meeting(meeting)
54
+ check_or_create_new_chard()
55
+ @current_shard.add_meeting(meeting)
56
+ @current_shard_count += 1
57
+ end
58
+
43
59
  private
44
60
  def add_deal(deal)
45
61
  check_or_create_new_chard()
@@ -75,7 +75,9 @@ module MoveToGo
75
75
  private
76
76
  def copy_source_to_folder(source_name, project_name)
77
77
  puts "Trying to create project '#{project_name}' from source '#{source_name}'..."
78
+
78
79
  FileUtils.cp_r ::File.expand_path(source_name, @path), project_name
80
+ puts 'ok'
79
81
  end
80
82
 
81
83
  private
@@ -65,6 +65,22 @@ def convert_source
65
65
  end
66
66
  end
67
67
 
68
+ if defined?(TODO_SHEET)
69
+ if excel_workbook.has_sheet?(TODO_SHEET)
70
+ todo_rows = excel_workbook.rows_for_sheet TODO_SHEET
71
+ else
72
+ puts "WARNING: can't find sheet '#{TODO_SHEET}'"
73
+ end
74
+ end
75
+
76
+ if defined?(MEETING_SHEET)
77
+ if excel_workbook.has_sheet?(MEETING_SHEET)
78
+ meeting_rows = excel_workbook.rows_for_sheet MEETING_SHEET
79
+ else
80
+ puts "WARNING: can't find sheet '#{MEETING_SHEET}'"
81
+ end
82
+ end
83
+
68
84
  if defined?(FILE_SHEET)
69
85
  if excel_workbook.has_sheet?(FILE_SHEET)
70
86
  file_rows = excel_workbook.rows_for_sheet FILE_SHEET
@@ -136,6 +152,24 @@ def convert_source
136
152
  end
137
153
  end
138
154
 
155
+ # Todo must be owned by a coworker and the be added to
156
+ # organizations
157
+ if defined?(todo_rows) && !todo_rows.nil?
158
+ puts "Trying to convert todos..."
159
+ todo_rows.with_progress().each do |row|
160
+ rootmodel.add_todo(converter.to_todo(row, rootmodel))
161
+ end
162
+ end
163
+
164
+ # Meeting must be owned by a coworker and the be added to
165
+ # organizations
166
+ if defined?(meeting_rows) && !meeting_rows.nil?
167
+ puts "Trying to convert meetings..."
168
+ meeting_rows.with_progress().each do |row|
169
+ rootmodel.add_meeting(converter.to_meeting(row, rootmodel))
170
+ end
171
+ end
172
+
139
173
  if defined?(file_rows) && !file_rows.nil?
140
174
  puts "Trying to convert files..."
141
175
  file_rows.with_progress().each do |row|
@@ -18,6 +18,8 @@ DEAL_SHEET = "Affär"
18
18
  HISTORY_SHEET = "Anteckningar"
19
19
  FILE_SHEET = "Dokument"
20
20
  LINK_SHEET = "Links"
21
+ TODO_SHEET = "Att göra"
22
+ MEETING_SHEET = "Möten"
21
23
 
22
24
  # Then you need to modify the script below according to the TODO
23
25
  # comments.
@@ -141,6 +143,8 @@ class Converter
141
143
  person.mobile_phone_number, person.direct_phone_number =
142
144
  MoveToGo::PhoneHelper.parse_numbers(row['Telefon'], [",", "/", "\\"])
143
145
 
146
+ person.has_mail_consent = row['MailConsent'] == "Ja"
147
+
144
148
  return person
145
149
  end
146
150
 
@@ -161,7 +165,6 @@ class Converter
161
165
 
162
166
  def to_file(row, rootmodel)
163
167
  file = MoveToGo::File.new()
164
-
165
168
  file.organization = rootmodel.find_organization_by_integration_id(row['Företag'])
166
169
  file.person = rootmodel.find_person_by_integration_id(row['Person'])
167
170
  file.deal = rootmodel.find_deal_by_integration_id(row['Affär'])
@@ -182,11 +185,51 @@ class Converter
182
185
  link.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad Av'])
183
186
  link.name = row['Namn']
184
187
  link.description = row['Kommentar']
185
- link.path = row['URL']
188
+ link.url = row['URL']
186
189
 
187
190
  return link
188
191
  end
189
192
 
193
+ def to_todo(row, rootmodel)
194
+ todo = MoveToGo::Todo.new()
195
+
196
+ todo.text = row['Text']
197
+ todo.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad Av'])
198
+ todo.organization = rootmodel.find_organization_by_integration_id(row['Företag'])
199
+ todo.person = rootmodel.find_person_by_integration_id(row['Person'])
200
+ todo.deal = rootmodel.find_deal_by_integration_id(row['Affär'])
201
+ todo.assigned_coworker = rootmodel.find_coworker_by_integration_id(row['Delegerad till'])
202
+ todo.date_checked = row['Avbockad']
203
+
204
+ if (row['Tid'].nil? || row['Tid'] == "")
205
+ todo.date_start = row['Datum']
206
+ todo.date_start_has_time = false
207
+ else
208
+ todo.date_start = "#{row['Datum']} #{row['Tid']}"
209
+ todo.date_start_has_time = true
210
+ end
211
+
212
+ return todo
213
+ end
214
+
215
+ def to_meeting(row, rootmodel)
216
+ meeting = MoveToGo::Meeting.new()
217
+
218
+ meeting.heading = row['Rubrik']
219
+ meeting.text = row['Text']
220
+ meeting.created_by = rootmodel.find_coworker_by_integration_id(row['Skapad Av'])
221
+ meeting.organization = rootmodel.find_organization_by_integration_id(row['Företag'])
222
+ meeting.person = rootmodel.find_person_by_integration_id(row['Person'])
223
+ meeting.deal = rootmodel.find_deal_by_integration_id(row['Affär'])
224
+ meeting.assigned_coworker = rootmodel.find_coworker_by_integration_id(row['Delegerad till'])
225
+
226
+ meeting.date_start = "#{row['Datum']} #{row['Tid']}"
227
+ meeting.date_start_has_time = true
228
+ meeting.date_stop = "#{row['Datum']} #{row['SlutTid']}"
229
+
230
+ return meeting
231
+ end
232
+
190
233
  # HOOKS
191
234
  #
192
235
  # Sometimes you need to add exra information to the rootmodel, this can be done
@@ -4,15 +4,16 @@ require 'move-to-go'
4
4
  require 'progress'
5
5
  require_relative("../converter")
6
6
 
7
- EXPORT_FOLDER = 'export'
8
7
  COWORKER_FILE = "#{EXPORT_FOLDER}/User.txt"
9
8
  ORGANIZATION_FILE = "#{EXPORT_FOLDER}/Company.txt"
10
9
  ORGANIZATION_HISTORY_FILE = "#{EXPORT_FOLDER}/Company-History.txt"
10
+ ORGANIZATION_TODO_FILE = "#{EXPORT_FOLDER}/Company-To do.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
+ DEAL_TODO_FILE = "#{EXPORT_FOLDER}/Project-To do.txt"
16
17
  PROJECT_DOCUMENT_FILE = "#{EXPORT_FOLDER}/Project-Document.txt"
17
18
 
18
19
  def convert_source
@@ -35,9 +36,12 @@ def convert_source
35
36
  # coworkers
36
37
  # start with these since they are referenced
37
38
  # from everywhere....
38
-
39
- process_rows(" - Reading Coworkers '#{COWORKER_FILE}'", COWORKER_FILE) do |row|
40
- rootmodel.add_coworker(to_coworker(row))
39
+ if(File.exists?(COWORKER_FILE))
40
+ process_rows(" - Reading Coworkers '#{COWORKER_FILE}'", COWORKER_FILE) do |row|
41
+ rootmodel.add_coworker(to_coworker(row))
42
+ end
43
+ else
44
+ puts "WARNING: can't find coworker file '#{COWORKER_FILE}'"
41
45
  end
42
46
 
43
47
  # organizations
@@ -48,49 +52,99 @@ def convert_source
48
52
  converter.organization_hook(row, organization, rootmodel) if defined? converter.organization_hook
49
53
  end
50
54
 
55
+ # Person - Consent connection
56
+ # Reads the file and creats a hash
57
+ # that connect persons to consents
58
+ if(File.exists?(PERSON_CONSENT_FILE))
59
+ if (defined?(VALID_EMAIL_CONSENTS) && VALID_EMAIL_CONSENTS.size > 0)
60
+ consent = Hash.new
61
+ process_rows(" - Reading Person Consents '#{PERSON_CONSENT_FILE}'", PERSON_CONSENT_FILE) do |row|
62
+ consent[row['idPerson']] = VALID_EMAIL_CONSENTS.include? row['String']
63
+ end
64
+ else
65
+ puts "WARNING: Person consent file exists but VALID_EMAIL_CONSENTS is not set."
66
+ end
67
+ end
68
+
51
69
  # persons
52
70
  # depends on organizations
53
71
  process_rows(" - Reading Persons '#{PERSON_FILE}'", PERSON_FILE) do |row|
54
72
  # init method also adds the person to the employer
55
- person = init_person(row, rootmodel)
73
+ person = init_person(row, rootmodel, consent)
56
74
  converter.to_person(person, row)
57
75
  end
58
76
 
59
77
  # organization histories
60
- process_rows(" - Reading Organization History '#{ORGANIZATION_HISTORY_FILE}'", ORGANIZATION_HISTORY_FILE) do |row|
61
- # adds itself if applicable
62
- rootmodel.add_history(to_organization_history(converter, row, rootmodel))
78
+ if(File.exists?(ORGANIZATION_HISTORY_FILE))
79
+ process_rows(" - Reading Organization History '#{ORGANIZATION_HISTORY_FILE}'", ORGANIZATION_HISTORY_FILE) do |row|
80
+ # adds itself if applicable
81
+ rootmodel.add_history(to_organization_history(converter, row, rootmodel))
82
+ end
83
+ else
84
+ puts "WARNING: can't find organization history file '#{ORGANIZATION_HISTORY_FILE}'"
85
+ end
86
+
87
+ # organization todos
88
+ if(File.exists?(ORGANIZATION_TODO_FILE))
89
+ process_rows(" - Reading Organization Todos '#{ORGANIZATION_TODO_FILE}'", ORGANIZATION_TODO_FILE) do |row|
90
+ # adds itself if applicable
91
+ rootmodel.add_todo(to_organization_todo(converter, row, rootmodel))
92
+ end
93
+ else
94
+ puts "WARNING: can't find organization history file '#{ORGANIZATION_TODO_FILE}'"
63
95
  end
64
96
 
65
97
  # Organization - Deal connection
66
98
  # Reads the includes.txt and creats a hash
67
- # that connect organizations to deals
99
+ # that connect organizations to deals
68
100
  process_rows(" - Reading Organization Deals '#{INCLUDE_FILE}'", INCLUDE_FILE) do |row|
69
101
  includes[row['idProject']] = row['idCompany']
70
102
  end
71
103
 
72
104
  # deals
73
105
  # deals can reference coworkers (responsible), organizations
74
- # and persons (contact)
106
+ # and persons (contact)
75
107
  process_rows(" - Reading Deals '#{DEAL_FILE}'", DEAL_FILE) do |row|
76
108
  deal = init_deal(row, rootmodel, includes)
77
109
  rootmodel.add_deal(converter.to_deal(deal, row))
78
110
  end
79
111
 
80
112
  # deal histories
81
- process_rows(" - Reading Deal Histories '#{DEAL_HISTORY_FILE}'", DEAL_HISTORY_FILE) do |row|
82
- # adds itself if applicable
83
- rootmodel.add_history(to_deal_history(converter, row, rootmodel))
113
+ if(File.exists?(DEAL_HISTORY_FILE))
114
+ process_rows(" - Reading Deal Histories '#{DEAL_HISTORY_FILE}'", DEAL_HISTORY_FILE) do |row|
115
+ # adds itself if applicable
116
+ rootmodel.add_history(to_deal_history(converter, row, rootmodel))
117
+ end
118
+ else
119
+ puts "WARNING: can't find deal history file '#{DEAL_HISTORY_FILE}'"
120
+ end
121
+
122
+ # deal todos
123
+ if(File.exists?(DEAL_TODO_FILE))
124
+ process_rows(" - Reading Deal Todos '#{DEAL_TODO_FILE}'", DEAL_TODO_FILE) do |row|
125
+ # adds itself if applicable
126
+ rootmodel.add_todo(to_deal_todo(converter, row, rootmodel))
127
+ end
128
+ else
129
+ puts "WARNING: can't find deal history file '#{DEAL_TODO_FILE}'"
84
130
  end
85
131
 
86
132
  # documents
87
133
  if defined?(IMPORT_DOCUMENTS) && !IMPORT_DOCUMENTS.nil? && IMPORT_DOCUMENTS
88
- process_rows(" - Reading Organization Documents", ORGANIZATION_DOCUMENT_FILE) do |row|
89
- rootmodel.add_file(to_organization_document(row, rootmodel))
134
+ if(File.exists?(ORGANIZATION_DOCUMENT_FILE))
135
+ process_rows(" - Reading Organization Documents", ORGANIZATION_DOCUMENT_FILE) do |row|
136
+ rootmodel.add_file(to_organization_document(row, rootmodel))
137
+ end
138
+ else
139
+ puts "WARNING: can't find company documents file '#{ORGANIZATION_DOCUMENT_FILE}'"
90
140
  end
91
141
 
92
- process_rows(" - Reading Project Documents", PROJECT_DOCUMENT_FILE) do |row|
93
- rootmodel.add_file(to_deal_document(row, rootmodel))
142
+ if(File.exists?(PROJECT_DOCUMENT_FILE))
143
+ process_rows(" - Reading Project Documents", PROJECT_DOCUMENT_FILE) do |row|
144
+ rootmodel.add_file(to_deal_document(row, rootmodel))
145
+ end
146
+ else
147
+ puts "WARNING: can't find project documents file '#{PROJECT_DOCUMENT_FILE}'"
94
148
  end
95
149
  end
96
150
 
@@ -99,7 +153,7 @@ end
99
153
 
100
154
  def to_coworker(row)
101
155
  coworker = MoveToGo::Coworker.new
102
-
156
+
103
157
  # integration_id is typically the userId in Easy
104
158
  # Must be set to be able to import the same file more
105
159
  # than once without creating duplicates
@@ -129,7 +183,7 @@ def init_organization(row, rootmodel)
129
183
  return organization
130
184
  end
131
185
 
132
- def init_person(row, rootmodel)
186
+ def init_person(row, rootmodel, consent)
133
187
  person = MoveToGo::Person.new
134
188
 
135
189
  # Easy standard fields created in configure method Easy
@@ -140,7 +194,9 @@ def init_person(row, rootmodel)
140
194
  person.integration_id = row['idPerson']
141
195
  person.first_name = row['First name']
142
196
  person.last_name = row['Last name']
143
-
197
+ if (!consent.nil?)
198
+ person.has_mail_consent = !!consent[row['idPerson']]
199
+ end
144
200
  # set employer connection
145
201
  employer = rootmodel.find_organization_by_integration_id(row['idCompany'])
146
202
  if employer
@@ -162,7 +218,7 @@ def to_organization_history(converter, row, rootmodel)
162
218
  history.created_by = coworker
163
219
  history.person = organization.find_employee_by_integration_id(row['idPerson'])
164
220
  history.date = row['Date']
165
-
221
+
166
222
  if converter.respond_to?(:get_history_classification_for_activity_on_company)
167
223
  # we will get an InvalidHistoryClassificationError if we are
168
224
  # setting and invalid classification. So no need to verify
@@ -173,7 +229,7 @@ def to_organization_history(converter, row, rootmodel)
173
229
  if classification.nil?
174
230
  classification = MoveToGo::HistoryClassification::Comment
175
231
  end
176
-
232
+
177
233
  history.classification = classification
178
234
 
179
235
  history.text = row['History']
@@ -188,6 +244,35 @@ def to_organization_history(converter, row, rootmodel)
188
244
  return nil
189
245
  end
190
246
 
247
+ # Turns a row from the Easy exported Company-To do.txt file into
248
+ # a move-to-go model that is used to generate xml.
249
+ def to_organization_todo(converter, row, rootmodel)
250
+ organization = rootmodel.find_organization_by_integration_id(row['idCompany'])
251
+ coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
252
+
253
+ if organization && coworker
254
+ todo = MoveToGo::Todo.new()
255
+ todo.organization = organization
256
+ todo.created_by = coworker
257
+ todo.assigned_coworker = coworker
258
+ todo.person = organization.find_employee_by_integration_id(row['idPerson'])
259
+ if row['Start time'] != ''
260
+ todo.date_start = "#{row['Start date']} #{row['Start time']}"
261
+ todo.date_start_has_time = true
262
+ else
263
+ todo.date_start = row['Start date'] != '' ? row['Start date'] : Date.today.to_s
264
+ todo.date_start_has_time = false
265
+ end
266
+
267
+ todo.date_checked = DateTime.now if row['Done'] == 1
268
+ todo.text = row['Description']
269
+
270
+ return todo.text.empty? ? nil : todo
271
+ end
272
+
273
+ return nil
274
+ end
275
+
191
276
  def to_organization_document(row, rootmodel)
192
277
  file = MoveToGo::File.new()
193
278
 
@@ -284,14 +369,14 @@ def to_deal_history(converter, row, rootmodel)
284
369
  if classification.nil?
285
370
  classification = MoveToGo::HistoryClassification::Comment
286
371
  end
287
-
372
+
288
373
  history.classification = classification
289
374
  history.text = row['RawHistory'].to_s.sub("#{row['Category']}:", "")
290
375
  else
291
376
  history.classification = MoveToGo::HistoryClassification::Comment
292
377
  history.text = row['RawHistory']
293
378
  end
294
-
379
+
295
380
 
296
381
  return history.text.empty? ? nil : history
297
382
  end
@@ -299,6 +384,35 @@ def to_deal_history(converter, row, rootmodel)
299
384
  return nil
300
385
  end
301
386
 
387
+ # Turns a row from the Easy exported Project-To do.txt file into
388
+ # a move-to-go model that is used to generate xml.
389
+ def to_deal_todo(converter, row, rootmodel)
390
+ deal = rootmodel.find_deal_by_integration_id(row['idProject'])
391
+ coworker = rootmodel.find_coworker_by_integration_id(row['idUser'])
392
+
393
+ if deal && coworker
394
+ todo = MoveToGo::Todo.new()
395
+ todo.deal = deal
396
+ todo.organization = deal.customer
397
+ todo.created_by = coworker
398
+ todo.assigned_coworker = coworker
399
+ todo.person = todo.organization.find_employee_by_integration_id(row['idPerson'])
400
+ if row['Start time'] != ''
401
+ todo.date_start = "#{row['Start date']} #{row['Start time']}"
402
+ todo.date_start_has_time = true
403
+ else
404
+ todo.date_start = row['Start date'] != '' ? row['Start date'] : Date.today.to_s
405
+ todo.date_start_has_time = false
406
+ end
407
+
408
+ todo.date_checked = DateTime.now if row['Done'] == 1
409
+ todo.text = row['Description']
410
+
411
+ return todo.text.empty? ? nil : todo
412
+ end
413
+
414
+ return nil
415
+ end
302
416
 
303
417
  def validate_constants()
304
418
  if !defined?(ORGANIZATION_RESPONSIBLE_FIELD)
@@ -321,6 +435,13 @@ def validate_constants()
321
435
  Otherwise you should define 'IMPORT_DOCUMENTS' in converter.rb
322
436
  with the value 'true'."
323
437
  end
438
+
439
+ if !defined?(VALID_EMAIL_CONSENTS) || VALID_EMAIL_CONSENTS.empty?
440
+ puts "WARNING: You havce not defined any valid email consents.
441
+ No person will now have the 'Email consent given' set.
442
+ To set the valid email consents, define 'VALID_EMAIL_CONSENTS' with
443
+ the strings from Company-Person-Consent.txt that are valid for email."
444
+ end
324
445
  end
325
446
 
326
447
 
@@ -336,13 +457,8 @@ def process_rows(description, file_name)
336
457
  end
337
458
 
338
459
  def make_sure_database_has_been_exported()
339
- return File.exists?(COWORKER_FILE) &&
340
- File.exists?(ORGANIZATION_FILE) &&
341
- File.exists?(ORGANIZATION_HISTORY_FILE) &&
342
- File.exists?(ORGANIZATION_DOCUMENT_FILE) &&
460
+ return File.exists?(ORGANIZATION_FILE) &&
343
461
  File.exists?(PERSON_FILE) &&
344
- File.exists?(INCLUDE_FILE) &&
345
- File.exists?(DEAL_FILE) &&
346
- File.exists?(DEAL_HISTORY_FILE) &&
347
- File.exists?(PROJECT_DOCUMENT_FILE)
462
+ # File.exists?(INCLUDE_FILE) &&
463
+ File.exists?(DEAL_FILE)
348
464
  end