Allow to get only the main account
This commit is contained in:
parent
49d2745257
commit
4cfe91039c
1 changed files with 9 additions and 6 deletions
15
src/main.rs
15
src/main.rs
|
|
@ -117,11 +117,8 @@ pub(crate) trait Spendings {
|
||||||
.sum()
|
.sum()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contributions(&self, archive: &BTreeMap<ReportDate, Report>) -> PossibleContributions {
|
fn main_account(&self, archive: &BTreeMap<ReportDate, Report>) -> (f64, u8) {
|
||||||
let total_spendings = self.total_spendings();
|
let (historic_spendings, count) = std::iter::once(self.total_spendings())
|
||||||
let total_earnings = self.earnings().total();
|
|
||||||
|
|
||||||
let (historic_spendings, count) = std::iter::once(total_spendings)
|
|
||||||
.chain(
|
.chain(
|
||||||
match self.date() {
|
match self.date() {
|
||||||
Some(date) => {
|
Some(date) => {
|
||||||
|
|
@ -143,7 +140,13 @@ pub(crate) trait Spendings {
|
||||||
(acc + spending, count + 1)
|
(acc + spending, count + 1)
|
||||||
});
|
});
|
||||||
|
|
||||||
let main_account = historic_spendings / count as f64;
|
(historic_spendings / count as f64, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn contributions(&self, archive: &BTreeMap<ReportDate, Report>) -> PossibleContributions {
|
||||||
|
let total_earnings = self.earnings().total();
|
||||||
|
|
||||||
|
let (main_account, count) = self.main_account(archive);
|
||||||
let main_factor = main_account / total_earnings;
|
let main_factor = main_account / total_earnings;
|
||||||
|
|
||||||
let mut remaining = self.earnings();
|
let mut remaining = self.earnings();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue