def FromRecurring(self, rt): """Given a RecurringTransaction, make our settings mirror it.""" self.repeatsCombo.SetSelection(rt.RepeatType) self.everySpin.SetValue(rt.RepeatEvery) end = rt.EndDate if end: self.endsSometimeRadio.SetValue(True) self.endDateCtrl.SetValue(helpers.pydate2wxdate(end)) else: self.ResetEndDate() self.endsNeverRadio.SetValue(True) self.Update()
def GetRecurrance(self): """Generate a string for describing the recurrance, such as "Daily until 2009-10-02".""" summary = "" repeatType = self.RepeatType if repeatType == 0: summary = gettext.ngettext("Daily", "Every %(num)d days", self.RepeatEvery) % {'num':self.RepeatEvery} elif repeatType == 1: if self.RepeatOn == [1,1,1,1,1,0,0]: summary = _("Weekly on weekdays") elif self.RepeatOn == [0,0,0,0,0,1,1]: summary = _("Weekly on weekends") elif self.RepeatOn == [1,1,1,1,1,1,1]: summary = _("Daily") else: pluralDayNames = (_("Mondays"), _("Tuesdays"), _("Wednesdays"), _("Thursdays"), _("Fridays"), _("Saturdays"), _("Sundays")) repeatDays = tuple(day for i, day in enumerate(pluralDayNames) if self.RepeatOn[i]) # Figure out the base for this string. if self.RepeatEvery == 1: summaryBase = _("Weekly on %s") else: summaryBase = _("Every %(num)d weeks on %%s") % {'num':self.RepeatEvery} if len(repeatDays) == 0: summary = "Never" elif len(repeatDays) == 1: summary = summaryBase % repeatDays[0] else: summary = summaryBase % ((", ".join(repeatDays[:-1])) + (_(" and %s") % repeatDays[-1])) elif repeatType == 2: summary = gettext.ngettext("Monthly", "Every %(num)d months", self.RepeatEvery) % {'num':self.RepeatEvery} elif repeatType == 3: summary = gettext.ngettext("Annually", "Every %(num)d years", self.RepeatEvery) % {'num':self.RepeatEvery} # If the recurring ends at some point, add that information to the summary text. if self.EndDate: summary += " " + _("until %s") % helpers.pydate2wxdate(self.EndDate).FormatISODate() return summary
def onEnter(self): self.isActive = True self.dateRange = self.bankController.Model.GetDateRange() self.startDate.Value = helpers.pydate2wxdate(self.dateRange[0]) self.endDate.Value = helpers.pydate2wxdate(self.dateRange[1]) self.generateData()
def FromRecurring(self, rt): self.descCtrl.Value = rt.Description self.amountCtrl.Value = "%.2f" % rt.Amount self.dateCtrl.Value = helpers.pydate2wxdate(rt.Date) self.transferCheck.Value = bool(rt.Source)