diff --git a/src/reporting/builders.rs b/src/reporting/builders.rs index 54717ae..a8f0027 100644 --- a/src/reporting/builders.rs +++ b/src/reporting/builders.rs @@ -16,6 +16,10 @@ along with this program. If not, see . */ +//! This module contains implementations of dynamic step builders +//! +//! See [ReportingContext::register_dynamic_builder][super::types::ReportingContext::register_dynamic_builder]. + use std::collections::HashMap; use std::fmt::Display; @@ -39,13 +43,13 @@ pub fn register_dynamic_builders(context: &mut ReportingContext) { BalancesAtToBalancesBetween::register_dynamic_builder(context); } +/// This dynamic builder automatically generates a [BalancesBetween] by subtracting [BalancesAt] between two dates #[derive(Debug)] pub struct BalancesAtToBalancesBetween { step_name: &'static str, args: DateStartDateEndArgs, } -/// This dynamic builder automatically generates a [BalancesBetween] by subtracting [BalancesAt] between two dates impl BalancesAtToBalancesBetween { // Implements BalancesAt, BalancesAt -> BalancesBetween @@ -205,7 +209,7 @@ impl ReportingStep for BalancesAtToBalancesBetween { } } -/// This dynamic builder automatically generates a [BalancesAt] from a step which has no dependencies and generates [Transactions] (e.g. [super::steps::PostUnreconciledStatementLines]) +/// This dynamic builder automatically generates a [BalancesAt] from a step which has no dependencies and generates [Transactions] (e.g. [PostUnreconciledStatementLines][super::steps::PostUnreconciledStatementLines]) #[derive(Debug)] pub struct GenerateBalances { step_name: &'static str, diff --git a/src/reporting/calculator.rs b/src/reporting/calculator.rs index 862df18..0c70a98 100644 --- a/src/reporting/calculator.rs +++ b/src/reporting/calculator.rs @@ -23,7 +23,7 @@ use super::types::{ ReportingStepFromArgsFn, ReportingStepId, }; -/// List of dependencies between [ReportingStep]s and [ReportingProduct]s +/// List of dependencies between [ReportingStep]s and [ReportingProduct][super::types::ReportingProduct]s #[derive(Debug)] pub struct ReportingGraphDependencies { vec: Vec, @@ -35,7 +35,7 @@ impl ReportingGraphDependencies { &self.vec } - /// Record that the [ReportingStep] depends on the [ReportingProduct] + /// Record that the [ReportingStep] depends on the [ReportingProduct][super::types::ReportingProduct] pub fn add_dependency(&mut self, step: ReportingStepId, product: ReportingProductId) { if !self .vec @@ -52,7 +52,7 @@ impl ReportingGraphDependencies { } } -/// Represents that a [ReportingStep] depends on a [ReportingProduct] +/// Represents that a [ReportingStep] depends on a [ReportingProduct][super::types::ReportingProduct] #[derive(Debug)] pub struct Dependency { pub step: ReportingStepId, @@ -74,7 +74,7 @@ pub enum HasStepOrCanBuild<'a, 'b> { None, } -/// Determines whether the [ReportingProduct] is generated by a known step, or can be generated by a lookup function or dynamic builder +/// Determines whether the [ReportingProduct][super::types::ReportingProduct] is generated by a known step, or can be generated by a lookup function or dynamic builder pub fn has_step_or_can_build<'a, 'b>( product: &ReportingProductId, steps: &'a Vec>, diff --git a/src/reporting/steps.rs b/src/reporting/steps.rs index ed87930..4d0d5f4 100644 --- a/src/reporting/steps.rs +++ b/src/reporting/steps.rs @@ -45,6 +45,11 @@ pub fn register_lookup_fns(context: &mut ReportingContext) { RetainedEarningsToEquity::register_lookup_fn(context); } +/// Target representing all transactions except charging retained earnings to equity +/// +/// By default, this is [CombineOrdinaryTransactions] and, if requested, [CalculateIncomeTax]. +/// +/// Used as the basis for the income statement. #[derive(Debug)] pub struct AllTransactionsExceptRetainedEarnings { pub product_kinds: &'static [ReportingProductKind], // Must have single member @@ -157,6 +162,11 @@ impl ReportingStep for AllTransactionsExceptRetainedEarnings { } } +/// Target representing all transactions including charging retained earnings to equity +/// +/// In other words, this is [AllTransactionsExceptRetainedEarnings] and [RetainedEarningsToEquity]. +/// +/// Used as the basis for the balance sheet. #[derive(Debug)] pub struct AllTransactionsIncludingRetainedEarnings { pub args: DateArgs, @@ -262,6 +272,7 @@ impl ReportingStep for AllTransactionsIncludingRetainedEarnings { } } +/// Calculates income tax #[derive(Debug)] pub struct CalculateIncomeTax {} @@ -358,6 +369,9 @@ impl ReportingStep for CalculateIncomeTax { } } +/// Combines all steps producing ordinary transactions +/// +/// By default, these are [DBBalances] and [PostUnreconciledStatementLines] #[derive(Debug)] pub struct CombineOrdinaryTransactions { pub args: DateArgs, @@ -455,6 +469,7 @@ impl ReportingStep for CombineOrdinaryTransactions { } } +/// Look up account balances from the database #[derive(Debug)] pub struct DBBalances { pub args: DateArgs, @@ -522,6 +537,7 @@ impl ReportingStep for DBBalances { } } +/// Generate transactions for unreconciled statement lines #[derive(Debug)] pub struct PostUnreconciledStatementLines { pub args: DateArgs, @@ -589,6 +605,7 @@ impl ReportingStep for PostUnreconciledStatementLines { } } +/// Transfer historical balances in income and expense accounts to the retained earnings equity account #[derive(Debug)] pub struct RetainedEarningsToEquity { pub args: DateArgs, diff --git a/src/util.rs b/src/util.rs index c8129c4..73bd8f9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -18,7 +18,7 @@ use chrono::{Datelike, NaiveDate}; +/// Return the start date of the financial year, given the end date of the financial year pub fn sofy_from_eofy(date_eofy: NaiveDate) -> NaiveDate { - // Return the start date of the financial year, given the end date of the financial year return date_eofy.with_year(date_eofy.year() - 1).unwrap().succ_opt().unwrap(); }