Correctly calculate same remaining main account
This used to include the total savings
This commit is contained in:
parent
4d65995af1
commit
8cc79d2331
1 changed files with 20 additions and 3 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -3,7 +3,7 @@ use std::{
|
|||
fs::{File, OpenOptions},
|
||||
io::BufReader,
|
||||
num::NonZeroU8,
|
||||
ops::{Mul, MulAssign, Sub, SubAssign},
|
||||
ops::{AddAssign, Mul, MulAssign, Sub, SubAssign},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ use anyhow::anyhow;
|
|||
use calc::calc_parser;
|
||||
use compare::Compare;
|
||||
use directories::ProjectDirs;
|
||||
use edit::{EditMessage, EditState, EditSaveFile};
|
||||
use edit::{EditMessage, EditSaveFile, EditState};
|
||||
use either::Either;
|
||||
use iced::{
|
||||
font, subscription,
|
||||
|
|
@ -54,6 +54,13 @@ impl ContributionPoint {
|
|||
}
|
||||
}
|
||||
|
||||
impl AddAssign<ContributionPoint> for ContributionPoint {
|
||||
fn add_assign(&mut self, rhs: ContributionPoint) {
|
||||
self.person_1 += rhs.person_1;
|
||||
self.person_2 += rhs.person_2;
|
||||
}
|
||||
}
|
||||
|
||||
impl SubAssign<ContributionPoint> for ContributionPoint {
|
||||
fn sub_assign(&mut self, rhs: ContributionPoint) {
|
||||
self.person_1 -= rhs.person_1;
|
||||
|
|
@ -156,6 +163,10 @@ pub(crate) trait Spendings {
|
|||
remaining -= main;
|
||||
|
||||
let mut total_depositing = main_account;
|
||||
let mut total_savings = ContributionPoint {
|
||||
person_1: 0.,
|
||||
person_2: 0.,
|
||||
};
|
||||
|
||||
let (savings_same_percent, saving_same_remaining) = self
|
||||
.savings()
|
||||
|
|
@ -166,6 +177,12 @@ pub(crate) trait Spendings {
|
|||
total_depositing += amount;
|
||||
remaining -= contributions;
|
||||
|
||||
let savings = ContributionPoint {
|
||||
person_1: amount / 2.,
|
||||
person_2: amount / 2.,
|
||||
};
|
||||
total_savings += savings;
|
||||
|
||||
(
|
||||
(account.to_string(), contributions),
|
||||
(
|
||||
|
|
@ -192,7 +209,7 @@ pub(crate) trait Spendings {
|
|||
savings: savings_same_percent,
|
||||
},
|
||||
same_remaining: Contribution {
|
||||
main: self.earnings() - remaining_per_person,
|
||||
main: self.earnings() - remaining_per_person - total_savings,
|
||||
remaining: remaining_per_person,
|
||||
savings: saving_same_remaining,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue