From c1d4b0a43046b8aa4bad6ebf6ca3f74aba1bb54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Fri, 9 Oct 2020 23:51:37 +0300 Subject: take into account shared expenses --- src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 5c64959..cd401e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -181,6 +181,20 @@ fn output(account: Account, maybe_calculated: Option) { println!(); + for (n, owed) in calculated.total_owed.iter() { + println!( + "{} person(s) owe you in shared expenses: {:.2}", + n - 1, + owed, + ); + + if *n > 2 { + println!("Each owes you: {}", *owed / (*n as f64 - 1.0)); + } + + println!(); + } + println!("Days until balance runs out:"); let days_left_output = format!( @@ -192,6 +206,8 @@ fn output(account: Account, maybe_calculated: Option) { calculated.days_left_essential, ); + // TODO: also show much money would be left by the end of the period + let mut all_are_healthy = true; let mut essential_are_healthy = true; -- cgit v1.2.3