Rename ReportingProductKind::Generic to ReportingProductKind::DynamicReport

This commit is contained in:
RunasSudo 2025-05-30 20:49:14 +10:00
parent e8e88e8629
commit 49dc6bc078
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
4 changed files with 27 additions and 19 deletions

View File

@ -65,7 +65,7 @@ async fn main() {
// }, // },
ReportingProductId { ReportingProductId {
name: "BalanceSheet", name: "BalanceSheet",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(MultipleDateArgs { args: Box::new(MultipleDateArgs {
dates: vec![DateArgs { dates: vec![DateArgs {
date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(),
@ -74,7 +74,7 @@ async fn main() {
}, },
ReportingProductId { ReportingProductId {
name: "IncomeStatement", name: "IncomeStatement",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(MultipleDateStartDateEndArgs { args: Box::new(MultipleDateStartDateEndArgs {
dates: vec![DateStartDateEndArgs { dates: vec![DateStartDateEndArgs {
date_start: NaiveDate::from_ymd_opt(YEAR - 1, 7, 1).unwrap(), date_start: NaiveDate::from_ymd_opt(YEAR - 1, 7, 1).unwrap(),
@ -133,7 +133,7 @@ async fn main() {
}, },
ReportingProductId { ReportingProductId {
name: "BalanceSheet", name: "BalanceSheet",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(MultipleDateArgs { args: Box::new(MultipleDateArgs {
dates: vec![DateArgs { dates: vec![DateArgs {
date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(),
@ -148,7 +148,7 @@ async fn main() {
let result = products let result = products
.get_or_err(&ReportingProductId { .get_or_err(&ReportingProductId {
name: "BalanceSheet", name: "BalanceSheet",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(MultipleDateArgs { args: Box::new(MultipleDateArgs {
dates: vec![DateArgs { dates: vec![DateArgs {
date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(),
@ -173,7 +173,7 @@ async fn main() {
}, },
ReportingProductId { ReportingProductId {
name: "TrialBalance", name: "TrialBalance",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(DateArgs { args: Box::new(DateArgs {
date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(),
}), }),
@ -186,7 +186,7 @@ async fn main() {
let result = products let result = products
.get_or_err(&ReportingProductId { .get_or_err(&ReportingProductId {
name: "TrialBalance", name: "TrialBalance",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(DateArgs { args: Box::new(DateArgs {
date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(), date: NaiveDate::from_ymd_opt(YEAR, 6, 30).unwrap(),
}), }),

View File

@ -384,7 +384,7 @@ impl BalanceSheet {
fn register_lookup_fn(context: &mut ReportingContext) { fn register_lookup_fn(context: &mut ReportingContext) {
context.register_lookup_fn( context.register_lookup_fn(
"BalanceSheet", "BalanceSheet",
&[ReportingProductKind::Generic], &[ReportingProductKind::DynamicReport],
Self::takes_args, Self::takes_args,
Self::from_args, Self::from_args,
); );
@ -412,7 +412,7 @@ impl ReportingStep for BalanceSheet {
fn id(&self) -> ReportingStepId { fn id(&self) -> ReportingStepId {
ReportingStepId { ReportingStepId {
name: "BalanceSheet", name: "BalanceSheet",
product_kinds: &[ReportingProductKind::Generic], product_kinds: &[ReportingProductKind::DynamicReport],
args: Box::new(self.args.clone()), args: Box::new(self.args.clone()),
} }
} }
@ -550,7 +550,7 @@ impl ReportingStep for BalanceSheet {
result.insert( result.insert(
ReportingProductId { ReportingProductId {
name: "BalanceSheet", name: "BalanceSheet",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(self.args.clone()), args: Box::new(self.args.clone()),
}, },
Box::new(report), Box::new(report),
@ -1120,7 +1120,7 @@ impl IncomeStatement {
fn register_lookup_fn(context: &mut ReportingContext) { fn register_lookup_fn(context: &mut ReportingContext) {
context.register_lookup_fn( context.register_lookup_fn(
"IncomeStatement", "IncomeStatement",
&[ReportingProductKind::Generic], &[ReportingProductKind::DynamicReport],
Self::takes_args, Self::takes_args,
Self::from_args, Self::from_args,
); );
@ -1148,7 +1148,7 @@ impl ReportingStep for IncomeStatement {
fn id(&self) -> ReportingStepId { fn id(&self) -> ReportingStepId {
ReportingStepId { ReportingStepId {
name: "IncomeStatement", name: "IncomeStatement",
product_kinds: &[ReportingProductKind::Generic], product_kinds: &[ReportingProductKind::DynamicReport],
args: Box::new(self.args.clone()), args: Box::new(self.args.clone()),
} }
} }
@ -1282,7 +1282,7 @@ impl ReportingStep for IncomeStatement {
result.insert( result.insert(
ReportingProductId { ReportingProductId {
name: "IncomeStatement", name: "IncomeStatement",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(self.args.clone()), args: Box::new(self.args.clone()),
}, },
Box::new(report), Box::new(report),
@ -1546,7 +1546,7 @@ impl TrialBalance {
fn register_lookup_fn(context: &mut ReportingContext) { fn register_lookup_fn(context: &mut ReportingContext) {
context.register_lookup_fn( context.register_lookup_fn(
"TrialBalance", "TrialBalance",
&[ReportingProductKind::Generic], &[ReportingProductKind::DynamicReport],
Self::takes_args, Self::takes_args,
Self::from_args, Self::from_args,
); );
@ -1574,7 +1574,7 @@ impl ReportingStep for TrialBalance {
fn id(&self) -> ReportingStepId { fn id(&self) -> ReportingStepId {
ReportingStepId { ReportingStepId {
name: "TrialBalance", name: "TrialBalance",
product_kinds: &[ReportingProductKind::Generic], product_kinds: &[ReportingProductKind::DynamicReport],
args: Box::new(self.args.clone()), args: Box::new(self.args.clone()),
} }
} }
@ -1677,7 +1677,7 @@ impl ReportingStep for TrialBalance {
result.insert( result.insert(
ReportingProductId { ReportingProductId {
name: "TrialBalance", name: "TrialBalance",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(self.args.clone()), args: Box::new(self.args.clone()),
}, },
Box::new(report), Box::new(report),

View File

@ -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)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum ReportingProductKind { pub enum ReportingProductKind {
/// The [Box]ed [ReportingProduct] is a [Transactions]
Transactions, Transactions,
/// The [Box]ed [ReportingProduct] is a [BalancesAt]
BalancesAt, BalancesAt,
/// The [Box]ed [ReportingProduct] is a [BalancesBetween]
BalancesBetween, BalancesBetween,
/// The [Box]ed [ReportingProduct] is a [DynamicReport]
DynamicReport,
/// Unused in libdrcr - available for plugin use
Generic, Generic,
} }

View File

@ -136,7 +136,7 @@ pub(crate) async fn get_balance_sheet(
state, state,
&ReportingProductId { &ReportingProductId {
name: "BalanceSheet", name: "BalanceSheet",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(MultipleDateArgs { args: Box::new(MultipleDateArgs {
dates: date_args.clone(), dates: date_args.clone(),
}), }),
@ -165,7 +165,7 @@ pub(crate) async fn get_income_statement(
state, state,
&ReportingProductId { &ReportingProductId {
name: "IncomeStatement", name: "IncomeStatement",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(MultipleDateStartDateEndArgs { args: Box::new(MultipleDateStartDateEndArgs {
dates: date_args.clone(), dates: date_args.clone(),
}), }),
@ -188,7 +188,7 @@ pub(crate) async fn get_trial_balance(
state, state,
&ReportingProductId { &ReportingProductId {
name: "TrialBalance", name: "TrialBalance",
kind: ReportingProductKind::Generic, kind: ReportingProductKind::DynamicReport,
args: Box::new(DateArgs { date }), args: Box::new(DateArgs { date }),
}, },
) )