Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions sqlite_export_for_ynab/ddl/create-relations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ LEFT JOIN subtransactions AS st
)
WHERE
TRUE
AND NOT t.deleted
AND NOT st.deleted
AND NOT COALESCE(st.deleted, t.deleted)
;

CREATE TABLE IF NOT EXISTS scheduled_transactions (
Expand Down Expand Up @@ -277,6 +276,5 @@ LEFT JOIN scheduled_subtransactions AS st
)
WHERE
TRUE
AND NOT t.deleted
AND NOT st.deleted
AND NOT COALESCE(st.deleted, t.deleted)
;
15 changes: 15 additions & 0 deletions testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@

TRANSACTION_ID_1 = str(uuid4())
TRANSACTION_ID_2 = str(uuid4())
TRANSACTION_ID_3 = str(uuid4())

SUBTRANSACTION_ID_1 = str(uuid4())
SUBTRANSACTION_ID_2 = str(uuid4())
Expand Down Expand Up @@ -155,10 +156,18 @@
"deleted": True,
"subtransactions": [],
},
{
"id": TRANSACTION_ID_3,
"date": "2024-03-01",
"amount": -19000,
"deleted": False,
"subtransactions": [],
},
]

SCHEDULED_TRANSACTION_ID_1 = str(uuid4())
SCHEDULED_TRANSACTION_ID_2 = str(uuid4())
SCHEDULED_TRANSACTION_ID_3 = str(uuid4())

SCHEDULED_SUBTRANSACTION_ID_1 = str(uuid4())
SCHEDULED_SUBTRANSACTION_ID_2 = str(uuid4())
Expand Down Expand Up @@ -189,6 +198,12 @@
"deleted": True,
"subtransactions": [],
},
{
"id": SCHEDULED_TRANSACTION_ID_3,
"amount": -9000,
"deleted": False,
"subtransactions": [],
},
]


Expand Down
30 changes: 30 additions & 0 deletions tests/_main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from testing.fixtures import SCHEDULED_SUBTRANSACTION_ID_2
from testing.fixtures import SCHEDULED_TRANSACTION_ID_1
from testing.fixtures import SCHEDULED_TRANSACTION_ID_2
from testing.fixtures import SCHEDULED_TRANSACTION_ID_3
from testing.fixtures import SCHEDULED_TRANSACTIONS
from testing.fixtures import SCHEDULED_TRANSACTIONS_ENDPOINT_RE
from testing.fixtures import SERVER_KNOWLEDGE_1
Expand All @@ -70,6 +71,7 @@
from testing.fixtures import TOKEN
from testing.fixtures import TRANSACTION_ID_1
from testing.fixtures import TRANSACTION_ID_2
from testing.fixtures import TRANSACTION_ID_3
from testing.fixtures import TRANSACTIONS
from testing.fixtures import TRANSACTIONS_ENDPOINT_RE

Expand Down Expand Up @@ -251,6 +253,13 @@ def test_insert_transactions(cur):
"amount": -15000,
"deleted": True,
},
{
"id": TRANSACTION_ID_3,
"budget_id": BUDGET_ID_1,
"date": "2024-03-01",
"amount": -19000,
"deleted": False,
},
]

cur.execute("SELECT * FROM subtransactions ORDER BY amount")
Expand All @@ -273,6 +282,14 @@ def test_insert_transactions(cur):

cur.execute("SELECT * FROM flat_transactions ORDER BY amount")
assert [strip_nones(d) for d in cur.fetchall()] == [
{
"transaction_id": TRANSACTION_ID_3,
"budget_id": BUDGET_ID_1,
"date": "2024-03-01",
"id": TRANSACTION_ID_3,
"amount": -19000,
"amount_major": pytest.approx(19),
},
{
"transaction_id": TRANSACTION_ID_1,
"subtransaction_id": SUBTRANSACTION_ID_1,
Expand Down Expand Up @@ -315,6 +332,12 @@ def test_insert_scheduled_transactions(cur):
"amount": -11000,
"deleted": True,
},
{
"id": SCHEDULED_TRANSACTION_ID_3,
"budget_id": BUDGET_ID_1,
"amount": -9000,
"deleted": False,
},
]

cur.execute("SELECT * FROM scheduled_subtransactions ORDER BY amount")
Expand All @@ -337,6 +360,13 @@ def test_insert_scheduled_transactions(cur):

cur.execute("SELECT * FROM scheduled_flat_transactions ORDER BY amount")
assert [strip_nones(d) for d in cur.fetchall()] == [
{
"transaction_id": SCHEDULED_TRANSACTION_ID_3,
"budget_id": BUDGET_ID_1,
"id": SCHEDULED_TRANSACTION_ID_3,
"amount": -9000,
"amount_major": pytest.approx(9),
},
{
"transaction_id": SCHEDULED_TRANSACTION_ID_1,
"subtransaction_id": SCHEDULED_SUBTRANSACTION_ID_1,
Expand Down