Example #1
0
    def _populate_widgets_with_record(self):
        # Format the amount field
        if self.currentrecord.amount:
            self.amount.set_text(utils.float_to_currency(self.currentrecord.amount))
        else:
            self.amount.set_text("")
        # Format the dueDate field
        dt = self.currentrecord.dueDate
        self.dueDate.set_date(dt)
        utils.select_combo_text(self.payee, self.currentrecord.payee)

        if self.currentrecord.category:
            actions = Actions()
            cat_name = self.currentrecord.category.name
            records = actions.get_categories(name=cat_name)
            if records:
                categoryname = records[0].name
                utils.select_combo_text(self.category, categoryname, 1)
        else:
            self.category.set_active(0)

        if self.currentrecord.notes:
            self.txtbuffer.set_text(self.currentrecord.notes)
        #self.chkPaid.set_active(self.currentrecord.Paid)

        if self.currentrecord.alarmDate:
            self.alarmbutton.set_date(self.currentrecord.alarmDate)
Example #2
0
    def on_timeline_cb(self, date, display_type, force=False):
        # TODO: Improve tooltip
        # TODO: Improve cache

        if date in self._bullet_cache.keys() and not force:
            return None

        self._bullet_cache[date] = self.actions.get_bills(dueDate=date)
        if self._bullet_cache[date]:
            status = self.gconf_client.get("show_paid_bills")
            amount = 0
            amount_not_paid = 0
            tooltip = ""
            bullet = Event()
            bullet.date = date

            for bill in self._bullet_cache[date]:
                amount += bill.amount
                if tooltip:
                    tooltip += "\n"
                tooltip += bill.payee + " (" + str(float_to_currency(bill.amount)) + ")"

                if bill.paid:
                    tooltip += " [%s]" % _("Paid")

                    if status == 0:
                        return False
                    bullet.status = bullet.status | bullet.PAID
                else:
                    amount_not_paid += bill.amount
                    if date <= datetime.date.today():
                        if status == 1:
                            return False
                        bullet.status = bullet.status | bullet.OVERDUE
                    else:
                        if status == 1:
                            return False
                        bullet.status = bullet.status | bullet.TO_BE_PAID

                if bill.notes:
                    tooltip += " - " + bill.notes

            bullet.amountdue = amount_not_paid if amount_not_paid else amount
            bullet.payee = bill.payee

            bills = len(self._bullet_cache[date])
            if bills > 1:
                bullet.multi = bills
                bullet.payee = "%d bills" % bills
            bullet.tooltip = tooltip
            return bullet

        return None