Example #1
0
   def Generate(self):
      """Generates transaction(s) for the current config entry.

         One transaction per interval up to to and including the
         target date. In normal operation zero or one transactions are
         generated, but if processing has been delayed, more than one
         transaction can be produced.
         
         Returns a list of transaction strings ready for sorting and
         output to a ledger file. Each one begins with a newline to
         ensure it is separated by an empty line on output.
      """
      Rv = []
      TargetDateObject = self._Parent._TargetDateObject
      Done = False
      while not Done:
         if self._DateObject > TargetDateObject: Done = True
         else:
            # Append transaction text.
            Rv.append('\n' + self.TransactionText())

            # Evaluate next posting date.
            NewDateObject = Time.DateAddPeriod(self._DateObject, self._Period)
            if NewDateObject <= self._DateObject:
               _Throw("Period is negative or zero!")
            self._DateObject = NewDateObject
            self._DateStr = Time.DateToText(self._DateObject)
      return Rv