From c92e19f0a58b926ff0288751747b874b220d6de9 Mon Sep 17 00:00:00 2001 From: Arvin <17693119+vindard@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:26:52 -0400 Subject: [PATCH] refactor: rename charts entity name, rename code to path (#1242) --- bats/admin-gql/chart-of-accounts.gql | 2 +- ...d3b890daf7d8004f554f9ac18eff28d47e0f3.json | 18 -- ...b7f7099bbbef7dcd2229208690d7432e962c7.json | 40 +++ ...4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json | 6 +- ...24b2556641f7645161a2b7366506ae9c17ba6.json | 40 +++ ...dab344009ac41253ac4a0f58949f692f88f5f.json | 6 +- ...b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json | 4 +- ...96c1d92d856d6d1f41765dbdaf2293e275d72.json | 18 -- ...0005f934c3d68a6033a9cec6b5667b362ec43.json | 41 --- ...c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json | 40 --- ...fabf0c12b96f0484f783906f92a6b567dc3d.json} | 6 +- ...e6859d45a4420f97759f03f46e9772f32d8a.json} | 4 +- ...3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json | 41 +++ ...51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json | 42 --- ...6682001d1570b138fa4bbc9322d13dd3a8f12.json | 41 --- ...f66362d1b098a53fede2059bc0747807f40e.json} | 7 +- ...4b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json | 18 ++ ...993f78a76f2dead178e7af565756b220602f8.json | 18 ++ .../src/chart_of_accounts/entity.rs | 221 ++++++------- .../src/chart_of_accounts/error.rs | 18 +- .../src/chart_of_accounts/repo.rs | 10 +- core/chart-of-accounts/src/code/error.rs | 31 -- core/chart-of-accounts/src/error.rs | 14 +- core/chart-of-accounts/src/event.rs | 7 - core/chart-of-accounts/src/lib.rs | 36 +-- core/chart-of-accounts/src/path/error.rs | 29 ++ .../src/{code => path}/mod.rs | 297 +++++++++--------- core/chart-of-accounts/src/primitives.rs | 14 +- .../src/transaction_account_factory.rs | 22 +- ...d3b890daf7d8004f554f9ac18eff28d47e0f3.json | 18 -- ...b7f7099bbbef7dcd2229208690d7432e962c7.json | 40 +++ ...d2b3ce4d55d9506f35be87eaeacc2485c5f9.json} | 6 +- ...24b2556641f7645161a2b7366506ae9c17ba6.json | 40 +++ ...ab344009ac41253ac4a0f58949f692f88f5f.json} | 6 +- ...4b75706d1fd5f6fc72d6cd66cb32b0c56432.json} | 4 +- ...96c1d92d856d6d1f41765dbdaf2293e275d72.json | 18 -- ...0005f934c3d68a6033a9cec6b5667b362ec43.json | 41 --- ...c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json | 40 --- ...9fabf0c12b96f0484f783906f92a6b567dc3d.json | 6 +- ...0e6859d45a4420f97759f03f46e9772f32d8a.json | 4 +- ...3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json | 41 +++ ...51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json | 42 --- ...6682001d1570b138fa4bbc9322d13dd3a8f12.json | 41 --- ...ef66362d1b098a53fede2059bc0747807f40e.json | 7 +- ...4b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json | 18 ++ ...993f78a76f2dead178e7af565756b220602f8.json | 18 ++ core/deposit/src/error.rs | 6 +- core/deposit/tests/deposit.rs | 4 +- core/deposit/tests/withdraw.rs | 4 +- ...d3b890daf7d8004f554f9ac18eff28d47e0f3.json | 18 -- ...b7f7099bbbef7dcd2229208690d7432e962c7.json | 40 +++ ...d2b3ce4d55d9506f35be87eaeacc2485c5f9.json} | 6 +- ...24b2556641f7645161a2b7366506ae9c17ba6.json | 40 +++ ...dab344009ac41253ac4a0f58949f692f88f5f.json | 42 +++ ...b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json | 4 +- ...96c1d92d856d6d1f41765dbdaf2293e275d72.json | 18 -- ...0005f934c3d68a6033a9cec6b5667b362ec43.json | 41 --- ...c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json | 40 --- ...9fabf0c12b96f0484f783906f92a6b567dc3d.json | 42 +++ ...e6859d45a4420f97759f03f46e9772f32d8a.json} | 4 +- ...3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json | 41 +++ ...51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json | 42 --- ...6682001d1570b138fa4bbc9322d13dd3a8f12.json | 41 --- ...f66362d1b098a53fede2059bc0747807f40e.json} | 7 +- ...4b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json | 18 ++ ...993f78a76f2dead178e7af565756b220602f8.json | 18 ++ .../migrations/20240517074612_core_setup.sql | 6 +- lana/app/src/accounting_init/error.rs | 4 +- lana/app/src/accounting_init/mod.rs | 2 +- lana/app/src/accounting_init/primitives.rs | 16 +- lana/app/src/accounting_init/seed.rs | 18 +- lana/app/src/app/error.rs | 2 +- .../credit_chart_of_accounts/error.rs | 4 +- lana/app/src/ledger/error.rs | 4 +- ...d3b890daf7d8004f554f9ac18eff28d47e0f3.json | 18 -- ...b7f7099bbbef7dcd2229208690d7432e962c7.json | 40 +++ ...4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json | 6 +- ...24b2556641f7645161a2b7366506ae9c17ba6.json | 40 +++ ...dab344009ac41253ac4a0f58949f692f88f5f.json | 42 +++ ...4b75706d1fd5f6fc72d6cd66cb32b0c56432.json} | 4 +- ...96c1d92d856d6d1f41765dbdaf2293e275d72.json | 18 -- ...0005f934c3d68a6033a9cec6b5667b362ec43.json | 41 --- ...c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json | 40 --- ...9fabf0c12b96f0484f783906f92a6b567dc3d.json | 42 +++ ...0e6859d45a4420f97759f03f46e9772f32d8a.json | 4 +- ...3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json | 41 +++ ...51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json | 42 --- ...6682001d1570b138fa4bbc9322d13dd3a8f12.json | 41 --- ...ef66362d1b098a53fede2059bc0747807f40e.json | 7 +- ...4b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json | 18 ++ ...993f78a76f2dead178e7af565756b220602f8.json | 18 ++ 91 files changed, 1214 insertions(+), 1261 deletions(-) delete mode 100644 core/chart-of-accounts/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json create mode 100644 core/chart-of-accounts/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json rename lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json => core/chart-of-accounts/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json (63%) create mode 100644 core/chart-of-accounts/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json rename lana/app/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json => core/chart-of-accounts/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json (60%) rename lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json => core/chart-of-accounts/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json (53%) delete mode 100644 core/chart-of-accounts/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json delete mode 100644 core/chart-of-accounts/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json delete mode 100644 core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json rename core/{deposit/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json => chart-of-accounts/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json} (60%) rename core/chart-of-accounts/.sqlx/{query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json => query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json} (53%) create mode 100644 core/chart-of-accounts/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json delete mode 100644 core/chart-of-accounts/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json delete mode 100644 core/chart-of-accounts/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json rename core/chart-of-accounts/.sqlx/{query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json => query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json} (58%) create mode 100644 core/chart-of-accounts/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json create mode 100644 core/chart-of-accounts/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json delete mode 100644 core/chart-of-accounts/src/code/error.rs delete mode 100644 core/chart-of-accounts/src/event.rs create mode 100644 core/chart-of-accounts/src/path/error.rs rename core/chart-of-accounts/src/{code => path}/mod.rs (65%) delete mode 100644 core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json create mode 100644 core/deposit/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json rename core/deposit/.sqlx/{query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json => query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json} (63%) create mode 100644 core/deposit/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json rename core/{chart-of-accounts/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json => deposit/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json} (60%) rename core/deposit/.sqlx/{query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json => query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json} (53%) delete mode 100644 core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json delete mode 100644 core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json delete mode 100644 core/deposit/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json rename lana/dashboard/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json => core/deposit/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json (60%) rename lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json => core/deposit/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json (53%) create mode 100644 core/deposit/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json delete mode 100644 core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json delete mode 100644 core/deposit/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json rename lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json => core/deposit/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json (58%) create mode 100644 core/deposit/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json create mode 100644 core/deposit/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json delete mode 100644 lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json create mode 100644 lana/app/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json rename lana/{dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json => app/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json} (63%) create mode 100644 lana/app/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json create mode 100644 lana/app/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json rename core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json => lana/app/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json (53%) delete mode 100644 lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json delete mode 100644 lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json delete mode 100644 lana/app/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json create mode 100644 lana/app/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json rename lana/{dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json => app/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json} (53%) create mode 100644 lana/app/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json delete mode 100644 lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json delete mode 100644 lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json rename lana/{dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json => app/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json} (58%) create mode 100644 lana/app/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json create mode 100644 lana/app/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json delete mode 100644 lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json create mode 100644 lana/dashboard/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json rename core/chart-of-accounts/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json => lana/dashboard/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json (63%) create mode 100644 lana/dashboard/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json create mode 100644 lana/dashboard/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json rename lana/dashboard/.sqlx/{query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json => query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json} (53%) delete mode 100644 lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json delete mode 100644 lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json delete mode 100644 lana/dashboard/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json create mode 100644 lana/dashboard/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json rename core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json => lana/dashboard/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json (53%) create mode 100644 lana/dashboard/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json delete mode 100644 lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json delete mode 100644 lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json rename core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json => lana/dashboard/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json (58%) create mode 100644 lana/dashboard/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json create mode 100644 lana/dashboard/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json diff --git a/bats/admin-gql/chart-of-accounts.gql b/bats/admin-gql/chart-of-accounts.gql index 46c08f7e5..475cda6dc 100644 --- a/bats/admin-gql/chart-of-accounts.gql +++ b/bats/admin-gql/chart-of-accounts.gql @@ -1,4 +1,4 @@ -query ChartOfAccount { +query ChartOfAccounts { chartOfAccounts { name categories { diff --git a/core/chart-of-accounts/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/core/chart-of-accounts/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json deleted file mode 100644 index 19e53c2ec..000000000 --- a/core/chart-of-accounts/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Timestamptz", - "Int8", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3" -} diff --git a/core/chart-of-accounts/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json b/core/chart-of-accounts/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json new file mode 100644 index 000000000..f2dd574b1 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE id = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7" +} diff --git a/lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/core/chart-of-accounts/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json similarity index 63% rename from lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json rename to core/chart-of-accounts/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json index 95a5300c8..5864f3728 100644 --- a/lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json +++ b/core/chart-of-accounts/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "SELECT i.id AS \"id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM core_chart_of_accounts i JOIN core_chart_of_account_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "query": "SELECT i.id AS \"id: ChartId\", e.sequence, e.event, e.recorded_at FROM core_charts i JOIN core_chart_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id: ChartOfAccountId", + "name": "id: ChartId", "type_info": "Uuid" }, { @@ -36,5 +36,5 @@ false ] }, - "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" + "hash": "3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9" } diff --git a/core/chart-of-accounts/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json b/core/chart-of-accounts/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json new file mode 100644 index 000000000..6bacdb20b --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6" +} diff --git a/lana/app/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/core/chart-of-accounts/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json similarity index 60% rename from lana/app/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json rename to core/chart-of-accounts/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json index dae4e1e2e..842d42442 100644 --- a/lana/app/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json +++ b/core/chart-of-accounts/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -38,5 +38,5 @@ false ] }, - "hash": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" + "hash": "4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f" } diff --git a/lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/core/chart-of-accounts/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json similarity index 53% rename from lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json rename to core/chart-of-accounts/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json index 95bebab0d..6cf19b9d2 100644 --- a/lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json +++ b/core/chart-of-accounts/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "query": "UPDATE core_charts SET reference = $2 WHERE id = $1", "describe": { "columns": [], "parameters": { @@ -11,5 +11,5 @@ }, "nullable": [] }, - "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" + "hash": "5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432" } diff --git a/core/chart-of-accounts/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/core/chart-of-accounts/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json deleted file mode 100644 index 5f58f2f07..000000000 --- a/core/chart-of-accounts/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Timestamptz", - "UuidArray", - "Int4Array", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72" -} diff --git a/core/chart-of-accounts/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/core/chart-of-accounts/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json deleted file mode 100644 index 68cc67380..000000000 --- a/core/chart-of-accounts/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43" -} diff --git a/core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json b/core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json deleted file mode 100644 index c2f814ec9..000000000 --- a/core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b" -} diff --git a/core/deposit/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/core/chart-of-accounts/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json similarity index 60% rename from core/deposit/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json rename to core/chart-of-accounts/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json index dae4e1e2e..ba8093387 100644 --- a/core/deposit/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json +++ b/core/chart-of-accounts/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -38,5 +38,5 @@ false ] }, - "hash": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" + "hash": "b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d" } diff --git a/core/chart-of-accounts/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/core/chart-of-accounts/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json similarity index 53% rename from core/chart-of-accounts/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json rename to core/chart-of-accounts/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json index d57a47c95..d634f5e29 100644 --- a/core/chart-of-accounts/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json +++ b/core/chart-of-accounts/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "query": "INSERT INTO core_charts (id, reference, created_at) VALUES ($1, $2, $3)", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" + "hash": "bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a" } diff --git a/core/chart-of-accounts/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json b/core/chart-of-accounts/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json new file mode 100644 index 000000000..0f22cddce --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5" +} diff --git a/core/chart-of-accounts/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/core/chart-of-accounts/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json deleted file mode 100644 index 65ba29133..000000000 --- a/core/chart-of-accounts/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid", - "Timestamptz" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42" -} diff --git a/core/chart-of-accounts/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json b/core/chart-of-accounts/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json deleted file mode 100644 index 369e3792b..000000000 --- a/core/chart-of-accounts/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12" -} diff --git a/core/chart-of-accounts/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/core/chart-of-accounts/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json similarity index 58% rename from core/chart-of-accounts/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json rename to core/chart-of-accounts/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json index 8ac8f7df0..9870c96b2 100644 --- a/core/chart-of-accounts/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json +++ b/core/chart-of-accounts/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE id = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -26,6 +26,7 @@ ], "parameters": { "Left": [ + "Int8", "Uuid" ] }, @@ -36,5 +37,5 @@ false ] }, - "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" + "hash": "d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e" } diff --git a/core/chart-of-accounts/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json b/core/chart-of-accounts/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json new file mode 100644 index 000000000..5cfce6af5 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4" +} diff --git a/core/chart-of-accounts/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json b/core/chart-of-accounts/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json new file mode 100644 index 000000000..aef1c5f66 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "UuidArray", + "Int4Array", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8" +} diff --git a/core/chart-of-accounts/src/chart_of_accounts/entity.rs b/core/chart-of-accounts/src/chart_of_accounts/entity.rs index 7e002c97b..30965fbe5 100644 --- a/core/chart-of-accounts/src/chart_of_accounts/entity.rs +++ b/core/chart-of-accounts/src/chart_of_accounts/entity.rs @@ -6,10 +6,8 @@ use audit::AuditInfo; use es_entity::*; use crate::{ - code::*, - primitives::{ - ChartId, ChartOfAccountAccountDetails, ChartOfAccountCreationDetails, LedgerAccountId, - }, + path::*, + primitives::{ChartAccountDetails, ChartCreationDetails, ChartId, LedgerAccountId}, }; pub use super::error::*; @@ -17,27 +15,27 @@ pub use super::error::*; #[derive(EsEvent, Debug, Clone, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] #[es_event(id = "ChartId")] -pub enum ChartOfAccountEvent { +pub enum ChartEvent { Initialized { id: ChartId, reference: String, audit_info: AuditInfo, }, ControlAccountAdded { - code: ChartOfAccountCode, + code: ChartPath, name: String, reference: String, audit_info: AuditInfo, }, ControlSubAccountAdded { - code: ChartOfAccountCode, + code: ChartPath, name: String, reference: String, audit_info: AuditInfo, }, TransactionAccountAdded { id: LedgerAccountId, - code: ChartOfAccountCode, + code: ChartPath, name: String, description: String, audit_info: AuditInfo, @@ -46,38 +44,35 @@ pub enum ChartOfAccountEvent { #[derive(EsEntity, Builder)] #[builder(pattern = "owned", build_fn(error = "EsEntityError"))] -pub struct ChartOfAccount { +pub struct Chart { pub id: ChartId, pub reference: String, - pub(super) events: EntityEvents, + pub(super) events: EntityEvents, } -impl ChartOfAccount { - fn next_control_account( - &self, - category: ChartOfAccountCode, - ) -> Result { +impl Chart { + fn next_control_account(&self, category: ChartPath) -> Result { Ok(self .events .iter_all() .rev() .find_map(|event| match event { - ChartOfAccountEvent::ControlAccountAdded { code, .. } + ChartEvent::ControlAccountAdded { code, .. } if code.category() == category.category() => { Some(code.next()) } _ => None, }) - .unwrap_or_else(|| ChartOfAccountCode::first_control_account(category))?) + .unwrap_or_else(|| ChartPath::first_control_account(category))?) } pub fn find_control_account_by_reference( &self, reference_to_check: String, - ) -> Option { + ) -> Option { self.events.iter_all().rev().find_map(|event| match event { - ChartOfAccountEvent::ControlAccountAdded { + ChartEvent::ControlAccountAdded { code, reference, .. } if reference_to_check == *reference => Some(*code), _ => None, @@ -86,22 +81,20 @@ impl ChartOfAccount { pub fn create_control_account( &mut self, - category: ChartOfAccountCode, + category: ChartPath, name: String, reference: String, audit_info: AuditInfo, - ) -> Result { + ) -> Result { if self .find_control_account_by_reference(reference.to_string()) .is_some() { - return Err(ChartOfAccountError::ControlAccountAlreadyRegistered( - reference, - )); + return Err(ChartError::ControlAccountAlreadyRegistered(reference)); }; let code = self.next_control_account(category)?; - self.events.push(ChartOfAccountEvent::ControlAccountAdded { + self.events.push(ChartEvent::ControlAccountAdded { code, name, reference, @@ -113,14 +106,14 @@ impl ChartOfAccount { fn next_control_sub_account( &self, - control_account: ChartOfAccountCode, - ) -> Result { + control_account: ChartPath, + ) -> Result { Ok(self .events .iter_all() .rev() .find_map(|event| match event { - ChartOfAccountEvent::ControlSubAccountAdded { code, .. } + ChartEvent::ControlSubAccountAdded { code, .. } if code.category() == control_account.category() && code.control_account() == control_account.control_account() => { @@ -128,15 +121,15 @@ impl ChartOfAccount { } _ => None, }) - .unwrap_or_else(|| ChartOfAccountCode::first_control_sub_account(&control_account))?) + .unwrap_or_else(|| ChartPath::first_control_sub_account(&control_account))?) } pub fn find_control_sub_account_by_reference( &self, reference_to_check: String, - ) -> Option { + ) -> Option { self.events.iter_all().rev().find_map(|event| match event { - ChartOfAccountEvent::ControlSubAccountAdded { + ChartEvent::ControlSubAccountAdded { code, reference, .. } if reference_to_check == *reference => Some(*code), _ => None, @@ -145,42 +138,39 @@ impl ChartOfAccount { pub fn create_control_sub_account( &mut self, - control_account: ChartOfAccountCode, + control_account: ChartPath, name: String, reference: String, audit_info: AuditInfo, - ) -> Result { + ) -> Result { if self .find_control_sub_account_by_reference(reference.to_string()) .is_some() { - return Err(ChartOfAccountError::ControlSubAccountAlreadyRegistered( - reference, - )); + return Err(ChartError::ControlSubAccountAlreadyRegistered(reference)); }; let code = self.next_control_sub_account(control_account)?; - self.events - .push(ChartOfAccountEvent::ControlSubAccountAdded { - code, - name, - reference, - audit_info, - }); + self.events.push(ChartEvent::ControlSubAccountAdded { + code, + name, + reference, + audit_info, + }); Ok(code) } fn next_transaction_account( &self, - control_sub_account: ChartOfAccountCode, - ) -> Result { + control_sub_account: ChartPath, + ) -> Result { Ok(self .events .iter_all() .rev() .find_map(|event| match event { - ChartOfAccountEvent::TransactionAccountAdded { code, .. } + ChartEvent::TransactionAccountAdded { code, .. } if code.category() == control_sub_account.category() && code.control_account() == control_sub_account.control_account() && code.control_sub_account() @@ -190,27 +180,24 @@ impl ChartOfAccount { } _ => None, }) - .unwrap_or_else(|| { - ChartOfAccountCode::first_transaction_account(&control_sub_account) - })?) + .unwrap_or_else(|| ChartPath::first_transaction_account(&control_sub_account))?) } pub fn add_transaction_account( &mut self, - creation_details: ChartOfAccountCreationDetails, + creation_details: ChartCreationDetails, audit_info: AuditInfo, - ) -> Result { + ) -> Result { let path = self.next_transaction_account(creation_details.parent_path)?; - self.events - .push(ChartOfAccountEvent::TransactionAccountAdded { - id: creation_details.account_id, - code: path, - name: creation_details.name.clone(), - description: creation_details.description.clone(), - audit_info, - }); + self.events.push(ChartEvent::TransactionAccountAdded { + id: creation_details.account_id, + code: path, + name: creation_details.name.clone(), + description: creation_details.description.clone(), + audit_info, + }); - Ok(ChartOfAccountAccountDetails { + Ok(ChartAccountDetails { account_id: creation_details.account_id, code: path.to_code(self.id), path, @@ -219,18 +206,15 @@ impl ChartOfAccount { }) } - pub fn find_account( - &self, - account_path: ChartOfAccountCode, - ) -> Option { + pub fn find_account(&self, account_path: ChartPath) -> Option { self.events.iter_all().rev().find_map(|event| match event { - ChartOfAccountEvent::TransactionAccountAdded { + ChartEvent::TransactionAccountAdded { id, code: path, name, description, .. - } if *path == account_path => Some(ChartOfAccountAccountDetails { + } if *path == account_path => Some(ChartAccountDetails { account_id: *id, path: *path, code: path.to_code(self.id), @@ -242,17 +226,17 @@ impl ChartOfAccount { } } -impl TryFromEvents for ChartOfAccount { - fn try_from_events(events: EntityEvents) -> Result { - let mut builder = ChartOfAccountBuilder::default(); +impl TryFromEvents for Chart { + fn try_from_events(events: EntityEvents) -> Result { + let mut builder = ChartBuilder::default(); for event in events.iter_all() { match event { - ChartOfAccountEvent::Initialized { id, reference, .. } => { + ChartEvent::Initialized { id, reference, .. } => { builder = builder.id(*id).reference(reference.to_string()) } - ChartOfAccountEvent::ControlAccountAdded { .. } => (), - ChartOfAccountEvent::ControlSubAccountAdded { .. } => (), - ChartOfAccountEvent::TransactionAccountAdded { .. } => (), + ChartEvent::ControlAccountAdded { .. } => (), + ChartEvent::ControlSubAccountAdded { .. } => (), + ChartEvent::TransactionAccountAdded { .. } => (), } } builder.events(events).build() @@ -260,7 +244,7 @@ impl TryFromEvents for ChartOfAccount { } #[derive(Debug, Builder)] -pub struct NewChartOfAccount { +pub struct NewChart { #[builder(setter(into))] pub(super) id: ChartId, pub(super) reference: String, @@ -268,17 +252,17 @@ pub struct NewChartOfAccount { pub audit_info: AuditInfo, } -impl NewChartOfAccount { - pub fn builder() -> NewChartOfAccountBuilder { - NewChartOfAccountBuilder::default() +impl NewChart { + pub fn builder() -> NewChartBuilder { + NewChartBuilder::default() } } -impl IntoEvents for NewChartOfAccount { - fn into_events(self) -> EntityEvents { +impl IntoEvents for NewChart { + fn into_events(self) -> EntityEvents { EntityEvents::init( self.id, - [ChartOfAccountEvent::Initialized { + [ChartEvent::Initialized { id: self.id, reference: self.reference, audit_info: self.audit_info, @@ -289,7 +273,7 @@ impl IntoEvents for NewChartOfAccount { #[cfg(test)] mod tests { - use crate::code::{AccountIdx, ChartOfAccountCategoryCode}; + use crate::path::{AccountIdx, ChartCategoryPath}; use super::*; @@ -302,11 +286,11 @@ mod tests { } } - fn init_chart_of_events() -> ChartOfAccount { + fn init_chart_of_events() -> Chart { let id = ChartId::new(); let audit_info = dummy_audit_info(); - let new_chart = NewChartOfAccount::builder() + let new_chart = NewChart::builder() .id(id) .reference("ref-01".to_string()) .audit_info(audit_info) @@ -314,7 +298,7 @@ mod tests { .unwrap(); let events = new_chart.into_events(); - ChartOfAccount::try_from_events(events).unwrap() + Chart::try_from_events(events).unwrap() } #[test] @@ -322,7 +306,7 @@ mod tests { let id = ChartId::new(); let audit_info = dummy_audit_info(); - let new_chart = NewChartOfAccount::builder() + let new_chart = NewChart::builder() .id(id) .reference("ref-01".to_string()) .audit_info(audit_info.clone()) @@ -330,7 +314,7 @@ mod tests { .unwrap(); let events = new_chart.into_events(); - let chart = ChartOfAccount::try_from_events(events).unwrap(); + let chart = Chart::try_from_events(events).unwrap(); assert_eq!(chart.id, id); } @@ -340,15 +324,15 @@ mod tests { let mut chart = init_chart_of_events(); match chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets".to_string(), "assets".to_string(), dummy_audit_info(), ) .unwrap() { - ChartOfAccountCode::ControlAccount { category, index } => { - assert_eq!(category, ChartOfAccountCategoryCode::Assets); + ChartPath::ControlAccount { category, index } => { + assert_eq!(category, ChartCategoryPath::Assets); assert_eq!(index, AccountIdx::FIRST); } other => panic!("Expected FIRST control account, got {:?}", other), @@ -360,7 +344,7 @@ mod tests { let mut chart = init_chart_of_events(); chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets #1".to_string(), "assets".to_string(), dummy_audit_info(), @@ -368,16 +352,13 @@ mod tests { .unwrap(); match chart.create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets #2".to_string(), "assets".to_string(), dummy_audit_info(), ) { Err(e) => { - assert!(matches!( - e, - ChartOfAccountError::ControlAccountAlreadyRegistered(_) - )); + assert!(matches!(e, ChartError::ControlAccountAlreadyRegistered(_))); } _ => { panic!("Expected duplicate reference to error") @@ -390,7 +371,7 @@ mod tests { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets".to_string(), "assets".to_string(), dummy_audit_info(), @@ -406,12 +387,12 @@ mod tests { ) .unwrap() { - ChartOfAccountCode::ControlSubAccount { + ChartPath::ControlSubAccount { category, control_index, index, } => { - assert_eq!(category, ChartOfAccountCategoryCode::Assets); + assert_eq!(category, ChartCategoryPath::Assets); assert_eq!(control_index, AccountIdx::FIRST); assert_eq!(index, AccountIdx::FIRST); } @@ -424,7 +405,7 @@ mod tests { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets".to_string(), "assets".to_string(), dummy_audit_info(), @@ -448,7 +429,7 @@ mod tests { Err(e) => { assert!(matches!( e, - ChartOfAccountError::ControlSubAccountAlreadyRegistered(_) + ChartError::ControlSubAccountAlreadyRegistered(_) )); } _ => { @@ -462,7 +443,7 @@ mod tests { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets".to_string(), "assets".to_string(), dummy_audit_info(), @@ -479,7 +460,7 @@ mod tests { match chart .add_transaction_account( - ChartOfAccountCreationDetails { + ChartCreationDetails { account_id: LedgerAccountId::new(), parent_path: control_sub_account, name: "Cash".to_string(), @@ -489,9 +470,9 @@ mod tests { ) .unwrap() { - ChartOfAccountAccountDetails { + ChartAccountDetails { path: - ChartOfAccountCode::TransactionAccount { + ChartPath::TransactionAccount { category, control_index, control_sub_index, @@ -499,7 +480,7 @@ mod tests { }, .. } => { - assert_eq!(category, ChartOfAccountCategoryCode::Assets); + assert_eq!(category, ChartCategoryPath::Assets); assert_eq!(control_index, AccountIdx::FIRST); assert_eq!(control_sub_index, AccountIdx::FIRST); assert_eq!(index, AccountIdx::FIRST); @@ -514,7 +495,7 @@ mod tests { chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "First".to_string(), "assets-01".to_string(), dummy_audit_info(), @@ -523,15 +504,15 @@ mod tests { match chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Second".to_string(), "assets-02".to_string(), dummy_audit_info(), ) .unwrap() { - ChartOfAccountCode::ControlAccount { category, index } => { - assert_eq!(category, ChartOfAccountCategoryCode::Assets); + ChartPath::ControlAccount { category, index } => { + assert_eq!(category, ChartCategoryPath::Assets); assert_eq!(index, AccountIdx::FIRST.next()); } other => panic!("Expected SECOND control account, got {:?}", other), @@ -543,7 +524,7 @@ mod tests { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets".to_string(), "assets".to_string(), dummy_audit_info(), @@ -568,12 +549,12 @@ mod tests { ) .unwrap() { - ChartOfAccountCode::ControlSubAccount { + ChartPath::ControlSubAccount { category, control_index, index, } => { - assert_eq!(category, ChartOfAccountCategoryCode::Assets); + assert_eq!(category, ChartCategoryPath::Assets); assert_eq!(control_index, AccountIdx::FIRST); assert_eq!(index, AccountIdx::FIRST.next()); } @@ -586,7 +567,7 @@ mod tests { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + ChartPath::Category(ChartCategoryPath::Assets), "Assets".to_string(), "assets".to_string(), dummy_audit_info(), @@ -603,7 +584,7 @@ mod tests { chart .add_transaction_account( - ChartOfAccountCreationDetails { + ChartCreationDetails { account_id: LedgerAccountId::new(), parent_path: sub_account, name: "First".to_string(), @@ -615,7 +596,7 @@ mod tests { match chart .add_transaction_account( - ChartOfAccountCreationDetails { + ChartCreationDetails { account_id: LedgerAccountId::new(), parent_path: sub_account, name: "Second".to_string(), @@ -625,9 +606,9 @@ mod tests { ) .unwrap() { - ChartOfAccountAccountDetails { + ChartAccountDetails { path: - ChartOfAccountCode::TransactionAccount { + ChartPath::TransactionAccount { category, control_index, control_sub_index, @@ -635,7 +616,7 @@ mod tests { }, .. } => { - assert_eq!(category, ChartOfAccountCategoryCode::Assets); + assert_eq!(category, ChartCategoryPath::Assets); assert_eq!(control_index, AccountIdx::FIRST); assert_eq!(control_sub_index, AccountIdx::FIRST); assert_eq!(index, AccountIdx::FIRST.next()); @@ -649,7 +630,7 @@ mod tests { let mut chart = init_chart_of_events(); let audit_info = dummy_audit_info(); - let category = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); + let category = ChartPath::Category(ChartCategoryPath::Assets); let control_account = chart .create_control_account( category, @@ -668,7 +649,7 @@ mod tests { .unwrap(); let transaction_account = chart .add_transaction_account( - ChartOfAccountCreationDetails { + ChartCreationDetails { account_id: LedgerAccountId::new(), parent_path: sub_account, name: "Cash".to_string(), diff --git a/core/chart-of-accounts/src/chart_of_accounts/error.rs b/core/chart-of-accounts/src/chart_of_accounts/error.rs index 8580a02c8..218177827 100644 --- a/core/chart-of-accounts/src/chart_of_accounts/error.rs +++ b/core/chart-of-accounts/src/chart_of_accounts/error.rs @@ -1,19 +1,19 @@ use thiserror::Error; #[derive(Error, Debug)] -pub enum ChartOfAccountError { - #[error("ChartOfAccountError - Sqlx: {0}")] +pub enum ChartError { + #[error("ChartError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("ChartOfAccountError - EsEntityError: {0}")] + #[error("ChartError - EsEntityError: {0}")] EsEntityError(es_entity::EsEntityError), - #[error("ChartOfAccountError - CursorDestructureError: {0}")] + #[error("ChartError - CursorDestructureError: {0}")] CursorDestructureError(#[from] es_entity::CursorDestructureError), - #[error("ChartOfAccountError - ChartOfAccountCodeError: '{0}'")] - ChartOfAccountCodeError(#[from] crate::code::error::ChartOfAccountCodeError), - #[error("ChartOfAccountError - ControlAccountAlreadyRegistered: '{0}'")] + #[error("ChartError - ChartPathError: '{0}'")] + ChartPathError(#[from] crate::path::error::ChartPathError), + #[error("ChartError - ControlAccountAlreadyRegistered: '{0}'")] ControlAccountAlreadyRegistered(String), - #[error("ChartOfAccountError - ControlSubAccountAlreadyRegistered: '{0}'")] + #[error("ChartError - ControlSubAccountAlreadyRegistered: '{0}'")] ControlSubAccountAlreadyRegistered(String), } -es_entity::from_es_entity_error!(ChartOfAccountError); +es_entity::from_es_entity_error!(ChartError); diff --git a/core/chart-of-accounts/src/chart_of_accounts/repo.rs b/core/chart-of-accounts/src/chart_of_accounts/repo.rs index 38750b449..6cd557d8a 100644 --- a/core/chart-of-accounts/src/chart_of_accounts/repo.rs +++ b/core/chart-of-accounts/src/chart_of_accounts/repo.rs @@ -2,22 +2,22 @@ use sqlx::PgPool; use es_entity::*; -use crate::primitives::ChartId as ChartOfAccountId; +use crate::primitives::ChartId; use super::entity::*; #[derive(EsRepo, Clone)] #[es_repo( - entity = "ChartOfAccount", - err = "ChartOfAccountError", + entity = "Chart", + err = "ChartError", columns(reference(ty = "String")), tbl_prefix = "core" )] -pub struct ChartOfAccountRepo { +pub struct ChartRepo { pool: PgPool, } -impl ChartOfAccountRepo { +impl ChartRepo { pub fn new(pool: &PgPool) -> Self { Self { pool: pool.clone() } } diff --git a/core/chart-of-accounts/src/code/error.rs b/core/chart-of-accounts/src/code/error.rs deleted file mode 100644 index 244223e9b..000000000 --- a/core/chart-of-accounts/src/code/error.rs +++ /dev/null @@ -1,31 +0,0 @@ -use thiserror::Error; - -use crate::code::{AccountIdx, ChartOfAccountCategoryCode}; - -#[derive(Error, Debug)] -pub enum ChartOfAccountCodeError { - #[error("ChartOfAccountError - ParseIntError: {0}")] - ParseIntError(#[from] std::num::ParseIntError), - #[error("ChartOfAccountError - InvalidCategoryCodeForNewControlAccount")] - InvalidCategoryCodeForNewControlAccount, - #[error("ChartOfAccountError - InvalidControlAccountCodeForNewControlSubAccount")] - InvalidControlAccountCodeForNewControlSubAccount, - #[error("ChartOfAccountError - InvalidSubControlAccountCodeForNewTransactionAccount")] - InvalidSubControlAccountCodeForNewTransactionAccount, - #[error("ChartOfAccountError - ControlIndexOverflowForCategory: Category '{0}'")] - ControlIndexOverflowForCategory(ChartOfAccountCategoryCode), - #[error("ChartOfAccountError - ControlSubIndexOverflowForControlAccount: Category '{0}' / Control '{1}'")] - ControlSubIndexOverflowForControlAccount(ChartOfAccountCategoryCode, AccountIdx), - #[error("ChartOfAccountError - TransactionIndexOverflowForControlSubAccount: Category '{0}' / Control '{1}' / Sub-control '{2}'")] - TransactionIndexOverflowForControlSubAccount( - ChartOfAccountCategoryCode, - AccountIdx, - AccountIdx, - ), - #[error("ChartOfAccountError - InvalidCodeLength: {0}")] - InvalidCodeLength(String), - #[error("ChartOfAccountError - InvalidCategoryNumber: {0}")] - InvalidCategoryNumber(u32), - #[error("ChartOfAccountError - InvalidCodeString: {0}")] - InvalidCodeString(String), -} diff --git a/core/chart-of-accounts/src/error.rs b/core/chart-of-accounts/src/error.rs index 0d5d16845..afbe3bb58 100644 --- a/core/chart-of-accounts/src/error.rs +++ b/core/chart-of-accounts/src/error.rs @@ -1,15 +1,15 @@ use thiserror::Error; #[derive(Error, Debug)] -pub enum CoreChartOfAccountError { - #[error("CoreChartOfAccountError - Sqlx: {0}")] +pub enum CoreChartOfAccountsError { + #[error("CoreChartOfAccountsError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("CoreChartOfAccountError - AuthorizationError: {0}")] + #[error("CoreChartOfAccountsError - AuthorizationError: {0}")] AuthorizationError(#[from] authz::error::AuthorizationError), - #[error("CoreChartOfAccountError - ChartOfAccountError: {0}")] - ChartOfAccountError(#[from] crate::chart_of_accounts::error::ChartOfAccountError), - #[error("CoreChartOfAccountError - AuditError: {0}")] + #[error("CoreChartOfAccountsError - ChartError: {0}")] + ChartError(#[from] crate::chart_of_accounts::error::ChartError), + #[error("CoreChartOfAccountsError - AuditError: {0}")] AuditError(#[from] audit::error::AuditError), - #[error("ChartOfAccountLedgerError - CalaAccountError: {0}")] + #[error("CoreChartOfAccountsError - CalaAccountError: {0}")] CalaAccount(#[from] cala_ledger::account::error::AccountError), } diff --git a/core/chart-of-accounts/src/event.rs b/core/chart-of-accounts/src/event.rs deleted file mode 100644 index e3671917a..000000000 --- a/core/chart-of-accounts/src/event.rs +++ /dev/null @@ -1,7 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Serialize, Deserialize)] -#[serde(tag = "type")] -pub enum CoreChartOfAccountEvent { - ChartOfAccountsCreated, -} diff --git a/core/chart-of-accounts/src/lib.rs b/core/chart-of-accounts/src/lib.rs index 9d212e21a..b1c9fe74a 100644 --- a/core/chart-of-accounts/src/lib.rs +++ b/core/chart-of-accounts/src/lib.rs @@ -2,9 +2,8 @@ #![cfg_attr(feature = "fail-on-warnings", deny(clippy::all))] mod chart_of_accounts; -mod code; pub mod error; -mod event; +mod path; mod primitives; mod transaction_account_factory; @@ -16,7 +15,6 @@ use authz::PermissionCheck; use chart_of_accounts::*; use error::*; -pub use event::*; pub use primitives::*; pub use transaction_account_factory::*; @@ -24,7 +22,7 @@ pub struct CoreChartOfAccounts where Perms: PermissionCheck, { - repo: ChartOfAccountRepo, + repo: ChartRepo, cala: CalaLedger, authz: Perms, } @@ -52,8 +50,8 @@ where pool: &sqlx::PgPool, authz: &Perms, cala: &CalaLedger, - ) -> Result { - let chart_of_account = ChartOfAccountRepo::new(pool); + ) -> Result { + let chart_of_account = ChartRepo::new(pool); let res = Self { repo: chart_of_account, cala: cala.clone(), @@ -65,7 +63,7 @@ where pub fn transaction_account_factory( &self, chart_id: ChartId, - control_sub_account: ChartOfAccountCode, + control_sub_account: ChartPath, ) -> TransactionAccountFactory { TransactionAccountFactory::new(&self.repo, &self.cala, chart_id, control_sub_account) } @@ -75,7 +73,7 @@ where &self, id: impl Into + std::fmt::Debug, reference: String, - ) -> Result { + ) -> Result { let id = id.into(); let mut op = self.repo.begin_op().await?; @@ -89,7 +87,7 @@ where ) .await?; - let new_chart_of_account = NewChartOfAccount::builder() + let new_chart_of_account = NewChart::builder() .id(id) .reference(reference) .audit_info(audit_info) @@ -109,7 +107,7 @@ where pub async fn find_by_reference( &self, reference: String, - ) -> Result, CoreChartOfAccountError> { + ) -> Result, CoreChartOfAccountsError> { let mut op = self.repo.begin_op().await?; self.authz .audit() @@ -134,7 +132,7 @@ where pub async fn list_charts( &self, sub: &<::Audit as AuditSvc>::Subject, - ) -> Result, CoreChartOfAccountError> { + ) -> Result, CoreChartOfAccountsError> { self.authz .enforce_permission( sub, @@ -154,7 +152,7 @@ where &self, chart_id: impl Into, reference: String, - ) -> Result, CoreChartOfAccountError> { + ) -> Result, CoreChartOfAccountsError> { let chart_id = chart_id.into(); let mut op = self.repo.begin_op().await?; @@ -176,10 +174,10 @@ where pub async fn create_control_account( &self, chart_id: impl Into, - category: ChartOfAccountCode, + category: ChartPath, name: String, reference: String, - ) -> Result { + ) -> Result { let chart_id = chart_id.into(); let mut op = self.repo.begin_op().await?; @@ -209,7 +207,7 @@ where &self, chart_id: impl Into, reference: String, - ) -> Result, CoreChartOfAccountError> { + ) -> Result, CoreChartOfAccountsError> { let chart_id = chart_id.into(); let mut op = self.repo.begin_op().await?; @@ -231,10 +229,10 @@ where pub async fn create_control_sub_account( &self, chart_id: impl Into + std::fmt::Debug, - control_account: ChartOfAccountCode, + control_account: ChartPath, name: String, reference: String, - ) -> Result { + ) -> Result { let chart_id = chart_id.into(); let mut op = self.repo.begin_op().await?; @@ -267,8 +265,8 @@ where &self, sub: &<::Audit as AuditSvc>::Subject, chart_id: impl Into + std::fmt::Debug, - code: impl Into + std::fmt::Debug, - ) -> Result, CoreChartOfAccountError> { + code: impl Into + std::fmt::Debug, + ) -> Result, CoreChartOfAccountsError> { let chart_id = chart_id.into(); self.authz .enforce_permission( diff --git a/core/chart-of-accounts/src/path/error.rs b/core/chart-of-accounts/src/path/error.rs new file mode 100644 index 000000000..0ba570cdc --- /dev/null +++ b/core/chart-of-accounts/src/path/error.rs @@ -0,0 +1,29 @@ +use thiserror::Error; + +use crate::path::{AccountIdx, ChartCategoryPath}; + +#[derive(Error, Debug)] +pub enum ChartPathError { + #[error("ChartError - ParseIntError: {0}")] + ParseIntError(#[from] std::num::ParseIntError), + #[error("ChartError - InvalidCategoryPathForNewControlAccount")] + InvalidCategoryPathForNewControlAccount, + #[error("ChartError - InvalidControlAccountPathForNewControlSubAccount")] + InvalidControlAccountPathForNewControlSubAccount, + #[error("ChartError - InvalidSubControlAccountPathForNewTransactionAccount")] + InvalidSubControlAccountPathForNewTransactionAccount, + #[error("ChartError - ControlIndexOverflowForCategory: Category '{0}'")] + ControlIndexOverflowForCategory(ChartCategoryPath), + #[error( + "ChartError - ControlSubIndexOverflowForControlAccount: Category '{0}' / Control '{1}'" + )] + ControlSubIndexOverflowForControlAccount(ChartCategoryPath, AccountIdx), + #[error("ChartError - TransactionIndexOverflowForControlSubAccount: Category '{0}' / Control '{1}' / Sub-control '{2}'")] + TransactionIndexOverflowForControlSubAccount(ChartCategoryPath, AccountIdx, AccountIdx), + #[error("ChartError - InvalidCodeLength: {0}")] + InvalidCodeLength(String), + #[error("ChartError - InvalidCategoryNumber: {0}")] + InvalidCategoryNumber(u32), + #[error("ChartError - InvalidCodeString: {0}")] + InvalidCodeString(String), +} diff --git a/core/chart-of-accounts/src/code/mod.rs b/core/chart-of-accounts/src/path/mod.rs similarity index 65% rename from core/chart-of-accounts/src/code/mod.rs rename to core/chart-of-accounts/src/path/mod.rs index 52f42f43d..e9ba3c45c 100644 --- a/core/chart-of-accounts/src/code/mod.rs +++ b/core/chart-of-accounts/src/path/mod.rs @@ -31,7 +31,7 @@ impl AccountIdx { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub enum ChartOfAccountCategoryCode { +pub enum ChartCategoryPath { Assets = 1, Liabilities = 2, Equity = 3, @@ -39,7 +39,7 @@ pub enum ChartOfAccountCategoryCode { Expenses = 5, } -impl Display for ChartOfAccountCategoryCode { +impl Display for ChartCategoryPath { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Assets => write!(f, "Assets"), @@ -52,26 +52,26 @@ impl Display for ChartOfAccountCategoryCode { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub enum ChartOfAccountCode { - Category(ChartOfAccountCategoryCode), +pub enum ChartPath { + Category(ChartCategoryPath), ControlAccount { - category: ChartOfAccountCategoryCode, + category: ChartCategoryPath, index: AccountIdx, }, ControlSubAccount { - category: ChartOfAccountCategoryCode, + category: ChartCategoryPath, control_index: AccountIdx, index: AccountIdx, }, TransactionAccount { - category: ChartOfAccountCategoryCode, + category: ChartCategoryPath, control_index: AccountIdx, control_sub_index: AccountIdx, index: AccountIdx, }, } -impl std::fmt::Display for ChartOfAccountCode { +impl std::fmt::Display for ChartPath { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Category(category) => { @@ -107,22 +107,21 @@ impl std::fmt::Display for ChartOfAccountCode { } } -impl std::str::FromStr for ChartOfAccountCode { - type Err = ChartOfAccountCodeError; +impl std::str::FromStr for ChartPath { + type Err = ChartPathError; - fn from_str(s: &str) -> Result { + fn from_str(s: &str) -> Result { if s.len() != 8 { - return Err(ChartOfAccountCodeError::InvalidCodeLength(s.to_string())); + return Err(ChartPathError::InvalidCodeLength(s.to_string())); } - fn parse_segment(s: &str) -> Result { + fn parse_segment(s: &str) -> Result { Ok(s.parse::()?) } let category_segment = parse_segment(&s[0..1])?; - let category = Self::category_from_number(category_segment).ok_or( - ChartOfAccountCodeError::InvalidCategoryNumber(category_segment), - )?; + let category = Self::category_from_number(category_segment) + .ok_or(ChartPathError::InvalidCategoryNumber(category_segment))?; let control = parse_segment(&s[1..3])?; let sub = parse_segment(&s[3..5])?; @@ -145,28 +144,26 @@ impl std::str::FromStr for ChartOfAccountCode { control_sub_index: s.into(), index: t.into(), }), - _ => Err(ChartOfAccountCodeError::InvalidCodeString(s.to_string())), + _ => Err(ChartPathError::InvalidCodeString(s.to_string())), } } } -impl ChartOfAccountCode { - fn category_from_number(num: u32) -> Option { +impl ChartPath { + fn category_from_number(num: u32) -> Option { match num { - 1 => Some(ChartOfAccountCategoryCode::Assets), - 2 => Some(ChartOfAccountCategoryCode::Liabilities), - 3 => Some(ChartOfAccountCategoryCode::Equity), - 4 => Some(ChartOfAccountCategoryCode::Revenues), - 5 => Some(ChartOfAccountCategoryCode::Expenses), + 1 => Some(ChartCategoryPath::Assets), + 2 => Some(ChartCategoryPath::Liabilities), + 3 => Some(ChartCategoryPath::Equity), + 4 => Some(ChartCategoryPath::Revenues), + 5 => Some(ChartCategoryPath::Expenses), _ => None, } } pub fn normal_balance_type(&self) -> DebitOrCredit { match self.category() { - ChartOfAccountCategoryCode::Assets | ChartOfAccountCategoryCode::Expenses => { - DebitOrCredit::Debit - } + ChartCategoryPath::Assets | ChartCategoryPath::Expenses => DebitOrCredit::Debit, _ => DebitOrCredit::Credit, } } @@ -175,7 +172,7 @@ impl ChartOfAccountCode { format!("{}::{}", chart_id, self) } - pub fn category(&self) -> ChartOfAccountCategoryCode { + pub fn category(&self) -> ChartCategoryPath { match *self { Self::Category(category) => category, Self::ControlAccount { category, .. } => category, @@ -184,7 +181,7 @@ impl ChartOfAccountCode { } } - pub fn control_account(&self) -> Option { + pub fn control_account(&self) -> Option { match *self { Self::ControlAccount { category, index } => { Some(Self::ControlAccount { category, index }) @@ -209,7 +206,7 @@ impl ChartOfAccountCode { } } - pub fn control_sub_account(&self) -> Option { + pub fn control_sub_account(&self) -> Option { match *self { Self::TransactionAccount { category, @@ -234,34 +231,28 @@ impl ChartOfAccountCode { } } - pub const fn first_control_account( - category: ChartOfAccountCode, - ) -> Result { + pub const fn first_control_account(category: ChartPath) -> Result { match category { Self::Category(category) => Ok(Self::ControlAccount { category, index: AccountIdx::FIRST, }), - _ => Err(ChartOfAccountCodeError::InvalidCategoryCodeForNewControlAccount), + _ => Err(ChartPathError::InvalidCategoryPathForNewControlAccount), } } - pub fn first_control_sub_account( - control_account: &Self, - ) -> Result { + pub fn first_control_sub_account(control_account: &Self) -> Result { match control_account { Self::ControlAccount { category, index } => Ok(Self::ControlSubAccount { category: *category, control_index: *index, index: AccountIdx::FIRST, }), - _ => Err(ChartOfAccountCodeError::InvalidControlAccountCodeForNewControlSubAccount), + _ => Err(ChartPathError::InvalidControlAccountPathForNewControlSubAccount), } } - pub fn first_transaction_account( - control_sub_account: &Self, - ) -> Result { + pub fn first_transaction_account(control_sub_account: &Self) -> Result { match control_sub_account { Self::ControlSubAccount { category, @@ -273,19 +264,17 @@ impl ChartOfAccountCode { control_sub_index: *index, index: AccountIdx::FIRST, }), - _ => Err(ChartOfAccountCodeError::InvalidSubControlAccountCodeForNewTransactionAccount), + _ => Err(ChartPathError::InvalidSubControlAccountPathForNewTransactionAccount), } } - pub fn next(&self) -> Result { + pub fn next(&self) -> Result { match *self { Self::Category(_) => Ok(*self), // Categories don't have next Self::ControlAccount { category, index } => { let next_index = index.next(); if next_index > AccountIdx::MAX_TWO_DIGIT { - Err(ChartOfAccountCodeError::ControlIndexOverflowForCategory( - category, - )) + Err(ChartPathError::ControlIndexOverflowForCategory(category)) } else { Ok(Self::ControlAccount { category, @@ -300,12 +289,10 @@ impl ChartOfAccountCode { } => { let next_index = index.next(); if next_index > AccountIdx::MAX_TWO_DIGIT { - Err( - ChartOfAccountCodeError::ControlSubIndexOverflowForControlAccount( - category, - control_index, - ), - ) + Err(ChartPathError::ControlSubIndexOverflowForControlAccount( + category, + control_index, + )) } else { Ok(Self::ControlSubAccount { category, @@ -323,7 +310,7 @@ impl ChartOfAccountCode { let next_index = index.next(); if next_index > AccountIdx::MAX_THREE_DIGIT { Err( - ChartOfAccountCodeError::TransactionIndexOverflowForControlSubAccount( + ChartPathError::TransactionIndexOverflowForControlSubAccount( category, control_index, control_sub_index, @@ -352,14 +339,14 @@ mod tests { #[test] fn test_category_formatting() { - let code = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); + let code = ChartPath::Category(ChartCategoryPath::Assets); assert_eq!(code.to_string(), "1000000"); } #[test] fn test_control_account_formatting() { - let code = ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Liabilities, + let code = ChartPath::ControlAccount { + category: ChartCategoryPath::Liabilities, index: 1.into(), }; assert_eq!(code.to_string(), "2010000"); @@ -367,8 +354,8 @@ mod tests { #[test] fn test_control_sub_account_formatting() { - let code = ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Equity, + let code = ChartPath::ControlSubAccount { + category: ChartCategoryPath::Equity, control_index: 1.into(), index: 2.into(), }; @@ -377,8 +364,8 @@ mod tests { #[test] fn test_transaction_account_formatting() { - let code = ChartOfAccountCode::TransactionAccount { - category: ChartOfAccountCategoryCode::Revenues, + let code = ChartPath::TransactionAccount { + category: ChartCategoryPath::Revenues, control_index: 1.into(), control_sub_index: 2.into(), index: 3.into(), @@ -393,31 +380,31 @@ mod tests { #[test] fn test_parsing_valid_codes() { assert_eq!( - ChartOfAccountCode::from_str("10000000").unwrap(), - ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets) + ChartPath::from_str("10000000").unwrap(), + ChartPath::Category(ChartCategoryPath::Assets) ); assert_eq!( - ChartOfAccountCode::from_str("20100000").unwrap(), - ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Liabilities, + ChartPath::from_str("20100000").unwrap(), + ChartPath::ControlAccount { + category: ChartCategoryPath::Liabilities, index: 1.into(), } ); assert_eq!( - ChartOfAccountCode::from_str("30102000").unwrap(), - ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Equity, + ChartPath::from_str("30102000").unwrap(), + ChartPath::ControlSubAccount { + category: ChartCategoryPath::Equity, control_index: 1.into(), index: 2.into(), } ); assert_eq!( - ChartOfAccountCode::from_str("40102003").unwrap(), - ChartOfAccountCode::TransactionAccount { - category: ChartOfAccountCategoryCode::Revenues, + ChartPath::from_str("40102003").unwrap(), + ChartPath::TransactionAccount { + category: ChartCategoryPath::Revenues, control_index: 1.into(), control_sub_index: 2.into(), index: 3.into(), @@ -427,8 +414,8 @@ mod tests { #[test] fn test_invalid_code_length() { - match ChartOfAccountCode::from_str("100") { - Err(ChartOfAccountCodeError::InvalidCodeLength(code)) => { + match ChartPath::from_str("100") { + Err(ChartPathError::InvalidCodeLength(code)) => { assert_eq!(code, "100"); } other => panic!("Expected InvalidCodeLength error, got {:?}", other), @@ -437,8 +424,8 @@ mod tests { #[test] fn test_invalid_category() { - match ChartOfAccountCode::from_str("90000000") { - Err(ChartOfAccountCodeError::InvalidCategoryNumber(num)) => { + match ChartPath::from_str("90000000") { + Err(ChartPathError::InvalidCategoryNumber(num)) => { assert_eq!(num, 9); } other => panic!("Expected InvalidCategoryNumber error, got {:?}", other), @@ -447,8 +434,8 @@ mod tests { #[test] fn test_invalid_code_format() { - match ChartOfAccountCode::from_str("10002030") { - Err(ChartOfAccountCodeError::InvalidCodeString(code)) => { + match ChartPath::from_str("10002030") { + Err(ChartPathError::InvalidCodeString(code)) => { assert_eq!(code, "10002030"); } other => panic!("Expected InvalidCodeString error, got {:?}", other), @@ -457,8 +444,8 @@ mod tests { #[test] fn test_non_numeric_input() { - match ChartOfAccountCode::from_str("A0000000") { - Err(ChartOfAccountCodeError::ParseIntError(_)) => { + match ChartPath::from_str("A0000000") { + Err(ChartPathError::ParseIntError(_)) => { // ParseIntError doesn't implement PartialEq, so we just check the variant } other => panic!("Expected ParseIntError, got {:?}", other), @@ -472,13 +459,13 @@ mod tests { #[test] fn test_category_from_category_code() { for category in [ - ChartOfAccountCategoryCode::Assets, - ChartOfAccountCategoryCode::Liabilities, - ChartOfAccountCategoryCode::Equity, - ChartOfAccountCategoryCode::Revenues, - ChartOfAccountCategoryCode::Expenses, + ChartCategoryPath::Assets, + ChartCategoryPath::Liabilities, + ChartCategoryPath::Equity, + ChartCategoryPath::Revenues, + ChartCategoryPath::Expenses, ] { - let code = ChartOfAccountCode::Category(category); + let code = ChartPath::Category(category); assert_eq!(code.category(), category); } } @@ -486,13 +473,13 @@ mod tests { #[test] fn test_category_from_control_account() { for category in [ - ChartOfAccountCategoryCode::Assets, - ChartOfAccountCategoryCode::Liabilities, - ChartOfAccountCategoryCode::Equity, - ChartOfAccountCategoryCode::Revenues, - ChartOfAccountCategoryCode::Expenses, + ChartCategoryPath::Assets, + ChartCategoryPath::Liabilities, + ChartCategoryPath::Equity, + ChartCategoryPath::Revenues, + ChartCategoryPath::Expenses, ] { - let code = ChartOfAccountCode::ControlAccount { + let code = ChartPath::ControlAccount { category, index: 1.into(), }; @@ -503,13 +490,13 @@ mod tests { #[test] fn test_category_from_control_sub_account() { for category in [ - ChartOfAccountCategoryCode::Assets, - ChartOfAccountCategoryCode::Liabilities, - ChartOfAccountCategoryCode::Equity, - ChartOfAccountCategoryCode::Revenues, - ChartOfAccountCategoryCode::Expenses, + ChartCategoryPath::Assets, + ChartCategoryPath::Liabilities, + ChartCategoryPath::Equity, + ChartCategoryPath::Revenues, + ChartCategoryPath::Expenses, ] { - let code = ChartOfAccountCode::ControlSubAccount { + let code = ChartPath::ControlSubAccount { category, control_index: 1.into(), index: 2.into(), @@ -521,13 +508,13 @@ mod tests { #[test] fn test_category_from_transaction_account() { for category in [ - ChartOfAccountCategoryCode::Assets, - ChartOfAccountCategoryCode::Liabilities, - ChartOfAccountCategoryCode::Equity, - ChartOfAccountCategoryCode::Revenues, - ChartOfAccountCategoryCode::Expenses, + ChartCategoryPath::Assets, + ChartCategoryPath::Liabilities, + ChartCategoryPath::Equity, + ChartCategoryPath::Revenues, + ChartCategoryPath::Expenses, ] { - let code = ChartOfAccountCode::TransactionAccount { + let code = ChartPath::TransactionAccount { category, control_index: 1.into(), control_sub_index: 2.into(), @@ -541,16 +528,16 @@ mod tests { mod control_account_extraction_tests { use super::*; - const CATEGORY: ChartOfAccountCategoryCode = ChartOfAccountCategoryCode::Assets; + const CATEGORY: ChartCategoryPath = ChartCategoryPath::Assets; const CONTROL_INDEX: AccountIdx = AccountIdx::FIRST; - const EXPECTED: ChartOfAccountCode = ChartOfAccountCode::ControlAccount { + const EXPECTED: ChartPath = ChartPath::ControlAccount { category: CATEGORY, index: CONTROL_INDEX, }; #[test] fn test_control_account_from_transaction_account() { - let transaction = ChartOfAccountCode::TransactionAccount { + let transaction = ChartPath::TransactionAccount { category: CATEGORY, control_index: CONTROL_INDEX, control_sub_index: 2.into(), @@ -562,7 +549,7 @@ mod tests { #[test] fn test_control_account_from_control_sub_account() { - let sub_account = ChartOfAccountCode::ControlSubAccount { + let sub_account = ChartPath::ControlSubAccount { category: CATEGORY, control_index: CONTROL_INDEX, index: 2.into(), @@ -573,7 +560,7 @@ mod tests { #[test] fn test_control_account_from_control_account() { - let control_account = ChartOfAccountCode::ControlAccount { + let control_account = ChartPath::ControlAccount { category: CATEGORY, index: CONTROL_INDEX, }; @@ -583,7 +570,7 @@ mod tests { #[test] fn test_control_account_from_category_returns_none() { - let category_code = ChartOfAccountCode::Category(CATEGORY); + let category_code = ChartPath::Category(CATEGORY); assert_eq!(category_code.control_account(), None); } } @@ -591,10 +578,10 @@ mod tests { mod control_sub_account_extraction_tests { use super::*; - const CATEGORY: ChartOfAccountCategoryCode = ChartOfAccountCategoryCode::Assets; + const CATEGORY: ChartCategoryPath = ChartCategoryPath::Assets; const CONTROL_INDEX: AccountIdx = AccountIdx::FIRST; const SUB_INDEX: AccountIdx = AccountIdx::FIRST; - const EXPECTED: ChartOfAccountCode = ChartOfAccountCode::ControlSubAccount { + const EXPECTED: ChartPath = ChartPath::ControlSubAccount { category: CATEGORY, control_index: CONTROL_INDEX, index: SUB_INDEX, @@ -602,7 +589,7 @@ mod tests { #[test] fn test_control_sub_account_from_transaction_account() { - let transaction = ChartOfAccountCode::TransactionAccount { + let transaction = ChartPath::TransactionAccount { category: CATEGORY, control_index: CONTROL_INDEX, control_sub_index: SUB_INDEX, @@ -614,7 +601,7 @@ mod tests { #[test] fn test_control_sub_account_from_control_sub_account() { - let sub_account = ChartOfAccountCode::ControlSubAccount { + let sub_account = ChartPath::ControlSubAccount { category: CATEGORY, control_index: CONTROL_INDEX, index: SUB_INDEX, @@ -625,7 +612,7 @@ mod tests { #[test] fn test_control_sub_account_from_control_account_returns_none() { - let control_account = ChartOfAccountCode::ControlAccount { + let control_account = ChartPath::ControlAccount { category: CATEGORY, index: CONTROL_INDEX, }; @@ -635,7 +622,7 @@ mod tests { #[test] fn test_control_sub_account_from_category_returns_none() { - let category_code = ChartOfAccountCode::Category(CATEGORY); + let category_code = ChartPath::Category(CATEGORY); assert_eq!(category_code.control_sub_account(), None); } } @@ -645,13 +632,13 @@ mod tests { #[test] fn test_first_control_account_creation() { - let category = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); - let control = ChartOfAccountCode::first_control_account(category).unwrap(); + let category = ChartPath::Category(ChartCategoryPath::Assets); + let control = ChartPath::first_control_account(category).unwrap(); assert_eq!( control, - ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Assets, + ChartPath::ControlAccount { + category: ChartCategoryPath::Assets, index: AccountIdx::FIRST, } ); @@ -659,26 +646,26 @@ mod tests { #[test] fn test_first_control_account_invalid_input() { - let invalid_input = ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Assets, + let invalid_input = ChartPath::ControlAccount { + category: ChartCategoryPath::Assets, index: 1.into(), }; - assert!(ChartOfAccountCode::first_control_account(invalid_input).is_err()); + assert!(ChartPath::first_control_account(invalid_input).is_err()); } #[test] fn test_first_control_sub_account_creation() { - let control = ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Assets, + let control = ChartPath::ControlAccount { + category: ChartCategoryPath::Assets, index: AccountIdx::FIRST, }; - let sub = ChartOfAccountCode::first_control_sub_account(&control).unwrap(); + let sub = ChartPath::first_control_sub_account(&control).unwrap(); assert_eq!( sub, - ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Assets, + ChartPath::ControlSubAccount { + category: ChartCategoryPath::Assets, control_index: AccountIdx::FIRST, index: AccountIdx::FIRST, } @@ -687,23 +674,23 @@ mod tests { #[test] fn test_first_control_sub_account_invalid_input() { - let invalid_input = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); - assert!(ChartOfAccountCode::first_control_sub_account(&invalid_input).is_err()); + let invalid_input = ChartPath::Category(ChartCategoryPath::Assets); + assert!(ChartPath::first_control_sub_account(&invalid_input).is_err()); } #[test] fn test_first_transaction_account_creation() { - let sub = ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Assets, + let sub = ChartPath::ControlSubAccount { + category: ChartCategoryPath::Assets, control_index: AccountIdx::FIRST, index: AccountIdx::FIRST, }; - let transaction = ChartOfAccountCode::first_transaction_account(&sub).unwrap(); + let transaction = ChartPath::first_transaction_account(&sub).unwrap(); assert_eq!( transaction, - ChartOfAccountCode::TransactionAccount { - category: ChartOfAccountCategoryCode::Assets, + ChartPath::TransactionAccount { + category: ChartCategoryPath::Assets, control_index: AccountIdx::FIRST, control_sub_index: AccountIdx::FIRST, index: AccountIdx::FIRST, @@ -713,8 +700,8 @@ mod tests { #[test] fn test_first_transaction_account_invalid_input() { - let invalid_input = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); - assert!(ChartOfAccountCode::first_transaction_account(&invalid_input).is_err()); + let invalid_input = ChartPath::Category(ChartCategoryPath::Assets); + assert!(ChartPath::first_transaction_account(&invalid_input).is_err()); } } @@ -723,16 +710,16 @@ mod tests { #[test] fn test_next_control_account_success() { - let control = ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Assets, + let control = ChartPath::ControlAccount { + category: ChartCategoryPath::Assets, index: 1.into(), }; let next_control = control.next().unwrap(); assert_eq!( next_control, - ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Assets, + ChartPath::ControlAccount { + category: ChartCategoryPath::Assets, index: 2.into(), } ); @@ -740,8 +727,8 @@ mod tests { #[test] fn test_next_control_account_overflow() { - let max_control = ChartOfAccountCode::ControlAccount { - category: ChartOfAccountCategoryCode::Assets, + let max_control = ChartPath::ControlAccount { + category: ChartCategoryPath::Assets, index: AccountIdx::MAX_TWO_DIGIT, }; assert!(max_control.next().is_err()); @@ -749,8 +736,8 @@ mod tests { #[test] fn test_next_control_sub_account_success() { - let sub = ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Assets, + let sub = ChartPath::ControlSubAccount { + category: ChartCategoryPath::Assets, control_index: 1.into(), index: 1.into(), }; @@ -758,8 +745,8 @@ mod tests { let next_sub = sub.next().unwrap(); assert_eq!( next_sub, - ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Assets, + ChartPath::ControlSubAccount { + category: ChartCategoryPath::Assets, control_index: 1.into(), index: 2.into(), } @@ -768,8 +755,8 @@ mod tests { #[test] fn test_next_control_sub_account_overflow() { - let max_sub = ChartOfAccountCode::ControlSubAccount { - category: ChartOfAccountCategoryCode::Assets, + let max_sub = ChartPath::ControlSubAccount { + category: ChartCategoryPath::Assets, control_index: 1.into(), index: AccountIdx::MAX_TWO_DIGIT, }; @@ -778,8 +765,8 @@ mod tests { #[test] fn test_next_transaction_account_success() { - let transaction = ChartOfAccountCode::TransactionAccount { - category: ChartOfAccountCategoryCode::Assets, + let transaction = ChartPath::TransactionAccount { + category: ChartCategoryPath::Assets, control_index: 1.into(), control_sub_index: 1.into(), index: 1.into(), @@ -788,8 +775,8 @@ mod tests { let next_transaction = transaction.next().unwrap(); assert_eq!( next_transaction, - ChartOfAccountCode::TransactionAccount { - category: ChartOfAccountCategoryCode::Assets, + ChartPath::TransactionAccount { + category: ChartCategoryPath::Assets, control_index: 1.into(), control_sub_index: 1.into(), index: 2.into(), @@ -799,8 +786,8 @@ mod tests { #[test] fn test_next_transaction_account_overflow() { - let max_transaction = ChartOfAccountCode::TransactionAccount { - category: ChartOfAccountCategoryCode::Assets, + let max_transaction = ChartPath::TransactionAccount { + category: ChartCategoryPath::Assets, control_index: 1.into(), control_sub_index: 1.into(), index: AccountIdx::MAX_THREE_DIGIT, @@ -810,7 +797,7 @@ mod tests { #[test] fn test_next_category_returns_same() { - let category = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); + let category = ChartPath::Category(ChartCategoryPath::Assets); let next_category = category.next().unwrap(); assert_eq!(category, next_category); } diff --git a/core/chart-of-accounts/src/primitives.rs b/core/chart-of-accounts/src/primitives.rs index 22d1fcada..5647453c1 100644 --- a/core/chart-of-accounts/src/primitives.rs +++ b/core/chart-of-accounts/src/primitives.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; pub use cala_ledger::{primitives::AccountId as LedgerAccountId, DebitOrCredit}; -pub use crate::code::{ChartOfAccountCategoryCode as CategoryPath, ChartOfAccountCode}; +pub use crate::path::{ChartCategoryPath as CategoryPath, ChartPath}; es_entity::entity_id! { ChartId, @@ -55,9 +55,7 @@ impl FromStr for CoreChartOfAccountsObject { use CoreChartOfAccountsObjectDiscriminants::*; let res = match entity.parse().expect("invalid entity") { Chart => { - let obj_ref = id - .parse() - .map_err(|_| "could not parse CoreChartOfAccountObject")?; + let obj_ref = id.parse().map_err(|_| "could not parse CoreChartObject")?; CoreChartOfAccountsObject::Chart(obj_ref) } }; @@ -123,17 +121,17 @@ impl From for CoreChartOfAccountsAction { } #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ChartOfAccountAccountDetails { +pub struct ChartAccountDetails { pub account_id: LedgerAccountId, - pub path: ChartOfAccountCode, + pub path: ChartPath, pub code: String, pub name: String, pub description: String, } #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ChartOfAccountCreationDetails { - pub parent_path: ChartOfAccountCode, +pub struct ChartCreationDetails { + pub parent_path: ChartPath, pub account_id: LedgerAccountId, pub name: String, pub description: String, diff --git a/core/chart-of-accounts/src/transaction_account_factory.rs b/core/chart-of-accounts/src/transaction_account_factory.rs index ede42b1a1..180093f6d 100644 --- a/core/chart-of-accounts/src/transaction_account_factory.rs +++ b/core/chart-of-accounts/src/transaction_account_factory.rs @@ -2,28 +2,26 @@ use audit::AuditInfo; use cala_ledger::{account::*, CalaLedger, LedgerOperation}; use crate::{ - chart_of_accounts::ChartOfAccountRepo, - code::ChartOfAccountCode, - error::CoreChartOfAccountError, - primitives::{ - ChartId, ChartOfAccountAccountDetails, ChartOfAccountCreationDetails, LedgerAccountId, - }, + chart_of_accounts::ChartRepo, + error::CoreChartOfAccountsError, + path::ChartPath, + primitives::{ChartAccountDetails, ChartCreationDetails, ChartId, LedgerAccountId}, }; #[derive(Clone)] pub struct TransactionAccountFactory { - repo: ChartOfAccountRepo, + repo: ChartRepo, cala: CalaLedger, chart_id: ChartId, - control_sub_account: ChartOfAccountCode, + control_sub_account: ChartPath, } impl TransactionAccountFactory { pub(super) fn new( - repo: &ChartOfAccountRepo, + repo: &ChartRepo, cala: &CalaLedger, chart_id: ChartId, - control_sub_account: ChartOfAccountCode, + control_sub_account: ChartPath, ) -> Self { Self { repo: repo.clone(), @@ -40,14 +38,14 @@ impl TransactionAccountFactory { name: &str, description: &str, audit_info: AuditInfo, - ) -> Result { + ) -> Result { let mut chart = self .repo .find_by_id_in_tx(op.op().tx(), self.chart_id) .await?; let account_details = chart.add_transaction_account( - ChartOfAccountCreationDetails { + ChartCreationDetails { account_id: account_id.into(), parent_path: self.control_sub_account, name: name.to_string(), diff --git a/core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json deleted file mode 100644 index 19e53c2ec..000000000 --- a/core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Timestamptz", - "Int8", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3" -} diff --git a/core/deposit/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json b/core/deposit/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json new file mode 100644 index 000000000..f2dd574b1 --- /dev/null +++ b/core/deposit/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE id = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7" +} diff --git a/core/deposit/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/core/deposit/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json similarity index 63% rename from core/deposit/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json rename to core/deposit/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json index 95a5300c8..5864f3728 100644 --- a/core/deposit/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json +++ b/core/deposit/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "SELECT i.id AS \"id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM core_chart_of_accounts i JOIN core_chart_of_account_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "query": "SELECT i.id AS \"id: ChartId\", e.sequence, e.event, e.recorded_at FROM core_charts i JOIN core_chart_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id: ChartOfAccountId", + "name": "id: ChartId", "type_info": "Uuid" }, { @@ -36,5 +36,5 @@ false ] }, - "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" + "hash": "3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9" } diff --git a/core/deposit/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json b/core/deposit/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json new file mode 100644 index 000000000..6bacdb20b --- /dev/null +++ b/core/deposit/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6" +} diff --git a/core/chart-of-accounts/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/core/deposit/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json similarity index 60% rename from core/chart-of-accounts/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json rename to core/deposit/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json index dae4e1e2e..842d42442 100644 --- a/core/chart-of-accounts/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json +++ b/core/deposit/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -38,5 +38,5 @@ false ] }, - "hash": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" + "hash": "4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f" } diff --git a/core/deposit/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/core/deposit/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json similarity index 53% rename from core/deposit/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json rename to core/deposit/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json index 95bebab0d..6cf19b9d2 100644 --- a/core/deposit/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json +++ b/core/deposit/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "query": "UPDATE core_charts SET reference = $2 WHERE id = $1", "describe": { "columns": [], "parameters": { @@ -11,5 +11,5 @@ }, "nullable": [] }, - "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" + "hash": "5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432" } diff --git a/core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json deleted file mode 100644 index 5f58f2f07..000000000 --- a/core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Timestamptz", - "UuidArray", - "Int4Array", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72" -} diff --git a/core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json deleted file mode 100644 index 68cc67380..000000000 --- a/core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43" -} diff --git a/core/deposit/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json b/core/deposit/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json deleted file mode 100644 index c2f814ec9..000000000 --- a/core/deposit/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b" -} diff --git a/lana/dashboard/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/core/deposit/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json similarity index 60% rename from lana/dashboard/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json rename to core/deposit/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json index dae4e1e2e..ba8093387 100644 --- a/lana/dashboard/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json +++ b/core/deposit/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -38,5 +38,5 @@ false ] }, - "hash": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" + "hash": "b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d" } diff --git a/lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/core/deposit/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json similarity index 53% rename from lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json rename to core/deposit/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json index d57a47c95..d634f5e29 100644 --- a/lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json +++ b/core/deposit/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "query": "INSERT INTO core_charts (id, reference, created_at) VALUES ($1, $2, $3)", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" + "hash": "bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a" } diff --git a/core/deposit/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json b/core/deposit/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json new file mode 100644 index 000000000..0f22cddce --- /dev/null +++ b/core/deposit/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5" +} diff --git a/core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json deleted file mode 100644 index 65ba29133..000000000 --- a/core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid", - "Timestamptz" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42" -} diff --git a/core/deposit/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json b/core/deposit/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json deleted file mode 100644 index 369e3792b..000000000 --- a/core/deposit/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12" -} diff --git a/lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/core/deposit/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json similarity index 58% rename from lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json rename to core/deposit/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json index 8ac8f7df0..9870c96b2 100644 --- a/lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json +++ b/core/deposit/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE id = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -26,6 +26,7 @@ ], "parameters": { "Left": [ + "Int8", "Uuid" ] }, @@ -36,5 +37,5 @@ false ] }, - "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" + "hash": "d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e" } diff --git a/core/deposit/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json b/core/deposit/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json new file mode 100644 index 000000000..5cfce6af5 --- /dev/null +++ b/core/deposit/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4" +} diff --git a/core/deposit/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json b/core/deposit/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json new file mode 100644 index 000000000..aef1c5f66 --- /dev/null +++ b/core/deposit/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "UuidArray", + "Int4Array", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8" +} diff --git a/core/deposit/src/error.rs b/core/deposit/src/error.rs index ccc2e0613..2248f8207 100644 --- a/core/deposit/src/error.rs +++ b/core/deposit/src/error.rs @@ -4,7 +4,7 @@ use thiserror::Error; pub enum CoreDepositError { #[error("CoreDepositError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("CoreChartOfAccountError - AuditError: {0}")] + #[error("CoreChartOfAccountsError - AuditError: {0}")] AuditError(#[from] audit::error::AuditError), #[error("CoreDepositError - AuthorizationError: {0}")] AuthorizationError(#[from] authz::error::AuthorizationError), @@ -18,8 +18,8 @@ pub enum CoreDepositError { DepositLedgerError(#[from] crate::ledger::error::DepositLedgerError), #[error("CoreDepositError - GovernanceError: {0}")] GovernanceError(#[from] governance::error::GovernanceError), - #[error("CoreDepositError - CoreChartOfAccountError: {0}")] - CoreChartOfAccountError(#[from] chart_of_accounts::error::CoreChartOfAccountError), + #[error("CoreDepositError - CoreChartOfAccountsError: {0}")] + CoreChartOfAccountsError(#[from] chart_of_accounts::error::CoreChartOfAccountsError), #[error("CoreDepositError - JobError: {0}")] JobError(#[from] job::error::JobError), #[error("CoreDepositError - ProcessError: {0}")] diff --git a/core/deposit/tests/deposit.rs b/core/deposit/tests/deposit.rs index 6e675f194..2c904e15c 100644 --- a/core/deposit/tests/deposit.rs +++ b/core/deposit/tests/deposit.rs @@ -4,7 +4,7 @@ use rust_decimal_macros::dec; use authz::dummy::DummySubject; use cala_ledger::{CalaLedger, CalaLedgerConfig}; -use chart_of_accounts::{CategoryPath, ChartOfAccountCode, CoreChartOfAccounts}; +use chart_of_accounts::{CategoryPath, ChartPath, CoreChartOfAccounts}; use deposit::*; use helpers::{action, event, object}; @@ -41,7 +41,7 @@ async fn deposit() -> anyhow::Result<()> { let control_account_path = chart_of_accounts .create_control_account( chart_id, - ChartOfAccountCode::Category(CategoryPath::Liabilities), + ChartPath::Category(CategoryPath::Liabilities), "Deposits".to_string(), "deposits".to_string(), ) diff --git a/core/deposit/tests/withdraw.rs b/core/deposit/tests/withdraw.rs index 39d988fb3..76b9ed854 100644 --- a/core/deposit/tests/withdraw.rs +++ b/core/deposit/tests/withdraw.rs @@ -4,7 +4,7 @@ use rust_decimal_macros::dec; use authz::dummy::DummySubject; use cala_ledger::{CalaLedger, CalaLedgerConfig}; -use chart_of_accounts::{CategoryPath, ChartOfAccountCode, CoreChartOfAccounts}; +use chart_of_accounts::{CategoryPath, ChartPath, CoreChartOfAccounts}; use deposit::*; use helpers::{action, event, object}; @@ -42,7 +42,7 @@ async fn cancel_withdrawal() -> anyhow::Result<()> { let control_account_path = chart_of_accounts .create_control_account( chart_id, - ChartOfAccountCode::Category(CategoryPath::Liabilities), + ChartPath::Category(CategoryPath::Liabilities), "Deposits".to_string(), "deposits".to_string(), ) diff --git a/lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json deleted file mode 100644 index 19e53c2ec..000000000 --- a/lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Timestamptz", - "Int8", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3" -} diff --git a/lana/app/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json b/lana/app/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json new file mode 100644 index 000000000..f2dd574b1 --- /dev/null +++ b/lana/app/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE id = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7" +} diff --git a/lana/dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/lana/app/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json similarity index 63% rename from lana/dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json rename to lana/app/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json index 95a5300c8..5864f3728 100644 --- a/lana/dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json +++ b/lana/app/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "SELECT i.id AS \"id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM core_chart_of_accounts i JOIN core_chart_of_account_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "query": "SELECT i.id AS \"id: ChartId\", e.sequence, e.event, e.recorded_at FROM core_charts i JOIN core_chart_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id: ChartOfAccountId", + "name": "id: ChartId", "type_info": "Uuid" }, { @@ -36,5 +36,5 @@ false ] }, - "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" + "hash": "3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9" } diff --git a/lana/app/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json b/lana/app/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json new file mode 100644 index 000000000..6bacdb20b --- /dev/null +++ b/lana/app/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6" +} diff --git a/lana/app/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json b/lana/app/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json new file mode 100644 index 000000000..842d42442 --- /dev/null +++ b/lana/app/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f" +} diff --git a/core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/lana/app/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json similarity index 53% rename from core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json rename to lana/app/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json index 95bebab0d..6cf19b9d2 100644 --- a/core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json +++ b/lana/app/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "query": "UPDATE core_charts SET reference = $2 WHERE id = $1", "describe": { "columns": [], "parameters": { @@ -11,5 +11,5 @@ }, "nullable": [] }, - "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" + "hash": "5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432" } diff --git a/lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json deleted file mode 100644 index 5f58f2f07..000000000 --- a/lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Timestamptz", - "UuidArray", - "Int4Array", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72" -} diff --git a/lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json deleted file mode 100644 index 68cc67380..000000000 --- a/lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43" -} diff --git a/lana/app/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json b/lana/app/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json deleted file mode 100644 index c2f814ec9..000000000 --- a/lana/app/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b" -} diff --git a/lana/app/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json b/lana/app/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json new file mode 100644 index 000000000..ba8093387 --- /dev/null +++ b/lana/app/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d" +} diff --git a/lana/dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/lana/app/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json similarity index 53% rename from lana/dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json rename to lana/app/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json index d57a47c95..d634f5e29 100644 --- a/lana/dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json +++ b/lana/app/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "query": "INSERT INTO core_charts (id, reference, created_at) VALUES ($1, $2, $3)", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" + "hash": "bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a" } diff --git a/lana/app/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json b/lana/app/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json new file mode 100644 index 000000000..0f22cddce --- /dev/null +++ b/lana/app/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5" +} diff --git a/lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json deleted file mode 100644 index 65ba29133..000000000 --- a/lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid", - "Timestamptz" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42" -} diff --git a/lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json b/lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json deleted file mode 100644 index 369e3792b..000000000 --- a/lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12" -} diff --git a/lana/dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/lana/app/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json similarity index 58% rename from lana/dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json rename to lana/app/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json index 8ac8f7df0..9870c96b2 100644 --- a/lana/dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json +++ b/lana/app/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE id = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -26,6 +26,7 @@ ], "parameters": { "Left": [ + "Int8", "Uuid" ] }, @@ -36,5 +37,5 @@ false ] }, - "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" + "hash": "d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e" } diff --git a/lana/app/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json b/lana/app/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json new file mode 100644 index 000000000..5cfce6af5 --- /dev/null +++ b/lana/app/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4" +} diff --git a/lana/app/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json b/lana/app/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json new file mode 100644 index 000000000..aef1c5f66 --- /dev/null +++ b/lana/app/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "UuidArray", + "Int4Array", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8" +} diff --git a/lana/app/migrations/20240517074612_core_setup.sql b/lana/app/migrations/20240517074612_core_setup.sql index 84d6a0512..daab1e2f3 100644 --- a/lana/app/migrations/20240517074612_core_setup.sql +++ b/lana/app/migrations/20240517074612_core_setup.sql @@ -46,14 +46,14 @@ CREATE TABLE approval_process_events ( UNIQUE(id, sequence) ); -CREATE TABLE core_chart_of_accounts ( +CREATE TABLE core_charts ( id UUID PRIMARY KEY, reference VARCHAR NOT NULL UNIQUE, created_at TIMESTAMPTZ NOT NULL ); -CREATE TABLE core_chart_of_account_events ( - id UUID NOT NULL REFERENCES core_chart_of_accounts(id), +CREATE TABLE core_chart_events ( + id UUID NOT NULL REFERENCES core_charts(id), sequence INT NOT NULL, event_type VARCHAR NOT NULL, event JSONB NOT NULL, diff --git a/lana/app/src/accounting_init/error.rs b/lana/app/src/accounting_init/error.rs index 9a8182468..fb6e65c2a 100644 --- a/lana/app/src/accounting_init/error.rs +++ b/lana/app/src/accounting_init/error.rs @@ -2,8 +2,8 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum AccountingInitError { - #[error("AccountingInitError - CoreChartOfAccountError: {0}")] - CoreChartOfAccountError(#[from] chart_of_accounts::error::CoreChartOfAccountError), + #[error("AccountingInitError - CoreChartOfAccountsError: {0}")] + CoreChartOfAccountsError(#[from] chart_of_accounts::error::CoreChartOfAccountsError), #[error("ApplicationError - JournalError: {0}")] JournalError(#[from] cala_ledger::journal::error::JournalError), } diff --git a/lana/app/src/accounting_init/mod.rs b/lana/app/src/accounting_init/mod.rs index e3d13a01b..750792402 100644 --- a/lana/app/src/accounting_init/mod.rs +++ b/lana/app/src/accounting_init/mod.rs @@ -4,7 +4,7 @@ mod seed; pub mod error; -use chart_of_accounts::{ChartId, ChartOfAccountCode}; +use chart_of_accounts::{ChartId, ChartPath}; use crate::chart_of_accounts::ChartOfAccounts; diff --git a/lana/app/src/accounting_init/primitives.rs b/lana/app/src/accounting_init/primitives.rs index 8667cef50..55602d631 100644 --- a/lana/app/src/accounting_init/primitives.rs +++ b/lana/app/src/accounting_init/primitives.rs @@ -1,4 +1,4 @@ -use chart_of_accounts::{ChartId, ChartOfAccountCode}; +use chart_of_accounts::{ChartId, ChartPath}; #[derive(Clone, Copy)] pub struct ChartIds { @@ -8,15 +8,15 @@ pub struct ChartIds { #[derive(Clone)] pub struct DepositsAccountPaths { - pub deposits: ChartOfAccountCode, + pub deposits: ChartPath, } #[derive(Clone)] pub struct CreditFacilitiesAccountPaths { - pub collateral: ChartOfAccountCode, - pub facility: ChartOfAccountCode, - pub disbursed_receivable: ChartOfAccountCode, - pub interest_receivable: ChartOfAccountCode, - pub interest_income: ChartOfAccountCode, - pub fee_income: ChartOfAccountCode, + pub collateral: ChartPath, + pub facility: ChartPath, + pub disbursed_receivable: ChartPath, + pub interest_receivable: ChartPath, + pub interest_income: ChartPath, + pub fee_income: ChartPath, } diff --git a/lana/app/src/accounting_init/seed.rs b/lana/app/src/accounting_init/seed.rs index e2e4cfb20..904ce2b82 100644 --- a/lana/app/src/accounting_init/seed.rs +++ b/lana/app/src/accounting_init/seed.rs @@ -80,12 +80,12 @@ async fn create_charts_of_accounts( async fn create_control_sub_account( chart_of_accounts: &ChartOfAccounts, chart_id: ChartId, - category: ChartOfAccountCode, + category: ChartPath, control_name: String, control_reference: String, sub_name: String, sub_reference: String, -) -> Result { +) -> Result { let control_path = match chart_of_accounts .find_control_account_by_reference(chart_id, control_reference.clone()) .await? @@ -120,7 +120,7 @@ async fn create_deposits_account_paths( let deposits = create_control_sub_account( chart_of_accounts, chart_ids.primary, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Liabilities), + ChartPath::Category(chart_of_accounts::CategoryPath::Liabilities), DEPOSITS_CONTROL_ACCOUNT_NAME.to_string(), DEPOSITS_CONTROL_ACCOUNT_REF.to_string(), DEPOSITS_CONTROL_SUB_ACCOUNT_NAME.to_string(), @@ -138,7 +138,7 @@ async fn create_credit_facilities_account_paths( let collateral = create_control_sub_account( chart_of_accounts, chart_ids.off_balance_sheet, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Liabilities), + ChartPath::Category(chart_of_accounts::CategoryPath::Liabilities), CREDIT_FACILITIES_COLLATERAL_CONTROL_ACCOUNT_NAME.to_string(), CREDIT_FACILITIES_COLLATERAL_CONTROL_ACCOUNT_REF.to_string(), CREDIT_FACILITIES_COLLATERAL_CONTROL_SUB_ACCOUNT_NAME.to_string(), @@ -149,7 +149,7 @@ async fn create_credit_facilities_account_paths( let facility = create_control_sub_account( chart_of_accounts, chart_ids.off_balance_sheet, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Assets), + ChartPath::Category(chart_of_accounts::CategoryPath::Assets), CREDIT_FACILITIES_FACILITY_CONTROL_ACCOUNT_NAME.to_string(), CREDIT_FACILITIES_FACILITY_CONTROL_ACCOUNT_REF.to_string(), CREDIT_FACILITIES_FACILITY_CONTROL_SUB_ACCOUNT_NAME.to_string(), @@ -160,7 +160,7 @@ async fn create_credit_facilities_account_paths( let disbursed_receivable = create_control_sub_account( chart_of_accounts, chart_ids.primary, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Assets), + ChartPath::Category(chart_of_accounts::CategoryPath::Assets), CREDIT_FACILITIES_DISBURSED_RECEIVABLE_CONTROL_ACCOUNT_NAME.to_string(), CREDIT_FACILITIES_DISBURSED_RECEIVABLE_CONTROL_ACCOUNT_REF.to_string(), CREDIT_FACILITIES_DISBURSED_RECEIVABLE_CONTROL_SUB_ACCOUNT_NAME.to_string(), @@ -171,7 +171,7 @@ async fn create_credit_facilities_account_paths( let interest_receivable = create_control_sub_account( chart_of_accounts, chart_ids.primary, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Assets), + ChartPath::Category(chart_of_accounts::CategoryPath::Assets), CREDIT_FACILITIES_INTEREST_RECEIVABLE_CONTROL_ACCOUNT_NAME.to_string(), CREDIT_FACILITIES_INTEREST_RECEIVABLE_CONTROL_ACCOUNT_REF.to_string(), CREDIT_FACILITIES_INTEREST_RECEIVABLE_CONTROL_SUB_ACCOUNT_NAME.to_string(), @@ -182,7 +182,7 @@ async fn create_credit_facilities_account_paths( let interest_income = create_control_sub_account( chart_of_accounts, chart_ids.primary, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Revenues), + ChartPath::Category(chart_of_accounts::CategoryPath::Revenues), CREDIT_FACILITIES_INTEREST_INCOME_CONTROL_ACCOUNT_NAME.to_string(), CREDIT_FACILITIES_INTEREST_INCOME_CONTROL_ACCOUNT_REF.to_string(), CREDIT_FACILITIES_INTEREST_INCOME_CONTROL_SUB_ACCOUNT_NAME.to_string(), @@ -193,7 +193,7 @@ async fn create_credit_facilities_account_paths( let fee_income = create_control_sub_account( chart_of_accounts, chart_ids.primary, - ChartOfAccountCode::Category(chart_of_accounts::CategoryPath::Revenues), + ChartPath::Category(chart_of_accounts::CategoryPath::Revenues), CREDIT_FACILITIES_FEE_INCOME_CONTROL_ACCOUNT_NAME.to_string(), CREDIT_FACILITIES_FEE_INCOME_CONTROL_ACCOUNT_REF.to_string(), CREDIT_FACILITIES_FEE_INCOME_CONTROL_SUB_ACCOUNT_NAME.to_string(), diff --git a/lana/app/src/app/error.rs b/lana/app/src/app/error.rs index c20d3e9a1..0fb181f4e 100644 --- a/lana/app/src/app/error.rs +++ b/lana/app/src/app/error.rs @@ -33,7 +33,7 @@ pub enum ApplicationError { #[error("ApplicationError - CalaInit: {0}")] CalaError(#[from] cala_ledger::error::LedgerError), #[error("ApplicationError - ChartOfAccountsError: {0}")] - ChartOfAccountsError(#[from] chart_of_accounts::error::CoreChartOfAccountError), + ChartOfAccountsError(#[from] chart_of_accounts::error::CoreChartOfAccountsError), #[error("ApplicationError - DepositError: {0}")] DepositError(#[from] crate::deposit::error::CoreDepositError), } diff --git a/lana/app/src/credit_facility/credit_chart_of_accounts/error.rs b/lana/app/src/credit_facility/credit_chart_of_accounts/error.rs index 31fad8341..163c98709 100644 --- a/lana/app/src/credit_facility/credit_chart_of_accounts/error.rs +++ b/lana/app/src/credit_facility/credit_chart_of_accounts/error.rs @@ -4,6 +4,6 @@ use thiserror::Error; pub enum CreditChartOfAccountsError { #[error("CreditChartOfAccountsError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("CreditChartOfAccountsError - CoreChartOfAccountError: {0}")] - CoreChartOfAccountError(#[from] chart_of_accounts::error::CoreChartOfAccountError), + #[error("CreditChartOfAccountsError - CoreChartOfAccountsError: {0}")] + CoreChartOfAccountsError(#[from] chart_of_accounts::error::CoreChartOfAccountsError), } diff --git a/lana/app/src/ledger/error.rs b/lana/app/src/ledger/error.rs index 0a3f33b67..c46504759 100644 --- a/lana/app/src/ledger/error.rs +++ b/lana/app/src/ledger/error.rs @@ -10,8 +10,8 @@ pub enum LedgerError { TryFromIntError(#[from] std::num::TryFromIntError), #[error("LedgerError - ConversionError: {0}")] ConversionError(#[from] crate::primitives::ConversionError), - #[error("LedgerError - CoreChartOfAccountError: {0}")] - CoreChartOfAccountError(#[from] chart_of_accounts::error::CoreChartOfAccountError), + #[error("LedgerError - CoreChartOfAccountsError: {0}")] + CoreChartOfAccountsError(#[from] chart_of_accounts::error::CoreChartOfAccountsError), #[error("LedgerError - CouldNotAssertAccountExists")] CouldNotAssertAccountExists, #[error("LedgerError - CouldNotAssertAccountSetExists")] diff --git a/lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json deleted file mode 100644 index 19e53c2ec..000000000 --- a/lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Timestamptz", - "Int8", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3" -} diff --git a/lana/dashboard/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json b/lana/dashboard/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json new file mode 100644 index 000000000..f2dd574b1 --- /dev/null +++ b/lana/dashboard/.sqlx/query-1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE id = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "1a6346652e61bace96a8fcb8726b7f7099bbbef7dcd2229208690d7432e962c7" +} diff --git a/core/chart-of-accounts/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/lana/dashboard/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json similarity index 63% rename from core/chart-of-accounts/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json rename to lana/dashboard/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json index 95a5300c8..5864f3728 100644 --- a/core/chart-of-accounts/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json +++ b/lana/dashboard/.sqlx/query-3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "SELECT i.id AS \"id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM core_chart_of_accounts i JOIN core_chart_of_account_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "query": "SELECT i.id AS \"id: ChartId\", e.sequence, e.event, e.recorded_at FROM core_charts i JOIN core_chart_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id: ChartOfAccountId", + "name": "id: ChartId", "type_info": "Uuid" }, { @@ -36,5 +36,5 @@ false ] }, - "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" + "hash": "3020ddc2bf2d3b00f0ce27a748c4d2b3ce4d55d9506f35be87eaeacc2485c5f9" } diff --git a/lana/dashboard/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json b/lana/dashboard/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json new file mode 100644 index 000000000..6bacdb20b --- /dev/null +++ b/lana/dashboard/.sqlx/query-3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "3e9775e68e6688f726c32fe9ee624b2556641f7645161a2b7366506ae9c17ba6" +} diff --git a/lana/dashboard/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json b/lana/dashboard/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json new file mode 100644 index 000000000..842d42442 --- /dev/null +++ b/lana/dashboard/.sqlx/query-4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "4f74d60a4cb2fab69a43928eba2dab344009ac41253ac4a0f58949f692f88f5f" +} diff --git a/lana/dashboard/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/lana/dashboard/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json similarity index 53% rename from lana/dashboard/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json rename to lana/dashboard/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json index 95bebab0d..6cf19b9d2 100644 --- a/lana/dashboard/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json +++ b/lana/dashboard/.sqlx/query-5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "query": "UPDATE core_charts SET reference = $2 WHERE id = $1", "describe": { "columns": [], "parameters": { @@ -11,5 +11,5 @@ }, "nullable": [] }, - "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" + "hash": "5434872de3b6f8793630492d354b4b75706d1fd5f6fc72d6cd66cb32b0c56432" } diff --git a/lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json deleted file mode 100644 index 5f58f2f07..000000000 --- a/lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_account_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Timestamptz", - "UuidArray", - "Int4Array", - "TextArray", - "JsonbArray" - ] - }, - "nullable": [] - }, - "hash": "551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72" -} diff --git a/lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json deleted file mode 100644 index 68cc67380..000000000 --- a/lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43" -} diff --git a/lana/dashboard/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json b/lana/dashboard/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json deleted file mode 100644 index c2f814ec9..000000000 --- a/lana/dashboard/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE reference = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b" -} diff --git a/lana/dashboard/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json b/lana/dashboard/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json new file mode 100644 index 000000000..ba8093387 --- /dev/null +++ b/lana/dashboard/.sqlx/query-b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_charts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "b6943ac9227478aee988c0e25f59fabf0c12b96f0484f783906f92a6b567dc3d" +} diff --git a/core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/lana/dashboard/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json similarity index 53% rename from core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json rename to lana/dashboard/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json index d57a47c95..d634f5e29 100644 --- a/core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json +++ b/lana/dashboard/.sqlx/query-bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "query": "INSERT INTO core_charts (id, reference, created_at) VALUES ($1, $2, $3)", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" + "hash": "bafbab3b7da17de2058228b767a0e6859d45a4420f97759f03f46e9772f32d8a" } diff --git a/lana/dashboard/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json b/lana/dashboard/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json new file mode 100644 index 000000000..0f22cddce --- /dev/null +++ b/lana/dashboard/.sqlx/query-c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: ChartId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "c0345a74de37c1b0514cd03de7a3cd4c4cbb1b40a747c2e4017f27fb066f2df5" +} diff --git a/lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json deleted file mode 100644 index 65ba29133..000000000 --- a/lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM core_chart_of_accounts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid", - "Timestamptz" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42" -} diff --git a/lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json b/lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json deleted file mode 100644 index 369e3792b..000000000 --- a/lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "entity_id: ChartOfAccountId", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - }, - { - "ordinal": 3, - "name": "recorded_at", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Int8", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12" -} diff --git a/core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/lana/dashboard/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json similarity index 58% rename from core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json rename to lana/dashboard/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json index 8ac8f7df0..9870c96b2 100644 --- a/core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json +++ b/lana/dashboard/.sqlx/query-d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM core_chart_of_accounts WHERE id = $1) SELECT i.id AS \"entity_id: ChartOfAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_of_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_charts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: ChartId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_chart_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "entity_id: ChartOfAccountId", + "name": "entity_id: ChartId", "type_info": "Uuid" }, { @@ -26,6 +26,7 @@ ], "parameters": { "Left": [ + "Int8", "Uuid" ] }, @@ -36,5 +37,5 @@ false ] }, - "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" + "hash": "d4fd0354bd4a03c1fb53744da0eef66362d1b098a53fede2059bc0747807f40e" } diff --git a/lana/dashboard/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json b/lana/dashboard/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json new file mode 100644 index 000000000..5cfce6af5 --- /dev/null +++ b/lana/dashboard/.sqlx/query-d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT $1, $2, ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::text[], $5::jsonb[]) AS unnested(event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "d86838e00987c3282427e13a3d04b0cc1ae51536ca32fc0be9cb4efa1ef163c4" +} diff --git a/lana/dashboard/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json b/lana/dashboard/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json new file mode 100644 index 000000000..aef1c5f66 --- /dev/null +++ b/lana/dashboard/.sqlx/query-e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_events (id, recorded_at, sequence, event_type, event) SELECT unnested.id, $1, unnested.sequence, unnested.event_type, unnested.event FROM UNNEST($2::UUID[], $3::INT[], $4::TEXT[], $5::JSONB[]) AS unnested(id, sequence, event_type, event)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "UuidArray", + "Int4Array", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [] + }, + "hash": "e0ccbc840d9e2b5ca533a52dc08993f78a76f2dead178e7af565756b220602f8" +}