diff --git a/libdrcr/src/main.rs b/libdrcr/src/main.rs index 79acabb..fa25ff3 100644 --- a/libdrcr/src/main.rs +++ b/libdrcr/src/main.rs @@ -65,7 +65,7 @@ async fn main() { // }, ReportingProductId { name: "BalanceSheet", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(MultipleDateArgs { dates: vec![DateArgs { date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), @@ -74,7 +74,7 @@ async fn main() { }, ReportingProductId { name: "IncomeStatement", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(MultipleDateStartDateEndArgs { dates: vec![DateStartDateEndArgs { date_start: NaiveDate::from_ymd_opt(YEAR - 1, 7, 1).unwrap(), @@ -133,7 +133,7 @@ async fn main() { }, ReportingProductId { name: "BalanceSheet", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(MultipleDateArgs { dates: vec![DateArgs { date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), @@ -148,7 +148,7 @@ async fn main() { let result = products .get_or_err(&ReportingProductId { name: "BalanceSheet", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(MultipleDateArgs { dates: vec![DateArgs { date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), @@ -173,7 +173,7 @@ async fn main() { }, ReportingProductId { name: "TrialBalance", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(DateArgs { date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), }), @@ -186,7 +186,7 @@ async fn main() { let result = products .get_or_err(&ReportingProductId { name: "TrialBalance", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(DateArgs { date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), }), diff --git a/libdrcr/src/reporting/steps.rs b/libdrcr/src/reporting/steps.rs index 37a9b86..2c4d9c5 100644 --- a/libdrcr/src/reporting/steps.rs +++ b/libdrcr/src/reporting/steps.rs @@ -384,7 +384,7 @@ impl BalanceSheet { fn register_lookup_fn(context: &mut ReportingContext) { context.register_lookup_fn( "BalanceSheet", - &[ReportingProductKind::Generic], + &[ReportingProductKind::DynamicReport], Self::takes_args, Self::from_args, ); @@ -412,7 +412,7 @@ impl ReportingStep for BalanceSheet { fn id(&self) -> ReportingStepId { ReportingStepId { name: "BalanceSheet", - product_kinds: &[ReportingProductKind::Generic], + product_kinds: &[ReportingProductKind::DynamicReport], args: Box::new(self.args.clone()), } } @@ -550,7 +550,7 @@ impl ReportingStep for BalanceSheet { result.insert( ReportingProductId { name: "BalanceSheet", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(self.args.clone()), }, Box::new(report), @@ -1120,7 +1120,7 @@ impl IncomeStatement { fn register_lookup_fn(context: &mut ReportingContext) { context.register_lookup_fn( "IncomeStatement", - &[ReportingProductKind::Generic], + &[ReportingProductKind::DynamicReport], Self::takes_args, Self::from_args, ); @@ -1148,7 +1148,7 @@ impl ReportingStep for IncomeStatement { fn id(&self) -> ReportingStepId { ReportingStepId { name: "IncomeStatement", - product_kinds: &[ReportingProductKind::Generic], + product_kinds: &[ReportingProductKind::DynamicReport], args: Box::new(self.args.clone()), } } @@ -1282,7 +1282,7 @@ impl ReportingStep for IncomeStatement { result.insert( ReportingProductId { name: "IncomeStatement", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(self.args.clone()), }, Box::new(report), @@ -1546,7 +1546,7 @@ impl TrialBalance { fn register_lookup_fn(context: &mut ReportingContext) { context.register_lookup_fn( "TrialBalance", - &[ReportingProductKind::Generic], + &[ReportingProductKind::DynamicReport], Self::takes_args, Self::from_args, ); @@ -1574,7 +1574,7 @@ impl ReportingStep for TrialBalance { fn id(&self) -> ReportingStepId { ReportingStepId { name: "TrialBalance", - product_kinds: &[ReportingProductKind::Generic], + product_kinds: &[ReportingProductKind::DynamicReport], args: Box::new(self.args.clone()), } } @@ -1677,7 +1677,7 @@ impl ReportingStep for TrialBalance { result.insert( ReportingProductId { name: "TrialBalance", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(self.args.clone()), }, Box::new(report), diff --git a/libdrcr/src/reporting/types.rs b/libdrcr/src/reporting/types.rs index 13891c2..52fc00f 100644 --- a/libdrcr/src/reporting/types.rs +++ b/libdrcr/src/reporting/types.rs @@ -152,12 +152,20 @@ impl Display for ReportingProductId { } } -/// Identifies a type of [ReportingProduct] +/// Identifies a type of [Box]ed [ReportingProduct] +/// +/// See [Box::downcast]. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum ReportingProductKind { + /// The [Box]ed [ReportingProduct] is a [Transactions] Transactions, + /// The [Box]ed [ReportingProduct] is a [BalancesAt] BalancesAt, + /// The [Box]ed [ReportingProduct] is a [BalancesBetween] BalancesBetween, + /// The [Box]ed [ReportingProduct] is a [DynamicReport] + DynamicReport, + /// Unused in libdrcr - available for plugin use Generic, } diff --git a/src-tauri/src/libdrcr_bridge.rs b/src-tauri/src/libdrcr_bridge.rs index 3813652..035db3b 100644 --- a/src-tauri/src/libdrcr_bridge.rs +++ b/src-tauri/src/libdrcr_bridge.rs @@ -136,7 +136,7 @@ pub(crate) async fn get_balance_sheet( state, &ReportingProductId { name: "BalanceSheet", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(MultipleDateArgs { dates: date_args.clone(), }), @@ -165,7 +165,7 @@ pub(crate) async fn get_income_statement( state, &ReportingProductId { name: "IncomeStatement", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(MultipleDateStartDateEndArgs { dates: date_args.clone(), }), @@ -188,7 +188,7 @@ pub(crate) async fn get_trial_balance( state, &ReportingProductId { name: "TrialBalance", - kind: ReportingProductKind::Generic, + kind: ReportingProductKind::DynamicReport, args: Box::new(DateArgs { date }), }, )