diff --git a/Cargo.lock b/Cargo.lock index 2cfd5c8e7..84d36284d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -832,12 +832,14 @@ dependencies = [ "derive_builder", "es-entity", "outbox", + "rand", "serde", "sqlx", "strum", "thiserror 1.0.69", "tokio", "tracing", + "uuid", ] [[package]] @@ -1185,6 +1187,7 @@ dependencies = [ "governance", "job", "outbox", + "rand", "rust_decimal", "rust_decimal_macros", "serde", diff --git a/core/chart-of-accounts/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/core/chart-of-accounts/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json new file mode 100644 index 000000000..d57a47c95 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" +} diff --git a/core/chart-of-accounts/.sqlx/query-12c19a58f42d5ec96fd75e628a04d5354b6cdb3f1a7881c2fad4c424eebadefc.json b/core/chart-of-accounts/.sqlx/query-12c19a58f42d5ec96fd75e628a04d5354b6cdb3f1a7881c2fad4c424eebadefc.json new file mode 100644 index 000000000..084162b24 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-12c19a58f42d5ec96fd75e628a04d5354b6cdb3f1a7881c2fad4c424eebadefc.json @@ -0,0 +1,53 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id AS \"id: AuditEntryId\", subject, object, action, authorized, recorded_at\n FROM audit_entries\n WHERE COALESCE(id < $1, true)\n ORDER BY id DESC\n LIMIT $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: AuditEntryId", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "subject", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "object", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "action", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "authorized", + "type_info": "Bool" + }, + { + "ordinal": 5, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false + ] + }, + "hash": "12c19a58f42d5ec96fd75e628a04d5354b6cdb3f1a7881c2fad4c424eebadefc" +} diff --git a/lana/app/.sqlx/query-0405575b2be806da0d1da533f0a1310ffa53080447fd05d318247e7ed3810246.json b/core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json similarity index 50% rename from lana/app/.sqlx/query-0405575b2be806da0d1da533f0a1310ffa53080447fd05d318247e7ed3810246.json rename to core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json index 88af9b0e3..95bebab0d 100644 --- a/lana/app/.sqlx/query-0405575b2be806da0d1da533f0a1310ffa53080447fd05d318247e7ed3810246.json +++ b/core/chart-of-accounts/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json @@ -1,16 +1,15 @@ { "db_name": "PostgreSQL", - "query": "UPDATE deposits SET customer_id = $2, reference = $3 WHERE id = $1", + "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", "describe": { "columns": [], "parameters": { "Left": [ - "Uuid", "Uuid", "Varchar" ] }, "nullable": [] }, - "hash": "0405575b2be806da0d1da533f0a1310ffa53080447fd05d318247e7ed3810246" + "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" } diff --git a/core/chart-of-accounts/.sqlx/query-3dbfcc01ab6bdb5df67d4025ec5e8adb21d798f96aaa64dab841db55d2f905d5.json b/core/chart-of-accounts/.sqlx/query-3dbfcc01ab6bdb5df67d4025ec5e8adb21d798f96aaa64dab841db55d2f905d5.json deleted file mode 100644 index 2b6a72b50..000000000 --- a/core/chart-of-accounts/.sqlx/query-3dbfcc01ab6bdb5df67d4025ec5e8adb21d798f96aaa64dab841db55d2f905d5.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO core_chart_of_accounts (id, created_at) VALUES ($1, $2)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Timestamptz" - ] - }, - "nullable": [] - }, - "hash": "3dbfcc01ab6bdb5df67d4025ec5e8adb21d798f96aaa64dab841db55d2f905d5" -} diff --git a/core/chart-of-accounts/.sqlx/query-4b6c51381b49631484d7318e49412c2861fb8a6ca78eeb12c99ea56e946e8fd8.json b/core/chart-of-accounts/.sqlx/query-4b6c51381b49631484d7318e49412c2861fb8a6ca78eeb12c99ea56e946e8fd8.json new file mode 100644 index 000000000..e3ab47346 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-4b6c51381b49631484d7318e49412c2861fb8a6ca78eeb12c99ea56e946e8fd8.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH max_sequence AS (\n SELECT COALESCE(MAX(sequence), 0) AS max FROM persistent_outbox_events\n )\n SELECT\n g.seq AS \"sequence!: EventSequence\",\n e.id AS \"id?\",\n e.payload AS \"payload?\",\n e.recorded_at AS \"recorded_at?\"\n FROM\n generate_series(LEAST($1 + 1, (SELECT max FROM max_sequence)),\n LEAST($1 + $2, (SELECT max FROM max_sequence)))\n AS g(seq)\n LEFT JOIN\n persistent_outbox_events e ON g.seq = e.sequence\n WHERE\n g.seq > $1\n ORDER BY\n g.seq ASC\n LIMIT $2", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "sequence!: EventSequence", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "id?", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "payload?", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at?", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int4", + "Int4" + ] + }, + "nullable": [ + null, + false, + true, + false + ] + }, + "hash": "4b6c51381b49631484d7318e49412c2861fb8a6ca78eeb12c99ea56e946e8fd8" +} diff --git a/core/chart-of-accounts/.sqlx/query-7a03aaa2e73d95b0273bcbfac7fe56cc9e0c427d7c32e6a2e1d9e66f43231623.json b/core/chart-of-accounts/.sqlx/query-7a03aaa2e73d95b0273bcbfac7fe56cc9e0c427d7c32e6a2e1d9e66f43231623.json new file mode 100644 index 000000000..285f3476a --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-7a03aaa2e73d95b0273bcbfac7fe56cc9e0c427d7c32e6a2e1d9e66f43231623.json @@ -0,0 +1,20 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT COALESCE(MAX(sequence), 0) AS \"max!\" FROM persistent_outbox_events", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "max!", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [] + }, + "nullable": [ + null + ] + }, + "hash": "7a03aaa2e73d95b0273bcbfac7fe56cc9e0c427d7c32e6a2e1d9e66f43231623" +} diff --git a/core/chart-of-accounts/.sqlx/query-7b0d547dda8c4a6ce921025c2e8dd7c9d0b2bbbda1f62fe3c82e5ada575f1bb6.json b/core/chart-of-accounts/.sqlx/query-7b0d547dda8c4a6ce921025c2e8dd7c9d0b2bbbda1f62fe3c82e5ada575f1bb6.json new file mode 100644 index 000000000..b2d3f7452 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-7b0d547dda8c4a6ce921025c2e8dd7c9d0b2bbbda1f62fe3c82e5ada575f1bb6.json @@ -0,0 +1,52 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT id AS \"id: AuditEntryId\", subject, object, action, authorized, recorded_at\n FROM audit_entries\n WHERE id = ANY($1)\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: AuditEntryId", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "subject", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "object", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "action", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "authorized", + "type_info": "Bool" + }, + { + "ordinal": 5, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8Array" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + false + ] + }, + "hash": "7b0d547dda8c4a6ce921025c2e8dd7c9d0b2bbbda1f62fe3c82e5ada575f1bb6" +} diff --git a/core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json b/core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json new file mode 100644 index 000000000..c2f814ec9 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json @@ -0,0 +1,40 @@ +{ + "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/chart-of-accounts/.sqlx/query-9af6eb14d4bb659fbfc6511756490722479c365d4760a490ec136a1ef9ebb979.json b/core/chart-of-accounts/.sqlx/query-9af6eb14d4bb659fbfc6511756490722479c365d4760a490ec136a1ef9ebb979.json new file mode 100644 index 000000000..14fc40a50 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-9af6eb14d4bb659fbfc6511756490722479c365d4760a490ec136a1ef9ebb979.json @@ -0,0 +1,31 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO audit_entries (subject, object, action, authorized)\n VALUES ($1, $2, $3, $4)\n RETURNING id, subject\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int8" + }, + { + "ordinal": 1, + "name": "subject", + "type_info": "Varchar" + } + ], + "parameters": { + "Left": [ + "Varchar", + "Varchar", + "Varchar", + "Bool" + ] + }, + "nullable": [ + false, + false + ] + }, + "hash": "9af6eb14d4bb659fbfc6511756490722479c365d4760a490ec136a1ef9ebb979" +} diff --git a/core/chart-of-accounts/.sqlx/query-a1dcaba56af024322df454768c2cef9cd0fbcf91128bb4e2a372a16e3b9b8c69.json b/core/chart-of-accounts/.sqlx/query-a1dcaba56af024322df454768c2cef9cd0fbcf91128bb4e2a372a16e3b9b8c69.json new file mode 100644 index 000000000..49d89a244 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-a1dcaba56af024322df454768c2cef9cd0fbcf91128bb4e2a372a16e3b9b8c69.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO persistent_outbox_events (sequence)\n SELECT unnest($1::bigint[]) AS sequence\n ON CONFLICT (sequence) DO UPDATE\n SET sequence = EXCLUDED.sequence\n RETURNING id, sequence AS \"sequence!: EventSequence\", payload, recorded_at\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence!: EventSequence", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "payload", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8Array" + ] + }, + "nullable": [ + false, + false, + true, + false + ] + }, + "hash": "a1dcaba56af024322df454768c2cef9cd0fbcf91128bb4e2a372a16e3b9b8c69" +} diff --git a/core/chart-of-accounts/.sqlx/query-da8bde1919fb0a4471ed9bed8b81050c40e68e8028cb4d118f4ad5c881e09081.json b/core/chart-of-accounts/.sqlx/query-da8bde1919fb0a4471ed9bed8b81050c40e68e8028cb4d118f4ad5c881e09081.json new file mode 100644 index 000000000..d0c5c79c7 --- /dev/null +++ b/core/chart-of-accounts/.sqlx/query-da8bde1919fb0a4471ed9bed8b81050c40e68e8028cb4d118f4ad5c881e09081.json @@ -0,0 +1,34 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH new_events AS (\n INSERT INTO persistent_outbox_events (payload)\n SELECT unnest($1::jsonb[]) AS payload\n RETURNING id AS \"id: OutboxEventId\", sequence AS \"sequence: EventSequence\", recorded_at\n )\n SELECT * FROM new_events\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: OutboxEventId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence: EventSequence", + "type_info": "Int8" + }, + { + "ordinal": 2, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "JsonbArray" + ] + }, + "nullable": [ + false, + false, + false + ] + }, + "hash": "da8bde1919fb0a4471ed9bed8b81050c40e68e8028cb4d118f4ad5c881e09081" +} diff --git a/core/chart-of-accounts/Cargo.toml b/core/chart-of-accounts/Cargo.toml index 20ca75057..1a5467cca 100644 --- a/core/chart-of-accounts/Cargo.toml +++ b/core/chart-of-accounts/Cargo.toml @@ -20,6 +20,11 @@ serde = { workspace = true } strum = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } +uuid = { workspace = true } tokio = { workspace = true } anyhow = { workspace = true } + +[dev-dependencies] +authz = { path = "../../lib/authz", features = ["test-dummy"] } +rand = { workspace = true } 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 2236b0243..e5fe1dc84 100644 --- a/core/chart-of-accounts/src/chart_of_accounts/entity.rs +++ b/core/chart-of-accounts/src/chart_of_accounts/entity.rs @@ -18,16 +18,19 @@ pub use super::error::*; pub enum ChartOfAccountEvent { Initialized { id: ChartId, + reference: String, audit_info: AuditInfo, }, ControlAccountAdded { code: ChartOfAccountCode, name: String, + reference: String, audit_info: AuditInfo, }, ControlSubAccountAdded { code: ChartOfAccountCode, name: String, + reference: String, audit_info: AuditInfo, }, TransactionAccountAdded { @@ -43,6 +46,7 @@ pub enum ChartOfAccountEvent { #[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct ChartOfAccount { pub id: ChartId, + pub reference: String, pub(super) events: EntityEvents, } @@ -66,16 +70,36 @@ impl ChartOfAccount { .unwrap_or_else(|| ChartOfAccountCode::first_control_account(category))?) } + pub fn find_control_account_by_reference( + &self, + reference_to_check: String, + ) -> Option { + self.events.iter_all().rev().find_map(|event| match event { + ChartOfAccountEvent::ControlAccountAdded { + code, reference, .. + } if reference_to_check == *reference => Some(*code), + _ => None, + }) + } + pub fn create_control_account( &mut self, category: ChartOfAccountCode, - name: &str, + name: String, + reference: String, audit_info: AuditInfo, ) -> Result { + if let Some(_) = self.find_control_account_by_reference(reference.to_string()) { + return Err(ChartOfAccountError::ControlAccountAlreadyRegistered( + reference, + )); + }; + let code = self.next_control_account(category)?; self.events.push(ChartOfAccountEvent::ControlAccountAdded { code, - name: name.to_string(), + name, + reference, audit_info, }); @@ -102,17 +126,37 @@ impl ChartOfAccount { .unwrap_or_else(|| ChartOfAccountCode::first_control_sub_account(&control_account))?) } + pub fn find_control_sub_account_by_reference( + &self, + reference_to_check: String, + ) -> Option { + self.events.iter_all().rev().find_map(|event| match event { + ChartOfAccountEvent::ControlSubAccountAdded { + code, reference, .. + } if reference_to_check == *reference => Some(*code), + _ => None, + }) + } + pub fn create_control_sub_account( &mut self, control_account: ChartOfAccountCode, - name: &str, + name: String, + reference: String, audit_info: AuditInfo, ) -> Result { + if let Some(_) = self.find_control_sub_account_by_reference(reference.to_string()) { + return Err(ChartOfAccountError::ControlSubAccountAlreadyRegistered( + reference, + )); + }; + let code = self.next_control_sub_account(control_account)?; self.events .push(ChartOfAccountEvent::ControlSubAccountAdded { code, - name: name.to_string(), + name, + reference, audit_info, }); @@ -143,19 +187,20 @@ impl ChartOfAccount { })?) } - pub fn create_transaction_account( + pub fn add_transaction_account( &mut self, + account_id: impl Into, control_sub_account: ChartOfAccountCode, name: &str, description: &str, audit_info: AuditInfo, ) -> Result { - let code = self.next_transaction_account(control_sub_account)?; - let account_id = LedgerAccountId::new(); + let account_id = account_id.into(); + let path = self.next_transaction_account(control_sub_account)?; self.events .push(ChartOfAccountEvent::TransactionAccountAdded { id: account_id, - code, + code: path, name: name.to_string(), description: description.to_string(), audit_info, @@ -163,7 +208,8 @@ impl ChartOfAccount { Ok(ChartOfAccountAccountDetails { account_id, - code, + code: path.to_code(self.id), + path, name: name.to_string(), description: description.to_string(), }) @@ -171,18 +217,19 @@ impl ChartOfAccount { pub fn find_account( &self, - account_code: ChartOfAccountCode, + account_path: ChartOfAccountCode, ) -> Option { self.events.iter_all().rev().find_map(|event| match event { ChartOfAccountEvent::TransactionAccountAdded { id, - code, + code: path, name, description, .. - } if *code == account_code => Some(ChartOfAccountAccountDetails { + } if *path == account_path => Some(ChartOfAccountAccountDetails { account_id: *id, - code: *code, + path: *path, + code: path.to_code(self.id), name: name.to_string(), description: description.to_string(), }), @@ -196,7 +243,9 @@ impl TryFromEvents for ChartOfAccount { let mut builder = ChartOfAccountBuilder::default(); for event in events.iter_all() { match event { - ChartOfAccountEvent::Initialized { id, .. } => builder = builder.id(*id), + ChartOfAccountEvent::Initialized { id, reference, .. } => { + builder = builder.id(*id).reference(reference.to_string()) + } ChartOfAccountEvent::ControlAccountAdded { .. } => (), ChartOfAccountEvent::ControlSubAccountAdded { .. } => (), ChartOfAccountEvent::TransactionAccountAdded { .. } => (), @@ -210,6 +259,7 @@ impl TryFromEvents for ChartOfAccount { pub struct NewChartOfAccount { #[builder(setter(into))] pub(super) id: ChartId, + pub(super) reference: String, #[builder(setter(into))] pub audit_info: AuditInfo, } @@ -226,6 +276,7 @@ impl IntoEvents for NewChartOfAccount { self.id, [ChartOfAccountEvent::Initialized { id: self.id, + reference: self.reference, audit_info: self.audit_info, }], ) @@ -234,7 +285,7 @@ impl IntoEvents for NewChartOfAccount { #[cfg(test)] mod tests { - use crate::{AccountIdx, ChartOfAccountCategoryCode}; + use crate::code::{AccountIdx, ChartOfAccountCategoryCode}; use super::*; @@ -253,6 +304,7 @@ mod tests { let new_chart = NewChartOfAccount::builder() .id(id) + .reference("ref-01".to_string()) .audit_info(audit_info) .build() .unwrap(); @@ -268,6 +320,7 @@ mod tests { let new_chart = NewChartOfAccount::builder() .id(id) + .reference("ref-01".to_string()) .audit_info(audit_info.clone()) .build() .unwrap(); @@ -284,7 +337,8 @@ mod tests { match chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "Assets", + "Assets".to_string(), + "assets".to_string(), dummy_audit_info(), ) .unwrap() @@ -297,19 +351,55 @@ mod tests { } } + #[test] + fn test_control_account_duplicate_reference() { + let mut chart = init_chart_of_events(); + chart + .create_control_account( + ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + "Assets #1".to_string(), + "assets".to_string(), + dummy_audit_info(), + ) + .unwrap(); + + match chart.create_control_account( + ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + "Assets #2".to_string(), + "assets".to_string(), + dummy_audit_info(), + ) { + Err(e) => { + assert!(matches!( + e, + ChartOfAccountError::ControlAccountAlreadyRegistered(_) + )); + } + _ => { + panic!("Expected duplicate reference to error") + } + } + } + #[test] fn test_create_control_sub_account() { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "Assets", + "Assets".to_string(), + "assets".to_string(), dummy_audit_info(), ) .unwrap(); match chart - .create_control_sub_account(control_account, "Current Assets", dummy_audit_info()) + .create_control_sub_account( + control_account, + "Current Assets".to_string(), + "current-assets".to_string(), + dummy_audit_info(), + ) .unwrap() { ChartOfAccountCode::ControlSubAccount { @@ -325,22 +415,67 @@ mod tests { } } + #[test] + fn test_control_sub_account_duplicate_reference() { + let mut chart = init_chart_of_events(); + let control_account = chart + .create_control_account( + ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), + "Assets".to_string(), + "assets".to_string(), + dummy_audit_info(), + ) + .unwrap(); + chart + .create_control_sub_account( + control_account, + "Current Assets #1".to_string(), + "current-assets".to_string(), + dummy_audit_info(), + ) + .unwrap(); + + match chart.create_control_sub_account( + control_account, + "Current Assets #2".to_string(), + "current-assets".to_string(), + dummy_audit_info(), + ) { + Err(e) => { + assert!(matches!( + e, + ChartOfAccountError::ControlSubAccountAlreadyRegistered(_) + )); + } + _ => { + panic!("Expected duplicate reference to error") + } + } + } + #[test] fn test_create_transaction_account() { let mut chart = init_chart_of_events(); let control_account = chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "Assets", + "Assets".to_string(), + "assets".to_string(), dummy_audit_info(), ) .unwrap(); let control_sub_account = chart - .create_control_sub_account(control_account, "Current Assets", dummy_audit_info()) + .create_control_sub_account( + control_account, + "Current Assets".to_string(), + "current-assets".to_string(), + dummy_audit_info(), + ) .unwrap(); match chart - .create_transaction_account( + .add_transaction_account( + LedgerAccountId::new(), control_sub_account, "Cash", "Cash account", @@ -349,7 +484,7 @@ mod tests { .unwrap() { ChartOfAccountAccountDetails { - code: + path: ChartOfAccountCode::TransactionAccount { category, control_index, @@ -374,7 +509,8 @@ mod tests { chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "First", + "First".to_string(), + "assets-01".to_string(), dummy_audit_info(), ) .unwrap(); @@ -382,7 +518,8 @@ mod tests { match chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "Second", + "Second".to_string(), + "assets-02".to_string(), dummy_audit_info(), ) .unwrap() @@ -401,17 +538,28 @@ mod tests { let control_account = chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "Assets", + "Assets".to_string(), + "assets".to_string(), dummy_audit_info(), ) .unwrap(); chart - .create_control_sub_account(control_account, "First", dummy_audit_info()) + .create_control_sub_account( + control_account, + "First".to_string(), + "first-asset".to_string(), + dummy_audit_info(), + ) .unwrap(); match chart - .create_control_sub_account(control_account, "Second", dummy_audit_info()) + .create_control_sub_account( + control_account, + "Second".to_string(), + "second-asset".to_string(), + dummy_audit_info(), + ) .unwrap() { ChartOfAccountCode::ControlSubAccount { @@ -433,16 +581,23 @@ mod tests { let control_account = chart .create_control_account( ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets), - "Assets", + "Assets".to_string(), + "assets".to_string(), dummy_audit_info(), ) .unwrap(); let sub_account = chart - .create_control_sub_account(control_account, "Current Assets", dummy_audit_info()) + .create_control_sub_account( + control_account, + "Current Assets".to_string(), + "current-assets".to_string(), + dummy_audit_info(), + ) .unwrap(); chart - .create_transaction_account( + .add_transaction_account( + LedgerAccountId::new(), sub_account, "First", "First transaction account", @@ -451,7 +606,8 @@ mod tests { .unwrap(); match chart - .create_transaction_account( + .add_transaction_account( + LedgerAccountId::new(), sub_account, "Second", "Second transaction account", @@ -460,7 +616,7 @@ mod tests { .unwrap() { ChartOfAccountAccountDetails { - code: + path: ChartOfAccountCode::TransactionAccount { category, control_index, @@ -485,16 +641,32 @@ mod tests { let category = ChartOfAccountCode::Category(ChartOfAccountCategoryCode::Assets); let control_account = chart - .create_control_account(category, "Assets", audit_info.clone()) + .create_control_account( + category, + "Assets".to_string(), + "assets".to_string(), + audit_info.clone(), + ) .unwrap(); let sub_account = chart - .create_control_sub_account(control_account, "Current Assets", audit_info.clone()) + .create_control_sub_account( + control_account, + "Current Assets".to_string(), + "current-assets".to_string(), + audit_info.clone(), + ) .unwrap(); let transaction_account = chart - .create_transaction_account(sub_account, "Cash", "Cash account", audit_info) + .add_transaction_account( + LedgerAccountId::new(), + sub_account, + "Cash", + "Cash account", + audit_info, + ) .unwrap(); - let found = chart.find_account(transaction_account.code).unwrap(); + let found = chart.find_account(transaction_account.path).unwrap(); assert_eq!(found.code, transaction_account.code); assert_eq!(found.name, "Cash"); 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 f310d6545..8580a02c8 100644 --- a/core/chart-of-accounts/src/chart_of_accounts/error.rs +++ b/core/chart-of-accounts/src/chart_of_accounts/error.rs @@ -10,6 +10,10 @@ pub enum ChartOfAccountError { CursorDestructureError(#[from] es_entity::CursorDestructureError), #[error("ChartOfAccountError - ChartOfAccountCodeError: '{0}'")] ChartOfAccountCodeError(#[from] crate::code::error::ChartOfAccountCodeError), + #[error("ChartOfAccountError - ControlAccountAlreadyRegistered: '{0}'")] + ControlAccountAlreadyRegistered(String), + #[error("ChartOfAccountError - ControlSubAccountAlreadyRegistered: '{0}'")] + ControlSubAccountAlreadyRegistered(String), } es_entity::from_es_entity_error!(ChartOfAccountError); 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 9b219e807..38750b449 100644 --- a/core/chart-of-accounts/src/chart_of_accounts/repo.rs +++ b/core/chart-of-accounts/src/chart_of_accounts/repo.rs @@ -10,6 +10,7 @@ use super::entity::*; #[es_repo( entity = "ChartOfAccount", err = "ChartOfAccountError", + columns(reference(ty = "String")), tbl_prefix = "core" )] pub struct ChartOfAccountRepo { diff --git a/core/chart-of-accounts/src/code/mod.rs b/core/chart-of-accounts/src/code/mod.rs index c8cf16030..52f42f43d 100644 --- a/core/chart-of-accounts/src/code/mod.rs +++ b/core/chart-of-accounts/src/code/mod.rs @@ -4,6 +4,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; +use super::primitives::{ChartId, DebitOrCredit}; use error::*; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Hash, Deserialize)] @@ -161,6 +162,19 @@ impl ChartOfAccountCode { } } + pub fn normal_balance_type(&self) -> DebitOrCredit { + match self.category() { + ChartOfAccountCategoryCode::Assets | ChartOfAccountCategoryCode::Expenses => { + DebitOrCredit::Debit + } + _ => DebitOrCredit::Credit, + } + } + + pub fn to_code(&self, chart_id: ChartId) -> String { + format!("{}::{}", chart_id, self) + } + pub fn category(&self) -> ChartOfAccountCategoryCode { match *self { Self::Category(category) => category, diff --git a/core/chart-of-accounts/src/error.rs b/core/chart-of-accounts/src/error.rs index cd87a217e..0d5d16845 100644 --- a/core/chart-of-accounts/src/error.rs +++ b/core/chart-of-accounts/src/error.rs @@ -8,6 +8,8 @@ pub enum CoreChartOfAccountError { AuthorizationError(#[from] authz::error::AuthorizationError), #[error("CoreChartOfAccountError - ChartOfAccountError: {0}")] ChartOfAccountError(#[from] crate::chart_of_accounts::error::ChartOfAccountError), - #[error("CoreChartOfAccountError - ChartOfAccountLedgerError: {0}")] - ChartOfAccountLedgerError(#[from] crate::ledger::error::ChartOfAccountLedgerError), + #[error("CoreChartOfAccountError - AuditError: {0}")] + AuditError(#[from] audit::error::AuditError), + #[error("ChartOfAccountLedgerError - CalaAccountError: {0}")] + CalaAccount(#[from] cala_ledger::account::error::AccountError), } diff --git a/core/chart-of-accounts/src/ledger/error.rs b/core/chart-of-accounts/src/ledger/error.rs deleted file mode 100644 index e6fa42518..000000000 --- a/core/chart-of-accounts/src/ledger/error.rs +++ /dev/null @@ -1,15 +0,0 @@ -use thiserror::Error; - -#[derive(Error, Debug)] -pub enum ChartOfAccountLedgerError { - #[error("ChartOfAccountLedgerError - Sqlx: {0}")] - Sqlx(#[from] sqlx::Error), - #[error("ChartOfAccountLedgerError - CalaLedger: {0}")] - CalaLedger(#[from] cala_ledger::error::LedgerError), - #[error("ChartOfAccountLedgerError - CalaAccountError: {0}")] - CalaAccount(#[from] cala_ledger::account::error::AccountError), - #[error("ChartOfAccountLedgerError - CalaTxTemplateError: {0}")] - CalaTxTemplate(#[from] cala_ledger::tx_template::error::TxTemplateError), - #[error("ChartOfAccountLedgerError - CalaBalanceError: {0}")] - CalaBalance(#[from] cala_ledger::balance::error::BalanceError), -} diff --git a/core/chart-of-accounts/src/ledger/mod.rs b/core/chart-of-accounts/src/ledger/mod.rs deleted file mode 100644 index 979a1d549..000000000 --- a/core/chart-of-accounts/src/ledger/mod.rs +++ /dev/null @@ -1,56 +0,0 @@ -pub mod error; - -use cala_ledger::{account::*, CalaLedger, DebitOrCredit}; - -use crate::{ - code::{ChartOfAccountCategoryCode, ChartOfAccountCode}, - primitives::ChartOfAccountAccountDetails, -}; - -use error::*; - -#[derive(Clone)] -pub struct ChartOfAccountLedger { - cala: CalaLedger, -} - -impl ChartOfAccountLedger { - pub async fn init(cala: &CalaLedger) -> Result { - Ok(Self { cala: cala.clone() }) - } - - fn normal_balance_type_for_code(code: ChartOfAccountCode) -> DebitOrCredit { - match code.category() { - ChartOfAccountCategoryCode::Assets | ChartOfAccountCategoryCode::Expenses => { - DebitOrCredit::Debit - } - _ => DebitOrCredit::Credit, - } - } - - pub async fn create_transaction_account( - &self, - op: es_entity::DbOp<'_>, - account_details: &ChartOfAccountAccountDetails, - ) -> Result<(), ChartOfAccountLedgerError> { - let mut op = self.cala.ledger_operation_from_db_op(op); - - let new_account = NewAccount::builder() - .id(account_details.account_id) - .name(account_details.name.to_string()) - .description(account_details.description.to_string()) - .code(account_details.code.to_string()) - .normal_balance_type(Self::normal_balance_type_for_code(account_details.code)) - .build() - .expect("Could not build new account"); - - self.cala - .accounts() - .create_in_op(&mut op, new_account) - .await?; - - op.commit().await?; - - Ok(()) - } -} diff --git a/core/chart-of-accounts/src/lib.rs b/core/chart-of-accounts/src/lib.rs index 2d68cb723..9d212e21a 100644 --- a/core/chart-of-accounts/src/lib.rs +++ b/core/chart-of-accounts/src/lib.rs @@ -5,28 +5,27 @@ mod chart_of_accounts; mod code; pub mod error; mod event; -mod ledger; mod primitives; +mod transaction_account_factory; use cala_ledger::CalaLedger; -use ledger::*; use tracing::instrument; use audit::AuditSvc; use authz::PermissionCheck; use chart_of_accounts::*; -use code::*; use error::*; pub use event::*; pub use primitives::*; +pub use transaction_account_factory::*; pub struct CoreChartOfAccounts where Perms: PermissionCheck, { - chart_of_account: ChartOfAccountRepo, - ledger: ChartOfAccountLedger, + repo: ChartOfAccountRepo, + cala: CalaLedger, authz: Perms, } @@ -36,8 +35,8 @@ where { fn clone(&self) -> Self { Self { - chart_of_account: self.chart_of_account.clone(), - ledger: self.ledger.clone(), + repo: self.repo.clone(), + cala: self.cala.clone(), authz: self.authz.clone(), } } @@ -55,26 +54,36 @@ where cala: &CalaLedger, ) -> Result { let chart_of_account = ChartOfAccountRepo::new(pool); - let ledger = ChartOfAccountLedger::init(cala).await?; let res = Self { - chart_of_account, - ledger, + repo: chart_of_account, + cala: cala.clone(), authz: authz.clone(), }; Ok(res) } + pub fn transaction_account_factory( + &self, + chart_id: ChartId, + control_sub_account: ChartOfAccountCode, + ) -> TransactionAccountFactory { + TransactionAccountFactory::new(&self.repo, &self.cala, chart_id, control_sub_account) + } + #[instrument(name = "chart_of_accounts.create_chart", skip(self))] pub async fn create_chart( &self, - sub: &<::Audit as AuditSvc>::Subject, id: impl Into + std::fmt::Debug, + reference: String, ) -> Result { let id = id.into(); + + let mut op = self.repo.begin_op().await?; let audit_info = self .authz - .enforce_permission( - sub, + .audit() + .record_system_entry_in_tx( + op.tx(), CoreChartOfAccountsObject::chart(id), CoreChartOfAccountsAction::CHART_CREATE, ) @@ -82,13 +91,13 @@ where let new_chart_of_account = NewChartOfAccount::builder() .id(id) + .reference(reference) .audit_info(audit_info) .build() .expect("Could not build new chart of accounts"); - let mut op = self.chart_of_account.begin_op().await?; let chart = self - .chart_of_account + .repo .create_in_op(&mut op, new_chart_of_account) .await?; op.commit().await?; @@ -96,6 +105,31 @@ where Ok(chart) } + #[instrument(name = "chart_of_accounts.find_by_reference", skip(self))] + pub async fn find_by_reference( + &self, + reference: String, + ) -> Result, CoreChartOfAccountError> { + let mut op = self.repo.begin_op().await?; + self.authz + .audit() + .record_system_entry_in_tx( + op.tx(), + CoreChartOfAccountsObject::all_charts(), + CoreChartOfAccountsAction::CHART_LIST, + ) + .await?; + + let chart = match self.repo.find_by_reference(reference).await { + Ok(chart) => Some(chart), + Err(e) if e.was_not_found() => None, + Err(e) => return Err(e.into()), + }; + op.commit().await?; + + Ok(chart) + } + #[instrument(name = "core_user.list_charts", skip(self))] pub async fn list_charts( &self, @@ -110,110 +144,122 @@ where .await?; Ok(self - .chart_of_account + .repo .list_by_id(Default::default(), es_entity::ListDirection::Ascending) .await? .entities) } - #[instrument(name = "chart_of_accounts.create_control_account", skip(self))] + pub async fn find_control_account_by_reference( + &self, + chart_id: impl Into, + reference: String, + ) -> Result, CoreChartOfAccountError> { + let chart_id = chart_id.into(); + + let mut op = self.repo.begin_op().await?; + self.authz + .audit() + .record_system_entry_in_tx( + op.tx(), + CoreChartOfAccountsObject::chart(chart_id), + CoreChartOfAccountsAction::CHART_FIND_CONTROL_ACCOUNT, + ) + .await?; + op.commit().await?; + + let chart = self.repo.find_by_id(chart_id).await?; + + Ok(chart.find_control_account_by_reference(reference)) + } + pub async fn create_control_account( &self, - sub: &<::Audit as AuditSvc>::Subject, - chart_id: impl Into + std::fmt::Debug, + chart_id: impl Into, category: ChartOfAccountCode, - name: &str, + name: String, + reference: String, ) -> Result { let chart_id = chart_id.into(); + + let mut op = self.repo.begin_op().await?; + let audit_info = self .authz - .enforce_permission( - sub, + .audit() + .record_system_entry_in_tx( + op.tx(), CoreChartOfAccountsObject::chart(chart_id), CoreChartOfAccountsAction::CHART_CREATE_CONTROL_ACCOUNT, ) .await?; - let mut chart = self.chart_of_account.find_by_id(chart_id).await?; + let mut chart = self.repo.find_by_id(chart_id).await?; - let code = chart.create_control_account(category, name, audit_info)?; + let code = chart.create_control_account(category, name, reference, audit_info)?; - let mut op = self.chart_of_account.begin_op().await?; - self.chart_of_account - .update_in_op(&mut op, &mut chart) - .await?; + self.repo.update_in_op(&mut op, &mut chart).await?; op.commit().await?; Ok(code) } - #[instrument(name = "chart_of_accounts.create_control_sub_account", skip(self))] - pub async fn create_control_sub_account( + pub async fn find_control_sub_account_by_reference( &self, - sub: &<::Audit as AuditSvc>::Subject, - chart_id: impl Into + std::fmt::Debug, - control_account: ChartOfAccountCode, - name: &str, - ) -> Result { + chart_id: impl Into, + reference: String, + ) -> Result, CoreChartOfAccountError> { let chart_id = chart_id.into(); - let audit_info = self - .authz - .enforce_permission( - sub, + + let mut op = self.repo.begin_op().await?; + self.authz + .audit() + .record_system_entry_in_tx( + op.tx(), CoreChartOfAccountsObject::chart(chart_id), - CoreChartOfAccountsAction::CHART_CREATE_CONTROL_SUB_ACCOUNT, + CoreChartOfAccountsAction::CHART_FIND_CONTROL_SUB_ACCOUNT, ) .await?; - - let mut chart = self.chart_of_account.find_by_id(chart_id).await?; - - let code = chart.create_control_sub_account(control_account, name, audit_info)?; - - let mut op = self.chart_of_account.begin_op().await?; - self.chart_of_account - .update_in_op(&mut op, &mut chart) - .await?; - op.commit().await?; - Ok(code) + let chart = self.repo.find_by_id(chart_id).await?; + + Ok(chart.find_control_sub_account_by_reference(reference)) } - #[instrument(name = "chart_of_accounts.create_transaction_account", skip(self))] - pub async fn create_transaction_account( + pub async fn create_control_sub_account( &self, - sub: &<::Audit as AuditSvc>::Subject, chart_id: impl Into + std::fmt::Debug, - control_sub_account: ChartOfAccountCode, - name: &str, - description: &str, - ) -> Result { + control_account: ChartOfAccountCode, + name: String, + reference: String, + ) -> Result { let chart_id = chart_id.into(); + + let mut op = self.repo.begin_op().await?; + let audit_info = self .authz - .enforce_permission( - sub, + .audit() + .record_system_entry_in_tx( + op.tx(), CoreChartOfAccountsObject::chart(chart_id), - CoreChartOfAccountsAction::CHART_CREATE_TRANSACTION_ACCOUNT, + CoreChartOfAccountsAction::CHART_CREATE_CONTROL_SUB_ACCOUNT, ) .await?; - let mut chart = self.chart_of_account.find_by_id(chart_id).await?; + let mut chart = self.repo.find_by_id(chart_id).await?; - let account_details = - chart.create_transaction_account(control_sub_account, name, description, audit_info)?; + let code = + chart.create_control_sub_account(control_account, name, reference, audit_info)?; - let mut op = self.chart_of_account.begin_op().await?; - self.chart_of_account - .update_in_op(&mut op, &mut chart) - .await?; + let mut op = self.repo.begin_op().await?; + self.repo.update_in_op(&mut op, &mut chart).await?; - self.ledger - .create_transaction_account(op, &account_details) - .await?; + op.commit().await?; - Ok(account_details) + Ok(code) } #[instrument(name = "chart_of_accounts.find_account_in_chart", skip(self))] @@ -232,7 +278,7 @@ where ) .await?; - let chart = self.chart_of_account.find_by_id(chart_id).await?; + let chart = self.repo.find_by_id(chart_id).await?; let account_details = chart.find_account(code.into()); diff --git a/core/chart-of-accounts/src/primitives.rs b/core/chart-of-accounts/src/primitives.rs index 2a789f3e7..34ae0e315 100644 --- a/core/chart-of-accounts/src/primitives.rs +++ b/core/chart-of-accounts/src/primitives.rs @@ -3,9 +3,9 @@ use std::{fmt::Display, str::FromStr}; use authz::AllOrOne; use serde::{Deserialize, Serialize}; -pub use cala_ledger::primitives::AccountId as LedgerAccountId; +pub use cala_ledger::{primitives::AccountId as LedgerAccountId, DebitOrCredit}; -use crate::code::ChartOfAccountCode; +pub use crate::code::{ChartOfAccountCategoryCode as CategoryPath, ChartOfAccountCode}; es_entity::entity_id! { ChartId, @@ -70,10 +70,12 @@ impl CoreChartOfAccountsAction { pub const CHART_LIST: Self = CoreChartOfAccountsAction::ChartAction(ChartAction::List); pub const CHART_CREATE_CONTROL_ACCOUNT: Self = CoreChartOfAccountsAction::ChartAction(ChartAction::CreateControlAccount); + pub const CHART_FIND_CONTROL_ACCOUNT: Self = + CoreChartOfAccountsAction::ChartAction(ChartAction::FindControlAccount); pub const CHART_CREATE_CONTROL_SUB_ACCOUNT: Self = CoreChartOfAccountsAction::ChartAction(ChartAction::CreateControlSubAccount); - pub const CHART_CREATE_TRANSACTION_ACCOUNT: Self = - CoreChartOfAccountsAction::ChartAction(ChartAction::CreateTransactionAccount); + pub const CHART_FIND_CONTROL_SUB_ACCOUNT: Self = + CoreChartOfAccountsAction::ChartAction(ChartAction::FindControlSubAccount); pub const CHART_FIND_TRANSACTION_ACCOUNT: Self = CoreChartOfAccountsAction::ChartAction(ChartAction::FindTransactionAccount); } @@ -108,8 +110,9 @@ pub enum ChartAction { Create, List, CreateControlAccount, + FindControlAccount, CreateControlSubAccount, - CreateTransactionAccount, + FindControlSubAccount, FindTransactionAccount, } @@ -122,7 +125,8 @@ impl From for CoreChartOfAccountsAction { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct ChartOfAccountAccountDetails { pub account_id: LedgerAccountId, - pub code: ChartOfAccountCode, + pub path: ChartOfAccountCode, + pub code: String, 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 new file mode 100644 index 000000000..a37134e2c --- /dev/null +++ b/core/chart-of-accounts/src/transaction_account_factory.rs @@ -0,0 +1,74 @@ +use audit::AuditInfo; +use cala_ledger::{account::*, CalaLedger}; + +use crate::{ + chart_of_accounts::ChartOfAccountRepo, + code::ChartOfAccountCode, + error::CoreChartOfAccountError, + primitives::{ChartId, ChartOfAccountAccountDetails, LedgerAccountId}, +}; + +#[derive(Clone)] +pub struct TransactionAccountFactory { + repo: ChartOfAccountRepo, + cala: CalaLedger, + chart_id: ChartId, + control_sub_account: ChartOfAccountCode, +} + +impl TransactionAccountFactory { + pub(super) fn new( + repo: &ChartOfAccountRepo, + cala: &CalaLedger, + chart_id: ChartId, + control_sub_account: ChartOfAccountCode, + ) -> Self { + Self { + repo: repo.clone(), + cala: cala.clone(), + chart_id, + control_sub_account, + } + } + + pub async fn create_transaction_account_in_op( + &self, + mut op: es_entity::DbOp<'_>, + account_id: impl Into, + name: &str, + description: &str, + audit_info: AuditInfo, + ) -> Result { + let mut chart = self.repo.find_by_id(self.chart_id).await?; + + let account_details = chart.add_transaction_account( + account_id, + self.control_sub_account, + name, + description, + audit_info, + )?; + + self.repo.update_in_op(&mut op, &mut chart).await?; + + let mut op = self.cala.ledger_operation_from_db_op(op); + + let new_account = NewAccount::builder() + .id(account_details.account_id) + .name(account_details.name.to_string()) + .description(account_details.description.to_string()) + .code(account_details.code.to_string()) + .normal_balance_type(account_details.path.normal_balance_type()) + .build() + .expect("Could not build new account"); + + self.cala + .accounts() + .create_in_op(&mut op, new_account) + .await?; + + op.commit().await?; + + Ok(account_details) + } +} diff --git a/core/chart-of-accounts/tests/chart_of_accounts.rs b/core/chart-of-accounts/tests/chart_of_accounts.rs index 03f3447fa..80a6a41bf 100644 --- a/core/chart-of-accounts/tests/chart_of_accounts.rs +++ b/core/chart-of-accounts/tests/chart_of_accounts.rs @@ -11,7 +11,9 @@ pub async fn init_pool() -> anyhow::Result { } #[tokio::test] -async fn chart_of_accounts() -> anyhow::Result<()> { +async fn create_and_populate() -> anyhow::Result<()> { + use rand::Rng; + let pool = init_pool().await?; let authz = @@ -26,7 +28,10 @@ async fn chart_of_accounts() -> anyhow::Result<()> { let chart_of_accounts = CoreChartOfAccounts::init(&pool, &authz, &cala).await?; let chart_id = ChartId::new(); chart_of_accounts - .create_chart(&DummySubject, chart_id) + .create_chart( + chart_id, + format!("{:02}", rand::thread_rng().gen_range(0..100)), + ) .await?; let charts = chart_of_accounts.list_charts(&DummySubject).await?; @@ -34,38 +39,60 @@ async fn chart_of_accounts() -> anyhow::Result<()> { let control_account_code = chart_of_accounts .create_control_account( - &DummySubject, chart_id, "10000000".parse()?, - "Credit Facilities Receivable", + "Credit Facilities Receivable".to_string(), + "credit-facilities-receivable".to_string(), ) .await?; + + let control_sub_account_name = "Fixed-Term Credit Facilities Receivable"; let control_sub_account_code = chart_of_accounts .create_control_sub_account( - &DummySubject, chart_id, control_account_code, - "Fixed-Term Credit Facilities Receivable", + control_sub_account_name.to_string(), + "fixed-term-credit-facilities-receivable".to_string(), ) .await?; + assert_eq!( + control_sub_account_code.control_account(), + Some(control_account_code) + ); - let transaction_account_name = "Fixed-Term Credit Facilities Receivable #1 for Customer 00-01"; - // FIXME: This will fail if we run it twice on different charts with same `code` value - let transaction_account = chart_of_accounts - .create_transaction_account( - &DummySubject, - chart_id, - control_sub_account_code, - transaction_account_name, - "", - ) + Ok(()) +} + +#[tokio::test] +async fn create_with_duplicate_reference() -> anyhow::Result<()> { + use rand::Rng; + + let pool = init_pool().await?; + + let authz = + authz::dummy::DummyPerms::::new(); + + let cala_config = CalaLedgerConfig::builder() + .pool(pool.clone()) + .exec_migrations(false) + .build()?; + let cala = CalaLedger::init(cala_config).await?; + + let chart_of_accounts = CoreChartOfAccounts::init(&pool, &authz, &cala).await?; + + let reference = format!("{:02}", rand::thread_rng().gen_range(0..100)); + + let chart_id = ChartId::new(); + chart_of_accounts + .create_chart(chart_id, reference.clone()) .await?; + let res = chart_of_accounts + .create_chart(chart_id, reference.clone()) + .await; + assert!(res.is_err()); - let transaction_account = chart_of_accounts - .find_account_in_chart(&DummySubject, chart_id, transaction_account.code) - .await? - .expect("Transaction account not found"); - assert_eq!(transaction_account.name, transaction_account_name); + let chart = chart_of_accounts.find_by_reference(reference).await?; + assert!(chart.is_some()); Ok(()) } diff --git a/core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json new file mode 100644 index 000000000..d57a47c95 --- /dev/null +++ b/core/deposit/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" +} diff --git a/core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json new file mode 100644 index 000000000..19e53c2ec --- /dev/null +++ b/core/deposit/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json @@ -0,0 +1,18 @@ +{ + "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-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/core/deposit/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json new file mode 100644 index 000000000..dae4e1e2e --- /dev/null +++ b/core/deposit/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json @@ -0,0 +1,42 @@ +{ + "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", + "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": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" +} diff --git a/core/deposit/.sqlx/query-1acdd1e2bb1410b469e2b9ac0d62a7e4578f5b279aa92b488a9762107cfa8f68.json b/core/deposit/.sqlx/query-1acdd1e2bb1410b469e2b9ac0d62a7e4578f5b279aa92b488a9762107cfa8f68.json new file mode 100644 index 000000000..f8790cd93 --- /dev/null +++ b/core/deposit/.sqlx/query-1acdd1e2bb1410b469e2b9ac0d62a7e4578f5b279aa92b488a9762107cfa8f68.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO job_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": "1acdd1e2bb1410b469e2b9ac0d62a7e4578f5b279aa92b488a9762107cfa8f68" +} diff --git a/core/deposit/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json b/core/deposit/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json index 6110045ff..3798ac4b7 100644 --- a/core/deposit/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json +++ b/core/deposit/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json @@ -6,7 +6,7 @@ "parameters": { "Left": [ "Uuid", - "Varchar", + "Uuid", "Timestamptz" ] }, diff --git a/core/deposit/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json b/core/deposit/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json index b137b511d..7bbe53766 100644 --- a/core/deposit/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json +++ b/core/deposit/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json @@ -26,7 +26,7 @@ ], "parameters": { "Left": [ - "Text", + "Uuid", "Int8", "Uuid" ] diff --git a/core/deposit/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/core/deposit/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json new file mode 100644 index 000000000..95a5300c8 --- /dev/null +++ b/core/deposit/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json @@ -0,0 +1,40 @@ +{ + "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", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" +} diff --git a/core/deposit/.sqlx/query-34389835f84cb59d33192cfa32161b91ae9e63003d5d69b012b7a841eeb2638e.json b/core/deposit/.sqlx/query-34389835f84cb59d33192cfa32161b91ae9e63003d5d69b012b7a841eeb2638e.json new file mode 100644 index 000000000..186061b58 --- /dev/null +++ b/core/deposit/.sqlx/query-34389835f84cb59d33192cfa32161b91ae9e63003d5d69b012b7a841eeb2638e.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM jobs 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: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_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: JobId", + "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": "34389835f84cb59d33192cfa32161b91ae9e63003d5d69b012b7a841eeb2638e" +} diff --git a/core/deposit/.sqlx/query-362952f889d279a7835e10ed4afac988153a20ab61a3d7569e48f5231feb66bd.json b/core/deposit/.sqlx/query-362952f889d279a7835e10ed4afac988153a20ab61a3d7569e48f5231feb66bd.json new file mode 100644 index 000000000..6e3876f3b --- /dev/null +++ b/core/deposit/.sqlx/query-362952f889d279a7835e10ed4afac988153a20ab61a3d7569e48f5231feb66bd.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM jobs WHERE job_type = $1) SELECT i.id AS \"entity_id: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: JobId", + "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": "362952f889d279a7835e10ed4afac988153a20ab61a3d7569e48f5231feb66bd" +} diff --git a/core/deposit/.sqlx/query-364c97526f1a0088917e7f71d3e4352ae9d08495eef030a851fc804f5def29b4.json b/core/deposit/.sqlx/query-364c97526f1a0088917e7f71d3e4352ae9d08495eef030a851fc804f5def29b4.json new file mode 100644 index 000000000..13500e90f --- /dev/null +++ b/core/deposit/.sqlx/query-364c97526f1a0088917e7f71d3e4352ae9d08495eef030a851fc804f5def29b4.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM jobs WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: JobId", + "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": "364c97526f1a0088917e7f71d3e4352ae9d08495eef030a851fc804f5def29b4" +} diff --git a/core/deposit/.sqlx/query-3c63094ffd89044cb3c53fcf3365f6f9806cea17ac260617c43c2beee3f88e0a.json b/core/deposit/.sqlx/query-3c63094ffd89044cb3c53fcf3365f6f9806cea17ac260617c43c2beee3f88e0a.json new file mode 100644 index 000000000..5d6007bf2 --- /dev/null +++ b/core/deposit/.sqlx/query-3c63094ffd89044cb3c53fcf3365f6f9806cea17ac260617c43c2beee3f88e0a.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE job_executions\n SET state = 'pending', reschedule_after = $2, attempt_index = $3\n WHERE id = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int4" + ] + }, + "nullable": [] + }, + "hash": "3c63094ffd89044cb3c53fcf3365f6f9806cea17ac260617c43c2beee3f88e0a" +} diff --git a/core/deposit/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/core/deposit/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json new file mode 100644 index 000000000..95bebab0d --- /dev/null +++ b/core/deposit/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" +} diff --git a/core/deposit/.sqlx/query-488c8df829dec058b499f7136baecd10347c93d30ed9b696f78fce8704492036.json b/core/deposit/.sqlx/query-488c8df829dec058b499f7136baecd10347c93d30ed9b696f78fce8704492036.json new file mode 100644 index 000000000..9c4335c42 --- /dev/null +++ b/core/deposit/.sqlx/query-488c8df829dec058b499f7136baecd10347c93d30ed9b696f78fce8704492036.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE FROM job_executions\n WHERE id = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "488c8df829dec058b499f7136baecd10347c93d30ed9b696f78fce8704492036" +} diff --git a/core/deposit/.sqlx/query-5365d819ca11da9bb8ded785c68ea6c680f32c2317badf364723d2b43bc3eb18.json b/core/deposit/.sqlx/query-5365d819ca11da9bb8ded785c68ea6c680f32c2317badf364723d2b43bc3eb18.json new file mode 100644 index 000000000..8eb181094 --- /dev/null +++ b/core/deposit/.sqlx/query-5365d819ca11da9bb8ded785c68ea6c680f32c2317badf364723d2b43bc3eb18.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM jobs WHERE id = $1) SELECT i.id AS \"entity_id: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: JobId", + "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": "5365d819ca11da9bb8ded785c68ea6c680f32c2317badf364723d2b43bc3eb18" +} diff --git a/core/deposit/.sqlx/query-5501335ba40775766d8425f09a4096d94594d0ed0e9064047c7bcc042fdd609d.json b/core/deposit/.sqlx/query-5501335ba40775766d8425f09a4096d94594d0ed0e9064047c7bcc042fdd609d.json new file mode 100644 index 000000000..79ca8a1a7 --- /dev/null +++ b/core/deposit/.sqlx/query-5501335ba40775766d8425f09a4096d94594d0ed0e9064047c7bcc042fdd609d.json @@ -0,0 +1,36 @@ +{ + "db_name": "PostgreSQL", + "query": "\n WITH selected_jobs AS (\n SELECT je.id, je.execution_state_json AS data_json\n FROM job_executions je\n JOIN jobs ON je.id = jobs.id\n WHERE reschedule_after < $2::timestamptz\n AND je.state = 'pending'\n ORDER BY reschedule_after ASC\n LIMIT $1\n FOR UPDATE\n )\n UPDATE job_executions AS je\n SET state = 'running', reschedule_after = $2::timestamptz + $3::interval\n FROM selected_jobs\n WHERE je.id = selected_jobs.id\n RETURNING je.id AS \"id!: JobId\", selected_jobs.data_json, je.attempt_index\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id!: JobId", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "data_json", + "type_info": "Jsonb" + }, + { + "ordinal": 2, + "name": "attempt_index", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int8", + "Timestamptz", + "Interval" + ] + }, + "nullable": [ + false, + true, + false + ] + }, + "hash": "5501335ba40775766d8425f09a4096d94594d0ed0e9064047c7bcc042fdd609d" +} diff --git a/core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json new file mode 100644 index 000000000..5f58f2f07 --- /dev/null +++ b/core/deposit/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json @@ -0,0 +1,18 @@ +{ + "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-57df56605fb4b569a77cfefaea65d15118559a331b056533319eb7c2082b670c.json b/core/deposit/.sqlx/query-57df56605fb4b569a77cfefaea65d15118559a331b056533319eb7c2082b670c.json new file mode 100644 index 000000000..6f97a490d --- /dev/null +++ b/core/deposit/.sqlx/query-57df56605fb4b569a77cfefaea65d15118559a331b056533319eb7c2082b670c.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE job_executions\n SET state = 'pending', reschedule_after = $2, attempt_index = 1\n WHERE id = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "57df56605fb4b569a77cfefaea65d15118559a331b056533319eb7c2082b670c" +} diff --git a/core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json new file mode 100644 index 000000000..8ac8f7df0 --- /dev/null +++ b/core/deposit/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json @@ -0,0 +1,40 @@ +{ + "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", + "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": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" +} diff --git a/core/deposit/.sqlx/query-719e96af5edfade9410f50148ff09f2914b3f333cb86fa99ede723854e4d49da.json b/core/deposit/.sqlx/query-719e96af5edfade9410f50148ff09f2914b3f333cb86fa99ede723854e4d49da.json new file mode 100644 index 000000000..37021d821 --- /dev/null +++ b/core/deposit/.sqlx/query-719e96af5edfade9410f50148ff09f2914b3f333cb86fa99ede723854e4d49da.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE job_executions\n SET state = 'pending', attempt_index = attempt_index + 1\n WHERE state = 'running' AND reschedule_after < $1::timestamptz + $2::interval\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Timestamptz", + "Interval" + ] + }, + "nullable": [] + }, + "hash": "719e96af5edfade9410f50148ff09f2914b3f333cb86fa99ede723854e4d49da" +} diff --git a/core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json new file mode 100644 index 000000000..68cc67380 --- /dev/null +++ b/core/deposit/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json @@ -0,0 +1,41 @@ +{ + "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 new file mode 100644 index 000000000..c2f814ec9 --- /dev/null +++ b/core/deposit/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json @@ -0,0 +1,40 @@ +{ + "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-88d9ffe43ee67de9c952da049634a091141fe27ce70790b021a9ba11bc0ff8ca.json b/core/deposit/.sqlx/query-88d9ffe43ee67de9c952da049634a091141fe27ce70790b021a9ba11bc0ff8ca.json new file mode 100644 index 000000000..909590ba2 --- /dev/null +++ b/core/deposit/.sqlx/query-88d9ffe43ee67de9c952da049634a091141fe27ce70790b021a9ba11bc0ff8ca.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT i.id AS \"id: JobId\", e.sequence, e.event, e.recorded_at FROM jobs i JOIN job_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: JobId", + "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "88d9ffe43ee67de9c952da049634a091141fe27ce70790b021a9ba11bc0ff8ca" +} diff --git a/core/deposit/.sqlx/query-94fd84ef0a46838021919a3a3ad762d92f350f613664fc316ddf04b16df44f6c.json b/core/deposit/.sqlx/query-94fd84ef0a46838021919a3a3ad762d92f350f613664fc316ddf04b16df44f6c.json new file mode 100644 index 000000000..9f0ca03ab --- /dev/null +++ b/core/deposit/.sqlx/query-94fd84ef0a46838021919a3a3ad762d92f350f613664fc316ddf04b16df44f6c.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO job_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": "94fd84ef0a46838021919a3a3ad762d92f350f613664fc316ddf04b16df44f6c" +} diff --git a/core/deposit/.sqlx/query-9b497f68c26cdf5bd4e620ded5de46ef06513ff035af517543e89cd0301c5748.json b/core/deposit/.sqlx/query-9b497f68c26cdf5bd4e620ded5de46ef06513ff035af517543e89cd0301c5748.json new file mode 100644 index 000000000..22d047b50 --- /dev/null +++ b/core/deposit/.sqlx/query-9b497f68c26cdf5bd4e620ded5de46ef06513ff035af517543e89cd0301c5748.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO jobs (id, job_type, unique_per_type, created_at) VALUES ($1, $2, $3, $4)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Bool", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "9b497f68c26cdf5bd4e620ded5de46ef06513ff035af517543e89cd0301c5748" +} diff --git a/core/deposit/.sqlx/query-9fede9da078d360a423a05568c80bb70294c30c7fe793c59cf51fad87eaabd37.json b/core/deposit/.sqlx/query-9fede9da078d360a423a05568c80bb70294c30c7fe793c59cf51fad87eaabd37.json new file mode 100644 index 000000000..994009e32 --- /dev/null +++ b/core/deposit/.sqlx/query-9fede9da078d360a423a05568c80bb70294c30c7fe793c59cf51fad87eaabd37.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n DELETE FROM job_executions\n WHERE id = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "9fede9da078d360a423a05568c80bb70294c30c7fe793c59cf51fad87eaabd37" +} diff --git a/core/deposit/.sqlx/query-a9b0439f9bcb73db012821d15b7d509acb2f8efb47ebd2ebd2b0369c85b1d079.json b/core/deposit/.sqlx/query-a9b0439f9bcb73db012821d15b7d509acb2f8efb47ebd2ebd2b0369c85b1d079.json new file mode 100644 index 000000000..ba89328f4 --- /dev/null +++ b/core/deposit/.sqlx/query-a9b0439f9bcb73db012821d15b7d509acb2f8efb47ebd2ebd2b0369c85b1d079.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE job_executions\n SET reschedule_after = $2::timestamptz + $3::interval\n WHERE id = ANY($1)\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "UuidArray", + "Timestamptz", + "Interval" + ] + }, + "nullable": [] + }, + "hash": "a9b0439f9bcb73db012821d15b7d509acb2f8efb47ebd2ebd2b0369c85b1d079" +} diff --git a/core/deposit/.sqlx/query-b3751891ebd9bfabaf7193e2481c16871a62117d67aeba9692b20683c39a99b5.json b/core/deposit/.sqlx/query-b3751891ebd9bfabaf7193e2481c16871a62117d67aeba9692b20683c39a99b5.json new file mode 100644 index 000000000..5d41d28a5 --- /dev/null +++ b/core/deposit/.sqlx/query-b3751891ebd9bfabaf7193e2481c16871a62117d67aeba9692b20683c39a99b5.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO job_executions (id, reschedule_after, created_at)\n VALUES ($1, $2, $3)\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "b3751891ebd9bfabaf7193e2481c16871a62117d67aeba9692b20683c39a99b5" +} diff --git a/core/deposit/.sqlx/query-c2a1f2601412fb1dd0c3b15356c92285828a5d5c1eae8068e0e1b85615fb75bb.json b/core/deposit/.sqlx/query-c2a1f2601412fb1dd0c3b15356c92285828a5d5c1eae8068e0e1b85615fb75bb.json new file mode 100644 index 000000000..e13b4cc43 --- /dev/null +++ b/core/deposit/.sqlx/query-c2a1f2601412fb1dd0c3b15356c92285828a5d5c1eae8068e0e1b85615fb75bb.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM jobs 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: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_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: JobId", + "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": "c2a1f2601412fb1dd0c3b15356c92285828a5d5c1eae8068e0e1b85615fb75bb" +} diff --git a/core/deposit/.sqlx/query-cc61b287619f81a694db97032f5c9d063e70f0594d16d0014704bfe44f59c3c1.json b/core/deposit/.sqlx/query-cc61b287619f81a694db97032f5c9d063e70f0594d16d0014704bfe44f59c3c1.json new file mode 100644 index 000000000..cd4827255 --- /dev/null +++ b/core/deposit/.sqlx/query-cc61b287619f81a694db97032f5c9d063e70f0594d16d0014704bfe44f59c3c1.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM jobs WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: JobId", + "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": "cc61b287619f81a694db97032f5c9d063e70f0594d16d0014704bfe44f59c3c1" +} diff --git a/core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json new file mode 100644 index 000000000..65ba29133 --- /dev/null +++ b/core/deposit/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json @@ -0,0 +1,42 @@ +{ + "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 new file mode 100644 index 000000000..369e3792b --- /dev/null +++ b/core/deposit/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json @@ -0,0 +1,41 @@ +{ + "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-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json b/core/deposit/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json index 4645e5ed6..303e96373 100644 --- a/core/deposit/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json +++ b/core/deposit/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json @@ -26,7 +26,7 @@ ], "parameters": { "Left": [ - "Text", + "Uuid", "Int8", "Uuid", "Timestamptz" diff --git a/core/deposit/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json b/core/deposit/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json index ea9b7f2a6..43c37d3f7 100644 --- a/core/deposit/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json +++ b/core/deposit/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json @@ -26,7 +26,7 @@ ], "parameters": { "Left": [ - "Text" + "Uuid" ] }, "nullable": [ diff --git a/core/deposit/.sqlx/query-e666d2e28c76cab9ed701d49d72646ee304f6574e4749f2f1878947b89ce6ae3.json b/core/deposit/.sqlx/query-e666d2e28c76cab9ed701d49d72646ee304f6574e4749f2f1878947b89ce6ae3.json new file mode 100644 index 000000000..893ead8f9 --- /dev/null +++ b/core/deposit/.sqlx/query-e666d2e28c76cab9ed701d49d72646ee304f6574e4749f2f1878947b89ce6ae3.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE job_executions\n SET execution_state_json = $1\n WHERE id = $2\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Jsonb", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "e666d2e28c76cab9ed701d49d72646ee304f6574e4749f2f1878947b89ce6ae3" +} diff --git a/core/deposit/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json b/core/deposit/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json index a6564e359..148827bb6 100644 --- a/core/deposit/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json +++ b/core/deposit/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json @@ -26,7 +26,7 @@ ], "parameters": { "Left": [ - "Text", + "Uuid", "Int8", "Uuid" ] diff --git a/core/deposit/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json b/core/deposit/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json index 75085b9d9..ed8d2f097 100644 --- a/core/deposit/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json +++ b/core/deposit/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json @@ -26,7 +26,7 @@ ], "parameters": { "Left": [ - "Text", + "Uuid", "Int8", "Uuid", "Timestamptz" diff --git a/core/deposit/.sqlx/query-f9ed0e9da47ada9f94c429de439dba3aff3d8a1aea294af673213462229a20b6.json b/core/deposit/.sqlx/query-f9ed0e9da47ada9f94c429de439dba3aff3d8a1aea294af673213462229a20b6.json new file mode 100644 index 000000000..4b3f1b7a1 --- /dev/null +++ b/core/deposit/.sqlx/query-f9ed0e9da47ada9f94c429de439dba3aff3d8a1aea294af673213462229a20b6.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM jobs WHERE unique_per_type = $1) SELECT i.id AS \"entity_id: JobId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN job_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: JobId", + "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": [ + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "f9ed0e9da47ada9f94c429de439dba3aff3d8a1aea294af673213462229a20b6" +} diff --git a/core/deposit/Cargo.toml b/core/deposit/Cargo.toml index 99b9a935a..9cef301b0 100644 --- a/core/deposit/Cargo.toml +++ b/core/deposit/Cargo.toml @@ -40,3 +40,4 @@ authz = { path = "../../lib/authz", features = ["test-dummy"] } tokio = { workspace = true } anyhow = { workspace = true } rust_decimal_macros = { workspace = true } +rand = { workspace = true } diff --git a/core/deposit/src/account/entity.rs b/core/deposit/src/account/entity.rs index 66b180e1d..95090e265 100644 --- a/core/deposit/src/account/entity.rs +++ b/core/deposit/src/account/entity.rs @@ -15,6 +15,8 @@ pub enum DepositAccountEvent { id: DepositAccountId, account_holder_id: DepositAccountHolderId, ledger_account_id: LedgerAccountId, + name: String, + description: String, audit_info: AuditInfo, }, } @@ -24,6 +26,8 @@ pub enum DepositAccountEvent { pub struct DepositAccount { pub id: DepositAccountId, pub account_holder_id: DepositAccountHolderId, + pub name: String, + pub description: String, pub(super) events: EntityEvents, } @@ -43,8 +47,16 @@ impl TryFromEvents for DepositAccount { DepositAccountEvent::Initialized { id, account_holder_id, + name, + description, .. - } => builder = builder.id(*id).account_holder_id(*account_holder_id), + } => { + builder = builder + .id(*id) + .account_holder_id(*account_holder_id) + .name(name.to_string()) + .description(description.to_string()) + } } } builder.events(events).build() @@ -57,6 +69,8 @@ pub struct NewDepositAccount { pub(super) id: DepositAccountId, #[builder(setter(into))] pub(super) account_holder_id: DepositAccountHolderId, + pub(super) name: String, + pub(super) description: String, #[builder(setter(into))] pub audit_info: AuditInfo, } @@ -75,6 +89,8 @@ impl IntoEvents for NewDepositAccount { id: self.id, account_holder_id: self.account_holder_id, ledger_account_id: self.id.into(), + name: self.name, + description: self.description, audit_info: self.audit_info, }], ) diff --git a/core/deposit/src/error.rs b/core/deposit/src/error.rs index 7d56e82e9..9a4564d1b 100644 --- a/core/deposit/src/error.rs +++ b/core/deposit/src/error.rs @@ -16,6 +16,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 - JobError: {0}")] JobError(#[from] job::error::JobError), #[error("CoreDepositError - ProcessError: {0}")] diff --git a/core/deposit/src/ledger/mod.rs b/core/deposit/src/ledger/mod.rs index 5b807e560..3ef08bd22 100644 --- a/core/deposit/src/ledger/mod.rs +++ b/core/deposit/src/ledger/mod.rs @@ -40,31 +40,6 @@ impl DepositLedger { }) } - pub async fn create_account_for_deposit_account( - &self, - op: es_entity::DbOp<'_>, - id: impl Into, - code: String, - ) -> Result<(), DepositLedgerError> { - let mut op = self.cala.ledger_operation_from_db_op(op); - - let new_account = NewAccount::builder() - .id(id) - .name("Deposit Account") - .code(code) - .build() - .expect("Could not build new account"); - - self.cala - .accounts() - .create_in_op(&mut op, new_account) - .await?; - - op.commit().await?; - - Ok(()) - } - pub async fn record_deposit( &self, op: es_entity::DbOp<'_>, diff --git a/core/deposit/src/lib.rs b/core/deposit/src/lib.rs index bed844801..7428dfd71 100644 --- a/core/deposit/src/lib.rs +++ b/core/deposit/src/lib.rs @@ -16,7 +16,7 @@ use tracing::instrument; use audit::AuditSvc; use authz::PermissionCheck; use cala_ledger::CalaLedger; -use chart_of_accounts::CoreChartOfAccounts; +use chart_of_accounts::TransactionAccountFactory; use governance::{Governance, GovernanceEvent}; use job::Jobs; use outbox::{Outbox, OutboxEventMarker}; @@ -47,6 +47,7 @@ where withdrawals: WithdrawalRepo, approve_withdrawal: ApproveWithdrawal, ledger: DepositLedger, + account_factory: TransactionAccountFactory, authz: Perms, governance: Governance, outbox: Outbox, @@ -63,6 +64,7 @@ where deposits: self.deposits.clone(), withdrawals: self.withdrawals.clone(), ledger: self.ledger.clone(), + account_factory: self.account_factory.clone(), authz: self.authz.clone(), governance: self.governance.clone(), approve_withdrawal: self.approve_withdrawal.clone(), @@ -87,8 +89,7 @@ where outbox: &Outbox, governance: &Governance, jobs: &Jobs, - _chart_of_accounts: &CoreChartOfAccounts, - // chart_id: ChartId + account_factory: TransactionAccountFactory, cala: &CalaLedger, journal_id: LedgerJournalId, omnibus_account_code: String, @@ -99,8 +100,6 @@ where let ledger = DepositLedger::init(cala, journal_id, omnibus_account_code).await?; let approve_withdrawal = ApproveWithdrawal::new(&withdrawals, authz.audit(), governance); - // chart_of_accounts.create_control_account() - // chart_of_accounts.create_sub_account() jobs.add_initializer_and_spawn_unique( WithdrawApprovalJobInitializer::new(outbox, &approve_withdrawal), @@ -125,6 +124,7 @@ where governance: governance.clone(), approve_withdrawal, ledger, + account_factory, }; Ok(res) } @@ -134,6 +134,8 @@ where &self, sub: &<::Audit as AuditSvc>::Subject, holder_id: impl Into + std::fmt::Debug, + name: &str, + description: &str, ) -> Result { let audit_info = self .authz @@ -148,14 +150,23 @@ where let new_account = NewDepositAccount::builder() .id(account_id) .account_holder_id(holder_id) - .audit_info(audit_info) + .name(name.to_string()) + .description(description.to_string()) + .audit_info(audit_info.clone()) .build() .expect("Could not build new committee"); let mut op = self.accounts.begin_op().await?; let account = self.accounts.create_in_op(&mut op, new_account).await?; - self.ledger - .create_account_for_deposit_account(op, account_id, account_id.to_string()) + + self.account_factory + .create_transaction_account_in_op( + op, + account_id, + &account.name, + &account.description, + audit_info, + ) .await?; Ok(account) } diff --git a/core/deposit/src/primitives.rs b/core/deposit/src/primitives.rs index c0b9bc7da..3796aff92 100644 --- a/core/deposit/src/primitives.rs +++ b/core/deposit/src/primitives.rs @@ -2,6 +2,7 @@ use std::{fmt::Display, str::FromStr}; use authz::AllOrOne; +pub use chart_of_accounts::ChartId; pub use governance::{ApprovalProcessId, GovernanceAction, GovernanceObject}; pub use cala_ledger::primitives::{ diff --git a/core/deposit/tests/deposit.rs b/core/deposit/tests/deposit.rs index 13b9cc4f0..6e675f194 100644 --- a/core/deposit/tests/deposit.rs +++ b/core/deposit/tests/deposit.rs @@ -4,12 +4,14 @@ use rust_decimal_macros::dec; use authz::dummy::DummySubject; use cala_ledger::{CalaLedger, CalaLedgerConfig}; -use chart_of_accounts::CoreChartOfAccounts; +use chart_of_accounts::{CategoryPath, ChartOfAccountCode, CoreChartOfAccounts}; use deposit::*; use helpers::{action, event, object}; #[tokio::test] async fn deposit() -> anyhow::Result<()> { + use rand::Rng; + let pool = helpers::init_pool().await?; let outbox = outbox::Outbox::::init(&pool).await?; @@ -27,14 +29,40 @@ async fn deposit() -> anyhow::Result<()> { let journal_id = helpers::init_journal(&cala).await?; let omnibus_code = journal_id.to_string(); + let chart_id = ChartId::new(); let chart_of_accounts = CoreChartOfAccounts::init(&pool, &authz, &cala).await?; + chart_of_accounts + .create_chart( + chart_id, + format!("{:02}", rand::thread_rng().gen_range(0..100)), + ) + .await?; + + let control_account_path = chart_of_accounts + .create_control_account( + chart_id, + ChartOfAccountCode::Category(CategoryPath::Liabilities), + "Deposits".to_string(), + "deposits".to_string(), + ) + .await?; + let control_sub_account_path = chart_of_accounts + .create_control_sub_account( + chart_id, + control_account_path, + "User Deposits".to_string(), + "user-deposits".to_string(), + ) + .await?; + let factory = chart_of_accounts.transaction_account_factory(chart_id, control_sub_account_path); + let deposit = CoreDeposit::init( &pool, &authz, &outbox, &governance, &jobs, - &chart_of_accounts, + factory, &cala, journal_id, omnibus_code, @@ -43,7 +71,12 @@ async fn deposit() -> anyhow::Result<()> { let account_holder_id = DepositAccountHolderId::new(); let account = deposit - .create_account(&DummySubject, account_holder_id) + .create_account( + &DummySubject, + account_holder_id, + "Deposit for User #1", + "Deposit checking account for user.", + ) .await?; deposit diff --git a/core/deposit/tests/withdraw.rs b/core/deposit/tests/withdraw.rs index a292c87d5..39d988fb3 100644 --- a/core/deposit/tests/withdraw.rs +++ b/core/deposit/tests/withdraw.rs @@ -4,13 +4,15 @@ use rust_decimal_macros::dec; use authz::dummy::DummySubject; use cala_ledger::{CalaLedger, CalaLedgerConfig}; -use chart_of_accounts::CoreChartOfAccounts; +use chart_of_accounts::{CategoryPath, ChartOfAccountCode, CoreChartOfAccounts}; use deposit::*; use helpers::{action, event, object}; #[tokio::test] async fn cancel_withdrawal() -> anyhow::Result<()> { + use rand::Rng; + let pool = helpers::init_pool().await?; let outbox = outbox::Outbox::::init(&pool).await?; @@ -28,14 +30,40 @@ async fn cancel_withdrawal() -> anyhow::Result<()> { let journal_id = helpers::init_journal(&cala).await?; let omnibus_code = journal_id.to_string(); + let chart_id = ChartId::new(); let chart_of_accounts = CoreChartOfAccounts::init(&pool, &authz, &cala).await?; + chart_of_accounts + .create_chart( + chart_id, + format!("{:02}", rand::thread_rng().gen_range(0..100)), + ) + .await?; + + let control_account_path = chart_of_accounts + .create_control_account( + chart_id, + ChartOfAccountCode::Category(CategoryPath::Liabilities), + "Deposits".to_string(), + "deposits".to_string(), + ) + .await?; + let control_sub_account_path = chart_of_accounts + .create_control_sub_account( + chart_id, + control_account_path, + "User Deposits".to_string(), + "user-deposits".to_string(), + ) + .await?; + let factory = chart_of_accounts.transaction_account_factory(chart_id, control_sub_account_path); + let deposit = CoreDeposit::init( &pool, &authz, &outbox, &governance, &jobs, - &chart_of_accounts, + factory, &cala, journal_id, omnibus_code, @@ -44,7 +72,12 @@ async fn cancel_withdrawal() -> anyhow::Result<()> { let account_holder_id = DepositAccountHolderId::new(); let account = deposit - .create_account(&DummySubject, account_holder_id) + .create_account( + &DummySubject, + account_holder_id, + "Deposit for User #1", + "Deposit checking account for user.", + ) .await?; let deposit_amount = UsdCents::try_from_usd(dec!(1000000)).unwrap(); diff --git a/lana/app/.sqlx/query-02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d.json b/lana/app/.sqlx/query-02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d.json new file mode 100644 index 000000000..88bca3d2b --- /dev/null +++ b/lana/app/.sqlx/query-02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d" +} diff --git a/lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json new file mode 100644 index 000000000..d57a47c95 --- /dev/null +++ b/lana/app/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" +} diff --git a/lana/app/.sqlx/query-5733c3caf212ae07a01e3fc8664b43084b2f2866b5311a7327518238b74cf5bc.json b/lana/app/.sqlx/query-0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca.json similarity index 61% rename from lana/app/.sqlx/query-5733c3caf212ae07a01e3fc8664b43084b2f2866b5311a7327518238b74cf5bc.json rename to lana/app/.sqlx/query-0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca.json index 20d5c4067..37511009c 100644 --- a/lana/app/.sqlx/query-5733c3caf212ae07a01e3fc8664b43084b2f2866b5311a7327518238b74cf5bc.json +++ b/lana/app/.sqlx/query-0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM deposits 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: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_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 deposit_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: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_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: DepositId", + "name": "entity_id: DepositAccountId", "type_info": "Uuid" }, { @@ -38,5 +38,5 @@ false ] }, - "hash": "5733c3caf212ae07a01e3fc8664b43084b2f2866b5311a7327518238b74cf5bc" + "hash": "0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca" } diff --git a/lana/app/.sqlx/query-0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b.json b/lana/app/.sqlx/query-0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b.json new file mode 100644 index 000000000..887a23764 --- /dev/null +++ b/lana/app/.sqlx/query-0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM deposit_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: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_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: DepositAccountId", + "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": "0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b" +} diff --git a/lana/app/.sqlx/query-0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483.json b/lana/app/.sqlx/query-0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483.json new file mode 100644 index 000000000..97e0681d4 --- /dev/null +++ b/lana/app/.sqlx/query-0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_deposits 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: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_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: DepositId", + "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": "0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483" +} diff --git a/lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json new file mode 100644 index 000000000..19e53c2ec --- /dev/null +++ b/lana/app/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json @@ -0,0 +1,18 @@ +{ + "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-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/lana/app/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json new file mode 100644 index 000000000..dae4e1e2e --- /dev/null +++ b/lana/app/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json @@ -0,0 +1,42 @@ +{ + "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", + "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": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" +} diff --git a/lana/app/.sqlx/query-1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2.json b/lana/app/.sqlx/query-1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2.json new file mode 100644 index 000000000..61bd68174 --- /dev/null +++ b/lana/app/.sqlx/query-1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2" +} diff --git a/lana/app/.sqlx/query-1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66.json b/lana/app/.sqlx/query-1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66.json new file mode 100644 index 000000000..388afccf9 --- /dev/null +++ b/lana/app/.sqlx/query-1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_deposit_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": "1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66" +} diff --git a/lana/app/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json b/lana/app/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json new file mode 100644 index 000000000..3798ac4b7 --- /dev/null +++ b/lana/app/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO deposit_accounts (id, account_holder_id, created_at) VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50" +} diff --git a/lana/app/.sqlx/query-232a1fae4d5cb6c8df0edd329e4ee1932f303ba0088babb594084eedef3abcfc.json b/lana/app/.sqlx/query-232a1fae4d5cb6c8df0edd329e4ee1932f303ba0088babb594084eedef3abcfc.json deleted file mode 100644 index f85caff67..000000000 --- a/lana/app/.sqlx/query-232a1fae4d5cb6c8df0edd329e4ee1932f303ba0088babb594084eedef3abcfc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO deposit_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": "232a1fae4d5cb6c8df0edd329e4ee1932f303ba0088babb594084eedef3abcfc" -} diff --git a/lana/app/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json b/lana/app/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json new file mode 100644 index 000000000..7bbe53766 --- /dev/null +++ b/lana/app/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9" +} diff --git a/lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json new file mode 100644 index 000000000..95a5300c8 --- /dev/null +++ b/lana/app/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json @@ -0,0 +1,40 @@ +{ + "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", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" +} diff --git a/lana/app/.sqlx/query-38a13a3cc0815490b71675782409afac1831450f6793793f037bc3250fdace2d.json b/lana/app/.sqlx/query-38a13a3cc0815490b71675782409afac1831450f6793793f037bc3250fdace2d.json deleted file mode 100644 index bc609716e..000000000 --- a/lana/app/.sqlx/query-38a13a3cc0815490b71675782409afac1831450f6793793f037bc3250fdace2d.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO deposit_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": "38a13a3cc0815490b71675782409afac1831450f6793793f037bc3250fdace2d" -} diff --git a/lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json new file mode 100644 index 000000000..95bebab0d --- /dev/null +++ b/lana/app/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" +} diff --git a/lana/app/.sqlx/query-19bc462c1de1d2806ed476303297ba8f442f18a8afe85317f6d1a78fcbcba92e.json b/lana/app/.sqlx/query-427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849.json similarity index 66% rename from lana/app/.sqlx/query-19bc462c1de1d2806ed476303297ba8f442f18a8afe85317f6d1a78fcbcba92e.json rename to lana/app/.sqlx/query-427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849.json index c47d19e28..52f020376 100644 --- a/lana/app/.sqlx/query-19bc462c1de1d2806ed476303297ba8f442f18a8afe85317f6d1a78fcbcba92e.json +++ b/lana/app/.sqlx/query-427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM deposits WHERE customer_id = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE id = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "19bc462c1de1d2806ed476303297ba8f442f18a8afe85317f6d1a78fcbcba92e" + "hash": "427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849" } diff --git a/lana/app/.sqlx/query-88ce779408e7f7d4bb6ab6e577c395a3218c6c0d9c17cd8166a122c7fd42b9c1.json b/lana/app/.sqlx/query-43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759.json similarity index 76% rename from lana/app/.sqlx/query-88ce779408e7f7d4bb6ab6e577c395a3218c6c0d9c17cd8166a122c7fd42b9c1.json rename to lana/app/.sqlx/query-43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759.json index 162d15ae7..e6340e31a 100644 --- a/lana/app/.sqlx/query-88ce779408e7f7d4bb6ab6e577c395a3218c6c0d9c17cd8166a122c7fd42b9c1.json +++ b/lana/app/.sqlx/query-43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT i.id AS \"id: DepositId\", e.sequence, e.event, e.recorded_at FROM deposits i JOIN deposit_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "query": "SELECT i.id AS \"id: DepositId\", e.sequence, e.event, e.recorded_at FROM core_deposits i JOIN core_deposit_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "88ce779408e7f7d4bb6ab6e577c395a3218c6c0d9c17cd8166a122c7fd42b9c1" + "hash": "43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759" } diff --git a/lana/app/.sqlx/query-4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9.json b/lana/app/.sqlx/query-4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9.json new file mode 100644 index 000000000..dda5454fb --- /dev/null +++ b/lana/app/.sqlx/query-4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE approval_process_id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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": "4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9" +} diff --git a/lana/app/.sqlx/query-8a17c09ef6cd471d852bd8afcaab9a6255c0a8be7cb1a0b0e7ae83cba333f5a7.json b/lana/app/.sqlx/query-47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19.json similarity index 60% rename from lana/app/.sqlx/query-8a17c09ef6cd471d852bd8afcaab9a6255c0a8be7cb1a0b0e7ae83cba333f5a7.json rename to lana/app/.sqlx/query-47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19.json index b4b95266c..bc225186e 100644 --- a/lana/app/.sqlx/query-8a17c09ef6cd471d852bd8afcaab9a6255c0a8be7cb1a0b0e7ae83cba333f5a7.json +++ b/lana/app/.sqlx/query-47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, id FROM deposits WHERE ((customer_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -38,5 +38,5 @@ false ] }, - "hash": "8a17c09ef6cd471d852bd8afcaab9a6255c0a8be7cb1a0b0e7ae83cba333f5a7" + "hash": "47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19" } diff --git a/lana/app/.sqlx/query-cbc9a47fe71182f750bab9564c98eadb8970fe203c14d2f342637ac0c26f98a2.json b/lana/app/.sqlx/query-4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4.json similarity index 57% rename from lana/app/.sqlx/query-cbc9a47fe71182f750bab9564c98eadb8970fe203c14d2f342637ac0c26f98a2.json rename to lana/app/.sqlx/query-4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4.json index 8e853277b..44c08f4da 100644 --- a/lana/app/.sqlx/query-cbc9a47fe71182f750bab9564c98eadb8970fe203c14d2f342637ac0c26f98a2.json +++ b/lana/app/.sqlx/query-4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, created_at, id FROM withdrawals WHERE ((customer_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_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 deposit_account_id, created_at, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -39,5 +39,5 @@ false ] }, - "hash": "cbc9a47fe71182f750bab9564c98eadb8970fe203c14d2f342637ac0c26f98a2" + "hash": "4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4" } diff --git a/lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json new file mode 100644 index 000000000..5f58f2f07 --- /dev/null +++ b/lana/app/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json @@ -0,0 +1,18 @@ +{ + "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-b175690cb8e5f3f4dac4c5bb0318a67a7d2991f4c9e830c3d7a5e65602ea439a.json b/lana/app/.sqlx/query-56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296.json similarity index 57% rename from lana/app/.sqlx/query-b175690cb8e5f3f4dac4c5bb0318a67a7d2991f4c9e830c3d7a5e65602ea439a.json rename to lana/app/.sqlx/query-56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296.json index 7c080aa5c..71459709a 100644 --- a/lana/app/.sqlx/query-b175690cb8e5f3f4dac4c5bb0318a67a7d2991f4c9e830c3d7a5e65602ea439a.json +++ b/lana/app/.sqlx/query-56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, created_at, id FROM deposits WHERE ((customer_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT deposit_account_id, created_at, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -39,5 +39,5 @@ false ] }, - "hash": "b175690cb8e5f3f4dac4c5bb0318a67a7d2991f4c9e830c3d7a5e65602ea439a" + "hash": "56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296" } diff --git a/lana/app/.sqlx/query-5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539.json b/lana/app/.sqlx/query-5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539.json new file mode 100644 index 000000000..550be8e80 --- /dev/null +++ b/lana/app/.sqlx/query-5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_withdrawal_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": "5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539" +} diff --git a/lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json new file mode 100644 index 000000000..8ac8f7df0 --- /dev/null +++ b/lana/app/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json @@ -0,0 +1,40 @@ +{ + "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", + "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": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" +} diff --git a/lana/app/.sqlx/query-7114f5dcbe429002c0b8b49dbf5091c53c9fa1c611721c58378072337d117d9f.json b/lana/app/.sqlx/query-606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2.json similarity index 51% rename from lana/app/.sqlx/query-7114f5dcbe429002c0b8b49dbf5091c53c9fa1c611721c58378072337d117d9f.json rename to lana/app/.sqlx/query-606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2.json index 5d8aa0a9f..db1a9fc59 100644 --- a/lana/app/.sqlx/query-7114f5dcbe429002c0b8b49dbf5091c53c9fa1c611721c58378072337d117d9f.json +++ b/lana/app/.sqlx/query-606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO withdrawals (id, customer_id, approval_process_id, reference, created_at) VALUES ($1, $2, $3, $4, $5)", + "query": "INSERT INTO core_withdrawals (id, deposit_account_id, approval_process_id, reference, created_at) VALUES ($1, $2, $3, $4, $5)", "describe": { "columns": [], "parameters": { @@ -14,5 +14,5 @@ }, "nullable": [] }, - "hash": "7114f5dcbe429002c0b8b49dbf5091c53c9fa1c611721c58378072337d117d9f" + "hash": "606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2" } diff --git a/lana/app/.sqlx/query-641ada7de795206f65162e37cdb53991e8bb75705ab4ec039e5f05b7bf9f0c6a.json b/lana/app/.sqlx/query-641ada7de795206f65162e37cdb53991e8bb75705ab4ec039e5f05b7bf9f0c6a.json deleted file mode 100644 index dfd81ba2f..000000000 --- a/lana/app/.sqlx/query-641ada7de795206f65162e37cdb53991e8bb75705ab4ec039e5f05b7bf9f0c6a.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO withdrawal_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": "641ada7de795206f65162e37cdb53991e8bb75705ab4ec039e5f05b7bf9f0c6a" -} diff --git a/lana/app/.sqlx/query-6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657.json b/lana/app/.sqlx/query-6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657.json new file mode 100644 index 000000000..08b2302b0 --- /dev/null +++ b/lana/app/.sqlx/query-6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, created_at, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_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: DepositId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657" +} diff --git a/lana/app/.sqlx/query-66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65.json b/lana/app/.sqlx/query-66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65.json new file mode 100644 index 000000000..b7dbe210c --- /dev/null +++ b/lana/app/.sqlx/query-66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO deposit_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": "66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65" +} diff --git a/lana/app/.sqlx/query-504b7967fa826280c7e94532ddbb0c63a23eec8949a15855844804af58746cb7.json b/lana/app/.sqlx/query-697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab.json similarity index 53% rename from lana/app/.sqlx/query-504b7967fa826280c7e94532ddbb0c63a23eec8949a15855844804af58746cb7.json rename to lana/app/.sqlx/query-697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab.json index 327ac60ee..c76e1cd1e 100644 --- a/lana/app/.sqlx/query-504b7967fa826280c7e94532ddbb0c63a23eec8949a15855844804af58746cb7.json +++ b/lana/app/.sqlx/query-697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO deposits (id, customer_id, reference, created_at) VALUES ($1, $2, $3, $4)", + "query": "INSERT INTO core_deposits (id, deposit_account_id, reference, created_at) VALUES ($1, $2, $3, $4)", "describe": { "columns": [], "parameters": { @@ -13,5 +13,5 @@ }, "nullable": [] }, - "hash": "504b7967fa826280c7e94532ddbb0c63a23eec8949a15855844804af58746cb7" + "hash": "697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab" } diff --git a/lana/app/.sqlx/query-6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f.json b/lana/app/.sqlx/query-6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f.json new file mode 100644 index 000000000..947523020 --- /dev/null +++ b/lana/app/.sqlx/query-6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f" +} diff --git a/lana/app/.sqlx/query-75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7.json b/lana/app/.sqlx/query-75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7.json new file mode 100644 index 000000000..c050398ce --- /dev/null +++ b/lana/app/.sqlx/query-75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE deposit_account_id = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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": "75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7" +} diff --git a/lana/app/.sqlx/query-757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b.json b/lana/app/.sqlx/query-757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b.json new file mode 100644 index 000000000..384262f22 --- /dev/null +++ b/lana/app/.sqlx/query-757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_withdrawals 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: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_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: WithdrawalId", + "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": "757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b" +} diff --git a/lana/app/.sqlx/query-769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c.json b/lana/app/.sqlx/query-769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c.json new file mode 100644 index 000000000..b22a7fa7c --- /dev/null +++ b/lana/app/.sqlx/query-769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_deposits 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: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_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: DepositId", + "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": "769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c" +} diff --git a/lana/app/.sqlx/query-77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971.json b/lana/app/.sqlx/query-77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971.json new file mode 100644 index 000000000..f9375e0c7 --- /dev/null +++ b/lana/app/.sqlx/query-77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971" +} diff --git a/lana/app/.sqlx/query-80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129.json b/lana/app/.sqlx/query-80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129.json new file mode 100644 index 000000000..c8aa136cc --- /dev/null +++ b/lana/app/.sqlx/query-80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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": "80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129" +} diff --git a/lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json new file mode 100644 index 000000000..68cc67380 --- /dev/null +++ b/lana/app/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json @@ -0,0 +1,41 @@ +{ + "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 new file mode 100644 index 000000000..c2f814ec9 --- /dev/null +++ b/lana/app/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json @@ -0,0 +1,40 @@ +{ + "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-8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369.json b/lana/app/.sqlx/query-8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369.json new file mode 100644 index 000000000..8c4ce1ff9 --- /dev/null +++ b/lana/app/.sqlx/query-8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE id = $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369" +} diff --git a/lana/app/.sqlx/query-d1adaf132ccf5ffafc7a9e22259014386c1793f1865b64d5bef64a95a27ede28.json b/lana/app/.sqlx/query-8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3.json similarity index 70% rename from lana/app/.sqlx/query-d1adaf132ccf5ffafc7a9e22259014386c1793f1865b64d5bef64a95a27ede28.json rename to lana/app/.sqlx/query-8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3.json index 7bd62541c..9179fa2eb 100644 --- a/lana/app/.sqlx/query-d1adaf132ccf5ffafc7a9e22259014386c1793f1865b64d5bef64a95a27ede28.json +++ b/lana/app/.sqlx/query-8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM withdrawals WHERE approval_process_id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE reference = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -26,7 +26,7 @@ ], "parameters": { "Left": [ - "Uuid" + "Text" ] }, "nullable": [ @@ -36,5 +36,5 @@ false ] }, - "hash": "d1adaf132ccf5ffafc7a9e22259014386c1793f1865b64d5bef64a95a27ede28" + "hash": "8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3" } diff --git a/lana/app/.sqlx/query-907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4.json b/lana/app/.sqlx/query-907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4.json new file mode 100644 index 000000000..cac5c07aa --- /dev/null +++ b/lana/app/.sqlx/query-907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE deposit_account_id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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": "907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4" +} diff --git a/lana/app/.sqlx/query-a090ce3986288a1db4eb02a4e31993fb4ab6411bb73cccadca1440ea4654dde1.json b/lana/app/.sqlx/query-91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e.json similarity index 59% rename from lana/app/.sqlx/query-a090ce3986288a1db4eb02a4e31993fb4ab6411bb73cccadca1440ea4654dde1.json rename to lana/app/.sqlx/query-91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e.json index f53454d76..2643d87f1 100644 --- a/lana/app/.sqlx/query-a090ce3986288a1db4eb02a4e31993fb4ab6411bb73cccadca1440ea4654dde1.json +++ b/lana/app/.sqlx/query-91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM withdrawals 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: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT created_at, id FROM core_withdrawals 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: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -38,5 +38,5 @@ false ] }, - "hash": "a090ce3986288a1db4eb02a4e31993fb4ab6411bb73cccadca1440ea4654dde1" + "hash": "91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e" } diff --git a/lana/app/.sqlx/query-9f9a8d992cb75c5caefd0995ba5da2b7a0a5be3e0fffdc13be8c4ba42e191fc1.json b/lana/app/.sqlx/query-9f9a8d992cb75c5caefd0995ba5da2b7a0a5be3e0fffdc13be8c4ba42e191fc1.json deleted file mode 100644 index 2f1eac19b..000000000 --- a/lana/app/.sqlx/query-9f9a8d992cb75c5caefd0995ba5da2b7a0a5be3e0fffdc13be8c4ba42e191fc1.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO withdrawal_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": "9f9a8d992cb75c5caefd0995ba5da2b7a0a5be3e0fffdc13be8c4ba42e191fc1" -} diff --git a/lana/app/.sqlx/query-a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0.json b/lana/app/.sqlx/query-a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0.json new file mode 100644 index 000000000..6380b4539 --- /dev/null +++ b/lana/app/.sqlx/query-a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, created_at, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_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: WithdrawalId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0" +} diff --git a/lana/app/.sqlx/query-a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f.json b/lana/app/.sqlx/query-a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f.json new file mode 100644 index 000000000..1d0a9782b --- /dev/null +++ b/lana/app/.sqlx/query-a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_withdrawals SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f" +} diff --git a/lana/app/.sqlx/query-bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c.json b/lana/app/.sqlx/query-bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c.json new file mode 100644 index 000000000..0e7e5da20 --- /dev/null +++ b/lana/app/.sqlx/query-bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_withdrawal_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": "bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c" +} diff --git a/lana/app/.sqlx/query-be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32.json b/lana/app/.sqlx/query-be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32.json new file mode 100644 index 000000000..5122b8a19 --- /dev/null +++ b/lana/app/.sqlx/query-be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_deposits SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32" +} diff --git a/lana/app/.sqlx/query-57725e4ce947dd5dc6ca29ff08cab86dc1cb96be20a75ad2f7be8a8cdf80cf6e.json b/lana/app/.sqlx/query-c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36.json similarity index 63% rename from lana/app/.sqlx/query-57725e4ce947dd5dc6ca29ff08cab86dc1cb96be20a75ad2f7be8a8cdf80cf6e.json rename to lana/app/.sqlx/query-c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36.json index 93213b3d4..6ea7cf34e 100644 --- a/lana/app/.sqlx/query-57725e4ce947dd5dc6ca29ff08cab86dc1cb96be20a75ad2f7be8a8cdf80cf6e.json +++ b/lana/app/.sqlx/query-c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM deposits WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -37,5 +37,5 @@ false ] }, - "hash": "57725e4ce947dd5dc6ca29ff08cab86dc1cb96be20a75ad2f7be8a8cdf80cf6e" + "hash": "c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36" } diff --git a/lana/app/.sqlx/query-a03b733597fdfbf4ad009bb0839a3479036e737dc40b28675425ab29b6208a20.json b/lana/app/.sqlx/query-cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585.json similarity index 62% rename from lana/app/.sqlx/query-a03b733597fdfbf4ad009bb0839a3479036e737dc40b28675425ab29b6208a20.json rename to lana/app/.sqlx/query-cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585.json index 0c87a6b9e..d0b957116 100644 --- a/lana/app/.sqlx/query-a03b733597fdfbf4ad009bb0839a3479036e737dc40b28675425ab29b6208a20.json +++ b/lana/app/.sqlx/query-cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM withdrawals WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -37,5 +37,5 @@ false ] }, - "hash": "a03b733597fdfbf4ad009bb0839a3479036e737dc40b28675425ab29b6208a20" + "hash": "cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585" } diff --git a/lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json new file mode 100644 index 000000000..65ba29133 --- /dev/null +++ b/lana/app/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json @@ -0,0 +1,42 @@ +{ + "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-cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19.json b/lana/app/.sqlx/query-cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19.json new file mode 100644 index 000000000..c7b6647b4 --- /dev/null +++ b/lana/app/.sqlx/query-cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT i.id AS \"id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM deposit_accounts i JOIN deposit_account_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: DepositAccountId", + "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19" +} diff --git a/lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json b/lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json new file mode 100644 index 000000000..369e3792b --- /dev/null +++ b/lana/app/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json @@ -0,0 +1,41 @@ +{ + "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-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json b/lana/app/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json new file mode 100644 index 000000000..303e96373 --- /dev/null +++ b/lana/app/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, created_at, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_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: DepositAccountId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa" +} diff --git a/lana/app/.sqlx/query-0cd96c1b48c58a144fd8b7a9d29dc45c51b4ee6205f4273383fba9983b965410.json b/lana/app/.sqlx/query-d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f.json similarity index 60% rename from lana/app/.sqlx/query-0cd96c1b48c58a144fd8b7a9d29dc45c51b4ee6205f4273383fba9983b965410.json rename to lana/app/.sqlx/query-d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f.json index a8967fda2..cc7d2c567 100644 --- a/lana/app/.sqlx/query-0cd96c1b48c58a144fd8b7a9d29dc45c51b4ee6205f4273383fba9983b965410.json +++ b/lana/app/.sqlx/query-d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, id FROM withdrawals WHERE ((customer_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -38,5 +38,5 @@ false ] }, - "hash": "0cd96c1b48c58a144fd8b7a9d29dc45c51b4ee6205f4273383fba9983b965410" + "hash": "d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f" } diff --git a/lana/app/.sqlx/query-d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1.json b/lana/app/.sqlx/query-d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1.json new file mode 100644 index 000000000..c6454531d --- /dev/null +++ b/lana/app/.sqlx/query-d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO deposit_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": "d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1" +} diff --git a/lana/app/.sqlx/query-4a8cda6b1c3baa03c891bf3360847c51bddf5f176bffbadb523c62bc9ada9f69.json b/lana/app/.sqlx/query-dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42.json similarity index 65% rename from lana/app/.sqlx/query-4a8cda6b1c3baa03c891bf3360847c51bddf5f176bffbadb523c62bc9ada9f69.json rename to lana/app/.sqlx/query-dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42.json index baff2224c..9723add52 100644 --- a/lana/app/.sqlx/query-4a8cda6b1c3baa03c891bf3360847c51bddf5f176bffbadb523c62bc9ada9f69.json +++ b/lana/app/.sqlx/query-dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM withdrawals WHERE id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "4a8cda6b1c3baa03c891bf3360847c51bddf5f176bffbadb523c62bc9ada9f69" + "hash": "dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42" } diff --git a/lana/app/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json b/lana/app/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json new file mode 100644 index 000000000..43c37d3f7 --- /dev/null +++ b/lana/app/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE account_holder_id = $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43" +} diff --git a/lana/app/.sqlx/query-e1409656c4c97657c942619a274cd648936201878d4ced532a19cafbe27ae8c8.json b/lana/app/.sqlx/query-e1409656c4c97657c942619a274cd648936201878d4ced532a19cafbe27ae8c8.json deleted file mode 100644 index 291f6398b..000000000 --- a/lana/app/.sqlx/query-e1409656c4c97657c942619a274cd648936201878d4ced532a19cafbe27ae8c8.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE withdrawals SET customer_id = $2, reference = $3 WHERE id = $1", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Varchar" - ] - }, - "nullable": [] - }, - "hash": "e1409656c4c97657c942619a274cd648936201878d4ced532a19cafbe27ae8c8" -} diff --git a/lana/app/.sqlx/query-e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f.json b/lana/app/.sqlx/query-e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f.json new file mode 100644 index 000000000..480c04811 --- /dev/null +++ b/lana/app/.sqlx/query-e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_deposit_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": "e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f" +} diff --git a/lana/app/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json b/lana/app/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json new file mode 100644 index 000000000..148827bb6 --- /dev/null +++ b/lana/app/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af" +} diff --git a/lana/app/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json b/lana/app/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json new file mode 100644 index 000000000..ed8d2f097 --- /dev/null +++ b/lana/app/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, created_at, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_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: DepositAccountId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126" +} diff --git a/lana/app/.sqlx/query-141ef4e83339c11f5fa63fcb8a091e1a12b2ce6d555ecae9869c66034d9d864c.json b/lana/app/.sqlx/query-f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb.json similarity index 65% rename from lana/app/.sqlx/query-141ef4e83339c11f5fa63fcb8a091e1a12b2ce6d555ecae9869c66034d9d864c.json rename to lana/app/.sqlx/query-f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb.json index 8c759697d..6c590f49e 100644 --- a/lana/app/.sqlx/query-141ef4e83339c11f5fa63fcb8a091e1a12b2ce6d555ecae9869c66034d9d864c.json +++ b/lana/app/.sqlx/query-f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM deposits WHERE reference = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE reference = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "141ef4e83339c11f5fa63fcb8a091e1a12b2ce6d555ecae9869c66034d9d864c" + "hash": "f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb" } diff --git a/lana/app/.sqlx/query-f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3.json b/lana/app/.sqlx/query-f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3.json new file mode 100644 index 000000000..2560d1d99 --- /dev/null +++ b/lana/app/.sqlx/query-f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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": "f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3" +} diff --git a/lana/app/.sqlx/query-1c5fd98754e7ffcb2421035201ade8263b2d3eb4fa423d610fde881d7cda29d2.json b/lana/app/.sqlx/query-f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc.json similarity index 76% rename from lana/app/.sqlx/query-1c5fd98754e7ffcb2421035201ade8263b2d3eb4fa423d610fde881d7cda29d2.json rename to lana/app/.sqlx/query-f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc.json index 8ec7180a2..caaf2edb7 100644 --- a/lana/app/.sqlx/query-1c5fd98754e7ffcb2421035201ade8263b2d3eb4fa423d610fde881d7cda29d2.json +++ b/lana/app/.sqlx/query-f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT i.id AS \"id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM withdrawals i JOIN withdrawal_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "query": "SELECT i.id AS \"id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM core_withdrawals i JOIN core_withdrawal_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "1c5fd98754e7ffcb2421035201ade8263b2d3eb4fa423d610fde881d7cda29d2" + "hash": "f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc" } diff --git a/lana/app/migrations/20240517074612_core_setup.sql b/lana/app/migrations/20240517074612_core_setup.sql index 9b2cc2b4e..84d6a0512 100644 --- a/lana/app/migrations/20240517074612_core_setup.sql +++ b/lana/app/migrations/20240517074612_core_setup.sql @@ -48,6 +48,7 @@ CREATE TABLE approval_process_events ( CREATE TABLE core_chart_of_accounts ( id UUID PRIMARY KEY, + reference VARCHAR NOT NULL UNIQUE, created_at TIMESTAMPTZ NOT NULL ); diff --git a/lana/app/src/accounting/error.rs b/lana/app/src/accounting/error.rs new file mode 100644 index 000000000..c58b5da2e --- /dev/null +++ b/lana/app/src/accounting/error.rs @@ -0,0 +1,7 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum AccountingError { + #[error("AccountingError - CoreChartOfAccountError: {0}")] + CoreChartOfAccountError(#[from] chart_of_accounts::error::CoreChartOfAccountError), +} diff --git a/lana/app/src/accounting/mod.rs b/lana/app/src/accounting/mod.rs new file mode 100644 index 000000000..b6e6fd820 --- /dev/null +++ b/lana/app/src/accounting/mod.rs @@ -0,0 +1,27 @@ +mod seed; + +pub mod error; + +use chart_of_accounts::{ChartId, ChartOfAccountCode}; + +use crate::chart_of_accounts::ChartOfAccounts; + +use error::*; + +#[derive(Clone)] +pub struct AccountingValues { + pub id: ChartId, + pub deposits_control_sub_path: ChartOfAccountCode, +} + +#[derive(Clone)] +pub struct Accounting { + pub values: AccountingValues, +} + +impl Accounting { + pub async fn init(chart_of_accounts: &ChartOfAccounts) -> Result { + let values = seed::execute(chart_of_accounts).await?; + Ok(Accounting { values }) + } +} diff --git a/lana/app/src/accounting/seed.rs b/lana/app/src/accounting/seed.rs new file mode 100644 index 000000000..abca96dcd --- /dev/null +++ b/lana/app/src/accounting/seed.rs @@ -0,0 +1,70 @@ +use chart_of_accounts::{ + error::CoreChartOfAccountError, CategoryPath, ChartId, ChartOfAccountCode, +}; + +use crate::chart_of_accounts::ChartOfAccounts; + +use super::AccountingValues; + +const CHART_REF: &str = "primary-chart"; + +const DEPOSITS_CONTROL_ACCOUNT_REF: &str = "deposits"; +const DEPOSITS_CONTROL_ACCOUNT_NAME: &str = "Deposits"; + +const DEPOSITS_CONTROL_SUB_ACCOUNT_REF: &str = "deposits-user"; +const DEPOSITS_CONTROL_SUB_ACCOUNT_NAME: &str = "User Deposits"; + +pub(super) async fn execute( + chart_of_accounts: &ChartOfAccounts, +) -> Result { + let chart = match chart_of_accounts + .find_by_reference(CHART_REF.to_string()) + .await? + { + Some(chart) => chart, + None => { + chart_of_accounts + .create_chart(ChartId::new(), CHART_REF.to_string()) + .await? + } + }; + + let deposits_control_path = match chart_of_accounts + .find_control_account_by_reference(chart.id, CHART_REF.to_string()) + .await? + { + Some(path) => path, + None => { + chart_of_accounts + .create_control_account( + chart.id, + ChartOfAccountCode::Category(CategoryPath::Liabilities), + DEPOSITS_CONTROL_ACCOUNT_REF.to_string(), + DEPOSITS_CONTROL_ACCOUNT_NAME.to_string(), + ) + .await? + } + }; + + let deposits_control_sub_path = match chart_of_accounts + .find_control_sub_account_by_reference(chart.id, CHART_REF.to_string()) + .await? + { + Some(path) => path, + None => { + chart_of_accounts + .create_control_sub_account( + chart.id, + deposits_control_path, + DEPOSITS_CONTROL_SUB_ACCOUNT_NAME.to_string(), + DEPOSITS_CONTROL_SUB_ACCOUNT_REF.to_string(), + ) + .await? + } + }; + + Ok(AccountingValues { + id: chart.id, + deposits_control_sub_path, + }) +} diff --git a/lana/app/src/app/error.rs b/lana/app/src/app/error.rs index de536e8ff..35bc7f292 100644 --- a/lana/app/src/app/error.rs +++ b/lana/app/src/app/error.rs @@ -1,5 +1,7 @@ use thiserror::Error; +use crate::accounting; + #[derive(Error, Debug)] pub enum ApplicationError { #[error("ApplicationError - Sqlx: {0}")] @@ -28,6 +30,8 @@ pub enum ApplicationError { GovernanceError(#[from] governance::error::GovernanceError), #[error("ApplicationError - DashboardError: {0}")] DashboardError(#[from] dashboard::error::DashboardError), + #[error("ApplicationError - AccountingError: {0}")] + AccountingError(#[from] accounting::error::AccountingError), #[error("ApplicationError - CalaInit: {0}")] CalaError(#[from] cala_ledger::error::LedgerError), #[error("ApplicationError - ChartOfAccountsError: {0}")] diff --git a/lana/app/src/app/mod.rs b/lana/app/src/app/mod.rs index 724fe4a54..d25ae2cb9 100644 --- a/lana/app/src/app/mod.rs +++ b/lana/app/src/app/mod.rs @@ -7,6 +7,7 @@ use tracing::instrument; use authz::PermissionCheck; use crate::{ + accounting::Accounting, applicant::Applicants, audit::{Audit, AuditCursor, AuditEntry}, authorization::{init as init_authz, AppAction, AppObject, AuditAction, Authorization}, @@ -73,6 +74,7 @@ impl LanaApp { let documents = Documents::new(&pool, &storage, &authz); let report = Reports::init(&pool, &config.report, &authz, &jobs, &storage, &export).await?; let users = Users::init(&pool, &authz, &outbox, config.user.superuser_email).await?; + let cala_config = cala_ledger::CalaLedgerConfig::builder() .pool(pool.clone()) .exec_migrations(false) @@ -81,13 +83,19 @@ impl LanaApp { let cala = cala_ledger::CalaLedger::init(cala_config).await?; let journal_id = Self::create_journal(&cala).await?; let chart_of_accounts = ChartOfAccounts::init(&pool, &authz, &cala).await?; + let accounting = Accounting::init(&chart_of_accounts).await?; + + let deposits_factory = chart_of_accounts.transaction_account_factory( + accounting.values.id, + accounting.values.deposits_control_sub_path, + ); let deposits = Deposits::init( &pool, &authz, &outbox, &governance, &jobs, - &chart_of_accounts, + deposits_factory, &cala, journal_id, String::from("OMNIBUS_ACCOUNT_ID"), diff --git a/lana/app/src/customer/mod.rs b/lana/app/src/customer/mod.rs index f702ab091..637490a59 100644 --- a/lana/app/src/customer/mod.rs +++ b/lana/app/src/customer/mod.rs @@ -85,7 +85,10 @@ impl Customers { .await? .expect("audit info missing"); let customer_id: uuid::Uuid = self.kratos.create_identity(&email).await?; - self.deposit.create_account(sub, customer_id).await?; + let account_name = &format!("Deposit Account for Customer {}", customer_id); + self.deposit + .create_account(sub, customer_id, account_name, account_name) + .await?; let ledger_account_ids = self .ledger diff --git a/lana/app/src/ledger/error.rs b/lana/app/src/ledger/error.rs index d222c943f..0a3f33b67 100644 --- a/lana/app/src/ledger/error.rs +++ b/lana/app/src/ledger/error.rs @@ -10,6 +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 - CouldNotAssertAccountExists")] CouldNotAssertAccountExists, #[error("LedgerError - CouldNotAssertAccountSetExists")] diff --git a/lana/app/src/ledger/mod.rs b/lana/app/src/ledger/mod.rs index 6d63c62c3..cbb742bc0 100644 --- a/lana/app/src/ledger/mod.rs +++ b/lana/app/src/ledger/mod.rs @@ -45,6 +45,7 @@ impl Ledger { pub async fn init(config: LedgerConfig, authz: &Authorization) -> Result { let cala = CalaClient::new(config.cala_url); Self::initialize_tx_templates(&cala).await?; + Ok(Ledger { cala, authz: authz.clone(), diff --git a/lana/app/src/lib.rs b/lana/app/src/lib.rs index 5619b6eea..2c907798a 100644 --- a/lana/app/src/lib.rs +++ b/lana/app/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(feature = "fail-on-warnings", deny(warnings))] #![cfg_attr(feature = "fail-on-warnings", deny(clippy::all))] +pub mod accounting; pub mod app; pub mod applicant; pub mod authorization; diff --git a/lana/dashboard/.sqlx/query-02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d.json b/lana/dashboard/.sqlx/query-02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d.json new file mode 100644 index 000000000..88bca3d2b --- /dev/null +++ b/lana/dashboard/.sqlx/query-02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "02617f65a7603c309ee825ba9be372c2ef44f685337992ee50bef039f3be423d" +} diff --git a/lana/dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json b/lana/dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json new file mode 100644 index 000000000..d57a47c95 --- /dev/null +++ b/lana/dashboard/.sqlx/query-04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_chart_of_accounts (id, reference, created_at) VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "04e9fe97f19059e0bf36dfee58b0b11c5f603dd09713f75fc440b1ddd1ed589d" +} diff --git a/lana/app/.sqlx/query-3b93bcf494c2cd834d244dd7df44a12dc790c9c11ade4ed60a41a872d9292557.json b/lana/dashboard/.sqlx/query-0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca.json similarity index 61% rename from lana/app/.sqlx/query-3b93bcf494c2cd834d244dd7df44a12dc790c9c11ade4ed60a41a872d9292557.json rename to lana/dashboard/.sqlx/query-0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca.json index fbc105c75..37511009c 100644 --- a/lana/app/.sqlx/query-3b93bcf494c2cd834d244dd7df44a12dc790c9c11ade4ed60a41a872d9292557.json +++ b/lana/dashboard/.sqlx/query-0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca.json @@ -1,11 +1,11 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM deposits 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: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT created_at, id FROM deposit_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: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_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: DepositId", + "name": "entity_id: DepositAccountId", "type_info": "Uuid" }, { @@ -38,5 +38,5 @@ false ] }, - "hash": "3b93bcf494c2cd834d244dd7df44a12dc790c9c11ade4ed60a41a872d9292557" + "hash": "0911a137c1a3afe9f301cf1b019a53ff041653d94f89a52ee250c93878ea2cca" } diff --git a/lana/dashboard/.sqlx/query-0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b.json b/lana/dashboard/.sqlx/query-0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b.json new file mode 100644 index 000000000..887a23764 --- /dev/null +++ b/lana/dashboard/.sqlx/query-0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM deposit_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: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_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: DepositAccountId", + "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": "0a8086357bfd95aee2480af351f90dbc6c00ab45e92297732f4f548426327f4b" +} diff --git a/lana/dashboard/.sqlx/query-0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483.json b/lana/dashboard/.sqlx/query-0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483.json new file mode 100644 index 000000000..97e0681d4 --- /dev/null +++ b/lana/dashboard/.sqlx/query-0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_deposits 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: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_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: DepositId", + "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": "0e0b27fef175ac24eb757a0e45e7b99d81e2947c6f7e64040446e0456976a483" +} diff --git a/lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json b/lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json new file mode 100644 index 000000000..19e53c2ec --- /dev/null +++ b/lana/dashboard/.sqlx/query-1156d623ff44db8627f328d379cd3b890daf7d8004f554f9ac18eff28d47e0f3.json @@ -0,0 +1,18 @@ +{ + "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-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json b/lana/dashboard/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json new file mode 100644 index 000000000..dae4e1e2e --- /dev/null +++ b/lana/dashboard/.sqlx/query-1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a.json @@ -0,0 +1,42 @@ +{ + "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", + "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": "1274f497c9c37b278a717c77db0bf6ed7a910acdcfee8970d30adb5703565d5a" +} diff --git a/lana/dashboard/.sqlx/query-1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2.json b/lana/dashboard/.sqlx/query-1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2.json new file mode 100644 index 000000000..61bd68174 --- /dev/null +++ b/lana/dashboard/.sqlx/query-1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "1885cb45c95e595339e8dc305fc3e72bd63e66f331eab8c57980e6d7e0e64cc2" +} diff --git a/lana/dashboard/.sqlx/query-1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66.json b/lana/dashboard/.sqlx/query-1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66.json new file mode 100644 index 000000000..388afccf9 --- /dev/null +++ b/lana/dashboard/.sqlx/query-1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_deposit_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": "1db91bf209069691293eef23a38715c4db000954e0ffb38eccf9d565e0d54c66" +} diff --git a/lana/dashboard/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json b/lana/dashboard/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json new file mode 100644 index 000000000..3798ac4b7 --- /dev/null +++ b/lana/dashboard/.sqlx/query-1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO deposit_accounts (id, account_holder_id, created_at) VALUES ($1, $2, $3)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "1f4ab93dd25d5e57350e4f9e089562d3988dac58a8d3dd6448c79329fbd2bf50" +} diff --git a/lana/dashboard/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json b/lana/dashboard/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json new file mode 100644 index 000000000..7bbe53766 --- /dev/null +++ b/lana/dashboard/.sqlx/query-253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "253f173128747ab15dfd97869fefe3a4b7ff59391ad86c03652dae9d0a3df5e9" +} diff --git a/lana/dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json b/lana/dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json new file mode 100644 index 000000000..95a5300c8 --- /dev/null +++ b/lana/dashboard/.sqlx/query-2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35.json @@ -0,0 +1,40 @@ +{ + "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", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "2f45d36f0e8877f3ed52708a8636ae0e4fb8ba12437c9003ccee2eaff8e25e35" +} diff --git a/lana/dashboard/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json b/lana/dashboard/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json new file mode 100644 index 000000000..95bebab0d --- /dev/null +++ b/lana/dashboard/.sqlx/query-3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_chart_of_accounts SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "3da903ccbfd0702095ea8643f7eff1402220d2a7c0a531619a4d1a0e9ea2537d" +} diff --git a/lana/app/.sqlx/query-02cdc8c50ee47fe180783166e55072897ad294a82bb20a5fa54649d0d6bf199c.json b/lana/dashboard/.sqlx/query-427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849.json similarity index 66% rename from lana/app/.sqlx/query-02cdc8c50ee47fe180783166e55072897ad294a82bb20a5fa54649d0d6bf199c.json rename to lana/dashboard/.sqlx/query-427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849.json index 3672d1460..52f020376 100644 --- a/lana/app/.sqlx/query-02cdc8c50ee47fe180783166e55072897ad294a82bb20a5fa54649d0d6bf199c.json +++ b/lana/dashboard/.sqlx/query-427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM deposits WHERE id = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE id = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "02cdc8c50ee47fe180783166e55072897ad294a82bb20a5fa54649d0d6bf199c" + "hash": "427eff7cb96e2e6229ff1126596883e4dcd306cadd5d96f3d91a50047b91a849" } diff --git a/lana/dashboard/.sqlx/query-43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759.json b/lana/dashboard/.sqlx/query-43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759.json new file mode 100644 index 000000000..e6340e31a --- /dev/null +++ b/lana/dashboard/.sqlx/query-43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT i.id AS \"id: DepositId\", e.sequence, e.event, e.recorded_at FROM core_deposits i JOIN core_deposit_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: DepositId", + "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "43a7816dc14d728deb7d179c5e862d5c510b70336c69e74e0a0ac6b8381a5759" +} diff --git a/lana/dashboard/.sqlx/query-4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9.json b/lana/dashboard/.sqlx/query-4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9.json new file mode 100644 index 000000000..dda5454fb --- /dev/null +++ b/lana/dashboard/.sqlx/query-4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE approval_process_id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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": "4695792a24d5b9b4f2784151b66c15412a584727eb684cd18123a4d2c00929e9" +} diff --git a/lana/app/.sqlx/query-3eacdc397a8b0a90d868e824a586b1234d3073c13d9870d34b57aeede3801db5.json b/lana/dashboard/.sqlx/query-47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19.json similarity index 60% rename from lana/app/.sqlx/query-3eacdc397a8b0a90d868e824a586b1234d3073c13d9870d34b57aeede3801db5.json rename to lana/dashboard/.sqlx/query-47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19.json index 559553240..bc225186e 100644 --- a/lana/app/.sqlx/query-3eacdc397a8b0a90d868e824a586b1234d3073c13d9870d34b57aeede3801db5.json +++ b/lana/dashboard/.sqlx/query-47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, id FROM deposits WHERE ((customer_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -38,5 +38,5 @@ false ] }, - "hash": "3eacdc397a8b0a90d868e824a586b1234d3073c13d9870d34b57aeede3801db5" + "hash": "47e131061ca46b535e7610767eb5e80026e67ee62235c9c5b2f91ea88f7fdb19" } diff --git a/lana/app/.sqlx/query-d021a20f3880ced5776b8591e7e0a5934602c504dd007b13166db1d61717c1a4.json b/lana/dashboard/.sqlx/query-4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4.json similarity index 57% rename from lana/app/.sqlx/query-d021a20f3880ced5776b8591e7e0a5934602c504dd007b13166db1d61717c1a4.json rename to lana/dashboard/.sqlx/query-4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4.json index 65bfcd9ea..44c08f4da 100644 --- a/lana/app/.sqlx/query-d021a20f3880ced5776b8591e7e0a5934602c504dd007b13166db1d61717c1a4.json +++ b/lana/dashboard/.sqlx/query-4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, created_at, id FROM withdrawals WHERE ((customer_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT deposit_account_id, created_at, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -39,5 +39,5 @@ false ] }, - "hash": "d021a20f3880ced5776b8591e7e0a5934602c504dd007b13166db1d61717c1a4" + "hash": "4ddaa20ede3df1a493c3a91136250b79c2a69f0ff5938d5e082b86346aeac6c4" } diff --git a/lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json b/lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json new file mode 100644 index 000000000..5f58f2f07 --- /dev/null +++ b/lana/dashboard/.sqlx/query-551f141faab899d8c375d65bbdb96c1d92d856d6d1f41765dbdaf2293e275d72.json @@ -0,0 +1,18 @@ +{ + "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-b1a1db7b6ffad05a27356811a3ed42d2f13101d9563fb5f64104d19b9e1d5de7.json b/lana/dashboard/.sqlx/query-56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296.json similarity index 57% rename from lana/app/.sqlx/query-b1a1db7b6ffad05a27356811a3ed42d2f13101d9563fb5f64104d19b9e1d5de7.json rename to lana/dashboard/.sqlx/query-56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296.json index 24940a585..71459709a 100644 --- a/lana/app/.sqlx/query-b1a1db7b6ffad05a27356811a3ed42d2f13101d9563fb5f64104d19b9e1d5de7.json +++ b/lana/dashboard/.sqlx/query-56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, created_at, id FROM deposits WHERE ((customer_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_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 deposit_account_id, created_at, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -39,5 +39,5 @@ false ] }, - "hash": "b1a1db7b6ffad05a27356811a3ed42d2f13101d9563fb5f64104d19b9e1d5de7" + "hash": "56a93a89179b42b6c18ccfbd9aa6012ca664f55cb601a19e0ced610e5b442296" } diff --git a/lana/dashboard/.sqlx/query-5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539.json b/lana/dashboard/.sqlx/query-5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539.json new file mode 100644 index 000000000..550be8e80 --- /dev/null +++ b/lana/dashboard/.sqlx/query-5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_withdrawal_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": "5cf7924a6417fd9d6a1fc4fc373aeac4e1c0e3953425a4e62acc8a8039cbe539" +} diff --git a/lana/dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json b/lana/dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json new file mode 100644 index 000000000..8ac8f7df0 --- /dev/null +++ b/lana/dashboard/.sqlx/query-5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1.json @@ -0,0 +1,40 @@ +{ + "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", + "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": [ + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "5e769147de76e5bd36547ff4abfb62ce0f8e709cfa6159bff54608ce5706f9e1" +} diff --git a/lana/dashboard/.sqlx/query-606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2.json b/lana/dashboard/.sqlx/query-606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2.json new file mode 100644 index 000000000..db1a9fc59 --- /dev/null +++ b/lana/dashboard/.sqlx/query-606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_withdrawals (id, deposit_account_id, approval_process_id, reference, created_at) VALUES ($1, $2, $3, $4, $5)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Varchar", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "606f56745ea686c3c98655f1ba29c892b469fe2e630d9824372ebb58c22314f2" +} diff --git a/lana/dashboard/.sqlx/query-6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657.json b/lana/dashboard/.sqlx/query-6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657.json new file mode 100644 index 000000000..08b2302b0 --- /dev/null +++ b/lana/dashboard/.sqlx/query-6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, created_at, id FROM core_deposits WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_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: DepositId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "6652182373e14925412ce85f358c64af3a98ec895e1747e2ce6a61221af8c657" +} diff --git a/lana/dashboard/.sqlx/query-66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65.json b/lana/dashboard/.sqlx/query-66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65.json new file mode 100644 index 000000000..b7dbe210c --- /dev/null +++ b/lana/dashboard/.sqlx/query-66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO deposit_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": "66660428ec43617b9017f0f4d08630c3934c48c74e14bd08fd81d70880c5ae65" +} diff --git a/lana/dashboard/.sqlx/query-697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab.json b/lana/dashboard/.sqlx/query-697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab.json new file mode 100644 index 000000000..c76e1cd1e --- /dev/null +++ b/lana/dashboard/.sqlx/query-697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_deposits (id, deposit_account_id, reference, created_at) VALUES ($1, $2, $3, $4)", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Varchar", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "697f26ecc715a804258dfb0112308539202abe4dd3af28d528bedcd09b551cab" +} diff --git a/lana/dashboard/.sqlx/query-6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f.json b/lana/dashboard/.sqlx/query-6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f.json new file mode 100644 index 000000000..947523020 --- /dev/null +++ b/lana/dashboard/.sqlx/query-6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "6f45f539edff97cdbcdf8ba879e33fd48abe353bbc92cb690d98dcf6f641750f" +} diff --git a/lana/dashboard/.sqlx/query-75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7.json b/lana/dashboard/.sqlx/query-75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7.json new file mode 100644 index 000000000..c050398ce --- /dev/null +++ b/lana/dashboard/.sqlx/query-75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE deposit_account_id = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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": "75052c2b453721eae52cfaf6e65c9b5067c492748febc14e8e2b40925422eea7" +} diff --git a/lana/dashboard/.sqlx/query-757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b.json b/lana/dashboard/.sqlx/query-757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b.json new file mode 100644 index 000000000..384262f22 --- /dev/null +++ b/lana/dashboard/.sqlx/query-757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_withdrawals 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: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_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: WithdrawalId", + "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": "757592f9832c8e1efb9b8dfb0f78868b00c3c0bdc73fe72a03bae7a807139c6b" +} diff --git a/lana/dashboard/.sqlx/query-769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c.json b/lana/dashboard/.sqlx/query-769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c.json new file mode 100644 index 000000000..b22a7fa7c --- /dev/null +++ b/lana/dashboard/.sqlx/query-769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM core_deposits 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: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_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: DepositId", + "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": "769e2b41629abb4c12e1b195dee654423c0b2415cae74021b701cc3ed1a6a72c" +} diff --git a/lana/dashboard/.sqlx/query-77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971.json b/lana/dashboard/.sqlx/query-77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971.json new file mode 100644 index 000000000..f9375e0c7 --- /dev/null +++ b/lana/dashboard/.sqlx/query-77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "77b298409650fb826ef92b5cbc7bc30091a70e30b6615cd1da20f5b2ada92971" +} diff --git a/lana/dashboard/.sqlx/query-80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129.json b/lana/dashboard/.sqlx/query-80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129.json new file mode 100644 index 000000000..c8aa136cc --- /dev/null +++ b/lana/dashboard/.sqlx/query-80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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": "80de7b594db20b2c5f17d3b803fb44ec8e0639c0f896b11baf340f2092677129" +} diff --git a/lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json b/lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json new file mode 100644 index 000000000..68cc67380 --- /dev/null +++ b/lana/dashboard/.sqlx/query-827868aae350955f8231c8fc3a90005f934c3d68a6033a9cec6b5667b362ec43.json @@ -0,0 +1,41 @@ +{ + "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 new file mode 100644 index 000000000..c2f814ec9 --- /dev/null +++ b/lana/dashboard/.sqlx/query-87a9c75884b5c802ba1380fa2b9c1b30ceb43374aaf8dfd45713fd6a30fbf14b.json @@ -0,0 +1,40 @@ +{ + "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-8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369.json b/lana/dashboard/.sqlx/query-8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369.json new file mode 100644 index 000000000..8c4ce1ff9 --- /dev/null +++ b/lana/dashboard/.sqlx/query-8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE id = $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "8ea5f8d69ed4ad9113e4908cf740743f30dfbe27e5432c6587968ea0c2b73369" +} diff --git a/lana/app/.sqlx/query-44ef66d2de29baa18a0a820240376d3eb9e06066d628baa9ed9514bd6f115bf8.json b/lana/dashboard/.sqlx/query-8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3.json similarity index 65% rename from lana/app/.sqlx/query-44ef66d2de29baa18a0a820240376d3eb9e06066d628baa9ed9514bd6f115bf8.json rename to lana/dashboard/.sqlx/query-8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3.json index 33f87b771..9179fa2eb 100644 --- a/lana/app/.sqlx/query-44ef66d2de29baa18a0a820240376d3eb9e06066d628baa9ed9514bd6f115bf8.json +++ b/lana/dashboard/.sqlx/query-8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM withdrawals WHERE reference = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE reference = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "44ef66d2de29baa18a0a820240376d3eb9e06066d628baa9ed9514bd6f115bf8" + "hash": "8f1fda3b0a2a441736e6a2a540cee908b0c2e2db176cdc639192d4e887ebd4a3" } diff --git a/lana/dashboard/.sqlx/query-907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4.json b/lana/dashboard/.sqlx/query-907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4.json new file mode 100644 index 000000000..cac5c07aa --- /dev/null +++ b/lana/dashboard/.sqlx/query-907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE deposit_account_id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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": "907e360e9cf644967b883943c7975388153d6f0cb0f91e4da0741427b00deea4" +} diff --git a/lana/app/.sqlx/query-5b3aff9b38a860659e1353d04237754d0031588358085a6841ff0ee518b8a9b3.json b/lana/dashboard/.sqlx/query-91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e.json similarity index 59% rename from lana/app/.sqlx/query-5b3aff9b38a860659e1353d04237754d0031588358085a6841ff0ee518b8a9b3.json rename to lana/dashboard/.sqlx/query-91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e.json index 88db2a8b4..2643d87f1 100644 --- a/lana/app/.sqlx/query-5b3aff9b38a860659e1353d04237754d0031588358085a6841ff0ee518b8a9b3.json +++ b/lana/dashboard/.sqlx/query-91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT created_at, id FROM withdrawals 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: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_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_withdrawals 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: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -38,5 +38,5 @@ false ] }, - "hash": "5b3aff9b38a860659e1353d04237754d0031588358085a6841ff0ee518b8a9b3" + "hash": "91debda9c1f7653b7bcb38a311d0f665f05d8fb39a8f371b9bbdcd4d35b2280e" } diff --git a/lana/dashboard/.sqlx/query-a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0.json b/lana/dashboard/.sqlx/query-a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0.json new file mode 100644 index 000000000..6380b4539 --- /dev/null +++ b/lana/dashboard/.sqlx/query-a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT deposit_account_id, created_at, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_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: WithdrawalId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "a27bea0d43b3ea7c807ef1a668378640d5eac3049bd61d937bd657b24601a3f0" +} diff --git a/lana/dashboard/.sqlx/query-a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f.json b/lana/dashboard/.sqlx/query-a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f.json new file mode 100644 index 000000000..1d0a9782b --- /dev/null +++ b/lana/dashboard/.sqlx/query-a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_withdrawals SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "a6fae2f669eeb47bb3bf3f098bea0f41f5b7c3475ca4794739e41332a36d106f" +} diff --git a/lana/dashboard/.sqlx/query-bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c.json b/lana/dashboard/.sqlx/query-bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c.json new file mode 100644 index 000000000..0e7e5da20 --- /dev/null +++ b/lana/dashboard/.sqlx/query-bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_withdrawal_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": "bd95c4f0035427d576ce6870ff35c376cab226ee9072da6069e0a119ef75fc2c" +} diff --git a/lana/dashboard/.sqlx/query-be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32.json b/lana/dashboard/.sqlx/query-be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32.json new file mode 100644 index 000000000..5122b8a19 --- /dev/null +++ b/lana/dashboard/.sqlx/query-be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE core_deposits SET reference = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "be503ebd92a55095d55f425717738f6931baa191d2469f30a09b76acab2bbe32" +} diff --git a/lana/app/.sqlx/query-bf8f19f41664b0fde5c10a323c4a1bc80b783fea1ae6354707c5a2d405d21e6e.json b/lana/dashboard/.sqlx/query-c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36.json similarity index 63% rename from lana/app/.sqlx/query-bf8f19f41664b0fde5c10a323c4a1bc80b783fea1ae6354707c5a2d405d21e6e.json rename to lana/dashboard/.sqlx/query-c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36.json index f3ba172d7..6ea7cf34e 100644 --- a/lana/app/.sqlx/query-bf8f19f41664b0fde5c10a323c4a1bc80b783fea1ae6354707c5a2d405d21e6e.json +++ b/lana/dashboard/.sqlx/query-c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM deposits WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -37,5 +37,5 @@ false ] }, - "hash": "bf8f19f41664b0fde5c10a323c4a1bc80b783fea1ae6354707c5a2d405d21e6e" + "hash": "c231caf2cdfc7a61e91f230ee1a02672d8159fb2bff2aa35be28a5193febea36" } diff --git a/lana/app/.sqlx/query-0fd80b693e2d7c1bd22f0ea9c054ce5dba08225f18368ded6a60c304c8852222.json b/lana/dashboard/.sqlx/query-cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585.json similarity index 62% rename from lana/app/.sqlx/query-0fd80b693e2d7c1bd22f0ea9c054ce5dba08225f18368ded6a60c304c8852222.json rename to lana/dashboard/.sqlx/query-cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585.json index cc09d48c5..d0b957116 100644 --- a/lana/app/.sqlx/query-0fd80b693e2d7c1bd22f0ea9c054ce5dba08225f18368ded6a60c304c8852222.json +++ b/lana/dashboard/.sqlx/query-cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM withdrawals WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -37,5 +37,5 @@ false ] }, - "hash": "0fd80b693e2d7c1bd22f0ea9c054ce5dba08225f18368ded6a60c304c8852222" + "hash": "cc6402da73a5a1ab26212376f75dd1227bc43f97be6382fa23fe08f9a1d5a585" } diff --git a/lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json b/lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json new file mode 100644 index 000000000..65ba29133 --- /dev/null +++ b/lana/dashboard/.sqlx/query-cd486dafd04d97f195181ebd61b51c9e6a2f42cbdbbd67ed4fdcadefc824ed42.json @@ -0,0 +1,42 @@ +{ + "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-cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19.json b/lana/dashboard/.sqlx/query-cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19.json new file mode 100644 index 000000000..c7b6647b4 --- /dev/null +++ b/lana/dashboard/.sqlx/query-cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT i.id AS \"id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM deposit_accounts i JOIN deposit_account_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: DepositAccountId", + "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "cfde9407b814888676bae2c43c29791052da1117559c851b9c003fe2c4483c19" +} diff --git a/lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json b/lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json new file mode 100644 index 000000000..369e3792b --- /dev/null +++ b/lana/dashboard/.sqlx/query-d08a091af5e49d01bb5686222446682001d1570b138fa4bbc9322d13dd3a8f12.json @@ -0,0 +1,41 @@ +{ + "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-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json b/lana/dashboard/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json new file mode 100644 index 000000000..303e96373 --- /dev/null +++ b/lana/dashboard/.sqlx/query-d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, created_at, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_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: DepositAccountId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "d17a8eecb086b7593ee3e83c3a3576dcdcabb95d9c559c34d62547e3d36ac2fa" +} diff --git a/lana/app/.sqlx/query-184beadf19357a98ce6b0372517f063ee81cbb843f0e776c74ea525628cc9a24.json b/lana/dashboard/.sqlx/query-d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f.json similarity index 60% rename from lana/app/.sqlx/query-184beadf19357a98ce6b0372517f063ee81cbb843f0e776c74ea525628cc9a24.json rename to lana/dashboard/.sqlx/query-d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f.json index 8fb7cef2f..cc7d2c567 100644 --- a/lana/app/.sqlx/query-184beadf19357a98ce6b0372517f063ee81cbb843f0e776c74ea525628cc9a24.json +++ b/lana/dashboard/.sqlx/query-d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT customer_id, id FROM withdrawals WHERE ((customer_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "query": "WITH entities AS (SELECT deposit_account_id, id FROM core_withdrawals WHERE ((deposit_account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", "describe": { "columns": [ { @@ -38,5 +38,5 @@ false ] }, - "hash": "184beadf19357a98ce6b0372517f063ee81cbb843f0e776c74ea525628cc9a24" + "hash": "d316bf8d73764c5b013048816f51df5eef2f87e6f57403e9cf8ad809d8c6de5f" } diff --git a/lana/dashboard/.sqlx/query-d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1.json b/lana/dashboard/.sqlx/query-d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1.json new file mode 100644 index 000000000..c6454531d --- /dev/null +++ b/lana/dashboard/.sqlx/query-d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO deposit_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": "d904610a418a5ac37f82313e0a1cfbc2697554a02545749dbf398705bee034f1" +} diff --git a/lana/app/.sqlx/query-f00dd78231df95c51682946d788e20cf0b6cb3beca375efc772bdc5dbc36afa9.json b/lana/dashboard/.sqlx/query-dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42.json similarity index 65% rename from lana/app/.sqlx/query-f00dd78231df95c51682946d788e20cf0b6cb3beca375efc772bdc5dbc36afa9.json rename to lana/dashboard/.sqlx/query-dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42.json index a2be9620c..9723add52 100644 --- a/lana/app/.sqlx/query-f00dd78231df95c51682946d788e20cf0b6cb3beca375efc772bdc5dbc36afa9.json +++ b/lana/dashboard/.sqlx/query-dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH entities AS (SELECT id FROM withdrawals WHERE customer_id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE id = $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { @@ -36,5 +36,5 @@ false ] }, - "hash": "f00dd78231df95c51682946d788e20cf0b6cb3beca375efc772bdc5dbc36afa9" + "hash": "dbe4ece20e9ec7b11016522a24e613008b81814b9c099b1fa62f3885debeae42" } diff --git a/lana/dashboard/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json b/lana/dashboard/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json new file mode 100644 index 000000000..43c37d3f7 --- /dev/null +++ b/lana/dashboard/.sqlx/query-df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM deposit_accounts WHERE account_holder_id = $1) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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": "df0eb4298a26ac09dca4d645e42de3db5fbd5b24ad2c99a6bb4183c5c6f86d43" +} diff --git a/lana/dashboard/.sqlx/query-e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f.json b/lana/dashboard/.sqlx/query-e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f.json new file mode 100644 index 000000000..480c04811 --- /dev/null +++ b/lana/dashboard/.sqlx/query-e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO core_deposit_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": "e30cab1a790ff1dfce307ae2f174d551f322a1d72fd2cf639685a1a2cf4cbd3f" +} diff --git a/lana/dashboard/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json b/lana/dashboard/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json new file mode 100644 index 000000000..148827bb6 --- /dev/null +++ b/lana/dashboard/.sqlx/query-e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af.json @@ -0,0 +1,42 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositAccountId", + "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", + "Int8", + "Uuid" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "e99ee286fc20a1957a2bcff1c70808d7bc6b8ae881c6d445bec38d79a6a032af" +} diff --git a/lana/dashboard/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json b/lana/dashboard/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json new file mode 100644 index 000000000..ed8d2f097 --- /dev/null +++ b/lana/dashboard/.sqlx/query-f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126.json @@ -0,0 +1,43 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_holder_id, created_at, id FROM deposit_accounts WHERE ((account_holder_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: DepositAccountId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN deposit_account_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: DepositAccountId", + "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", + "Int8", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "f4215515cb8b8e4823a28867e118e7dc5877a809396cc1687fb287654dfbc126" +} diff --git a/lana/dashboard/.sqlx/query-f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb.json b/lana/dashboard/.sqlx/query-f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb.json new file mode 100644 index 000000000..6c590f49e --- /dev/null +++ b/lana/dashboard/.sqlx/query-f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_deposits WHERE reference = $1) SELECT i.id AS \"entity_id: DepositId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_deposit_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: DepositId", + "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": "f7769c30ea3f8b0a4f96a3a033c9f28a94eaba9cccca0d51f6d19fe435967dbb" +} diff --git a/lana/dashboard/.sqlx/query-f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3.json b/lana/dashboard/.sqlx/query-f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3.json new file mode 100644 index 000000000..2560d1d99 --- /dev/null +++ b/lana/dashboard/.sqlx/query-f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3.json @@ -0,0 +1,41 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM core_withdrawals WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM entities i JOIN core_withdrawal_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: WithdrawalId", + "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": "f7bac8b748ff6e5b70952d2ff5efe97a704b71707bcc506db2feb941b5e314f3" +} diff --git a/lana/dashboard/.sqlx/query-f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc.json b/lana/dashboard/.sqlx/query-f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc.json new file mode 100644 index 000000000..caaf2edb7 --- /dev/null +++ b/lana/dashboard/.sqlx/query-f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc.json @@ -0,0 +1,40 @@ +{ + "db_name": "PostgreSQL", + "query": "SELECT i.id AS \"id: WithdrawalId\", e.sequence, e.event, e.recorded_at FROM core_withdrawals i JOIN core_withdrawal_events e ON i.id = e.id WHERE i.id = ANY($1) ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id: WithdrawalId", + "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": [ + "UuidArray" + ] + }, + "nullable": [ + false, + false, + false, + false + ] + }, + "hash": "f8bc7e13180dafd658190520f81f6cbce2cb9976ede2b5d1c2065f2cc47d27dc" +}