Refactor AllTransactionsIncludingRetainedEarnings
This commit is contained in:
parent
e47ad229eb
commit
ed0fbfb5dd
@ -60,10 +60,9 @@ fn main() {
|
|||||||
let targets: Vec<Box<dyn ReportingStep>> = vec![
|
let targets: Vec<Box<dyn ReportingStep>> = vec![
|
||||||
Box::new(CalculateIncomeTax {}),
|
Box::new(CalculateIncomeTax {}),
|
||||||
Box::new(AllTransactionsIncludingRetainedEarnings {
|
Box::new(AllTransactionsIncludingRetainedEarnings {
|
||||||
product_kinds: &[ReportingProductKind::BalancesAt],
|
args: DateArgs {
|
||||||
args: Box::new(DateArgs {
|
|
||||||
date: NaiveDate::from_ymd_opt(2025, 6, 30).unwrap(),
|
date: NaiveDate::from_ymd_opt(2025, 6, 30).unwrap(),
|
||||||
}),
|
},
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -52,24 +52,7 @@ pub fn register_lookup_fns(context: &mut ReportingContext) {
|
|||||||
"AllTransactionsIncludingRetainedEarnings",
|
"AllTransactionsIncludingRetainedEarnings",
|
||||||
&[ReportingProductKind::BalancesAt],
|
&[ReportingProductKind::BalancesAt],
|
||||||
AllTransactionsIncludingRetainedEarnings::takes_args,
|
AllTransactionsIncludingRetainedEarnings::takes_args,
|
||||||
|a| {
|
AllTransactionsIncludingRetainedEarnings::from_args,
|
||||||
AllTransactionsIncludingRetainedEarnings::from_args(
|
|
||||||
&[ReportingProductKind::BalancesAt],
|
|
||||||
a,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
context.register_lookup_fn(
|
|
||||||
"AllTransactionsIncludingRetainedEarnings",
|
|
||||||
&[ReportingProductKind::BalancesBetween],
|
|
||||||
AllTransactionsIncludingRetainedEarnings::takes_args,
|
|
||||||
|a| {
|
|
||||||
AllTransactionsIncludingRetainedEarnings::from_args(
|
|
||||||
&[ReportingProductKind::BalancesBetween],
|
|
||||||
a,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
context.register_lookup_fn(
|
context.register_lookup_fn(
|
||||||
@ -141,22 +124,17 @@ impl ReportingStep for AllTransactionsExceptRetainedEarnings {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AllTransactionsIncludingRetainedEarnings {
|
pub struct AllTransactionsIncludingRetainedEarnings {
|
||||||
pub product_kinds: &'static [ReportingProductKind], // Must have single member
|
pub args: DateArgs,
|
||||||
pub args: Box<dyn ReportingStepArgs>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AllTransactionsIncludingRetainedEarnings {
|
impl AllTransactionsIncludingRetainedEarnings {
|
||||||
fn takes_args(_args: &Box<dyn ReportingStepArgs>) -> bool {
|
fn takes_args(args: &Box<dyn ReportingStepArgs>) -> bool {
|
||||||
true
|
args.is::<DateArgs>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_args(
|
fn from_args(args: Box<dyn ReportingStepArgs>) -> Box<dyn ReportingStep> {
|
||||||
product_kinds: &'static [ReportingProductKind],
|
|
||||||
args: Box<dyn ReportingStepArgs>,
|
|
||||||
) -> Box<dyn ReportingStep> {
|
|
||||||
Box::new(AllTransactionsIncludingRetainedEarnings {
|
Box::new(AllTransactionsIncludingRetainedEarnings {
|
||||||
product_kinds,
|
args: *args.downcast().unwrap(),
|
||||||
args,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,17 +149,26 @@ impl ReportingStep for AllTransactionsIncludingRetainedEarnings {
|
|||||||
fn id(&self) -> ReportingStepId {
|
fn id(&self) -> ReportingStepId {
|
||||||
ReportingStepId {
|
ReportingStepId {
|
||||||
name: "AllTransactionsIncludingRetainedEarnings",
|
name: "AllTransactionsIncludingRetainedEarnings",
|
||||||
product_kinds: self.product_kinds,
|
product_kinds: &[ReportingProductKind::BalancesAt],
|
||||||
args: self.args.clone(),
|
args: Box::new(self.args.clone()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires(&self, _context: &ReportingContext) -> Vec<ReportingProductId> {
|
fn requires(&self, _context: &ReportingContext) -> Vec<ReportingProductId> {
|
||||||
vec![ReportingProductId {
|
vec![
|
||||||
|
// AllTransactionsIncludingRetainedEarnings requires AllTransactionsExceptRetainedEarnings
|
||||||
|
ReportingProductId {
|
||||||
name: "AllTransactionsExceptRetainedEarnings",
|
name: "AllTransactionsExceptRetainedEarnings",
|
||||||
kind: self.product_kinds[0],
|
kind: ReportingProductKind::BalancesAt,
|
||||||
args: self.args.clone(),
|
args: Box::new(self.args.clone()),
|
||||||
}]
|
},
|
||||||
|
// AllTransactionsIncludingRetainedEarnings requires RetainedEarningsToEquity
|
||||||
|
ReportingProductId {
|
||||||
|
name: "RetainedEarningsToEquity",
|
||||||
|
kind: ReportingProductKind::Transactions,
|
||||||
|
args: Box::new(self.args.clone()),
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user