move-to-go 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/move-to-go +210 -0
- data/lib/move-to-go/can_become_immutable.rb +29 -0
- data/lib/move-to-go/csv_helper.rb +47 -0
- data/lib/move-to-go/email_helper.rb +14 -0
- data/lib/move-to-go/errors.rb +31 -0
- data/lib/move-to-go/excel_helper.rb +10 -0
- data/lib/move-to-go/global_phone.json +6571 -0
- data/lib/move-to-go/model/address.rb +63 -0
- data/lib/move-to-go/model/class_settings.rb +50 -0
- data/lib/move-to-go/model/clientvisit.rb +10 -0
- data/lib/move-to-go/model/comment.rb +10 -0
- data/lib/move-to-go/model/coworker.rb +82 -0
- data/lib/move-to-go/model/coworker_reference.rb +33 -0
- data/lib/move-to-go/model/customfield.rb +87 -0
- data/lib/move-to-go/model/deal.rb +216 -0
- data/lib/move-to-go/model/deal_class_settings.rb +97 -0
- data/lib/move-to-go/model/deal_state.rb +15 -0
- data/lib/move-to-go/model/deal_status.rb +23 -0
- data/lib/move-to-go/model/deal_status_reference.rb +47 -0
- data/lib/move-to-go/model/deal_status_setting.rb +49 -0
- data/lib/move-to-go/model/documents.rb +76 -0
- data/lib/move-to-go/model/file.rb +193 -0
- data/lib/move-to-go/model/history.rb +148 -0
- data/lib/move-to-go/model/history_classification.rb +26 -0
- data/lib/move-to-go/model/link.rb +82 -0
- data/lib/move-to-go/model/organization.rb +250 -0
- data/lib/move-to-go/model/person.rb +164 -0
- data/lib/move-to-go/model/referencetosource.rb +58 -0
- data/lib/move-to-go/model/relation.rb +23 -0
- data/lib/move-to-go/model/rootmodel.rb +663 -0
- data/lib/move-to-go/model/salescall.rb +10 -0
- data/lib/move-to-go/model/settings.rb +61 -0
- data/lib/move-to-go/model/tag.rb +35 -0
- data/lib/move-to-go/model/talkedto.rb +10 -0
- data/lib/move-to-go/model/triedtoreach.rb +10 -0
- data/lib/move-to-go/model_helpers.rb +97 -0
- data/lib/move-to-go/phone_helper.rb +75 -0
- data/lib/move-to-go/roo_helper.rb +82 -0
- data/lib/move-to-go/serialize_helper.rb +199 -0
- data/lib/move-to-go/shard_helper.rb +96 -0
- data/lib/move-to-go/source.rb +108 -0
- data/lib/move-to-go/templating.rb +52 -0
- data/lib/move-to-go.rb +20 -0
- data/sources/VISMA/.gitignore +14 -0
- data/sources/VISMA/.move-to-go/readme.txt +1 -0
- data/sources/VISMA/.move-to-go/runner.rb +89 -0
- data/sources/VISMA/Database/KONTAKT.DBF +0 -0
- data/sources/VISMA/Database/KUND.DBF +0 -0
- data/sources/VISMA/Gemfile +5 -0
- data/sources/VISMA/converter.rb +120 -0
- data/sources/base-crm/.move-to-go/runner.rb +235 -0
- data/sources/base-crm/Gemfile +5 -0
- data/sources/base-crm/README.md +9 -0
- data/sources/base-crm/converter.rb +56 -0
- data/sources/base-crm/data/contacts.csv +13 -0
- data/sources/base-crm/data/coworkers.csv +3 -0
- data/sources/base-crm/data/deals.csv +5 -0
- data/sources/base-crm/data/histories.csv +6 -0
- data/sources/base-crm/data/leads.csv +4 -0
- data/sources/base-crm/data/tasks.csv +5 -0
- data/sources/csv/.gitignore +14 -0
- data/sources/csv/.move-to-go/readme.txt +1 -0
- data/sources/csv/.move-to-go/runner.rb +65 -0
- data/sources/csv/Gemfile +5 -0
- data/sources/csv/converter.rb +218 -0
- data/sources/csv/data/coworkers.csv +2 -0
- data/sources/csv/data/deals.csv +2 -0
- data/sources/csv/data/organizations.csv +2 -0
- data/sources/csv/data/persons.csv +2 -0
- data/sources/custom/.gitignore +14 -0
- data/sources/custom/.move-to-go/readme.txt +1 -0
- data/sources/custom/.move-to-go/runner.rb +30 -0
- data/sources/custom/Gemfile +4 -0
- data/sources/custom/converter.rb +45 -0
- data/sources/excel/.gitignore +14 -0
- data/sources/excel/.move-to-go/readme.txt +3 -0
- data/sources/excel/.move-to-go/runner.rb +140 -0
- data/sources/excel/Gemfile +7 -0
- data/sources/excel/converter.rb +188 -0
- data/sources/excel/files/avtal.docx +0 -0
- data/sources/excel/files/more/avtal.docx +0 -0
- data/sources/excel/files/more/offert-2.pdf +0 -0
- data/sources/excel/files/offert-2.docx +0 -0
- data/sources/excel/files/offert.docx +0 -0
- data/sources/excel/sample-data.xlsx +0 -0
- data/sources/excel-basic/.gitignore +14 -0
- data/sources/excel-basic/.move-to-go/readme.txt +3 -0
- data/sources/excel-basic/.move-to-go/runner.rb +139 -0
- data/sources/excel-basic/Exempelfil.xlsx +0 -0
- data/sources/excel-basic/Gemfile +6 -0
- data/sources/excel-basic/converter.rb +175 -0
- data/sources/excel-basic/files/avtal.docx +0 -0
- data/sources/excel-basic/files/more/avtal.docx +0 -0
- data/sources/excel-basic/files/more/offert-2.pdf +0 -0
- data/sources/excel-basic/files/offert-2.docx +0 -0
- data/sources/excel-basic/files/offert.docx +0 -0
- data/sources/lime-crm-basic/.gitignore +14 -0
- data/sources/lime-crm-basic/.move-to-go/readme.txt +1 -0
- data/sources/lime-crm-basic/.move-to-go/runner.rb +524 -0
- data/sources/lime-crm-basic/Gemfile +6 -0
- data/sources/lime-crm-basic/converter.rb +396 -0
- data/sources/lime-easy/.gitignore +14 -0
- data/sources/lime-easy/.move-to-go/readme.txt +1 -0
- data/sources/lime-easy/.move-to-go/runner.rb +348 -0
- data/sources/lime-easy/Export/readme.txt +6 -0
- data/sources/lime-easy/Gemfile +5 -0
- data/sources/lime-easy/converter.rb +362 -0
- data/sources/salesforce/.gitignore +14 -0
- data/sources/salesforce/.move-to-go/readme.txt +1 -0
- data/sources/salesforce/.move-to-go/runner.rb +404 -0
- data/sources/salesforce/Gemfile +6 -0
- data/sources/salesforce/Gemfile.lock +48 -0
- data/sources/salesforce/converter.rb +113 -0
- data/sources/salesforce/export/readme.txt +3 -0
- data/spec/address_spec.rb +49 -0
- data/spec/class_settings_spec.rb +37 -0
- data/spec/coworker_spec.rb +94 -0
- data/spec/custom_field_spec.rb +22 -0
- data/spec/deal_class_settings_spec.rb +116 -0
- data/spec/deal_spec.rb +232 -0
- data/spec/deal_status_reference_spec.rb +17 -0
- data/spec/documents_spec.rb +64 -0
- data/spec/file_spec.rb +178 -0
- data/spec/helpers/csv_helper_spec.rb +45 -0
- data/spec/helpers/email_helper_spec.rb +37 -0
- data/spec/helpers/phone_helper_spec.rb +119 -0
- data/spec/helpers/roo_helper_spec.rb +10 -0
- data/spec/helpers/serialize_helper_spec.rb +253 -0
- data/spec/helpers/shard_helper_spec.rb +141 -0
- data/spec/helpers/xsd_validate_spec.rb +57 -0
- data/spec/history_spec.rb +150 -0
- data/spec/link_spec.rb +107 -0
- data/spec/organization_spec.rb +221 -0
- data/spec/person_spec.rb +129 -0
- data/spec/rootmodel_spec.rb +993 -0
- data/spec/spec_helper.rb +30 -0
- metadata +362 -0
@@ -0,0 +1,250 @@
|
|
1
|
+
require 'date'
|
2
|
+
module MoveToGo
|
3
|
+
class OrganizationReference
|
4
|
+
include SerializeHelper
|
5
|
+
attr_accessor :id, :integration_id, :heading
|
6
|
+
def serialize_variables
|
7
|
+
[ :id, :integration_id, :heading ].map { |prop| {
|
8
|
+
:id => prop, :type => :string
|
9
|
+
}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(opt = nil)
|
14
|
+
if opt != nil
|
15
|
+
serialize_variables.each do |var|
|
16
|
+
value = opt[var[:id]]
|
17
|
+
instance_variable_set("@" + var[:id].to_s, value) if value != nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
return "(#{id}, #{integration_id}, #{heading})"
|
24
|
+
end
|
25
|
+
|
26
|
+
def empty?
|
27
|
+
return !@integration_id && !@id && !@heading
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.from_organization(organization)
|
31
|
+
if organization.nil?
|
32
|
+
return nil
|
33
|
+
elsif organization.is_a?(Organization)
|
34
|
+
return organization.to_reference
|
35
|
+
elsif organization.is_a?(OrganizationReference)
|
36
|
+
return organization
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Organization < CanBecomeImmutable
|
42
|
+
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
43
|
+
|
44
|
+
immutable_accessor :id
|
45
|
+
immutable_accessor :integration_id
|
46
|
+
immutable_accessor :name
|
47
|
+
immutable_accessor :organization_number
|
48
|
+
immutable_accessor :email
|
49
|
+
immutable_accessor :web_site
|
50
|
+
immutable_accessor :postal_address
|
51
|
+
immutable_accessor :visit_address
|
52
|
+
immutable_accessor :central_phone_number
|
53
|
+
immutable_accessor :source_data
|
54
|
+
|
55
|
+
# Sets/gets the date when this organization's relation was
|
56
|
+
# changed. Default is Now.
|
57
|
+
attr_reader :relation_last_modified
|
58
|
+
|
59
|
+
attr_reader :employees, :responsible_coworker, :relation
|
60
|
+
# you add custom values by using {#set_custom_value}
|
61
|
+
attr_reader :custom_values
|
62
|
+
|
63
|
+
def initialize(opt = nil)
|
64
|
+
if !opt.nil?
|
65
|
+
serialize_variables.each do |myattr|
|
66
|
+
val = opt[myattr[:id]]
|
67
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
@relation = Relation::NoRelation if @relation.nil?
|
72
|
+
set_tag 'Import'
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_reference()
|
76
|
+
reference = OrganizationReference.new
|
77
|
+
reference.id = @id
|
78
|
+
reference.integration_id = @integration_id
|
79
|
+
reference.heading = @name
|
80
|
+
return reference
|
81
|
+
end
|
82
|
+
|
83
|
+
def ==(that)
|
84
|
+
if that.nil?
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
|
88
|
+
if that.is_a? Organization
|
89
|
+
return @integration_id == that.integration_id
|
90
|
+
end
|
91
|
+
|
92
|
+
return false
|
93
|
+
end
|
94
|
+
|
95
|
+
# @example Set city of postal address to 'Lund'
|
96
|
+
# o.with_postal_address do |addr|
|
97
|
+
# addr.city = "Lund"
|
98
|
+
# end
|
99
|
+
# @see Address address
|
100
|
+
def with_postal_address
|
101
|
+
@postal_address = Address.new if @postal_address == nil
|
102
|
+
yield @postal_address
|
103
|
+
end
|
104
|
+
|
105
|
+
# @example Set city of visit address to 'Lund'
|
106
|
+
# o.with_visit_address do |addr|
|
107
|
+
# addr.city = "Lund"
|
108
|
+
# end
|
109
|
+
# @see Address address
|
110
|
+
def with_visit_address
|
111
|
+
@visit_address = Address.new if @visit_address == nil
|
112
|
+
yield @visit_address
|
113
|
+
end
|
114
|
+
|
115
|
+
# @example Set the source to par id 4653
|
116
|
+
# o.with_source do |source|
|
117
|
+
# source.par_se('4653')
|
118
|
+
# end
|
119
|
+
# @see ReferenceToSource source
|
120
|
+
def with_source
|
121
|
+
@source = ReferenceToSource.new if @source == nil
|
122
|
+
yield @source
|
123
|
+
end
|
124
|
+
|
125
|
+
# @example Add an employee and then add additional info to that employee
|
126
|
+
# employee = o.add_employee({
|
127
|
+
# :integration_id => "79654",
|
128
|
+
# :first_name => "Peter",
|
129
|
+
# :last_name => "Wilhelmsson"
|
130
|
+
# })
|
131
|
+
# employee.direct_phone_number = '+234234234'
|
132
|
+
# employee.currently_employed = true
|
133
|
+
# @see Person employee
|
134
|
+
def add_employee(val)
|
135
|
+
@employees = [] if @employees == nil
|
136
|
+
person = if val.is_a? Person then val else Person.new(val) end
|
137
|
+
person.set_organization_reference = self
|
138
|
+
@employees.push(person)
|
139
|
+
|
140
|
+
# *** TODO:
|
141
|
+
#
|
142
|
+
# The person should be immutable after it has been added
|
143
|
+
# to the organization. However most sources (LIME Easy,
|
144
|
+
# LIME Pro, Excel, SalesForce, etc) are updating the
|
145
|
+
# person after is has been added to the organization. We
|
146
|
+
# must update the sources before we can set the person
|
147
|
+
# immutable here.
|
148
|
+
|
149
|
+
#person.set_is_immutable
|
150
|
+
|
151
|
+
return person
|
152
|
+
end
|
153
|
+
|
154
|
+
def responsible_coworker=(coworker)
|
155
|
+
raise_if_immutable
|
156
|
+
@responsible_coworker_reference = CoworkerReference.from_coworker(coworker)
|
157
|
+
|
158
|
+
if coworker.is_a?(Coworker)
|
159
|
+
@responsible_coworker = coworker
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Sets the organization's relation to the specified value. The
|
164
|
+
# relation must be a valid value from the Relation module
|
165
|
+
# otherwise an InvalidRelationError error will be thrown.
|
166
|
+
def relation=(relation)
|
167
|
+
raise_if_immutable
|
168
|
+
|
169
|
+
if relation == Relation::NoRelation || relation == Relation::WorkingOnIt ||
|
170
|
+
relation == Relation::IsACustomer || relation == Relation::WasACustomer || relation == Relation::BeenInTouch
|
171
|
+
@relation = relation
|
172
|
+
@relation_last_modified = Time.now.strftime("%Y-%m-%d") if @relation_last_modified.nil? &&
|
173
|
+
@relation != Relation::NoRelation
|
174
|
+
else
|
175
|
+
raise InvalidRelationError
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def relation_last_modified=(date)
|
180
|
+
raise_if_immutable
|
181
|
+
|
182
|
+
begin
|
183
|
+
@relation_last_modified = @relation != Relation::NoRelation ? Date.parse(date).strftime("%Y-%m-%d") : nil
|
184
|
+
rescue
|
185
|
+
raise InvalidValueError, date
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def find_employee_by_integration_id(integration_id)
|
190
|
+
return nil if @employees.nil?
|
191
|
+
return @employees.find do |e|
|
192
|
+
e.integration_id == integration_id
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def serialize_variables
|
197
|
+
[
|
198
|
+
{ :id => :id, :type => :string },
|
199
|
+
{ :id => :integration_id, :type => :string },
|
200
|
+
{ :id => :source, :type => :source_ref },
|
201
|
+
{ :id => :name, :type => :string },
|
202
|
+
{ :id => :organization_number, :type => :string },
|
203
|
+
{ :id => :postal_address, :type => :address },
|
204
|
+
{ :id => :visit_address, :type => :address },
|
205
|
+
{ :id => :central_phone_number, :type => :string },
|
206
|
+
{ :id => :email, :type => :string },
|
207
|
+
{ :id => :web_site, :type => :string },
|
208
|
+
{ :id => :employees, :type => :persons },
|
209
|
+
{ :id => :custom_values, :type => :custom_values },
|
210
|
+
{ :id => :tags, :type => :tags },
|
211
|
+
{ :id => :responsible_coworker_reference, :type => :coworker_reference, :element_name => :responsible_coworker},
|
212
|
+
{ :id => :relation, :type => :string },
|
213
|
+
{ :id => :relation_last_modified, :type => :string }
|
214
|
+
]
|
215
|
+
end
|
216
|
+
|
217
|
+
def serialize_name
|
218
|
+
"Organization"
|
219
|
+
end
|
220
|
+
|
221
|
+
def to_s
|
222
|
+
return "#{name}"
|
223
|
+
end
|
224
|
+
|
225
|
+
def validate
|
226
|
+
error = String.new
|
227
|
+
|
228
|
+
if @name.nil? || @name.empty?
|
229
|
+
error = "A name is required for organization.\n#{serialize()}"
|
230
|
+
end
|
231
|
+
|
232
|
+
if !@source.nil?
|
233
|
+
if @source.id.nil? || @source.id == ""
|
234
|
+
error = "#{error}\nReference to source must have an id"
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
if @employees != nil
|
239
|
+
@employees.each do |person|
|
240
|
+
validation_message = person.validate()
|
241
|
+
if !validation_message.empty?
|
242
|
+
error = "#{error}\n#{validation_message}"
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
return error
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
module MoveToGo
|
2
|
+
class PersonReference
|
3
|
+
include SerializeHelper
|
4
|
+
attr_accessor :id, :integration_id
|
5
|
+
def serialize_variables
|
6
|
+
[ :id, :integration_id ].map { |prop| {:id=>prop,:type=>:string} }
|
7
|
+
end
|
8
|
+
|
9
|
+
def initalize()
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
return "(#{id}, #{integration_id})"
|
14
|
+
end
|
15
|
+
|
16
|
+
def empty?
|
17
|
+
return !@integration_id && !@id
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.from_person(person)
|
21
|
+
if person.nil?
|
22
|
+
return nil
|
23
|
+
elsif person.is_a?(Person)
|
24
|
+
return person.to_reference
|
25
|
+
elsif person.is_a?(PersonReference)
|
26
|
+
return person
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Person < CanBecomeImmutable
|
32
|
+
include SerializeHelper, ModelHasCustomFields, ModelHasTags
|
33
|
+
|
34
|
+
immutable_accessor :id
|
35
|
+
immutable_accessor :integration_id
|
36
|
+
immutable_accessor :first_name
|
37
|
+
immutable_accessor :last_name
|
38
|
+
immutable_accessor :direct_phone_number
|
39
|
+
immutable_accessor :fax_phone_number
|
40
|
+
immutable_accessor :mobile_phone_number
|
41
|
+
immutable_accessor :home_phone_number
|
42
|
+
immutable_accessor :position
|
43
|
+
immutable_accessor :email
|
44
|
+
immutable_accessor :alternative_email
|
45
|
+
immutable_accessor :postal_address
|
46
|
+
immutable_accessor :currently_employed
|
47
|
+
|
48
|
+
# you add custom values by using {#set_custom_value}
|
49
|
+
attr_reader :custom_values, :organization
|
50
|
+
|
51
|
+
def initialize(opt = nil)
|
52
|
+
@currently_employed = true
|
53
|
+
if opt != nil
|
54
|
+
serialize_variables.each do |myattr|
|
55
|
+
val = opt[myattr[:id]]
|
56
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
set_tag 'Import'
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_organization_reference=(org)
|
64
|
+
@organization = OrganizationReference.from_organization(org)
|
65
|
+
end
|
66
|
+
|
67
|
+
# @example Set city of postal address to 'Lund'
|
68
|
+
# p.with_postal_address do |addr|
|
69
|
+
# addr.city = "Lund"
|
70
|
+
# end
|
71
|
+
# @see Address address
|
72
|
+
def with_postal_address
|
73
|
+
@postal_address = Address.new if @postal_address == nil
|
74
|
+
yield @postal_address
|
75
|
+
end
|
76
|
+
|
77
|
+
# @example Set the source to par id 4653
|
78
|
+
# p.with_source do |source|
|
79
|
+
# source.par_se('4653')
|
80
|
+
# end
|
81
|
+
# @see ReferenceToSource source
|
82
|
+
def with_source
|
83
|
+
@source = ReferenceToSource.new if @source == nil
|
84
|
+
yield @source
|
85
|
+
end
|
86
|
+
|
87
|
+
def tags
|
88
|
+
@tags
|
89
|
+
end
|
90
|
+
|
91
|
+
def serialize_name
|
92
|
+
"Person"
|
93
|
+
end
|
94
|
+
|
95
|
+
def serialize_variables
|
96
|
+
[
|
97
|
+
{:id => :id, :type => :string},
|
98
|
+
{:id => :integration_id, :type => :string},
|
99
|
+
{:id => :source, :type => :source_ref},
|
100
|
+
{:id => :first_name, :type => :string},
|
101
|
+
{:id => :last_name, :type => :string},
|
102
|
+
|
103
|
+
{:id => :direct_phone_number, :type => :string},
|
104
|
+
{:id => :fax_phone_number, :type => :string},
|
105
|
+
{:id => :mobile_phone_number, :type => :string},
|
106
|
+
{:id => :home_phone_number, :type => :string},
|
107
|
+
|
108
|
+
{:id => :position, :type => :string},
|
109
|
+
|
110
|
+
{:id => :tags, :type => :tags},
|
111
|
+
|
112
|
+
{:id => :email, :type => :string},
|
113
|
+
{:id => :alternative_email, :type => :string},
|
114
|
+
|
115
|
+
{:id => :postal_address, :type => :address},
|
116
|
+
{:id => :custom_values, :type => :custom_values},
|
117
|
+
{:id => :currently_employed, :type => :bool},
|
118
|
+
{:id => :organization, :type => :organization_reference},
|
119
|
+
|
120
|
+
]
|
121
|
+
end
|
122
|
+
|
123
|
+
def to_reference()
|
124
|
+
reference = PersonReference.new
|
125
|
+
reference.id = @id
|
126
|
+
reference.integration_id = @integration_id
|
127
|
+
return reference
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_import_rows
|
131
|
+
(serialize_variables + [ { :id => :organization, :type => :organization_reference } ]).map do |p|
|
132
|
+
map_to_row p
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def to_s
|
137
|
+
return "#{first_name} #{last_name}"
|
138
|
+
end
|
139
|
+
|
140
|
+
def validate
|
141
|
+
error = String.new
|
142
|
+
|
143
|
+
if (@first_name.nil? || @first_name.empty?) &&
|
144
|
+
(@last_name.nil? || @last_name.empty?)
|
145
|
+
error = "A firstname or lastname is required for person.\n#{serialize()}"
|
146
|
+
end
|
147
|
+
|
148
|
+
return error
|
149
|
+
end
|
150
|
+
|
151
|
+
def parse_name_to_firstname_lastname_se(name, when_missing = '')
|
152
|
+
if name.nil? or name.empty?
|
153
|
+
@first_name = when_missing
|
154
|
+
return
|
155
|
+
end
|
156
|
+
|
157
|
+
splitted = name.split(' ')
|
158
|
+
@first_name = splitted[0]
|
159
|
+
if splitted.length > 1
|
160
|
+
@last_name = splitted.drop(1).join(' ')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module MoveToGo
|
2
|
+
class ReferenceToSource
|
3
|
+
include SerializeHelper
|
4
|
+
attr_accessor :name, :id, :format
|
5
|
+
|
6
|
+
def serialize_variables
|
7
|
+
[:name, :format, :id].map { |prop| { :id => prop, :type => :string } }
|
8
|
+
end
|
9
|
+
|
10
|
+
def serialize_name
|
11
|
+
"ReferenceToSource"
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_import_rows
|
15
|
+
(serialize_variables + [{ :id => :value, :type => :string }]).map do |p|
|
16
|
+
map_to_row p
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(opt = nil)
|
21
|
+
if opt != nil
|
22
|
+
serialize_variables.each do |myattr|
|
23
|
+
val = opt[myattr[:id]]
|
24
|
+
instance_variable_set("@" + myattr[:id].to_s,val) if val != nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
return "#{@name}_#{@format}_#{@id}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def ==(other)
|
34
|
+
if other==nil
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
return @name == other.name && @id == other.id && @format== other.format
|
38
|
+
end
|
39
|
+
# Sets the id of this instance to the parameter supplied. Will also set {#name} and {#format} so that this reference is identified as a PAR identifier by Go.
|
40
|
+
def par_se(id)
|
41
|
+
@name = 'pase'
|
42
|
+
@format = 'External'
|
43
|
+
@id = id
|
44
|
+
end
|
45
|
+
|
46
|
+
def ecp_no(id)
|
47
|
+
@name = 'eno'
|
48
|
+
@format = 'External'
|
49
|
+
@id = id
|
50
|
+
end
|
51
|
+
|
52
|
+
def ecp_dk(id)
|
53
|
+
@name = 'edk'
|
54
|
+
@format = 'External'
|
55
|
+
@id = id
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module MoveToGo
|
2
|
+
module Relation
|
3
|
+
# This is the default, we have not been in contact with this
|
4
|
+
# organization in any way.
|
5
|
+
NoRelation = 0
|
6
|
+
|
7
|
+
# Something is happening with this organization, we might have
|
8
|
+
# booked a meeting with them or created a deal, etc.
|
9
|
+
WorkingOnIt = 1
|
10
|
+
|
11
|
+
# We have made a deal with this organization.
|
12
|
+
IsACustomer = 2
|
13
|
+
|
14
|
+
# We have made a deal with this organization but it was some
|
15
|
+
# time ago and we don't consider them a customer any more.
|
16
|
+
WasACustomer = 3
|
17
|
+
|
18
|
+
# We had something going with this organization but we
|
19
|
+
# couldn't close the deal and we don't think they will be a
|
20
|
+
# customer to us in the foreseeable future.
|
21
|
+
BeenInTouch = 4
|
22
|
+
end
|
23
|
+
end
|