Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add first statement #1289

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2aa5ad7
refactor: expand seed into module
vindard Jan 20, 2025
9b9cf2a
feat: add account_set_id when creating control accounts
vindard Jan 20, 2025
add56db
chore: setup core/statements module boilerplate
vindard Jan 21, 2025
5edd8e3
chore: add statements entity boilerplate
vindard Jan 21, 2025
6168432
refactor: change statement entity to trial_balance_statement
vindard Jan 21, 2025
980ac0b
refactor: use statement entity id as account set id
vindard Jan 21, 2025
fdfc2c4
feat: add trial balance ledger boilerplate
vindard Jan 21, 2025
3881aeb
refactor: expand accounting_init constants into module
vindard Jan 21, 2025
ade2958
chore: add Statements to accounting_init
vindard Jan 21, 2025
8d81449
feat: add 'create_trial_balance_statement' use-case
vindard Jan 21, 2025
8bb9af1
chore: add statement actions to rbac
vindard Jan 22, 2025
4a8bfd5
chore: add 'find_by_reference' function
vindard Jan 22, 2025
97bc301
feat: create trial balance statements in accounting_init
vindard Jan 22, 2025
845139b
feat: add created control-sub-accounts to trial balance
vindard Jan 22, 2025
45220bf
chore: update cala
vindard Jan 22, 2025
ee38b6b
chore: replicate core TrialBalances module in lana app
vindard Jan 22, 2025
e8800a1
refactor: swap core/statements for lana/trial_balances in seed
vindard Jan 22, 2025
6bc7b8d
chore: remove unused core/statements module
vindard Jan 22, 2025
8466545
feat: add trial_balance query function with balances
vindard Jan 22, 2025
42fa6bc
refactor: change trial balance query param to name
vindard Jan 23, 2025
aeac5eb
refactor: remove currency argument, fetch both usd & btc currencies
vindard Jan 24, 2025
fcbf192
refactor: use Satoshi/UsdCent types in trial_balance ledger
vindard Jan 24, 2025
6a01d0e
chore: implement new trial_balance gql query
vindard Jan 24, 2025
03e3aa4
chore: clean up lints
vindard Jan 24, 2025
94248c6
chore: add TrialBalance auth for bank manager
vindard Jan 24, 2025
ba78b62
fix: handle no balance found error
vindard Jan 24, 2025
3c70c57
chore: add control_sub_account to control account cala account set
vindard Jan 24, 2025
fc354c9
chore: re-add off-trial-balance implementation
vindard Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 49 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,64 @@ cala-ledger = { git = "https://github.com/galoymoney/cala.git", branch = "main"
# cala-types = "0.3.1"

anyhow = "1.0.95"
async-graphql = { version = "7.0.11", default-features = false, features = ["dataloader", "tracing", "chrono", "playground"] }
async-graphql = { version = "7.0.11", default-features = false, features = [
"dataloader",
"tracing",
"chrono",
"playground",
] }
async-graphql-axum = "7.0.9"
async-trait = "0.1.80"
axum = { version = "0.7.9", features = ["macros"] }
axum-extra = { version = "0.9.6", default-features = false, features = ["tracing", "typed-header"] }
chrono = { version = "0.4.31", features = ["clock", "serde"], default-features = false }
axum-extra = { version = "0.9.6", default-features = false, features = [
"tracing",
"typed-header",
] }
chrono = { version = "0.4.31", features = [
"clock",
"serde",
], default-features = false }
clap = { version = "4.5", features = ["derive", "env"] }
derive_builder = "0.20.0"
graphql_client = {version = "0.14.0", features = ["reqwest-rustls"]}
sqlx = { version = "0.8.2", features = [ "runtime-tokio-rustls", "postgres", "rust_decimal", "uuid", "chrono", "json" ] }
graphql_client = { version = "0.14.0", features = ["reqwest-rustls"] }
sqlx = { version = "0.8.2", features = [
"runtime-tokio-rustls",
"postgres",
"rust_decimal",
"uuid",
"chrono",
"json",
] }
thiserror = "1.0.69"
uuid = { version = "1.11", features = ["serde", "v4"] }
tracing = "0.1.40"
tracing-opentelemetry = "0.25.0"
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] }
opentelemetry = { version = "0.24.0" }
opentelemetry_sdk = { version = "0.24.1", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.17.0", features = ["http-proto", "reqwest-client"] }
opentelemetry-otlp = { version = "0.17.0", features = [
"http-proto",
"reqwest-client",
] }
opentelemetry-http = "0.13"
opentelemetry-semantic-conventions = "0.16.0"
tokio = { version = "1.43", features = ["rt-multi-thread", "macros", "time", "sync"] }
tokio = { version = "1.43", features = [
"rt-multi-thread",
"macros",
"time",
"sync",
] }
tokio-stream = { version = "0.1.16", features = ["sync"] }
strum = { version = "0.26", features = ["derive"] }
serde = { version = "1.0.214", features = ["derive"] }
serde_yaml = "0.9.32"
serde_json = "1.0.133"
serde_with = "3.8.1"
futures = "0.3.29"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
reqwest = { version = "0.12", default-features = false, features = [
"json",
"rustls-tls",
] }
rust_decimal_macros = "1.34.2"
rust_decimal = "1.35.0"
rusty-money = { version = "0.4", features = ["iso", "crypto"] }
Expand All @@ -71,12 +100,21 @@ hex = "0.4.3"
hmac = "0.12.1"
sha2 = "0.10.8"
tower-http = { version = "0.5.2", features = ["cors"] }
sqlx-adapter = { version = "1.6.0", default-features = false, features = ["postgres", "runtime-tokio-rustls"]}
sqlx-adapter = { version = "1.6.0", default-features = false, features = [
"postgres",
"runtime-tokio-rustls",
] }
ory-kratos-client = "1.1.0"
cached = { version = "0.53.1", features = ["async"] }
gcp_auth = { version = "0.12.2", features = ["webpki-roots"] }
gcp-bigquery-client = { git = "https://github.com/bodymindarts/gcp-bigquery-client.git", branch = "feat--webpki", features = ["rust-tls"] }
cloud-storage = { version = "0.11.1",default-features = false, features = ["rustls-tls", "sync", "global-client"] }
gcp-bigquery-client = { git = "https://github.com/bodymindarts/gcp-bigquery-client.git", branch = "feat--webpki", features = [
"rust-tls",
] }
cloud-storage = { version = "0.11.1", default-features = false, features = [
"rustls-tls",
"sync",
"global-client",
] }
rand = "0.8"

[profile.release]
Expand Down
46 changes: 34 additions & 12 deletions core/chart-of-accounts/src/chart_of_accounts/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use es_entity::*;
use crate::{
path::*,
primitives::{ChartId, LedgerAccountSetId},
ControlSubAccountDetails,
ControlAccountDetails, ControlSubAccountDetails,
};

pub use super::error::*;
Expand All @@ -25,6 +25,7 @@ pub enum ChartEvent {
audit_info: AuditInfo,
},
ControlAccountAdded {
id: LedgerAccountSetId,
encoded_path: String,
path: ControlAccountPath,
name: String,
Expand Down Expand Up @@ -85,11 +86,12 @@ impl Chart {

pub fn create_control_account(
&mut self,
id: LedgerAccountSetId,
category: ChartCategory,
name: String,
reference: String,
audit_info: AuditInfo,
) -> Result<ControlAccountPath, ChartError> {
) -> Result<ControlAccountDetails, ChartError> {
if self
.find_control_account_by_reference(reference.to_string())
.is_some()
Expand All @@ -99,14 +101,20 @@ impl Chart {

let path = self.next_control_account(category)?;
self.events.push(ChartEvent::ControlAccountAdded {
id,
encoded_path: path.path_encode(self.id),
path,
name,
reference,
name: name.to_string(),
reference: reference.to_string(),
audit_info,
});

Ok(path)
Ok(ControlAccountDetails {
path,
account_set_id: id,
name,
reference,
})
}

fn next_control_sub_account(
Expand Down Expand Up @@ -283,8 +291,12 @@ mod tests {
#[test]
fn test_create_control_account() {
let mut chart = init_chart_of_events();
let ControlAccountPath { category, index } = chart
let ControlAccountDetails {
path: ControlAccountPath { category, index },
..
} = chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
Expand All @@ -300,6 +312,7 @@ mod tests {
let mut chart = init_chart_of_events();
chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Assets #1".to_string(),
"assets".to_string(),
Expand All @@ -308,6 +321,7 @@ mod tests {
.unwrap();

match chart.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Assets #2".to_string(),
"assets".to_string(),
Expand All @@ -327,6 +341,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
Expand All @@ -345,7 +360,7 @@ mod tests {
} = chart
.create_control_sub_account(
LedgerAccountSetId::new(),
control_account,
control_account.path,
"Current Assets".to_string(),
"current-assets".to_string(),
dummy_audit_info(),
Expand All @@ -361,6 +376,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
Expand All @@ -370,7 +386,7 @@ mod tests {
chart
.create_control_sub_account(
LedgerAccountSetId::new(),
control_account,
control_account.path,
"Current Assets #1".to_string(),
"current-assets".to_string(),
dummy_audit_info(),
Expand All @@ -379,7 +395,7 @@ mod tests {

match chart.create_control_sub_account(
LedgerAccountSetId::new(),
control_account,
control_account.path,
"Current Assets #2".to_string(),
"current-assets".to_string(),
dummy_audit_info(),
Expand All @@ -402,15 +418,20 @@ mod tests {

chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"First".to_string(),
"assets-01".to_string(),
dummy_audit_info(),
)
.unwrap();

let ControlAccountPath { category, index } = chart
let ControlAccountDetails {
path: ControlAccountPath { category, index },
..
} = chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Second".to_string(),
"assets-02".to_string(),
Expand All @@ -426,6 +447,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
LedgerAccountSetId::new(),
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
Expand All @@ -436,7 +458,7 @@ mod tests {
chart
.create_control_sub_account(
LedgerAccountSetId::new(),
control_account,
control_account.path,
"First".to_string(),
"first-asset".to_string(),
dummy_audit_info(),
Expand All @@ -454,7 +476,7 @@ mod tests {
} = chart
.create_control_sub_account(
LedgerAccountSetId::new(),
control_account,
control_account.path,
"Second".to_string(),
"second-asset".to_string(),
dummy_audit_info(),
Expand Down
Loading
Loading