go_import 3.0.12 → 3.0.13
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.
- data/sources/VISMA/.go_import/runner.rb +1 -1
- data/sources/VISMA/converter.rb +0 -1
- data/sources/csv/.go_import/runner.rb +1 -1
- data/sources/csv/converter.rb +3 -3
- data/sources/easy/.go_import/runner.rb +7 -1
- data/sources/easy/converter.rb +7 -10
- data/sources/excel/.go_import/runner.rb +1 -1
- metadata +2 -3
- data/sources/VISMA/tomodel.rb +0 -202
data/sources/VISMA/converter.rb
CHANGED
@@ -36,7 +36,7 @@ def convert_source
|
|
36
36
|
if defined?(ORGANIZATION_FILE) && !ORGANIZATION_FILE.nil? && !ORGANIZATION_FILE.empty?
|
37
37
|
process_rows ORGANIZATION_FILE do |row|
|
38
38
|
organization = converter.to_organization(row, rootmodel)
|
39
|
-
organization.set_tag "
|
39
|
+
organization.set_tag "Import"
|
40
40
|
rootmodel.add_organization(organization)
|
41
41
|
end
|
42
42
|
end
|
data/sources/csv/converter.rb
CHANGED
@@ -94,9 +94,9 @@ class Converter
|
|
94
94
|
coworker = rootmodel.find_coworker_by_integration_id row['responsible_id']
|
95
95
|
organization.responsible_coworker = coworker.to_reference
|
96
96
|
|
97
|
-
#
|
98
|
-
#
|
99
|
-
organization.set_tag("
|
97
|
+
# Set tags for the organization. All organizations will get
|
98
|
+
# the tag "import" automagically
|
99
|
+
organization.set_tag("Guldkund")
|
100
100
|
|
101
101
|
# When imported from web based ERP or similair that
|
102
102
|
# client will continue to use it can be useful to be
|
@@ -105,7 +105,7 @@ end
|
|
105
105
|
|
106
106
|
def init_organization(row, rootmodel)
|
107
107
|
organization = GoImport::Organization.new
|
108
|
-
organization.set_tag "
|
108
|
+
organization.set_tag "Import"
|
109
109
|
# integration_id is typically the company Id in Easy
|
110
110
|
# Must be set to be able to import the same file more
|
111
111
|
# than once without creating duplicates
|
@@ -174,6 +174,9 @@ def to_organization_document(row, rootmodel)
|
|
174
174
|
file.name = row['Comment']
|
175
175
|
|
176
176
|
file.created_by = rootmodel.find_coworker_by_integration_id(row['idUser-Created'])
|
177
|
+
if file.created_by.nil?
|
178
|
+
file.created_by = rootmodel.import_coworker
|
179
|
+
end
|
177
180
|
|
178
181
|
org = rootmodel.find_organization_by_integration_id(row['idCompany'])
|
179
182
|
if org.nil?
|
@@ -192,6 +195,9 @@ def from_project_document_to_organization_document(row, includes, rootmodel)
|
|
192
195
|
file.name = row['Comment']
|
193
196
|
|
194
197
|
file.created_by = rootmodel.find_coworker_by_integration_id(row['idUser-Created'])
|
198
|
+
if file.created_by.nil?
|
199
|
+
file.created_by = rootmodel.import_coworker
|
200
|
+
end
|
195
201
|
|
196
202
|
organization_id = includes[row['idProject']]
|
197
203
|
org = rootmodel.find_organization_by_integration_id(organization_id)
|
data/sources/easy/converter.rb
CHANGED
@@ -130,10 +130,10 @@ class Converter
|
|
130
130
|
|
131
131
|
#####################################################################
|
132
132
|
## Tags.
|
133
|
-
#
|
134
|
-
#
|
133
|
+
# Set tags for the organization. All organizations will get
|
134
|
+
# the tag "import" automagically
|
135
135
|
|
136
|
-
# organization.set_tag("
|
136
|
+
# organization.set_tag("Guldkund")
|
137
137
|
|
138
138
|
#####################################################################
|
139
139
|
## Option fields.
|
@@ -192,10 +192,8 @@ class Converter
|
|
192
192
|
|
193
193
|
#####################################################################
|
194
194
|
## Tags.
|
195
|
-
#
|
196
|
-
#
|
197
|
-
|
198
|
-
# person.set_tag("Imported")
|
195
|
+
# Set tags for the person
|
196
|
+
# person.set_tag("VIP")
|
199
197
|
|
200
198
|
#####################################################################
|
201
199
|
## Checkbox fields.
|
@@ -263,10 +261,9 @@ class Converter
|
|
263
261
|
|
264
262
|
#####################################################################
|
265
263
|
## Tags.
|
266
|
-
#
|
267
|
-
# Setting a tag: Imported is useful for the user
|
264
|
+
# Set tags for the deal
|
268
265
|
|
269
|
-
# deal.set_tag("
|
266
|
+
# deal.set_tag("Product name")
|
270
267
|
|
271
268
|
return deal
|
272
269
|
end
|
@@ -95,7 +95,7 @@ def convert_source
|
|
95
95
|
puts "Trying to convert organizations..."
|
96
96
|
organization_rows.each do |row|
|
97
97
|
organization = converter.to_organization(row, rootmodel)
|
98
|
-
organization.set_tag "
|
98
|
+
organization.set_tag "Import"
|
99
99
|
rootmodel.add_organization(organization)
|
100
100
|
end
|
101
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.13
|
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-10-
|
15
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: iso_country_codes
|
@@ -237,7 +237,6 @@ files:
|
|
237
237
|
- sources/VISMA/Database/KONTAKT.DBF
|
238
238
|
- sources/VISMA/Database/KUND.DBF
|
239
239
|
- sources/VISMA/Gemfile
|
240
|
-
- sources/VISMA/tomodel.rb
|
241
240
|
- lib/go_import/global_phone.json
|
242
241
|
- spec/address_spec.rb
|
243
242
|
- spec/class_settings_spec.rb
|
data/sources/VISMA/tomodel.rb
DELETED
@@ -1,202 +0,0 @@
|
|
1
|
-
require 'go_import'
|
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 go_import can be found at
|
9
|
-
# http://rubygems.org/gems/go_import
|
10
|
-
#
|
11
|
-
# go_import 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 = GoImport::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 GoImport::Relation.
|
72
|
-
organization.relation = GoImport::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 = GoImport::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
|
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 = GoImport::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 GoImport::EmailHelper.is_valid?(row['EPOST'])
|
105
|
-
person.email = row['EPOST']
|
106
|
-
end
|
107
|
-
person.mobile_phone_number = GoImport::PhoneHelper.parse_numbers(row['MBTEL'], [",", "/", "\\"])
|
108
|
-
person.direct_phone_number = GoImport::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 = GoImport::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
|