diff options
Diffstat (limited to 'finance/flow.py')
-rw-r--r-- | finance/flow.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/finance/flow.py b/finance/flow.py index a5817af..9ea72c8 100644 --- a/finance/flow.py +++ b/finance/flow.py @@ -9,12 +9,22 @@ class Flow: """Time-discrete flow of money paid on the first day of a month""" amount: Decimal + since: None | datetime + until: None | datetime def integrate(self, start: datetime, end: datetime) -> Decimal: """Integrate the flow between two dates to an amount of money""" payments: int = 0 + if self.since is not None: + if start < self.since: + start = self.since + + if self.until is not None: + if end > self.until: + end = self.until + for candidate in monthly_candidates(start): if start <= candidate <= end: payments += 1 |