From b28c75c00f49462b262b1e0ae94b04b1fa5a5389 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Wed, 21 May 2025 17:16:25 +1000 Subject: [PATCH] Implement Display for ReportingStep --- src/main.rs | 2 +- src/reporting/builders.rs | 20 ++++++++++++++++++++ src/reporting/mod.rs | 2 +- src/reporting/steps.rs | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5870164..30bd029 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,7 +46,7 @@ fn main() { match solve_for(targets, context) { Ok(steps) => { for step in steps { - println!("- {}", step.id()); + println!("- {}", step); } } Err(err) => panic!("Error: {:?}", err), diff --git a/src/reporting/builders.rs b/src/reporting/builders.rs index af5e455..7905298 100644 --- a/src/reporting/builders.rs +++ b/src/reporting/builders.rs @@ -16,6 +16,8 @@ along with this program. If not, see . */ +use std::fmt::Display; + use super::{ calculator::{has_step_or_can_build, HasStepOrCanBuild, ReportingGraphDependencies}, DateArgs, DateStartDateEndArgs, ReportingContext, ReportingProductId, ReportingProductKind, @@ -101,6 +103,12 @@ impl BalancesAtToBalancesBetween { } } +impl Display for BalancesAtToBalancesBetween { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{} {{BalancesAtToBalancesBetween}}", self.id())) + } +} + impl ReportingStep for BalancesAtToBalancesBetween { fn id(&self) -> ReportingStepId { ReportingStepId { @@ -194,6 +202,12 @@ impl GenerateBalances { } } +impl Display for GenerateBalances { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{} {{GenerateBalances}}", self.id())) + } +} + impl ReportingStep for GenerateBalances { fn id(&self) -> ReportingStepId { ReportingStepId { @@ -284,6 +298,12 @@ impl UpdateBalancesBetween { } } +impl Display for UpdateBalancesBetween { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{} {{UpdateBalancesBetween}}", self.id())) + } +} + impl ReportingStep for UpdateBalancesBetween { fn id(&self) -> ReportingStepId { ReportingStepId { diff --git a/src/reporting/mod.rs b/src/reporting/mod.rs index dd0fe23..b0155bd 100644 --- a/src/reporting/mod.rs +++ b/src/reporting/mod.rs @@ -121,7 +121,7 @@ impl Display for ReportingStepId { } } -pub trait ReportingStep: Debug + Downcast { +pub trait ReportingStep: Debug + Display + Downcast { // Info fn id(&self) -> ReportingStepId; diff --git a/src/reporting/steps.rs b/src/reporting/steps.rs index 3c94461..c3f8f19 100644 --- a/src/reporting/steps.rs +++ b/src/reporting/steps.rs @@ -16,6 +16,8 @@ along with this program. If not, see . */ +use std::fmt::Display; + use crate::util::sofy_from_eofy; use super::{ @@ -78,6 +80,12 @@ impl AllTransactionsExceptRetainedEarnings { } } +impl Display for AllTransactionsExceptRetainedEarnings { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{}", self.id())) + } +} + impl ReportingStep for AllTransactionsExceptRetainedEarnings { fn id(&self) -> ReportingStepId { ReportingStepId { @@ -105,6 +113,12 @@ impl CalculateIncomeTax { } } +impl Display for CalculateIncomeTax { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{}", self.id())) + } +} + impl ReportingStep for CalculateIncomeTax { fn id(&self) -> ReportingStepId { ReportingStepId { @@ -161,6 +175,12 @@ impl CombineOrdinaryTransactions { } } +impl Display for CombineOrdinaryTransactions { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{}", self.id())) + } +} + impl ReportingStep for CombineOrdinaryTransactions { fn id(&self) -> ReportingStepId { ReportingStepId { @@ -205,6 +225,12 @@ impl DBBalances { } } +impl Display for DBBalances { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{}", self.id())) + } +} + impl ReportingStep for DBBalances { fn id(&self) -> ReportingStepId { ReportingStepId { @@ -232,6 +258,12 @@ impl PostUnreconciledStatementLines { } } +impl Display for PostUnreconciledStatementLines { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_fmt(format_args!("{}", self.id())) + } +} + impl ReportingStep for PostUnreconciledStatementLines { fn id(&self) -> ReportingStepId { ReportingStepId {