-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: change ChartOfAccounts gql query to new implementation
- Loading branch information
Showing
14 changed files
with
212 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
use async_graphql::*; | ||
|
||
use lana_app::chart_of_accounts::chart::*; | ||
|
||
#[derive(SimpleObject)] | ||
pub struct ChartOfAccounts { | ||
name: String, | ||
categories: ChartCategories, | ||
} | ||
|
||
impl From<ChartOfAccountsProjection> for ChartOfAccounts { | ||
fn from(projection: ChartOfAccountsProjection) -> Self { | ||
ChartOfAccounts { | ||
name: projection.name, | ||
categories: ChartCategories { | ||
assets: ChartCategory { | ||
name: projection.assets.name, | ||
account_code: projection.assets.encoded_path, | ||
control_accounts: projection | ||
.assets | ||
.children | ||
.into_iter() | ||
.map(ChartControlAccount::from) | ||
.collect(), | ||
}, | ||
liabilities: ChartCategory { | ||
name: projection.liabilities.name, | ||
account_code: projection.liabilities.encoded_path, | ||
control_accounts: projection | ||
.liabilities | ||
.children | ||
.into_iter() | ||
.map(ChartControlAccount::from) | ||
.collect(), | ||
}, | ||
equity: ChartCategory { | ||
name: projection.equity.name, | ||
account_code: projection.equity.encoded_path, | ||
control_accounts: projection | ||
.equity | ||
.children | ||
.into_iter() | ||
.map(ChartControlAccount::from) | ||
.collect(), | ||
}, | ||
revenues: ChartCategory { | ||
name: projection.revenues.name, | ||
account_code: projection.revenues.encoded_path, | ||
control_accounts: projection | ||
.revenues | ||
.children | ||
.into_iter() | ||
.map(ChartControlAccount::from) | ||
.collect(), | ||
}, | ||
expenses: ChartCategory { | ||
name: projection.expenses.name, | ||
account_code: projection.expenses.encoded_path, | ||
control_accounts: projection | ||
.expenses | ||
.children | ||
.into_iter() | ||
.map(ChartControlAccount::from) | ||
.collect(), | ||
}, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
#[derive(SimpleObject)] | ||
pub struct ChartCategories { | ||
assets: ChartCategory, | ||
liabilities: ChartCategory, | ||
equity: ChartCategory, | ||
revenues: ChartCategory, | ||
expenses: ChartCategory, | ||
} | ||
|
||
#[derive(SimpleObject)] | ||
pub struct ChartCategory { | ||
name: String, | ||
account_code: String, | ||
control_accounts: Vec<ChartControlAccount>, | ||
} | ||
|
||
#[derive(SimpleObject)] | ||
pub struct ChartControlAccount { | ||
name: String, | ||
account_code: String, | ||
control_sub_accounts: Vec<ChartControlSubAccount>, | ||
} | ||
|
||
impl From<ControlAccountProjection> for ChartControlAccount { | ||
fn from(projection: ControlAccountProjection) -> Self { | ||
ChartControlAccount { | ||
name: projection.name, | ||
account_code: projection.encoded_path, | ||
control_sub_accounts: projection | ||
.children | ||
.into_iter() | ||
.map(ChartControlSubAccount::from) | ||
.collect(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(SimpleObject)] | ||
pub struct ChartControlSubAccount { | ||
name: String, | ||
account_code: String, | ||
} | ||
|
||
impl From<ControlSubAccountProjection> for ChartControlSubAccount { | ||
fn from(projection: ControlSubAccountProjection) -> Self { | ||
ChartControlSubAccount { | ||
name: projection.name, | ||
account_code: projection.encoded_path, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
mod account_set; | ||
mod balance_sheet; | ||
mod cash_flow; | ||
mod chart_of_accounts; | ||
mod category; | ||
mod profit_and_loss; | ||
mod shareholder_equity; | ||
mod trial_balance; | ||
|
||
pub use account_set::*; | ||
pub use balance_sheet::*; | ||
pub use cash_flow::*; | ||
pub use chart_of_accounts::*; | ||
pub use profit_and_loss::*; | ||
pub use shareholder_equity::*; | ||
pub use trial_balance::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mod constants; | ||
pub mod constants; | ||
mod primitives; | ||
mod seed; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.