fruit_to_lime 2.5.7 → 2.6.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.
@@ -116,17 +116,21 @@ module FruitToLime
116
116
  end
117
117
 
118
118
  def value=(value)
119
- # we have had some issues with LIME Easy imports where the
120
- # value was in the format "357 000". We need to remove
121
- # those spaces.
122
- fixed_value = value.gsub(" ", "")
123
-
124
- if is_integer?(fixed_value)
125
- @value = fixed_value
126
- elsif is_float?(fixed_value)
127
- @value = fixed_value
119
+ if value.nil?
120
+ @value = 0
128
121
  else
129
- raise InvalidValueError, value
122
+ # we have had some issues with LIME Easy imports where
123
+ # the value was in the format "357 000". We need to
124
+ # remove those spaces.
125
+ fixed_value = value.gsub(" ", "")
126
+
127
+ if is_integer?(fixed_value)
128
+ @value = fixed_value
129
+ elsif is_float?(fixed_value)
130
+ @value = fixed_value
131
+ else
132
+ raise InvalidValueError, value
133
+ end
130
134
  end
131
135
  end
132
136
 
data/spec/deal_spec.rb CHANGED
@@ -98,4 +98,15 @@ describe "Deal" do
98
98
  # then
99
99
  deal.value.should eq "100.10"
100
100
  end
101
+
102
+ it "should set value to 0 if value is nil" do
103
+ # given
104
+ deal.name = "The new deal"
105
+
106
+ # when
107
+ deal.value = nil
108
+
109
+ # then
110
+ deal.value.should eq 0
111
+ end
101
112
  end
@@ -0,0 +1,6 @@
1
+ Export all data from KONTAKT.mdb to this folder.
2
+
3
+ Export data using the magical tool called PowerSellMigrationExport.exe
4
+ that can be found in K:\Lundalogik\LIME Easy\Tillbeh�r\Migrationsexport.
5
+
6
+ Yay!
@@ -0,0 +1,8 @@
1
+ :: This script will convert an exported KONTAKT.mdb in the folder
2
+ :: Export to a file that can be imported into LIME Go.
3
+ :: The file will be named go.xml
4
+
5
+ @echo off
6
+ ruby convert.rb to_go --coworkers=Export\User.txt --organizations=Export\Company.txt --persons=Export\Company-Person.txt --orgnotes=Export\Company-History.txt --includes=Export\Project-Included.txt --deals=Export\Project.txt --dealnotes=Export\Project-History.txt --output=go.xml
7
+
8
+
@@ -1,22 +1,54 @@
1
1
  # encoding: UTF-8
2
2
  require 'fruit_to_lime'
3
3
 
4
+ # Customize this file to suit your input files.
5
+ #
6
+ # Documentation fruit_to_lime can be found at
7
+ # http://rubygems.org/gems/fruit_to_lime
8
+ #
9
+ # Fruit_to_lime contains all objects in LIME Go such as organization,
10
+ # people, deals, etc. What properties each object has is described in
11
+ # the documentation.
12
+
13
+ # *** TODO:
14
+ #
15
+ # You must customize this template so it works with your LIME Easy
16
+ # database. Modify each to_* method and set properties on the LIME Go
17
+ # objects.
18
+ #
19
+ # Follow these steps:
20
+ #
21
+ # 1) Export all data from KONTAKT.mdb to a folder named Export located
22
+ # in the folder created by fruit_to_lime unpack_template. Export data
23
+ # using the magical tool called PowerSellMigrationExport.exe that can
24
+ # be found in K:\Lundalogik\LIME Easy\Tillbeh�r\Migrationsexport.
25
+ #
26
+ # 2) Modify this file (the to_* methods) according to your customer's
27
+ # KONTAKT.mdb and wishes.
28
+ #
29
+ # 3) Run easy-to-go.bat in a command prompt.
30
+ #
31
+ # 4) Upload go.xml to LIME Go. First test your import on staging and
32
+ # when your customer has approved the import, run it on production.
4
33
  class Exporter
5
34
  # Turns a user from the User.txt Easy Export file into
6
- # a fruit_to_lime coworker-model that is used to generate xml
35
+ # a fruit_to_lime coworker.
7
36
  def to_coworker(row)
8
37
  coworker = FruitToLime::Coworker.new
9
38
  # integration_id is typically the userId in Easy
10
39
  # Must be set to be able to import the same file more
11
40
  # than once without creating duplicates
