-
Notifications
You must be signed in to change notification settings - Fork 1
/
Customers.sql
71 lines (61 loc) · 2.43 KB
/
Customers.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
Use this as a starter for an import from Visma Business.
Remember that Visma Business-installations are like snow flakes, so consult with your client and/or their
significant Visma Business consultant in order to get this as right as possible.
There are no such thing as two identical Visma Business installations.
*/
SELECT
[name] = a.Nm,
[number] = a.CustNo,
[accountReference] = a.CustNo,
[corporateId] = a.BsNo,
[vatRegistrationId] = a.BsNo,
[customerClass] = '1',
[currencyId] = ISNULL(Cur.ISO, 'NOK'),
[status] = 'Active',
[creditVerification] = NULL,
[creditLimit] = NULL,
[creditDaysPastDue] = NULL,
[mainAddress.addressLine1] = a.ad1,
[mainAddress.addressLine2] = a.ad2,
[mainAddress.addressLine3] = a.ad3,
[mainAddress.country] = ISNULL(Ctry.ISO, 'NO'),
[mainAddress.postalCode] = a.PNo,
[mainContact.name] = a.Nm,
[mainContact.email] = Mail.MailAd,
[mainContact.web] = NULL,
[mainContact.phone1] = a.Phone,
[mainContact.fax] = NULL,
-- You might want to set these based on the information the Visma Business consultant gives you.
--[deliveryAddress.addressLine1] = DelACt.Ad1,
--[deliveryAddress.addressLine2] = DelACt.Ad2,
--[deliveryAddress.addressLine3] = DelACt.Ad3,
--[deliveryAddress.country] = NULL,
--[deliveryAddress.postalCode] = DelACt.PNo,
--[invoiceAddress.addressLine1] = NULL,
--[invoiceAddress.addressLine2] = NULL,
--[invoiceAddress.addressLine3] = NULL,
--[invoiceAddress.country] = NULL,
--[invoiceAddress.postalCode] = NULL,
--[deliveryContact.name] = NULL,
--[deliveryContact.email] = NULL,
--[deliveryContact.phone1] = NULL,
--[deliveryContact.phone2] = NULL,
--[deliveryContact.fax] = NULL,
--[invoiceContact.name] = NULL,
--[invoiceContact.email] = NULL,
--[invoiceContact.phone1] = NULL,
--[invoiceContact.phone2] = NULL,
--[invoiceContact.fax] = NULL,
[acceptAutoInvoices] = 1,
[printInvoices] = 0,
[sendInvoicesByEmail] = 0,
[printStatements] = 1,
[sendStatementsByEmail] = 0,
[printMultiCurrencyStatements] = 0
FROM dbo.Actor A
LEFT OUTER JOIN dbo.cur cur on cur.CurNo = A.Cur
LEFT OUTER JOIN dbo.ctry ctry on ctry.CtryNo = A.ctry
-- Make sure the e-mail address is valid, and remove those who are not.
OUTER APPLY (SELECT CASE WHEN A.MailAd LIKE '%@%.%' THEN A.MailAd ELSE NULL END MailAd)Mail
WHERE A.CustNo > 0