Example #1
0
 def test_time_series_subset(self):
     """ Tests `time_series` for a subset of keys. """
     # start and end are equally weighted:
     timing = Timing({0: 1, 1: 1})
     result = timing.time_series(2, keys={1})
     # Spreading a value of 2 equally across _just end_ means
     # allocating 2 at end:
     self.assertEqual(result, {1: 2})
Example #2
0
 def test_time_series_basic(self):
     """ Tests `time_series` with simple input. """
     # start and end are equally weighted:
     timing = Timing({0: 1, 1: 1})
     result = timing.time_series(2)
     # Spreading a value of 2 equally across start and end means
     # allocating 1 at start and 1 at end:
     self.assertEqual(result, {0: 1, 1: 1})
Example #3
0
    def _carryover_tax(self, tax_adjustment_previous):
        """ Add tax refunds/payments arising from last year's taxes. """
        # Nothing to carry over is there's no known tax adjustment:
        if tax_adjustment_previous is None:
            return

        # Determine the time series of transactions as appropriate:
        if tax_adjustment_previous > 0:  # refund
            if hasattr(self.tax_forecast, "tax_refund_timing"):
                timing = self.tax_forecast.tax_refund_timing
            else:
                timing = Timing(0, high_precision=self.high_precision)
        elif tax_adjustment_previous < 0:  # payment owing
            if hasattr(self.tax_forecast, "tax_payment_timing"):
                timing = self.tax_forecast.tax_payment_timing
            else:
                timing = Timing(0, high_precision=self.high_precision)
        else:  # no adjustment
            return  # No need to proceed on to add_transactions
        # Add the time-series of transactions to `available`:
        transactions = timing.time_series(tax_adjustment_previous)
        add_transactions(self.available, transactions)