Statically require single member for AllTransactionsExceptRetainedEarnings.product_kinds

This commit is contained in:
RunasSudo 2025-05-21 22:29:18 +10:00
parent 1bed0f269e
commit 0eb583d028
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -52,7 +52,7 @@ pub fn register_lookup_fns(context: &mut ReportingContext) {
/// Used as the basis for the income statement. /// Used as the basis for the income statement.
#[derive(Debug)] #[derive(Debug)]
pub struct AllTransactionsExceptRetainedEarnings { pub struct AllTransactionsExceptRetainedEarnings {
pub product_kinds: &'static [ReportingProductKind], // Must have single member pub product_kinds: &'static [ReportingProductKind; 1], // Must have single member - represented as static array for compatibility with ReportingStepId
pub args: Box<dyn ReportingStepArgs>, pub args: Box<dyn ReportingStepArgs>,
} }
@ -78,7 +78,7 @@ impl AllTransactionsExceptRetainedEarnings {
} }
fn from_args( fn from_args(
product_kinds: &'static [ReportingProductKind], product_kinds: &'static [ReportingProductKind; 1],
args: Box<dyn ReportingStepArgs>, args: Box<dyn ReportingStepArgs>,
) -> Box<dyn ReportingStep> { ) -> Box<dyn ReportingStep> {
Box::new(AllTransactionsExceptRetainedEarnings { Box::new(AllTransactionsExceptRetainedEarnings {
@ -113,10 +113,7 @@ impl ReportingStep for AllTransactionsExceptRetainedEarnings {
// Get all dependencies // Get all dependencies
let step_dependencies = dependencies.dependencies_for_step(&self.id()); let step_dependencies = dependencies.dependencies_for_step(&self.id());
// Identify the product_kinds dependency most recently generated // Identify the product_kind dependency most recently generated
if self.product_kinds.len() != 1 {
panic!("AllTransactionsExceptRetainedEarnings.product_kinds.len() != 1");
}
let product_kind = self.product_kinds[0]; let product_kind = self.product_kinds[0];
for (product_id, product) in products.map().iter().rev() { for (product_id, product) in products.map().iter().rev() {