-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.sql
328 lines (294 loc) · 12.4 KB
/
template.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
CREATE TABLE `Users` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `ContactID` integer NOT NULL DEFAULT '0'
, `Email` varchar(64) NOT NULL DEFAULT ''
, `Password` varchar(64) NOT NULL DEFAULT ''
, `Status` varchar(64) NOT NULL DEFAULT ''
);
CREATE TABLE `Contacts` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `Name` varchar(64) NOT NULL DEFAULT ''
, `Address` varchar(64) NOT NULL DEFAULT ''
, `Zipcode` varchar(64) NOT NULL DEFAULT ''
, `City` varchar(64) NOT NULL DEFAULT ''
, `Country` varchar(64) NOT NULL DEFAULT ''
, `VATnumber` varchar(64) NOT NULL DEFAULT ''
, `RegistrationNumber` varchar(64) NOT NULL DEFAULT ''
, `Phone` varchar(64) NOT NULL DEFAULT ''
, `Email` varchar(64) NOT NULL DEFAULT ''
, `Member` varchar NOT NULL DEFAULT ''
, `Status` varchar(64) NOT NULL DEFAULT ''
);
CREATE TABLE `Projects` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `AccountID` integer NOT NULL DEFAULT '0'
, `UserIDs` varchar(64) NOT NULL DEFAULT ''
, `Status` varchar(64) NOT NULL DEFAULT ''
, `Name` varchar(64) NOT NULL DEFAULT ''
);
CREATE TABLE `Accounts` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `PID` integer NOT NULL DEFAULT '0'
, `RGS` varchar(32) NOT NULL DEFAULT ''
, `Name` varchar(64) NOT NULL DEFAULT ''
);
--Generic values for all entries
CREATE TABLE `Entries` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `TransactionDate` date NOT NULL DEFAULT '0000-00-00' -- date of invoice, bank transfer etc
, `AccountingDate` date NOT NULL DEFAULT '0000-00-00' -- date of uploading into accounting
, `PeriodFrom` date NOT NULL DEFAULT '0000-00-00'
, `PeriodTo` date NOT NULL DEFAULT '0000-00-00'
, `URL` varchar(63) NOT NULL DEFAULT '' -- URL or location of the entry , transaction list line x, invoice 201, purchases folder 1
, `Log` text NOT NULL DEFAULT ''
);
--BOOKS: purchases, sales, bank, memorial
--properties of purchases
CREATE TABLE 'Purchases' (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `EntryID` integer NOT NULL DEFAULT ''
, `Status` integer NOT NULL DEFAULT '0' -- status in review process
, `Reference` varchar(63) NOT NULL DEFAULT '' -- reference number or description
, `ContactID` integer NOT NULL DEFAULT '0' -- ID of contact that submits the reciept, recieves the invoice, or to/from bank transfer
, `SupplierID` integer NOT NULL DEFAULT '0' -- in case of a declaration, the supplier is different from the contactID
, `ProjectID` integer NOT NULL DEFAULT '0' -- ID of project
, `Charge` integer Not NULL DEFAULT '0' -- If the expense/purchase needs to be charged on the invoice for the project 0=no,1=to charge,2=charged
);
--properties of sales
CREATE TABLE 'Sales' (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `EntryID` integer NOT NULL DEFAULT ''
, `Status` integer NOT NULL DEFAULT '0' -- status in review process
, `Reference` varchar(63) NOT NULL DEFAULT '' -- reference number or description
, `ContactID` integer NOT NULL DEFAULT '0' -- ID of contact that recieves the invoice
, `ProjectID` integer NOT NULL DEFAULT '0' -- ID of project
);
--properties of a bank transaction
CREATE TABLE 'Bank' (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `EntryID` integer NOT NULL DEFAULT ''
, `StatementID` integer NOT NULL DEFAULT '' -- used to prevent double import of bank statements
, `Description` varchar(63) NOT NULL DEFAULT ''
, `FromPaymentEndpointID` integer NOT NULL DEFAULT '0'
, `ToPaymentEndpointID` integer NOT NULL DEFAULT '0'
);
--properties of a memorial -- Memorial has no status, always done by admin
CREATE TABLE 'Memorial' (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `EntryID` integer NOT NULL DEFAULT ''
, `Description` varchar(63) NOT NULL DEFAULT '' -- Larger description to explain booking
, `ContactID` integer DEFAULT '0' -- ID of contact that recieves the invoice
, `ProjectID` integer DEFAULT '0' -- ID of project
);
CREATE TABLE `Transactions` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `EntryID` integer NOT NULL DEFAULT '0' --refers to the entry to which the transaction belongs
, `MergeID`integer DEFAULT NULL --merging on the level of transactions?
);
CREATE TABLE `Mutations` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `TransactionID` integer NOT NULL DEFAULT '0' --refers to the transaction to which the mutation belongs
, `AccountID` integer NOT NULL DEFAULT '0' --the account to which the mutation should be booked
, `Amount` decimal(10,2) NOT NULL DEFAULT '0.00' --the amount
);
CREATE TABLE `PaymentProviders` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `AccountID` integer NOT NULL --account ID in accounting structure (PID=3)
, `Name` varchar(63) NOT NULL DEFAULT '' --Triodos, PayPal, Mollie, ...
, `Account` varchar(63) NOT NULL DEFAULT '' --banks own account number identifier (IBAN, email, ...)
, `API` varchar(63) NOT NULL DEFAULT ''
);
CREATE TABLE `PaymentEndpoint` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `ContactID` integer NOT NULL DEFAULT '0' --account
, `PaymentProviderID` integer NOT NULL DEFAULT '0'
, `Account` varchar(63) NOT NULL DEFAULT '' --account number
, `API` varchar(63) NOT NULL DEFAULT ''
);
CREATE TABLE `Log` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `Timestamp` datetime NOT NULL DEFAULT '0'
, `UserID` integer NOT NULL DEFAULT '0'
, `Message` text NOT NULL DEFAULT ''
);
CREATE TABLE `Merge` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `MergeDate` date NOT NULL DEFAULT '0'
);
CREATE TABLE `Rules` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `Name` varchar(64) NOT NULL DEFAULT ''
, `Json` text NOT NULL DEFAULT ''
);
/*
CREATE TABLE `ObligationTypes` (
`ID` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `Name` varchar(64) NOT NULL DEFAULT ''
, `Mutations` text
);
CREATE TABLE `Obligations` (
ID INT PRIMARY KEY NOT NULL,
Type TEXT NOT NULL // type=in/verkoop, lening, investering, projectverplichting (de typen verplichting hebben een niveau, bon-bank is niveau 0, projectverplichting hoogste niveau)
);
*/
INSERT INTO `Accounts` (ID, PID, RGS, Name) VALUES
(1,0,'B','balansrekeningen'),
(11,1,'BMva','materiële vaste activa'),
(111,11,'BMvaMei','machines en installaties'),
(1111,111,'BMvaMeiCae','Cumulatieve afschrijvingen en waardeverminderingen'),
(12,1,'BVrd','vooraden'),
(13,1,'BVor','vorderingen'),
(131,13,'BVorDeb','debiteuren (te ontvangen)'),
(132,13,'BVorOva','overlopende activa'),
(14,1,'BLim','liquide middelen'),
(141,14,'BLimKas','Kasmiddelen'),
(142,14,'BLimBan','Tegoeden op bankgirorekeningen'),
(1421,142,'','triodos'),
(1422,142,'','mollie'),
(1423,142,'','paypal'),
(1424,142,'','sumup'),
(15,1,'BEiv','Eigen vermogen'),
(151,15,'BEivSev','Kapitaal stichting, coöperatie en vereniging'),
(152,15,'BEivBef','Bestemmingsfondsen'),
(1521,152,'','Projectenfonds'),
/*(153,41,'BEivKap','Eigen vermogen onderneming natuurlijke personen'),
(1531,413,'BEivKapOnd','Ondernemingsvermogen exclusief fiscale reserves fiscaal'),*/
(154,15,'BEivFir','Fiscale reserves'),
(1541,154,'BEivFirHer','Herinvesteringsreserve fiscaal'),
/*(1542,414,'BEivFirFor','Fiscale oudedagsreserve'),*/
(16,1,'BLas','langlopende schulden'),
(161,16,'BLasAcl','achtergestelde schulden'),
(162,16,'BLasSakCla','schulden aan banken'), /*geen niveau er onder*/
(163,16,'BLasOvp','Overlopende passiva'),
(1631,163,'BSchOpaNtb','Nog te betalen andere kosten'),
(17,1,'BSch','kortlopende schulden'),
(171,17,'BSchKol','Kortlopende leningen-schulden-verplichtingen'),
(172,17,'BSchSak','schulden aan banken'),
(173,17,'BSchCre','crediteuren (te betalen)'),
(174,17,'BSchBep','Belastingen en premies sociale verzekeringen'),
(1741,174,'BSchBepBtw','Te betalen Omzetbelasting'),
(17411,1741,'BSchBepBtwOla','Omzetbelasting leveringen/diensten belast met hoog tarief'),
(17412,1741,'BSchBepBtwOlv','Omzetbelasting leveringen/diensten belast met laag tarief '),
(17413,1741,'BSchBepBtwOlw','Omzetbelasting leveringen/diensten waarbij de omzetbelasting naar u is verlegd '),
(17414,1741,'BSchBepBtwOlu','Omzetbelasting leveringen/diensten uit landen binnen EU '),
(17415,1741,'BSchBepBtwVoo','Voorbelasting'),
(17416,1741,'BSchBepBtwAfo','Afgedragen omzetbelasting '),
(17417,1741,'BSchBepBtwOvm','Overige mutaties omzetbelasting'),
(174171,17417,'','Omzetbelasting leveringen/diensten belast met nul tarief'),
(174172,17417,'','Omzetbelasting leveringen/diensten vrijgesteld van btw'),
(1742,174,'BSchBepVpb','Te betalen Vennootschapsbelasting'),
(17421,1742,'BSchBepVpbAav','Aangifte vennootschapsbelasting '),
(17422,1742,'BSchBepVpbTvv','Te verrekenen vennootschapsbelasting'),
(17423,1742,'BSchBepVpbAfv','Afgedragen vennootschapsbelasting'),
(175,17,'BSchOpa','overlopende passiva'),
(1751,173,'BSchOpaNto','Nog te ontvangen facturen'),
(1752,173,'BSchOpaNtb','Nog te betalen andere kosten'),
(18,1,'BVrz','voorzieningen'),
(181,18,'BVrzOvz','overige voorzieningen'),
(1811,181,'BVrzOvzVhe','Voorziening voor herstelkosten'),
(2,0,'W','Winst en verliesrekening'),
(21,2,'WOmz','Netto-omzet'),
(211,21,'WOmzNoo','Overige netto-omzet'),
(212,21,'WOmzGrp','Netto-omzet groepen'),
(22,2,'WRev','Netto resultaat exploitatie van vastgoedportefeuille'),
(221,22,'WRevHuo','Huuropbrengsten'),
(222,22,'WRevOsc','Opbrengsten servicecontracten'),
(223,22,'WRevLsc','Lasten servicecontracten'),
(224,22,'WRevLvb','Lasten verhuur en beheeractiviteiten'),
(225,22,'WRevLoa','Lasten onderhoudsactiviteiten'),
(23,2,'WNoa','Netto resultaat overige activiteiten'),
(231,23,'WNoaOoa','Opbrengsten overige activiteiten'),
(232,23,'WNoaKoa','Kosten overige activiteiten'),
(24,2,'WAkf','algemene beheerskosten'),
(25,2,'WWiv','wijziging voorraden'),
(26,2,'WKpr','kostprijs van de omzet'),
(261,26,'WKprKuw','kosten uitbesteed werk en andere externe kosten'),
(262,26,'WKprKra','kosten van rente en afschrijvingen'),
(27,2,'WOvb','Overige bedrijfsopbrengsten'),
(28,2,'WAfs','Afschrijvingen op immateriële en materiële vaste activa'),
(29,2,'WBed','Overige bedrijfskosten'),
(291,29,'WBedHui','Huisvestingskosten'),
(292,29,'WBedEem','Exploitatie- en machinekosten'),
(293,29,'WBedVkk','Verkoop gerelateerde kosten'),
(294,29,'WBedAut','Autokosten'),
(295,29,'WBedTra','Transportkosten'),
(296,29,'WBedKan','Kantoorkosten'),
(297,29,'WBedOrg','Organisatiekosten'),
(298,29,'WBedAss','Assurantiekosten'),
(299,29,'WBedAea','Accountants- en advieskosten'),
(300,29,'WBedAlk','Andere kosten'),
(31,2,'WFbe','Financiële baten en lasten'),
(32,2,'WBel','Belastingen'),
(33,2,'WLbe','Ledenbetalingen (inclusief reeds betaalde voorschotten)'),
(34,2,'WNer','Nettoresultaat')
/*(35,2,'WMfo','Mutatie fiscale oudedagsreserve'),*/
;
INSERT INTO `PaymentProviders` (ID, AccountID, Name, Account, API) VALUES
(1,36,'Triodos','ABCD1234','{
"addHeaderRow": "\"datum\",\"eigenRekening\",\"bedrag\",\"creditDebet\",\"wederpartij\",\"rekeningWederpartij\",\"transactiecode\",\"omschrijving\"",
"fieldSeparator": ",",
"stringDelimiter": "\"",
"dateField": "datum",
"dateFormat": "mm-dd-YYYY",
"amountField": "bedrag",
"amountFormat": ",",
"signField": "creditDebet",
"signFieldMinusValue": "Debet",
"descriptionField": "omschrijving",
"accountField": "wederpartij",
"paymentEndPointField": "rekeningWederpartij",
"transactionFeeField": "",
"transactionID": ""
}'),
(2,37,'Mollie','','{
"addHeaderRow": "",
"fieldSeparator": ",",
"stringDelimiter": "\"",
"dateField": "Datum",
"dateFormat": "YYYY-mm-dd H:M:s",
"amountField": "Bedrag",
"amountFormat": "",
"signField": "",
"signFieldMinusValue": "",
"descriptionField": "Omschrijving",
"accountField": "Naam consument",
"paymentEndPointField": "Rekening consument",
"transactionFeeField": "",
"transactionID": "ID"
}'),
(3,38,'PayPal','[email protected]','{
"addHeaderRow": "",
"fieldSeparator": ",",
"stringDelimiter": "\"",
"dateField": "Date",
"dateFormat": "mm-dd-YYYY",
"amountField": "Gross",
"amountFormat": "",
"signField": "",
"signFieldMinusValue": "",
"descriptionField": "Subject",
"accountField": "Name",
"paymentEndPointField": "",
"transactionFeeField": "Fee",
"transactionID": "Transaction ID"
}'),
(4,39,'Sumup','','{
"addHeaderRow": "",
"fieldSeparator": ",",
"stringDelimiter": "",
"dateField": "Datum",
"dateFormat": "YYYY-mm-dd H:M:s",
"amountField": "Totaal bedrag",
"amountFormat": "",
"signField": "",
"signFieldMinusValue": "",
"descriptionField": "Beschrijving",
"accountField": "",
"paymentEndPointField": "Laatste 4 cijfers",
"transactionFeeField": "Transactiekosten",
"transactionID": "Transactie ID"
}');
-- ~ INSERT INTO `TransactionTypes` (ID, Name, MutationFormula) VALUES
-- ~ (1,'transfer', '3=1'),
-- ~ (2,'purchase', '5=12+6'),
-- ~ (3,'sale', '4=13+6');