diff options
Diffstat (limited to 'finance/income.py')
-rw-r--r-- | finance/income.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/finance/income.py b/finance/income.py deleted file mode 100644 index 8d775cb..0000000 --- a/finance/income.py +++ /dev/null @@ -1,33 +0,0 @@ -import dataclasses -from datetime import datetime -from decimal import Decimal - - -@dataclasses.dataclass(kw_only=True, frozen=True) -class Income: - """Income models financial income paid on the first day of a month""" - - amount: Decimal - - def integrate(self, start: datetime, end: datetime) -> Decimal: - """Integrate the income from a start to an end date""" - - retval = Decimal(0.0) - - current = datetime(start.year, start.month, 1) - - if start == current: - retval += self.amount - - while True: - if current.month == 12: - current = datetime(current.year + 1, 1, 1) - else: - current = datetime(current.year, current.month + 1, 1) - - if current <= end: - retval += self.amount - else: - break - - return retval |