sqlite-export-for-ynab 2.9.1__py3-none-any.whl

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.
@@ -0,0 +1,334 @@
1
+ CREATE TABLE IF NOT EXISTS plans (
2
+ id TEXT PRIMARY KEY
3
+ , name TEXT
4
+ , currency_format_currency_symbol TEXT
5
+ , currency_format_decimal_digits INT
6
+ , currency_format_decimal_separator TEXT
7
+ , currency_format_display_symbol BOOLEAN
8
+ , currency_format_group_separator TEXT
9
+ , currency_format_iso_code TEXT
10
+ , currency_format_symbol_first BOOLEAN
11
+ , last_knowledge_of_server INT
12
+ )
13
+ ;
14
+
15
+ CREATE TABLE IF NOT EXISTS accounts (
16
+ id TEXT PRIMARY KEY
17
+ , plan_id TEXT
18
+ , balance INT
19
+ , balance_formatted TEXT
20
+ , balance_currency REAL
21
+ , cleared_balance INT
22
+ , cleared_balance_formatted TEXT
23
+ , cleared_balance_currency REAL
24
+ , closed BOOLEAN
25
+ , debt_original_balance INT
26
+ , deleted BOOLEAN
27
+ , direct_import_in_error BOOLEAN
28
+ , direct_import_linked BOOLEAN
29
+ , last_reconciled_at TEXT
30
+ , name TEXT
31
+ , note TEXT
32
+ , on_budget BOOLEAN
33
+ , transfer_payee_id TEXT
34
+ , type TEXT
35
+ , uncleared_balance INT
36
+ , uncleared_balance_formatted TEXT
37
+ , uncleared_balance_currency REAL
38
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
39
+ )
40
+ ;
41
+
42
+ CREATE TABLE IF NOT EXISTS account_periodic_values (
43
+ "date" TEXT
44
+ , name TEXT
45
+ , plan_id TEXT
46
+ , account_id TEXT
47
+ , amount INT
48
+ , PRIMARY KEY ("date", name, plan_id, account_id)
49
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
50
+ , FOREIGN KEY (account_id) REFERENCES accounts (id)
51
+ )
52
+ ;
53
+
54
+ CREATE TABLE IF NOT EXISTS category_groups (
55
+ id TEXT PRIMARY KEY
56
+ , plan_id TEXT
57
+ , name TEXT
58
+ , hidden BOOLEAN
59
+ , internal BOOLEAN
60
+ , deleted BOOLEAN
61
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
62
+ )
63
+ ;
64
+
65
+ CREATE TABLE IF NOT EXISTS categories (
66
+ id TEXT PRIMARY KEY
67
+ , plan_id TEXT
68
+ , category_group_id TEXT
69
+ , category_group_name TEXT
70
+ , name TEXT
71
+ , hidden BOOLEAN
72
+ , internal BOOLEAN
73
+ , original_category_group_id TEXT
74
+ , note TEXT
75
+ , budgeted INT
76
+ , budgeted_formatted TEXT
77
+ , budgeted_currency REAL
78
+ , activity INT
79
+ , activity_formatted TEXT
80
+ , activity_currency REAL
81
+ , balance INT
82
+ , balance_formatted TEXT
83
+ , balance_currency REAL
84
+ , goal_type TEXT
85
+ , goal_needs_whole_amount BOOLEAN
86
+ , goal_day INT
87
+ , goal_cadence INT
88
+ , goal_cadence_frequency INT
89
+ , goal_creation_month TEXT
90
+ , goal_snoozed_at TEXT
91
+ , goal_target INT
92
+ , goal_target_formatted TEXT
93
+ , goal_target_currency REAL
94
+ , goal_target_date TEXT
95
+ , goal_target_month TEXT
96
+ , goal_percentage_complete INT
97
+ , goal_months_to_budget INT
98
+ , goal_under_funded INT
99
+ , goal_under_funded_formatted TEXT
100
+ , goal_under_funded_currency REAL
101
+ , goal_overall_funded INT
102
+ , goal_overall_funded_formatted TEXT
103
+ , goal_overall_funded_currency REAL
104
+ , goal_overall_left INT
105
+ , goal_overall_left_formatted TEXT
106
+ , goal_overall_left_currency REAL
107
+ , deleted BOOLEAN
108
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
109
+ , FOREIGN KEY (category_group_id) REFERENCES category_groups (id)
110
+ )
111
+ ;
112
+
113
+ CREATE TABLE IF NOT EXISTS payees (
114
+ id TEXT PRIMARY KEY
115
+ , plan_id TEXT
116
+ , name TEXT
117
+ , transfer_account_id TEXT
118
+ , deleted BOOLEAN
119
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
120
+ )
121
+ ;
122
+
123
+ CREATE TABLE IF NOT EXISTS transactions (
124
+ id TEXT PRIMARY KEY
125
+ , plan_id TEXT
126
+ , account_id TEXT
127
+ , account_name TEXT
128
+ , amount INT
129
+ , amount_formatted TEXT
130
+ , amount_currency REAL
131
+ , approved BOOLEAN
132
+ , category_id TEXT
133
+ , category_name TEXT
134
+ , cleared TEXT
135
+ , "date" TEXT
136
+ , debt_transaction_type TEXT
137
+ , deleted BOOLEAN
138
+ , flag_color TEXT
139
+ , flag_name TEXT
140
+ , import_id TEXT
141
+ , import_payee_name TEXT
142
+ , import_payee_name_original TEXT
143
+ , matched_transaction_id TEXT
144
+ , memo TEXT
145
+ , payee_id TEXT
146
+ , payee_name TEXT
147
+ , transfer_account_id TEXT
148
+ , transfer_transaction_id TEXT
149
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
150
+ , FOREIGN KEY (account_id) REFERENCES accounts (id)
151
+ , FOREIGN KEY (category_id) REFERENCES categories (id)
152
+ , FOREIGN KEY (payee_id) REFERENCES payees (id)
153
+ )
154
+ ;
155
+
156
+ CREATE TABLE IF NOT EXISTS subtransactions (
157
+ id TEXT PRIMARY KEY
158
+ , plan_id TEXT
159
+ , amount INT
160
+ , amount_formatted TEXT
161
+ , amount_currency REAL
162
+ , category_id TEXT
163
+ , category_name TEXT
164
+ , deleted BOOLEAN
165
+ , memo TEXT
166
+ , payee_id TEXT
167
+ , payee_name TEXT
168
+ , transaction_id TEXT
169
+ , transfer_account_id TEXT
170
+ , transfer_transaction_id TEXT
171
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
172
+ , FOREIGN KEY (transfer_account_id) REFERENCES accounts (id)
173
+ , FOREIGN KEY (category_id) REFERENCES categories (id)
174
+ , FOREIGN KEY (payee_id) REFERENCES payees (id)
175
+ , FOREIGN KEY (transaction_id) REFERENCES transactions (id)
176
+ )
177
+ ;
178
+
179
+ CREATE VIEW IF NOT EXISTS flat_transactions AS
180
+ SELECT
181
+ t.id AS transaction_id
182
+ , st.id AS subtransaction_id
183
+ , t.plan_id
184
+ , t.account_id
185
+ , t.account_name
186
+ , t.cleared
187
+ , t."date"
188
+ , t.debt_transaction_type
189
+ , t.flag_color
190
+ , t.flag_name
191
+ , t.import_id
192
+ , t.import_payee_name
193
+ , t.import_payee_name_original
194
+ , t.matched_transaction_id
195
+ , c.category_group_id
196
+ , c.category_group_name
197
+ , COALESCE(st.id, t.id) AS id
198
+ , COALESCE(st.amount, t.amount) AS amount
199
+ , COALESCE(st.amount_formatted, t.amount_formatted) AS amount_formatted
200
+ , COALESCE(st.amount_currency, t.amount_currency) AS amount_currency
201
+ , CASE
202
+ WHEN st.id IS NULL THEN t.category_id ELSE st.category_id END
203
+ AS category_id
204
+ , CASE
205
+ WHEN st.id IS NULL THEN t.category_name ELSE st.category_name END
206
+ AS category_name
207
+ , COALESCE(NULLIF(st.memo, ''), NULLIF(t.memo, '')) AS memo
208
+ , COALESCE(st.payee_id, t.payee_id) AS payee_id
209
+ , COALESCE(st.payee_name, t.payee_name) AS payee_name
210
+ , COALESCE(st.transfer_account_id, t.transfer_account_id)
211
+ AS transfer_account_id
212
+ , COALESCE(st.transfer_transaction_id, t.transfer_transaction_id)
213
+ AS transfer_transaction_id
214
+ FROM
215
+ transactions AS t
216
+ LEFT JOIN subtransactions AS st
217
+ ON (
218
+ t.plan_id = st.plan_id
219
+ AND t.id = st.transaction_id
220
+ )
221
+ INNER JOIN categories AS c
222
+ ON (
223
+ t.plan_id = c.plan_id
224
+ AND c.id
225
+ = CASE
226
+ WHEN st.id IS NULL THEN t.category_id ELSE st.category_id
227
+ END
228
+ )
229
+ WHERE
230
+ TRUE
231
+ AND t.approved
232
+ AND NOT COALESCE(st.deleted, t.deleted)
233
+ ;
234
+
235
+ CREATE TABLE IF NOT EXISTS scheduled_transactions (
236
+ id TEXT PRIMARY KEY
237
+ , plan_id TEXT
238
+ , account_id TEXT
239
+ , account_name TEXT
240
+ , amount INT
241
+ , amount_formatted TEXT
242
+ , amount_currency REAL
243
+ , category_id TEXT
244
+ , category_name TEXT
245
+ , date_first TEXT
246
+ , date_next TEXT
247
+ , deleted BOOLEAN
248
+ , flag_color TEXT
249
+ , flag_name TEXT
250
+ , frequency TEXT
251
+ , memo TEXT
252
+ , payee_id TEXT
253
+ , payee_name TEXT
254
+ , transfer_account_id TEXT
255
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
256
+ , FOREIGN KEY (account_id) REFERENCES accounts (id)
257
+ , FOREIGN KEY (category_id) REFERENCES categories (id)
258
+ , FOREIGN KEY (payee_id) REFERENCES payees (id)
259
+ , FOREIGN KEY (transfer_account_id) REFERENCES accounts (id)
260
+ )
261
+ ;
262
+
263
+ CREATE TABLE IF NOT EXISTS scheduled_subtransactions (
264
+ id TEXT PRIMARY KEY
265
+ , plan_id TEXT
266
+ , scheduled_transaction_id TEXT
267
+ , amount INT
268
+ , amount_formatted TEXT
269
+ , amount_currency REAL
270
+ , memo TEXT
271
+ , payee_id TEXT
272
+ , payee_name TEXT
273
+ , category_id TEXT
274
+ , category_name TEXT
275
+ , transfer_account_id TEXT
276
+ , deleted BOOLEAN
277
+ , FOREIGN KEY (plan_id) REFERENCES plans (id)
278
+ , FOREIGN KEY (transfer_account_id) REFERENCES accounts (id)
279
+ , FOREIGN KEY (category_id) REFERENCES categories (id)
280
+ , FOREIGN KEY (payee_id) REFERENCES payees (id)
281
+ , FOREIGN KEY (
282
+ scheduled_transaction_id
283
+ ) REFERENCES scheduled_transactions (id)
284
+ )
285
+ ;
286
+
287
+ CREATE VIEW IF NOT EXISTS scheduled_flat_transactions AS
288
+ SELECT
289
+ t.id AS transaction_id
290
+ , st.id AS subtransaction_id
291
+ , t.plan_id
292
+ , t.account_id
293
+ , t.account_name
294
+ , t.date_first
295
+ , t.date_next
296
+ , t.flag_color
297
+ , t.flag_name
298
+ , t.frequency
299
+ , c.category_group_id
300
+ , c.category_group_name
301
+ , COALESCE(st.payee_name, t.payee_name) AS payee_name
302
+ , COALESCE(st.id, t.id) AS id
303
+ , COALESCE(st.amount, t.amount) AS amount
304
+ , COALESCE(st.amount_formatted, t.amount_formatted) AS amount_formatted
305
+ , COALESCE(st.amount_currency, t.amount_currency) AS amount_currency
306
+ , CASE
307
+ WHEN st.id IS NULL THEN t.category_id ELSE st.category_id END
308
+ AS category_id
309
+ , CASE
310
+ WHEN st.id IS NULL THEN t.category_name ELSE st.category_name END
311
+ AS category_name
312
+ , COALESCE(NULLIF(st.memo, ''), NULLIF(t.memo, '')) AS memo
313
+ , COALESCE(st.payee_id, t.payee_id) AS payee_id
314
+ , COALESCE(st.transfer_account_id, t.transfer_account_id)
315
+ AS transfer_account_id
316
+ FROM
317
+ scheduled_transactions AS t
318
+ LEFT JOIN scheduled_subtransactions AS st
319
+ ON (
320
+ t.plan_id = st.plan_id
321
+ AND t.id = st.scheduled_transaction_id
322
+ )
323
+ INNER JOIN categories AS c
324
+ ON (
325
+ t.plan_id = c.plan_id
326
+ AND c.id
327
+ = CASE
328
+ WHEN st.id IS NULL THEN t.category_id ELSE st.category_id
329
+ END
330
+ )
331
+ WHERE
332
+ TRUE
333
+ AND NOT COALESCE(st.deleted, t.deleted)
334
+ ;
@@ -0,0 +1,23 @@
1
+ DROP TABLE IF EXISTS plans;
2
+
3
+ DROP TABLE IF EXISTS accounts;
4
+
5
+ DROP TABLE IF EXISTS account_periodic_values;
6
+
7
+ DROP TABLE IF EXISTS category_groups;
8
+
9
+ DROP TABLE IF EXISTS categories;
10
+
11
+ DROP TABLE IF EXISTS payees;
12
+
13
+ DROP TABLE IF EXISTS transactions;
14
+
15
+ DROP TABLE IF EXISTS subtransactions;
16
+
17
+ DROP VIEW IF EXISTS flat_transactions;
18
+
19
+ DROP TABLE IF EXISTS scheduled_transactions;
20
+
21
+ DROP TABLE IF EXISTS scheduled_subtransactions;
22
+
23
+ DROP VIEW IF EXISTS scheduled_flat_transactions;
File without changes