12
- coworker.integration_id = row['userId']
41
+
42
+ # NOTE: You shouldn't have to modify this method
43
+
44
+ coworker.integration_id = row['PowerSellUserID']
13
45
  coworker.parse_name_to_firstname_lastname_se(row['Name'])
14
46
 
15
47
  return coworker
16
48
  end
17
49
 
18
50
  # Turns a row from the Easy exported Company.txt file into a
19
- # fruit_to_lime model that is used to generate xml
51
+ # fruit_to_lime organization.
20
52
  def to_organization(row, coworkers)
21
53
  organization = FruitToLime::Organization.new
22
54
  # integration_id is typically the company Id in Easy
@@ -24,16 +56,19 @@ class Exporter
24
56
  # than once without creating duplicates
25
57
 
26
58
  # Easy standard fields
27
- organization.integration_id = row['companyId']
28
- organization.name = row['company name']
59
+ organization.integration_id = row['PowerSellCompanyID']
60
+ organization.name = row['Company name']
29
61
  organization.central_phone_number = row['Telephone']
30
62
 
31
- # NOTE!! if a bisnode-id is present maybe you want to
32
- # consider not setting this.
33
- # Addresses consists of several parts in Go.
34
- # Lots of other systems have the address all in one
35
- # line, to be able to match when importing it is
36
- # way better to split the addresses
63
+ # *** TODO: Customize below this line (address, superfield,
64
+ # relation, etc)
65
+
66
+ # NOTE!! if a bisnode-id is present maybe you want to consider
67
+ # not setting this (because if you set the address LIME Go
68
+ # will NOT automagically update the address from PAR)
69
+ # Addresses consists of several parts in Go. Lots of other
70
+ # systems have the address all in one line, to be able to
71
+ # match when importing it is way better to split the addresses
37
72
  organization.with_postal_address do |address|
38
73
  address.street = row['street']
39
74
  address.zip_code = row['zip']
@@ -42,8 +77,6 @@ class Exporter
42
77
  end
43
78
 
44
79
  # Easy superfields
45
- organization.email = row['e-mail']
46
- organization.web_site = row['website']
47
80
 
48
81
  # Same as postal address
49
82
  organization.with_visit_address do |addr|
@@ -52,6 +85,9 @@ class Exporter
52
85
  addr.city = row['visit city']
53
86
  end
54
87
 
88
+ organization.email = row['e-mail']
89
+ organization.organization_number = row['orgnr']
90
+
55
91
  # Set Bisnode Id if present
56
92
  bisnode_id = row['Bisnode-id']
57
93
 
@@ -63,12 +99,12 @@ class Exporter
63
99
 
64
100
  # Only set other Bisnode fields if the Bisnode Id is empty
65
101
  if bisnode_id.empty?
66
- organization.organization_number = row['orgnr']
102
+ organization.web_site = row['website']
67
103
  end
68
104
 
69
105
  # Responsible coworker for the organization.
70
106
  # For instance responsible sales rep.
71
- coworker_id = coworkers[row['userIndex - our reference']]
107
+ coworker_id = coworkers[row['idUser-Responsible']]
72
108
  organization.responsible_coworker = @rootmodel.find_coworker_by_integration_id(coworker_id)
73
109
 
74
110
  # Tags are set and defined at the same place
@@ -85,21 +121,21 @@ class Exporter
85
121
  # with the options '1.Customer', '2.Prospect' '3.Partner' and '4.Lost customer'
86
122
  if row['Customer relation'] == '1.Customer'
87
123
  # We have made a deal with this organization.
88
- organization.relation = Relation::IsACustomer
124
+ organization.relation = FruitToLime::Relation::IsACustomer
89
125
  elsif row['Customer relation'] == '3.Partner'
90
126
  # We have made a deal with this organization.
91
- organization.relation = Relation::IsACustomer
127
+ organization.relation = FruitToLime::Relation::IsACustomer
92
128
  elsif row['Customer relation'] == '2.Prospect'
93
129
  # Something is happening with this organization, we might have
94
130
  # booked a meeting with them or created a deal, etc.
95
- organization.relation = Relation::WorkingOnIt
131
+ organization.relation = FruitToLime::Relation::WorkingOnIt
96
132
  elsif row['Customer relation'] == '4.Lost customer'
97
133
  # We had something going with this organization but we
98
134
  # couldn't close the deal and we don't think they will be a
99
135
  # customer to us in the foreseeable future.
100
- organization.relation = Relation::BeenInTouch
136
+ organization.relation = FruitToLime::Relation::BeenInTouch
101
137
  else
