fruit_to_lime 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fruit_to_lime/model/deal.rb +8 -2
- data/lib/fruit_to_lime/model/documents.rb +51 -0
- data/lib/fruit_to_lime/model/link.rb +70 -0
- data/lib/fruit_to_lime/model/rootmodel.rb +23 -6
- data/spec/documents_spec.rb +37 -0
- data/spec/link_spec.rb +106 -0
- data/spec/rootmodel_spec.rb +32 -0
- data/templates/VISMA/Databas/KUND.DBS +1 -0
- data/templates/VISMA/Gemfile +7 -0
- data/templates/VISMA/Rakefile.rb +7 -0
- data/templates/VISMA/convert.rb +3 -0
- data/templates/VISMA/lib/tomodel.rb +202 -0
- data/templates/easy/lib/tomodel.rb +3 -3
- metadata +13 -2
@@ -7,7 +7,13 @@ module FruitToLime
|
|
7
7
|
[ :id, :integration_id ].map { |prop| {:id => prop, :type => :string} }
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def initialize(opt = nil)
|
11
|
+
if opt != nil
|
12
|
+
serialize_variables.each do |var|
|
13
|
+
value = opt[var[:id]]
|
14
|
+
instance_variable_set("@" + var[:id].to_s, value) if value != nil
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
def to_s
|
@@ -23,7 +29,7 @@ module FruitToLime
|
|
23
29
|
return nil
|
24
30
|
elsif deal.is_a?(Deal)
|
25
31
|
return deal.to_reference
|
26
|
-
elsif
|
32
|
+
elsif deal.is_a?(DealReference)
|
27
33
|
return deal
|
28
34
|
end
|
29
35
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module FruitToLime
|
3
|
+
# This class is the container for all documents, ie links and
|
4
|
+
# files.
|
5
|
+
class Documents
|
6
|
+
# *** TODO: add files when supported by the backend.
|
7
|
+
|
8
|
+
include SerializeHelper
|
9
|
+
|
10
|
+
attr_accessor :links
|
11
|
+
|
12
|
+
def serialize_variables
|
13
|
+
[
|
14
|
+
{:id => :links, @type => :links}
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def serialize_name
|
19
|
+
"Documents"
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@links = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_link(link)
|
27
|
+
@links = [] if @links == nil
|
28
|
+
|
29
|
+
if link.nil?
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
|
33
|
+
link = Link.new(link) if !link.is_a?(Link)
|
34
|
+
|
35
|
+
if (!link.integration_id.nil? && link.integration_id.length > 0) &&
|
36
|
+
find_link_by_integration_id(link.integration_id) != nil
|
37
|
+
raise AlreadyAddedError, "Already added a link with integration_id #{link.integration_id}"
|
38
|
+
end
|
39
|
+
|
40
|
+
@links.push(link)
|
41
|
+
|
42
|
+
return link
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_link_by_integration_id(integration_id)
|
46
|
+
return @links.find do |link|
|
47
|
+
link.integration_id == integration_id
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module FruitToLime
|
2
|
+
class Link
|
3
|
+
include SerializeHelper
|
4
|
+
attr_accessor :id, :integration_id, :url, :name, :description
|
5
|
+
|
6
|
+
attr_reader :organization, :created_by, :deal
|
7
|
+
|
8
|
+
def initialize(opt = nil)
|
9
|
+
if !opt.nil?
|
10
|
+
serialize_variables.each do |myattr|
|
11
|
+
val = opt[myattr[:id]]
|
12
|
+
instance_variable_set("@" + myattr[:id].to_s, val) if val != nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def serialize_name
|
18
|
+
"Link"
|
19
|
+
end
|
20
|
+
|
21
|
+
def serialize_variables
|
22
|
+
[ :id, :integration_id, :url, :name, :description ].map {
|
23
|
+
|p| {
|
24
|
+
:id => p,
|
25
|
+
:type => :string
|
26
|
+
}
|
27
|
+
} +
|
28
|
+
[
|
29
|
+
{ :id => :created_by, :type => :coworker_reference },
|
30
|
+
{ :id => :organization, :type => :organization_reference },
|
31
|
+
{ :id => :deal, :type => :deal_reference }
|
32
|
+
]
|
33
|
+
end
|
34
|
+
|
35
|
+
def organization=(org)
|
36
|
+
@organization = OrganizationReference.from_organization(org)
|
37
|
+
end
|
38
|
+
|
39
|
+
def deal=(deal)
|
40
|
+
@deal = DealReference.from_deal(deal)
|
41
|
+
end
|
42
|
+
|
43
|
+
def created_by=(coworker)
|
44
|
+
@created_by = CoworkerReference.from_coworker(coworker)
|
45
|
+
end
|
46
|
+
|
47
|
+
def validate
|
48
|
+
error = String.new
|
49
|
+
|
50
|
+
if @url.nil? || @url.empty?
|
51
|
+
error = "Url is required for link\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
if @created_by.nil?
|
55
|
+
error = "#{error}Created_by is required for link\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
if @organization.nil? && @deal.nil?
|
59
|
+
error = "#{error}A link must have either an organization or a deal\n"
|
60
|
+
end
|
61
|
+
|
62
|
+
if !@organization.nil? && !@deal.nil?
|
63
|
+
error = "#{error}A link can't be attached to both an organization and a deal"
|
64
|
+
end
|
65
|
+
|
66
|
+
return error
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -7,6 +7,9 @@ module FruitToLime
|
|
7
7
|
attr_accessor :import_coworker
|
8
8
|
|
9
9
|
attr_accessor :settings, :organizations, :coworkers, :deals, :notes
|
10
|
+
|
11
|
+
attr_reader :documents
|
12
|
+
|
10
13
|
def serialize_variables
|
11
14
|
[
|
12
15
|
{:id => :settings, :type => :settings},
|
@@ -14,6 +17,7 @@ module FruitToLime
|
|
14
17
|
{:id => :organizations, :type => :organizations},
|
15
18
|
{:id => :deals, :type => :deals},
|
16
19
|
{:id => :notes, :type => :notes},
|
20
|
+
{:id => :documents, :type => :documents},
|
17
21
|
]
|
18
22
|
end
|
19
23
|
|
@@ -33,6 +37,7 @@ module FruitToLime
|
|
33
37
|
@coworkers.push @import_coworker
|
34
38
|
@deals = []
|
35
39
|
@notes = []
|
40
|
+
@documents = Documents.new
|
36
41
|
end
|
37
42
|
|
38
43
|
# Adds the specifed coworker object to the model.
|
@@ -202,13 +207,12 @@ module FruitToLime
|
|
202
207
|
return note
|
203
208
|
end
|
204
209
|
|
205
|
-
|
206
|
-
|
210
|
+
def add_link(link)
|
211
|
+
@documents = Documents.new if @documents == nil
|
212
|
+
|
213
|
+
return @documents.add_link(link)
|
214
|
+
end
|
207
215
|
|
208
|
-
# note = Note.new
|
209
|
-
# @notes.push note
|
210
|
-
# yield note
|
211
|
-
# end
|
212
216
|
|
213
217
|
def find_coworker_by_integration_id(integration_id)
|
214
218
|
return @coworkers.find do |coworker|
|
@@ -282,6 +286,12 @@ module FruitToLime
|
|
282
286
|
error = "#{error}\nDuplicate person integration_id: #{dups_error_items.join(", ")}."
|
283
287
|
end
|
284
288
|
|
289
|
+
dups = get_integration_id_duplicates(with_non_empty_integration_id(@documents.links))
|
290
|
+
dups_error_items = (dups.collect{|l| l.integration_id}).compact
|
291
|
+
if dups_error_items.length > 0
|
292
|
+
error = "#{error}\nDuplicate link integration_id: #{dups_error_items.join(", ")}."
|
293
|
+
end
|
294
|
+
|
285
295
|
return error.strip
|
286
296
|
end
|
287
297
|
|
@@ -312,6 +322,13 @@ module FruitToLime
|
|
312
322
|
end
|
313
323
|
end
|
314
324
|
|
325
|
+
@documents.links.each do |link|
|
326
|
+
validation_message = link.validate
|
327
|
+
if !validation_message.empty?
|
328
|
+
error = "#{error}\n#{validation_message}"
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
315
332
|
return error.strip
|
316
333
|
end
|
317
334
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe "Documents" do
|
5
|
+
let(:documents) {
|
6
|
+
FruitToLime::Documents.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "can add a new link" do
|
10
|
+
# given
|
11
|
+
link = FruitToLime::Link.new
|
12
|
+
link.integration_id = "123key"
|
13
|
+
link.url = "http://dropbox.com/files/readme.txt"
|
14
|
+
|
15
|
+
# when
|
16
|
+
documents.add_link link
|
17
|
+
|
18
|
+
# then
|
19
|
+
documents.find_link_by_integration_id("123key").url.should eq "http://dropbox.com/files/readme.txt"
|
20
|
+
documents.links.length.should eq 1
|
21
|
+
end
|
22
|
+
|
23
|
+
it "will not add a new link when a link with the same integration_id already exists" do
|
24
|
+
# given
|
25
|
+
documents.add_link({ :integration_id => "123", :url => "http://dropbox.com" })
|
26
|
+
documents.links.length.should eq 1
|
27
|
+
|
28
|
+
# when, then
|
29
|
+
expect {
|
30
|
+
documents.add_link({ :integration_id => "123", :url => "http://drive.google.com" })
|
31
|
+
}.to raise_error(FruitToLime::AlreadyAddedError)
|
32
|
+
documents.links.length.should eq 1
|
33
|
+
documents.find_link_by_integration_id("123").url.should eq "http://dropbox.com"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
data/spec/link_spec.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require 'fruit_to_lime'
|
3
|
+
|
4
|
+
describe "Link" do
|
5
|
+
let("link") {
|
6
|
+
FruitToLime::Link.new
|
7
|
+
}
|
8
|
+
|
9
|
+
it "is valid when it has url, created_by and organization" do
|
10
|
+
# given
|
11
|
+
link.url = "http://dropbox.com/"
|
12
|
+
link.created_by = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
13
|
+
link.organization = FruitToLime::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
|
14
|
+
|
15
|
+
# when, then
|
16
|
+
link.validate.should eq ""
|
17
|
+
end
|
18
|
+
|
19
|
+
it "is valid when it has url, created_by and deal" do
|
20
|
+
# given
|
21
|
+
link.url = "http://dropbox.com/"
|
22
|
+
link.created_by = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
23
|
+
link.deal = FruitToLime::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
|
24
|
+
|
25
|
+
# when, then
|
26
|
+
link.validate.should eq ""
|
27
|
+
end
|
28
|
+
|
29
|
+
it "is not valid when it has url and deal" do
|
30
|
+
# must have a created_by
|
31
|
+
# given
|
32
|
+
link.url = "http://dropbox.com/"
|
33
|
+
link.deal = FruitToLime::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
|
34
|
+
|
35
|
+
# when, then
|
36
|
+
link.validate.length.should be > 0
|
37
|
+
end
|
38
|
+
|
39
|
+
it "is not valid when it has url and created_by" do
|
40
|
+
# must have an deal or organization
|
41
|
+
# given
|
42
|
+
link.url = "http://dropbox.com/"
|
43
|
+
link.created_by = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
44
|
+
|
45
|
+
# when, then
|
46
|
+
link.validate.length.should be > 0
|
47
|
+
end
|
48
|
+
|
49
|
+
it "is not valid when it has deal and created_by" do
|
50
|
+
# must have an url
|
51
|
+
# given
|
52
|
+
link.created_by = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
53
|
+
link.deal = FruitToLime::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
|
54
|
+
|
55
|
+
# when, then
|
56
|
+
link.validate.length.should be > 0
|
57
|
+
end
|
58
|
+
|
59
|
+
it "is not valid when it has url, created_by, deal and orgaization" do
|
60
|
+
# given
|
61
|
+
link.url = "http://dropbox.com/"
|
62
|
+
link.created_by = FruitToLime::CoworkerReference.new( { :integration_id => "123", :heading => "billy bob" } )
|
63
|
+
link.deal = FruitToLime::DealReference.new({ :integration_id => "456", :heading => "The new deal" })
|
64
|
+
link.organization = FruitToLime::OrganizationReference.new({ :integration_id => "456", :heading => "Lundalogik" })
|
65
|
+
|
66
|
+
# when, then
|
67
|
+
link.validate.length.should be > 0
|
68
|
+
end
|
69
|
+
|
70
|
+
it "will auto convert org to org.ref during assignment" do
|
71
|
+
# given
|
72
|
+
org = FruitToLime::Organization.new({:integration_id => "123", :name => "Beagle Boys!"})
|
73
|
+
|
74
|
+
# when
|
75
|
+
link.organization = org
|
76
|
+
|
77
|
+
# then
|
78
|
+
link.organization.is_a?(FruitToLime::OrganizationReference).should eq true
|
79
|
+
end
|
80
|
+
|
81
|
+
it "will auto convert deal to deal.ref during assignment" do
|
82
|
+
# given
|
83
|
+
deal = FruitToLime::Deal.new({:integration_id => "123" })
|
84
|
+
deal.name = "The new deal"
|
85
|
+
|
86
|
+
# when
|
87
|
+
link.deal = deal
|
88
|
+
|
89
|
+
# then
|
90
|
+
link.deal.is_a?(FruitToLime::DealReference).should eq true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "will auto convert coworker to coworker.ref during assignment" do
|
94
|
+
# given
|
95
|
+
coworker = FruitToLime::Coworker.new({:integration_id => "123" })
|
96
|
+
coworker.parse_name_to_firstname_lastname_se "Billy Bob"
|
97
|
+
|
98
|
+
# when
|
99
|
+
link.created_by = coworker
|
100
|
+
|
101
|
+
# then
|
102
|
+
link.created_by.is_a?(FruitToLime::CoworkerReference).should eq true
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
end
|
data/spec/rootmodel_spec.rb
CHANGED
@@ -224,6 +224,20 @@ describe "RootModel" do
|
|
224
224
|
rootmodel.coworkers.length.should eq 1
|
225
225
|
end
|
226
226
|
|
227
|
+
it "will add a new link" do
|
228
|
+
# given
|
229
|
+
link = FruitToLime::Link.new
|
230
|
+
link.integration_id = "123key"
|
231
|
+
link.url = "http://dropbox.com/files/readme.txt"
|
232
|
+
|
233
|
+
# when
|
234
|
+
rootmodel.add_link link
|
235
|
+
|
236
|
+
# then
|
237
|
+
rootmodel.documents.find_link_by_integration_id("123key").url.should eq "http://dropbox.com/files/readme.txt"
|
238
|
+
rootmodel.documents.links.length.should eq 1
|
239
|
+
end
|
240
|
+
|
227
241
|
it "will not add a new organizations when the organizations is already added (same integration id)" do
|
228
242
|
# given
|
229
243
|
rootmodel.add_note({
|
@@ -336,4 +350,22 @@ describe "RootModel" do
|
|
336
350
|
|
337
351
|
rootmodel.sanity_check.should eq "Duplicate person integration_id: 1."
|
338
352
|
end
|
353
|
+
|
354
|
+
it "will report when two links has the same integration id during sanity check" do
|
355
|
+
# given
|
356
|
+
link1 = FruitToLime::Link.new
|
357
|
+
link1.integration_id = "1"
|
358
|
+
|
359
|
+
link2 = FruitToLime::Link.new
|
360
|
+
link2.integration_id = "2"
|
361
|
+
|
362
|
+
rootmodel.add_link link1
|
363
|
+
rootmodel.add_link link2
|
364
|
+
|
365
|
+
# when
|
366
|
+
link2.integration_id = "1"
|
367
|
+
|
368
|
+
# then
|
369
|
+
rootmodel.sanity_check.should eq "Duplicate link integration_id: 1."
|
370
|
+
end
|
339
371
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
DUMMY
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'fruit_to_lime'
|
2
|
+
require 'roo'
|
3
|
+
require 'dbf'
|
4
|
+
|
5
|
+
# Customize this file to suit your input for a VISMA database.
|
6
|
+
# You'll need KUND.DBS and KONTAKTER.DBS
|
7
|
+
#
|
8
|
+
# Documentation fruit_to_lime can be found at
|
9
|
+
# http://rubygems.org/gems/fruit_to_lime
|
10
|
+
#
|
11
|
+
# Fruit_to_lime contains all objects in LIME Go such as organization,
|
12
|
+
# people, deals, etc. What properties each object has is described in
|
13
|
+
# the documentation.
|
14
|
+
|
15
|
+
# *** TODO:
|
16
|
+
#
|
17
|
+
# This template will convert the files KUNDER.dbs and KONTAKTER.DBS to LIME Go. You
|
18
|
+
# should modify the Converted class suit your input file.
|
19
|
+
#
|
20
|
+
# Try this template with the template.xlsx file to generate a go.xml
|
21
|
+
#file:
|
22
|
+
# ruby convert.rb to_go lime-go.xml
|
23
|
+
|
24
|
+
class Converter
|
25
|
+
def configure(model)
|
26
|
+
# Add custom field to your model here. Custom fields can be
|
27
|
+
# added to organization, deal and person. Valid types are
|
28
|
+
# :String and :Link. If no type is specified :String is used
|
29
|
+
# as default.
|
30
|
+
|
31
|
+
#Creates a custom field to add invoicing data
|
32
|
+
model.settings.with_organization do |org|
|
33
|
+
org.set_custom_field( { :integrationid => 'ackoms', :title => 'Fakturerat', :type => :String } )
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def import_person_to_organization(row)
|
38
|
+
person = to_person(row)
|
39
|
+
organization = @rootmodel.find_organization_by_integration_id(row['KUNDNR'])
|
40
|
+
|
41
|
+
if !organization.nil?
|
42
|
+
organization.add_employee(person)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_organization(row)
|
47
|
+
organization = FruitToLime::Organization.new()
|
48
|
+
|
49
|
+
#Add tags:
|
50
|
+
organization.set_tag "Importerad"
|
51
|
+
organization.set_tag "Kund"
|
52
|
+
|
53
|
+
organization.name = row['NAMN']
|
54
|
+
# Integrationid is typically the id in the system that we are
|
55
|
+
# getting the csv from. Must be set to be able to import the
|
56
|
+
# same file more than once without creating duplicates
|
57
|
+
organization.integration_id = row['KUNDNR']
|
58
|
+
|
59
|
+
#address
|
60
|
+
organization.with_postal_address do |address|
|
61
|
+
address.street = row['POSTADR']
|
62
|
+
address.zip_code = row['POSTNR']
|
63
|
+
address.city = row['ORT']
|
64
|
+
end
|
65
|
+
|
66
|
+
organization.email = row['EPOST']
|
67
|
+
organization.organization_number = row['ORGNR']
|
68
|
+
organization.central_phone_number = row['TEL']
|
69
|
+
|
70
|
+
# Sets the organization's relation. Relation must be a value
|
71
|
+
# from FruitToLime::Relation.
|
72
|
+
organization.relation = FruitToLime::Relation::IsACustomer
|
73
|
+
|
74
|
+
#Fill data to custom fields
|
75
|
+
organization.set_custom_field({:integration_id=>"ackoms", :value=>row["ACKOMS"]})
|
76
|
+
|
77
|
+
return organization
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_note(row)
|
81
|
+
note = FruitToLime::Note.new()
|
82
|
+
|
83
|
+
# *** TODO:
|
84
|
+
#
|
85
|
+
# Set note properties from the row.
|
86
|
+
organization = @rootmodel.find_organization_by_integration_id(row['KUNDNR'])
|
87
|
+
unless organization.nil?
|
88
|
+
note.organization = organization.to_reference
|
89
|
+
end
|
90
|
+
note.created_by = @rootmodel.import_coworker
|
91
|
+
note.text = row['ANTECK_1']
|
92
|
+
|
93
|
+
return note
|
94
|
+
end
|
95
|
+
|
96
|
+
def to_person(row)
|
97
|
+
person = FruitToLime::Person.new()
|
98
|
+
|
99
|
+
# *** TODO:
|
100
|
+
#
|
101
|
+
# Set person properties from the row.
|
102
|
+
|
103
|
+
person.parse_name_to_firstname_lastname_se(row['NAMN'])
|
104
|
+
if FruitToLime::EmailHelper.is_valid?(row['EPOST'])
|
105
|
+
person.email = row['EPOST']
|
106
|
+
end
|
107
|
+
person.mobile_phone_number = FruitToLime::PhoneHelper.parse_numbers(row['MBTEL'], [",", "/", "\\"])
|
108
|
+
person.direct_phone_number = FruitToLime::PhoneHelper.parse_numbers(row['TEL'], [",", "/", "\\"])
|
109
|
+
|
110
|
+
return person
|
111
|
+
end
|
112
|
+
|
113
|
+
def to_model()
|
114
|
+
# First we read each database into separate variables
|
115
|
+
puts "Reading data from './Databas/'"
|
116
|
+
organization_rows = DBF::Table.new("./Databas/KUND.DBF")
|
117
|
+
person_rows = DBF::Table.new("./Databas/KONTAKT.DBF")
|
118
|
+
|
119
|
+
# Then we create a rootmodel that should contain all data that
|
120
|
+
# should be exported to LIME Go.
|
121
|
+
@rootmodel = FruitToLime::RootModel.new
|
122
|
+
|
123
|
+
# And configure the model if we have any custom fields
|
124
|
+
puts "Adding custom fields to model"
|
125
|
+
configure @rootmodel
|
126
|
+
|
127
|
+
# Then create organizations, they are only referenced by
|
128
|
+
# coworkers.
|
129
|
+
puts "Importing Organization..."
|
130
|
+
organization_rows.each do |row|
|
131
|
+
if not row.nil?
|
132
|
+
if not row["NAMN"] == ""
|
133
|
+
@rootmodel.add_organization(to_organization(row))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
puts "Imported #{@rootmodel.organizations.length} Organization"
|
138
|
+
|
139
|
+
# Add people and link them to their organizations
|
140
|
+
puts "Importing Persons..."
|
141
|
+
imported_person_count = 0
|
142
|
+
person_rows.each do |row|
|
143
|
+
# People are special since they are not added directly to
|
144
|
+
# the root model
|
145
|
+
if not row.nil?
|
146
|
+
if not row["KUNDNR"] == "" and not row["NAMN"] == ""
|
147
|
+
import_person_to_organization(row)
|
148
|
+
imported_person_count = nbrPersons + 1
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
puts "Imported #{imported_person_count} Persons"
|
153
|
+
|
154
|
+
# Deals can connected to coworkers, organizations and people.
|
155
|
+
# deal_rows.each do |row|
|
156
|
+
# @rootmodel.add_deal(to_deal(row))
|
157
|
+
# end
|
158
|
+
|
159
|
+
# Notes must be owned by a coworker and the be added to
|
160
|
+
# organizations and notes and might refernce a person
|
161
|
+
puts "Importing Notes..."
|
162
|
+
organization_rows.each do |row|
|
163
|
+
if not row.nil?
|
164
|
+
if row['ANTECK_1'].length > 0
|
165
|
+
@rootmodel.add_note(to_note(row))
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
return @rootmodel
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# You don't need to change anything below this line.
|
175
|
+
|
176
|
+
require "thor"
|
177
|
+
require "fileutils"
|
178
|
+
require 'pathname'
|
179
|
+
|
180
|
+
class Cli < Thor
|
181
|
+
desc "to_go GO_DATA_FILENAME", "Converts VISMA 'KUND.DBS' and 'KONTAKTER.DBS' to Go xml format. Place the DBS-files in the folder 'Databas'. GO_DATA_FILENAME is output file where Go xml will go."
|
182
|
+
def to_go(go_data_filename = nil)
|
183
|
+
go_data_filename = 'go-data.xml' if go_data_filename == nil
|
184
|
+
converter = Converter.new()
|
185
|
+
model = converter.to_model()
|
186
|
+
error = model.sanity_check
|
187
|
+
if error.empty?
|
188
|
+
validation_errors = model.validate
|
189
|
+
|
190
|
+
if validation_errors.empty?
|
191
|
+
model.serialize_to_file(go_data_filename)
|
192
|
+
puts "VISMA data has been converted into '#{go_data_filename}'."
|
193
|
+
else
|
194
|
+
puts "VISMA database could not be converted due to"
|
195
|
+
puts validation_errors
|
196
|
+
end
|
197
|
+
else
|
198
|
+
puts "VISMA database could not be converted due to"
|
199
|
+
puts error
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -301,8 +301,8 @@ class Exporter
|
|
301
301
|
model.settings.with_deal do |deal|
|
302
302
|
# assessment is default DealState::NoEndState
|
303
303
|
deal.add_status( {:label => '1. Kvalificering' })
|
304
|
-
deal.add_status( {:label => '2. Deal closed', :assessment => DealState::PositiveEndState })
|
305
|
-
deal.add_status( {:label => '4. Deal lost', :assessment => DealState::NegativeEndState })
|
304
|
+
deal.add_status( {:label => '2. Deal closed', :assessment => FruitToLime::DealState::PositiveEndState })
|
305
|
+
deal.add_status( {:label => '4. Deal lost', :assessment => FruitToLime::DealState::NegativeEndState })
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
@@ -348,7 +348,7 @@ class Exporter
|
|
348
348
|
# depends on organizations
|
349
349
|
if persons_filename && !persons_filename.empty?
|
350
350
|
process_rows persons_filename do |row|
|
351
|
-
people[row['personIndex']] = "#{row['
|
351
|
+
people[row['personIndex']] = "#{row['PowerSellReferenceID']}-#{row['PowerSellCompanyID']}"
|
352
352
|
# adds it self to the employer
|
353
353
|
to_person(row)
|
354
354
|
end
|
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.
|
4
|
+
version: 2.7.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-
|
15
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: iso_country_codes
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- lib/fruit_to_lime/model/deal_status.rb
|
184
184
|
- lib/fruit_to_lime/model/deal_status_reference.rb
|
185
185
|
- lib/fruit_to_lime/model/deal_status_setting.rb
|
186
|
+
- lib/fruit_to_lime/model/documents.rb
|
187
|
+
- lib/fruit_to_lime/model/link.rb
|
186
188
|
- lib/fruit_to_lime/model/note.rb
|
187
189
|
- lib/fruit_to_lime/model/organization.rb
|
188
190
|
- lib/fruit_to_lime/model/person.rb
|
@@ -231,6 +233,11 @@ files:
|
|
231
233
|
- templates/sqlserver/Rakefile.rb
|
232
234
|
- templates/sqlserver/spec/spec_helper.rb
|
233
235
|
- templates/sqlserver/spec/tomodel_spec.rb
|
236
|
+
- templates/VISMA/convert.rb
|
237
|
+
- templates/VISMA/Databas/KUND.DBS
|
238
|
+
- templates/VISMA/Gemfile
|
239
|
+
- templates/VISMA/lib/tomodel.rb
|
240
|
+
- templates/VISMA/Rakefile.rb
|
234
241
|
- lib/fruit_to_lime/global_phone.json
|
235
242
|
- spec/address_spec.rb
|
236
243
|
- spec/class_settings_spec.rb
|
@@ -239,12 +246,14 @@ files:
|
|
239
246
|
- spec/deal_class_settings_spec.rb
|
240
247
|
- spec/deal_spec.rb
|
241
248
|
- spec/deal_status_reference_spec.rb
|
249
|
+
- spec/documents_spec.rb
|
242
250
|
- spec/helpers/csv_helper_spec.rb
|
243
251
|
- spec/helpers/email_helper_spec.rb
|
244
252
|
- spec/helpers/phone_helper_spec.rb
|
245
253
|
- spec/helpers/roo_helper_spec.rb
|
246
254
|
- spec/helpers/serialize_helper_spec.rb
|
247
255
|
- spec/helpers/xsd_validate_spec.rb
|
256
|
+
- spec/link_spec.rb
|
248
257
|
- spec/note_spec.rb
|
249
258
|
- spec/organization_spec.rb
|
250
259
|
- spec/person_spec.rb
|
@@ -283,12 +292,14 @@ test_files:
|
|
283
292
|
- spec/deal_class_settings_spec.rb
|
284
293
|
- spec/deal_spec.rb
|
285
294
|
- spec/deal_status_reference_spec.rb
|
295
|
+
- spec/documents_spec.rb
|
286
296
|
- spec/helpers/csv_helper_spec.rb
|
287
297
|
- spec/helpers/email_helper_spec.rb
|
288
298
|
- spec/helpers/phone_helper_spec.rb
|
289
299
|
- spec/helpers/roo_helper_spec.rb
|
290
300
|
- spec/helpers/serialize_helper_spec.rb
|
291
301
|
- spec/helpers/xsd_validate_spec.rb
|
302
|
+
- spec/link_spec.rb
|
292
303
|
- spec/note_spec.rb
|
293
304
|
- spec/organization_spec.rb
|
294
305
|
- spec/person_spec.rb
|