Exemplo n.º 1
0
    def add_regular(self, from_acc, to_acc, payment, interval,
                    date_start, day=1, name='', date_stop = None,
                    fixed = False, meta={}):
        """ Adds a regular payment to the list, with a given
        payment: amount to pay
        interval: 'monthly': every month
                  'quarter': every quarter with date_start as start month
                  'quarter_year': every quarter of a year (mar, jun, sep, dec)
                  'yearly': every year
        day: day to start with
        date_start: start date of this payment
        name : optional name
        fixed: only everything or nothing must be transfered (true)
               or depending on the receiving account a smaller amount
               can be transfered (false)
        """
        if not interval in C_interval.keys():
            raise ValueError("interval must be one of '" + '\',\''.join(C_interval))
        if day >= 29:
            warnings.warn(("note that in months which have less days than {} the " +
                           "payment will be transferred earlier").format(day)
                          )
        self.check_errors_payment(payment)

        if not date_stop:
            date_stop = Bank_Date.max
        else:
            date_stop = validate.valid_stop_date(date_stop)

        # converts any payment to a function
        conv_payment = conv_payment_func(payment)

        self._regular.append({'from_acc': from_acc,
                              'to_acc': to_acc,
                              'interval': interval,
                              'day' : day,
                              'date_start': Bank_Date.fromtimestamp(date_start.timestamp()),
                              'date_stop': date_stop,
                              'payment': conv_payment,
                              'name' : name,
                              'fixed': fixed,
                              'meta': meta
                              }
                             )
Exemplo n.º 2
0
 def add_regular(self,
                 from_acc,
                 to_acc,
                 payment,
                 interval,
                 date_start=datetime(1971, 1, 1),
                 day=1,
                 name='',
                 date_stop=None,
                 fixed=False,
                 meta={}):
     """ Transfers money from one account to the other on regular basis
     date_stop can be a function of the form lambda x: x > datetime(...)
     If it returns true, the payment is stopped
     """
     from_acc, to_acc = valid_account_type(from_acc, to_acc)
     date_start = validate.valid_date(date_start)
     if date_stop is not None:
         date_stop = validate.valid_stop_date(date_stop)
     self._payments.add_regular(from_acc, to_acc, payment, interval,
                                date_start, day, name, date_stop, fixed,
                                meta)
     self.update_payment_iterators()