102
- organization.relation = Relation::NoRelation
138
+ organization.relation = FruitToLime::Relation::NoRelation
103
139
  end
104
140
 
105
141
  return organization
@@ -115,10 +151,18 @@ class Exporter
115
151
  # unique within the scope of the company, so we combine the
116
152
  # referenceId and the companyId to make a globally unique
117
153
  # integration_id
118
- person.integration_id = "#{row['referenceId']}-#{row['companyId']}"
154
+ person.integration_id = "#{row['PowerSellReferenceID']}-#{row['PowerSellCompanyID']}"
119
155
  person.first_name = row['First name']
120
156
  person.last_name = row['Last name']
121
157
 
158
+ # set employer connection
159
+ employer = @rootmodel.find_organization_by_integration_id(row['PowerSellCompanyID'])
160
+ if employer
161
+ employer.add_employee person
162
+ end
163
+
164
+ # *** TODO: Customize below this line (superfields, tags, etc)
165
+
122
166
  # Easy superfields
123
167
  person.direct_phone_number = row['Direktnummer']
124
168
  person.mobile_phone_number = row['Mobil']
@@ -138,15 +182,11 @@ class Exporter
138
182
  end
139
183
 
140
184
  # Multioption fields or "Set"- fields
141
- intrests = row['intrests'].split(';')
142
- intrests.each do |intrest|
143
- person.set_tag(intrest)
144
- end
145
-
146
- # set employer connection
147
- employer = @rootmodel.find_organization_by_integration_id(row['companyId'])
148
- if employer
149
- employer.add_employee person
185
+ if row['intrests']
186
+ intrests = row['intrests'].split(';')
187
+ intrests.each do |intrest|
188
+ person.set_tag(intrest)
189
+ end
150
190
  end
151
191
  end
152
192
 
@@ -157,15 +197,15 @@ class Exporter
157
197
  def to_deal(row, includes, coworkers)
158
198
  deal = FruitToLime::Deal.new
159
199
  # Easy standard fields
160
- deal.integration_id = row['projectId']
200
+ deal.integration_id = row['PowerSellProjectID']
161
201
  deal.name = row['Name']
162
202
  deal.description = row['Description']
163
203
 
164
204
  # Easy superfields
165
- deal.order_date = row[' order date']
205
+ deal.order_date = row['order date']
166
206
 
167
- coworker_id = coworkers[row['userIndex']]
168
- deal.responsible_coworker = @rootmodel.find_coworker_by_integration_id coworker_id
207
+ coworker_id = coworkers[row['isUser-Ansvarig']]
208
+ deal.responsible_coworker = @rootmodel.find_coworker_by_integration_id(coworker_id)
169
209
 
170
210
  # Should be integer
171
211
  # The currency used in Easy should match the one used in Go
@@ -173,18 +213,20 @@ class Exporter
173
213
 
174
214
  # should be between 0 - 100
175
215
  # remove everything that is not an intiger
176
- deal.probability = row['probability'].gsub(/[^\d]/,"").to_i
216
+ deal.probability = row['probability'].gsub(/[^\d]/,"").to_i unless row['probability'].nil?
177
217
 
178
218
  # Create a status object and set it's label to the value of the Easy field
179
- deal.status = FruitToLime::DealStatus.new
180
- deal.status.label = row['Status']
219
+ if !row['Status'].empty?
220
+ deal.status = FruitToLime::DealStatus.new
221
+ deal.status.label = row['Status']
222
+ end
181
223
 
182
224
  # Tags
183
225
  deal.set_tag("Imported")
184
226
 
185
227
  # Make the deal - organization connection
186
228
  if includes
187
- organization_id = includes[row['projectId']]
229
+ organization_id = includes[row['PowerSellProjectID']]
188
230
  organization = @rootmodel.find_organization_by_integration_id(organization_id)
189
231
  if organization
190
232
  deal.customer = organization
@@ -199,23 +241,23 @@ class Exporter
199
241
  # Uses coworkers hash to lookup coworkers to connect
200
242
  # Uses people hash to lookup persons to connect
201
243
  def to_organization_note(row, coworkers, people)
202
- organization = @rootmodel.find_organization_by_integration_id(row['companyId'])
244
+ organization = @rootmodel.find_organization_by_integration_id(row['PowerSellCompanyID'])
203
245
 
204
- coworker_id = coworkers[row['userIndex']]
246
+ coworker_id = coworkers[row['idUser']]
205
247
  coworker = @rootmodel.find_coworker_by_integration_id(coworker_id)
