From d72da795947c8c9251ddd59245633fed40ba5f62 Mon Sep 17 00:00:00 2001 From: Max R Date: Tue, 15 Jul 2025 06:45:22 -0700 Subject: [PATCH 1/8] Save budget currency data --- sqlite_export_for_ynab/_main.py | 31 ++++++++++- .../ddl/create-relations.sql | 53 ++++++++++++------ testing/fixtures.py | 43 +++++++-------- tests/_main_test.py | 55 ++++++++----------- 4 files changed, 107 insertions(+), 75 deletions(-) diff --git a/sqlite_export_for_ynab/_main.py b/sqlite_export_for_ynab/_main.py index ba57140..9bda60a 100644 --- a/sqlite_export_for_ynab/_main.py +++ b/sqlite_export_for_ynab/_main.py @@ -211,8 +211,35 @@ def insert_budgets( cur: sqlite3.Cursor, budgets: list[dict[str, Any]], lkos: dict[str, int] ) -> None: cur.executemany( - "INSERT OR REPLACE INTO budgets (id, name, last_knowledge_of_server) VALUES (?, ?, ?)", - ((bid := b["id"], b["name"], lkos[bid]) for b in budgets), + """ + INSERT OR REPLACE INTO budgets ( + id + , name + , currency_format_currency_symbol + , currency_format_decimal_digits + , currency_format_decimal_separator + , currency_format_display_symbol + , currency_format_group_separator + , currency_format_iso_code + , currency_format_symbol_first + , last_knowledge_of_server + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + """, + ( + ( + bid := b["id"], + b["name"], + b["currency_format"]["currency_symbol"], + b["currency_format"]["decimal_digits"], + b["currency_format"]["decimal_separator"], + b["currency_format"]["display_symbol"], + b["currency_format"]["group_separator"], + b["currency_format"]["iso_code"], + b["currency_format"]["symbol_first"], + lkos[bid], + ) + for b in budgets + ), ) diff --git a/sqlite_export_for_ynab/ddl/create-relations.sql b/sqlite_export_for_ynab/ddl/create-relations.sql index 9bb05a0..a367b29 100644 --- a/sqlite_export_for_ynab/ddl/create-relations.sql +++ b/sqlite_export_for_ynab/ddl/create-relations.sql @@ -1,6 +1,13 @@ CREATE TABLE IF NOT EXISTS budgets ( id TEXT PRIMARY KEY , name TEXT + , currency_format_currency_symbol TEXT + , currency_format_decimal_digits INT + , currency_format_decimal_separator TEXT + , currency_format_display_symbol BOOLEAN + , currency_format_group_separator TEXT + , currency_format_iso_code TEXT + , currency_format_symbol_first BOOLEAN , last_knowledge_of_server INT ) ; @@ -161,17 +168,26 @@ SELECT , COALESCE(st.id, t.id) AS id , COALESCE(st.amount, t.amount) AS amount , COALESCE(st.amount, t.amount) / -1000.0 AS amount_major - , CASE WHEN st.id IS NULL THEN t.category_id ELSE st.category_id END - AS category_id - , CASE WHEN st.id IS NULL THEN t.category_name ELSE st.category_name END - AS category_name - , COALESCE(NULLIF(st.memo, ''), NULLIF(t.memo, '')) AS memo + , CASE + WHEN + COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + THEN COALESCE(st.category_id, t.category_id) + END AS category_id + , CASE + WHEN + COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + THEN COALESCE(st.category_name, t.category_name) + END AS category_name + , COALESCE(st.deleted, t.deleted) AS deleted + , COALESCE(st.memo, t.memo) AS memo , COALESCE(st.payee_id, t.payee_id) AS payee_id , COALESCE(st.payee_name, t.payee_name) AS payee_name , COALESCE(st.transfer_account_id, t.transfer_account_id) AS transfer_account_id - , COALESCE(st.transfer_transaction_id, t.transfer_transaction_id) - AS transfer_transaction_id + , COALESCE( + st.transfer_transaction_id + , t.transfer_transaction_id + ) AS transfer_transaction_id FROM transactions AS t LEFT JOIN subtransactions AS st @@ -179,9 +195,6 @@ LEFT JOIN subtransactions AS st t.budget_id = st.budget_id AND t.id = st.transaction_id ) -WHERE - TRUE - AND NOT COALESCE(st.deleted, t.deleted) ; CREATE TABLE IF NOT EXISTS scheduled_transactions ( @@ -245,11 +258,18 @@ SELECT , COALESCE(st.id, t.id) AS id , COALESCE(st.amount, t.amount) AS amount , COALESCE(st.amount, t.amount) / -1000.0 AS amount_major - , CASE WHEN st.id IS NULL THEN t.category_id ELSE st.category_id END - AS category_id - , CASE WHEN st.id IS NULL THEN t.category_name ELSE st.category_name END - AS category_name - , COALESCE(NULLIF(st.memo, ''), NULLIF(t.memo, '')) AS memo + , CASE + WHEN + COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + THEN COALESCE(st.category_id, t.category_id) + END AS category_id + , CASE + WHEN + COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + THEN COALESCE(st.category_name, t.category_name) + END AS category_name + , COALESCE(st.deleted, t.deleted) AS deleted + , COALESCE(st.memo, t.memo) AS memo , COALESCE(st.payee_id, t.payee_id) AS payee_id , COALESCE(st.transfer_account_id, t.transfer_account_id) AS transfer_account_id @@ -260,7 +280,4 @@ LEFT JOIN scheduled_subtransactions AS st t.budget_id = st.budget_id AND t.id = st.scheduled_transaction_id ) -WHERE - TRUE - AND NOT COALESCE(st.deleted, t.deleted) ; diff --git a/testing/fixtures.py b/testing/fixtures.py index c808f66..39405a0 100644 --- a/testing/fixtures.py +++ b/testing/fixtures.py @@ -18,10 +18,30 @@ { "id": BUDGET_ID_1, "name": "Budget 1", + "currency_format": { + "currency_symbol": "$", + "decimal_digits": 2, + "decimal_separator": ".", + "display_symbol": True, + "example_format": "123,456.78", + "group_separator": ",", + "iso_code": "USD", + "symbol_first": True, + }, }, { "id": BUDGET_ID_2, "name": "Budget 2", + "currency_format": { + "currency_symbol": "$", + "decimal_digits": 2, + "decimal_separator": ".", + "display_symbol": True, + "example_format": "123,456.78", + "group_separator": ",", + "iso_code": "USD", + "symbol_first": True, + }, }, ] @@ -123,7 +143,6 @@ 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()) @@ -133,19 +152,16 @@ "id": TRANSACTION_ID_1, "date": "2024-01-01", "amount": -10000, - "deleted": False, "subtransactions": [ { "id": SUBTRANSACTION_ID_1, "transaction_id": TRANSACTION_ID_1, "amount": -7500, - "deleted": False, }, { "id": SUBTRANSACTION_ID_2, "transaction_id": TRANSACTION_ID_1, "amount": -2500, - "deleted": False, }, ], }, @@ -153,21 +169,12 @@ "id": TRANSACTION_ID_2, "date": "2024-02-01", "amount": -15000, - "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()) @@ -176,18 +183,15 @@ { "id": SCHEDULED_TRANSACTION_ID_1, "amount": -12000, - "deleted": False, "subtransactions": [ { "id": SCHEDULED_SUBTRANSACTION_ID_1, "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, - "deleted": False, "amount": -8040, }, { "id": SCHEDULED_SUBTRANSACTION_ID_2, "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, - "deleted": False, "amount": -2960, }, ], @@ -195,13 +199,6 @@ { "id": SCHEDULED_TRANSACTION_ID_2, "amount": -11000, - "deleted": True, - "subtransactions": [], - }, - { - "id": SCHEDULED_TRANSACTION_ID_3, - "amount": -9000, - "deleted": False, "subtransactions": [], }, ] diff --git a/tests/_main_test.py b/tests/_main_test.py index 6322547..5ea3594 100644 --- a/tests/_main_test.py +++ b/tests/_main_test.py @@ -61,7 +61,6 @@ 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 @@ -71,7 +70,6 @@ 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 @@ -107,11 +105,25 @@ def test_insert_budgets(cur): { "id": BUDGET_ID_1, "name": BUDGETS[0]["name"], + "currency_format_currency_symbol": "$", + "currency_format_decimal_digits": 2, + "currency_format_decimal_separator": ".", + "currency_format_display_symbol": 1, + "currency_format_group_separator": ",", + "currency_format_iso_code": "USD", + "currency_format_symbol_first": 1, "last_knowledge_of_server": LKOS[BUDGET_ID_1], }, { "id": BUDGET_ID_2, "name": BUDGETS[1]["name"], + "currency_format_currency_symbol": "$", + "currency_format_decimal_digits": 2, + "currency_format_decimal_separator": ".", + "currency_format_display_symbol": 1, + "currency_format_group_separator": ",", + "currency_format_iso_code": "USD", + "currency_format_symbol_first": 1, "last_knowledge_of_server": LKOS[BUDGET_ID_2], }, ] @@ -244,21 +256,12 @@ def test_insert_transactions(cur): "budget_id": BUDGET_ID_1, "date": "2024-01-01", "amount": -10000, - "deleted": False, }, { "id": TRANSACTION_ID_2, "budget_id": BUDGET_ID_1, "date": "2024-02-01", "amount": -15000, - "deleted": True, - }, - { - "id": TRANSACTION_ID_3, - "budget_id": BUDGET_ID_1, - "date": "2024-03-01", - "amount": -19000, - "deleted": False, }, ] @@ -269,26 +272,24 @@ def test_insert_transactions(cur): "transaction_id": TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -7500, - "deleted": False, }, { "id": SUBTRANSACTION_ID_2, "transaction_id": TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -2500, - "deleted": False, }, ] cur.execute("SELECT * FROM flat_transactions ORDER BY amount") assert [strip_nones(d) for d in cur.fetchall()] == [ { - "transaction_id": TRANSACTION_ID_3, + "transaction_id": TRANSACTION_ID_2, "budget_id": BUDGET_ID_1, - "date": "2024-03-01", - "id": TRANSACTION_ID_3, - "amount": -19000, - "amount_major": pytest.approx(19), + "date": "2024-02-01", + "id": TRANSACTION_ID_2, + "amount": -15000, + "amount_major": pytest.approx(15), }, { "transaction_id": TRANSACTION_ID_1, @@ -324,19 +325,11 @@ def test_insert_scheduled_transactions(cur): "id": SCHEDULED_TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -12000, - "deleted": False, }, { "id": SCHEDULED_TRANSACTION_ID_2, "budget_id": BUDGET_ID_1, "amount": -11000, - "deleted": True, - }, - { - "id": SCHEDULED_TRANSACTION_ID_3, - "budget_id": BUDGET_ID_1, - "amount": -9000, - "deleted": False, }, ] @@ -347,25 +340,23 @@ def test_insert_scheduled_transactions(cur): "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -8040, - "deleted": False, }, { "id": SCHEDULED_SUBTRANSACTION_ID_2, "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -2960, - "deleted": False, }, ] 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, + "transaction_id": SCHEDULED_TRANSACTION_ID_2, "budget_id": BUDGET_ID_1, - "id": SCHEDULED_TRANSACTION_ID_3, - "amount": -9000, - "amount_major": pytest.approx(9), + "id": SCHEDULED_TRANSACTION_ID_2, + "amount": -11000, + "amount_major": pytest.approx(11), }, { "transaction_id": SCHEDULED_TRANSACTION_ID_1, From e5729d29d877f9854b589609a5736a082afde6c6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:45:53 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sqlite_export_for_ynab/ddl/create-relations.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sqlite_export_for_ynab/ddl/create-relations.sql b/sqlite_export_for_ynab/ddl/create-relations.sql index a367b29..51ad580 100644 --- a/sqlite_export_for_ynab/ddl/create-relations.sql +++ b/sqlite_export_for_ynab/ddl/create-relations.sql @@ -170,12 +170,12 @@ SELECT , COALESCE(st.amount, t.amount) / -1000.0 AS amount_major , CASE WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL THEN COALESCE(st.category_id, t.category_id) END AS category_id , CASE WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL THEN COALESCE(st.category_name, t.category_name) END AS category_name , COALESCE(st.deleted, t.deleted) AS deleted @@ -260,12 +260,12 @@ SELECT , COALESCE(st.amount, t.amount) / -1000.0 AS amount_major , CASE WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL THEN COALESCE(st.category_id, t.category_id) END AS category_id , CASE WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS null + COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL THEN COALESCE(st.category_name, t.category_name) END AS category_name , COALESCE(st.deleted, t.deleted) AS deleted From 7d18414aa79092bdc02aa5f52aff928201104c72 Mon Sep 17 00:00:00 2001 From: Max R Date: Tue, 15 Jul 2025 09:48:26 -0400 Subject: [PATCH 3/8] Update create-relations.sql --- .../ddl/create-relations.sql | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/sqlite_export_for_ynab/ddl/create-relations.sql b/sqlite_export_for_ynab/ddl/create-relations.sql index 51ad580..66c48a8 100644 --- a/sqlite_export_for_ynab/ddl/create-relations.sql +++ b/sqlite_export_for_ynab/ddl/create-relations.sql @@ -168,26 +168,17 @@ SELECT , COALESCE(st.id, t.id) AS id , COALESCE(st.amount, t.amount) AS amount , COALESCE(st.amount, t.amount) / -1000.0 AS amount_major - , CASE - WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL - THEN COALESCE(st.category_id, t.category_id) - END AS category_id - , CASE - WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL - THEN COALESCE(st.category_name, t.category_name) - END AS category_name - , COALESCE(st.deleted, t.deleted) AS deleted - , COALESCE(st.memo, t.memo) AS memo + , CASE WHEN st.id IS NULL THEN t.category_id ELSE st.category_id END + AS category_id + , CASE WHEN st.id IS NULL THEN t.category_name ELSE st.category_name END + AS category_name + , COALESCE(NULLIF(st.memo, ''), NULLIF(t.memo, '')) AS memo , COALESCE(st.payee_id, t.payee_id) AS payee_id , COALESCE(st.payee_name, t.payee_name) AS payee_name , COALESCE(st.transfer_account_id, t.transfer_account_id) AS transfer_account_id - , COALESCE( - st.transfer_transaction_id - , t.transfer_transaction_id - ) AS transfer_transaction_id + , COALESCE(st.transfer_transaction_id, t.transfer_transaction_id) + AS transfer_transaction_id FROM transactions AS t LEFT JOIN subtransactions AS st @@ -195,6 +186,9 @@ LEFT JOIN subtransactions AS st t.budget_id = st.budget_id AND t.id = st.transaction_id ) +WHERE + TRUE + AND NOT COALESCE(st.deleted, t.deleted) ; CREATE TABLE IF NOT EXISTS scheduled_transactions ( @@ -258,18 +252,11 @@ SELECT , COALESCE(st.id, t.id) AS id , COALESCE(st.amount, t.amount) AS amount , COALESCE(st.amount, t.amount) / -1000.0 AS amount_major - , CASE - WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL - THEN COALESCE(st.category_id, t.category_id) - END AS category_id - , CASE - WHEN - COALESCE(st.transfer_account_id, t.transfer_account_id) IS NULL - THEN COALESCE(st.category_name, t.category_name) - END AS category_name - , COALESCE(st.deleted, t.deleted) AS deleted - , COALESCE(st.memo, t.memo) AS memo + , CASE WHEN st.id IS NULL THEN t.category_id ELSE st.category_id END + AS category_id + , CASE WHEN st.id IS NULL THEN t.category_name ELSE st.category_name END + AS category_name + , COALESCE(NULLIF(st.memo, ''), NULLIF(t.memo, '')) AS memo , COALESCE(st.payee_id, t.payee_id) AS payee_id , COALESCE(st.transfer_account_id, t.transfer_account_id) AS transfer_account_id @@ -280,4 +267,8 @@ LEFT JOIN scheduled_subtransactions AS st t.budget_id = st.budget_id AND t.id = st.scheduled_transaction_id ) +WHERE + TRUE + AND NOT COALESCE(st.deleted, t.deleted) ; + From ea182e36edbd78efd93183bedccf582c1f896e15 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:48:38 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sqlite_export_for_ynab/ddl/create-relations.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/sqlite_export_for_ynab/ddl/create-relations.sql b/sqlite_export_for_ynab/ddl/create-relations.sql index 66c48a8..5ad0c4d 100644 --- a/sqlite_export_for_ynab/ddl/create-relations.sql +++ b/sqlite_export_for_ynab/ddl/create-relations.sql @@ -271,4 +271,3 @@ WHERE TRUE AND NOT COALESCE(st.deleted, t.deleted) ; - From ea97723ba3713586f7002ca7aab96dfe3dc86f10 Mon Sep 17 00:00:00 2001 From: Max R Date: Tue, 15 Jul 2025 09:49:36 -0400 Subject: [PATCH 5/8] Update fixtures.py --- testing/fixtures.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/testing/fixtures.py b/testing/fixtures.py index 39405a0..89f9f8e 100644 --- a/testing/fixtures.py +++ b/testing/fixtures.py @@ -18,7 +18,7 @@ { "id": BUDGET_ID_1, "name": "Budget 1", - "currency_format": { + "currency_format": { "currency_symbol": "$", "decimal_digits": 2, "decimal_separator": ".", @@ -32,7 +32,7 @@ { "id": BUDGET_ID_2, "name": "Budget 2", - "currency_format": { + "currency_format": { "currency_symbol": "$", "decimal_digits": 2, "decimal_separator": ".", @@ -143,6 +143,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()) @@ -152,16 +153,19 @@ "id": TRANSACTION_ID_1, "date": "2024-01-01", "amount": -10000, + "deleted": False, "subtransactions": [ { "id": SUBTRANSACTION_ID_1, "transaction_id": TRANSACTION_ID_1, "amount": -7500, + "deleted": False, }, { "id": SUBTRANSACTION_ID_2, "transaction_id": TRANSACTION_ID_1, "amount": -2500, + "deleted": False, }, ], }, @@ -169,12 +173,21 @@ "id": TRANSACTION_ID_2, "date": "2024-02-01", "amount": -15000, + "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()) @@ -183,15 +196,18 @@ { "id": SCHEDULED_TRANSACTION_ID_1, "amount": -12000, + "deleted": False, "subtransactions": [ { "id": SCHEDULED_SUBTRANSACTION_ID_1, "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, + "deleted": False, "amount": -8040, }, { "id": SCHEDULED_SUBTRANSACTION_ID_2, "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, + "deleted": False, "amount": -2960, }, ], @@ -199,6 +215,13 @@ { "id": SCHEDULED_TRANSACTION_ID_2, "amount": -11000, + "deleted": True, + "subtransactions": [], + }, + { + "id": SCHEDULED_TRANSACTION_ID_3, + "amount": -9000, + "deleted": False, "subtransactions": [], }, ] From 176d3ab1f424be3879a252de504e1635d309e0bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:49:48 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/fixtures.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/fixtures.py b/testing/fixtures.py index 89f9f8e..6784146 100644 --- a/testing/fixtures.py +++ b/testing/fixtures.py @@ -18,7 +18,7 @@ { "id": BUDGET_ID_1, "name": "Budget 1", - "currency_format": { + "currency_format": { "currency_symbol": "$", "decimal_digits": 2, "decimal_separator": ".", @@ -32,7 +32,7 @@ { "id": BUDGET_ID_2, "name": "Budget 2", - "currency_format": { + "currency_format": { "currency_symbol": "$", "decimal_digits": 2, "decimal_separator": ".", From 636f483eb8f48439455673ea0bc3386de53428bf Mon Sep 17 00:00:00 2001 From: Max R Date: Tue, 15 Jul 2025 09:50:40 -0400 Subject: [PATCH 7/8] Update _main_test.py --- tests/_main_test.py | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/tests/_main_test.py b/tests/_main_test.py index 5ea3594..3c2a844 100644 --- a/tests/_main_test.py +++ b/tests/_main_test.py @@ -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 @@ -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 @@ -105,7 +107,7 @@ def test_insert_budgets(cur): { "id": BUDGET_ID_1, "name": BUDGETS[0]["name"], - "currency_format_currency_symbol": "$", + "currency_format_currency_symbol": "$", "currency_format_decimal_digits": 2, "currency_format_decimal_separator": ".", "currency_format_display_symbol": 1, @@ -117,7 +119,7 @@ def test_insert_budgets(cur): { "id": BUDGET_ID_2, "name": BUDGETS[1]["name"], - "currency_format_currency_symbol": "$", + "currency_format_currency_symbol": "$", "currency_format_decimal_digits": 2, "currency_format_decimal_separator": ".", "currency_format_display_symbol": 1, @@ -256,12 +258,21 @@ def test_insert_transactions(cur): "budget_id": BUDGET_ID_1, "date": "2024-01-01", "amount": -10000, + "deleted": False, }, { "id": TRANSACTION_ID_2, "budget_id": BUDGET_ID_1, "date": "2024-02-01", "amount": -15000, + "deleted": True, + }, + { + "id": TRANSACTION_ID_3, + "budget_id": BUDGET_ID_1, + "date": "2024-03-01", + "amount": -19000, + "deleted": False, }, ] @@ -272,24 +283,26 @@ def test_insert_transactions(cur): "transaction_id": TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -7500, + "deleted": False, }, { "id": SUBTRANSACTION_ID_2, "transaction_id": TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -2500, + "deleted": False, }, ] cur.execute("SELECT * FROM flat_transactions ORDER BY amount") assert [strip_nones(d) for d in cur.fetchall()] == [ { - "transaction_id": TRANSACTION_ID_2, + "transaction_id": TRANSACTION_ID_3, "budget_id": BUDGET_ID_1, - "date": "2024-02-01", - "id": TRANSACTION_ID_2, - "amount": -15000, - "amount_major": pytest.approx(15), + "date": "2024-03-01", + "id": TRANSACTION_ID_3, + "amount": -19000, + "amount_major": pytest.approx(19), }, { "transaction_id": TRANSACTION_ID_1, @@ -325,11 +338,19 @@ def test_insert_scheduled_transactions(cur): "id": SCHEDULED_TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -12000, + "deleted": False, }, { "id": SCHEDULED_TRANSACTION_ID_2, "budget_id": BUDGET_ID_1, "amount": -11000, + "deleted": True, + }, + { + "id": SCHEDULED_TRANSACTION_ID_3, + "budget_id": BUDGET_ID_1, + "amount": -9000, + "deleted": False, }, ] @@ -340,23 +361,25 @@ def test_insert_scheduled_transactions(cur): "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -8040, + "deleted": False, }, { "id": SCHEDULED_SUBTRANSACTION_ID_2, "scheduled_transaction_id": SCHEDULED_TRANSACTION_ID_1, "budget_id": BUDGET_ID_1, "amount": -2960, + "deleted": False, }, ] cur.execute("SELECT * FROM scheduled_flat_transactions ORDER BY amount") assert [strip_nones(d) for d in cur.fetchall()] == [ { - "transaction_id": SCHEDULED_TRANSACTION_ID_2, + "transaction_id": SCHEDULED_TRANSACTION_ID_3, "budget_id": BUDGET_ID_1, - "id": SCHEDULED_TRANSACTION_ID_2, - "amount": -11000, - "amount_major": pytest.approx(11), + "id": SCHEDULED_TRANSACTION_ID_3, + "amount": -9000, + "amount_major": pytest.approx(9), }, { "transaction_id": SCHEDULED_TRANSACTION_ID_1, From 663028bc438c115ec56e9aed844d87897477d5f3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:50:54 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/_main_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/_main_test.py b/tests/_main_test.py index 3c2a844..7323865 100644 --- a/tests/_main_test.py +++ b/tests/_main_test.py @@ -107,7 +107,7 @@ def test_insert_budgets(cur): { "id": BUDGET_ID_1, "name": BUDGETS[0]["name"], - "currency_format_currency_symbol": "$", + "currency_format_currency_symbol": "$", "currency_format_decimal_digits": 2, "currency_format_decimal_separator": ".", "currency_format_display_symbol": 1, @@ -119,7 +119,7 @@ def test_insert_budgets(cur): { "id": BUDGET_ID_2, "name": BUDGETS[1]["name"], - "currency_format_currency_symbol": "$", + "currency_format_currency_symbol": "$", "currency_format_decimal_digits": 2, "currency_format_decimal_separator": ".", "currency_format_display_symbol": 1,