Implement Display for ReportingStep

This commit is contained in:
RunasSudo 2025-05-21 17:16:25 +10:00
parent 4add6292a1
commit b28c75c00f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
4 changed files with 54 additions and 2 deletions

View File

@ -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),

View File

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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 {

View File

@ -121,7 +121,7 @@ impl Display for ReportingStepId {
}
}
pub trait ReportingStep: Debug + Downcast {
pub trait ReportingStep: Debug + Display + Downcast {
// Info
fn id(&self) -> ReportingStepId;

View File

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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 {