206
248
 
207
249
  if organization && coworker
208
250
  note = FruitToLime::Note.new()
209
251
  note.organization = organization
210
252
  note.created_by = coworker
211
- note.person = organization.find_employee_by_integration_id(people[row['personIndex']])
253
+ note.person = organization.find_employee_by_integration_id(people[row['idPerson']])
212
254
  note.date = row['Date']
213
255
  note.text = "#{row['Category']}: #{row['History']}"
214
256
 
215
257
  return note.text.empty? ? nil : note
216
258
  end
217
259
 
218
- return note
260
+ return nil
219
261
  end
220
262
 
221
263
  # Turns a row from the Easy exported Project-History.txt file into
@@ -226,14 +268,13 @@ class Exporter
226
268
  # organization connected to this deal if any, but since it is
227
269
  # a many to many connection between organizations and deals
228
270
  # it's not a straight forward task
229
- note = FruitToLime::Note.new()
271
+ deal = @rootmodel.find_deal_by_integration_id(row['PowerSellProjectID'])
230
272
 
231
- deal = @rootmodel.find_deal_by_integration_id(row['projectId'])
232
-
233
- coworker_id = coworkers[row['userIndex']]
273
+ coworker_id = coworkers[row['idUser']]
234
274
  coworker = @rootmodel.find_coworker_by_integration_id(coworker_id)
235
275
 
236
276
  if deal && coworker
277
+ note = FruitToLime::Note.new()
237
278
  note.deal = deal
238
279
  note.created_by = coworker
239
280
  note.date = row['Date']
@@ -243,7 +284,7 @@ class Exporter
243
284
  return note.text.empty? ? nil : note
244
285
  end
245
286
 
246
- return note
287
+ return nil
247
288
  end
248
289
 
249
290
  def configure(model)
@@ -317,7 +358,7 @@ class Exporter
317
358
  # that connect organizations to deals
318
359
  if includes_filename && !includes_filename.empty?
319
360
  process_rows includes_filename do |row|
320
- includes[row['projectId']] = row['companyId']
361
+ includes[row['PowerSellProjectID']] = row['PowerSellCompanyID']
321
362
  end
322
363
  end
323
364
 
@@ -354,14 +395,14 @@ require 'pathname'
354
395
 
355
396
  class Cli < Thor
356
397
  desc "to_go", "Generates a Go XML file"
357
- method_option :output, :desc => "Path to file where xml will be output", :default => "export.xml", :type => :string
358
- method_option :coworkers, :desc => "Path to coworkers csv file", :type => :string
359
- method_option :organizations, :desc => "Path to organization csv file", :type => :string
360
- method_option :persons, :desc => "Path to persons csv file", :type => :string
361
- method_option :orgnotes, :desc => "Path to organization notes file", :type => :string
362
- method_option :includes, :desc => "Path to include file", :type => :string
363
- method_option :deals, :desc => "Path to deals csv file", :type => :string
364
- method_option :dealnotes, :desc => "Path to deal notes file", :type => :string
398
+ method_option :output, :desc => "Path to file where xml will be output", :default => "export.xml", :type => :string, :required => true
399
+ method_option :coworkers, :desc => "Path to coworkers csv file", :type => :string, :required => true
400
+ method_option :organizations, :desc => "Path to organization csv file", :type => :string, :required => true
401
+ method_option :persons, :desc => "Path to persons csv file", :type => :string, :required => true
402
+ method_option :orgnotes, :desc => "Path to organization notes file", :type => :string, :required => true
403
+ method_option :includes, :desc => "Path to include file", :type => :string, :required => true
404
+ method_option :deals, :desc => "Path to deals csv file", :type => :string, :required => true
405
+ method_option :dealnotes, :desc => "Path to deal notes file", :type => :string, :required => true
365
406
  def to_go
366
407
  output = options.output
367
408
  exporter = Exporter.new()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fruit_to_lime
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.7
4
+ version: 2.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-06-30 00:00:00.000000000 Z
15
+ date: 2014-07-01 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes
@@ -205,6 +205,8 @@ files:
205
205
  - templates/csv/spec/sample_data/persons.csv
206
206
  - templates/csv/spec/spec_helper.rb
207
207
  - templates/easy/convert.rb
208
+ - templates/easy/easy-to-go.bat
209
+ - templates/easy/Export/readme.txt
208
210
  - templates/easy/Gemfile
209
211
  - templates/easy/lib/tomodel.rb
210
212
  - templates/easy/Rakefile.rb