billreminder r656 - in trunk: . src/gui src/gui/widgets src/lib



Author: ogmaciel
Date: Sun Sep 28 02:14:56 2008
New Revision: 656
URL: http://svn.gnome.org/viewvc/billreminder?rev=656&view=rev

Log:
It should be possible to add bills without an amount defined (Bug #551953).

Modified:
   trunk/ChangeLog
   trunk/src/gui/adddialog.py
   trunk/src/gui/widgets/charting.py
   trunk/src/gui/widgets/viewbill.py
   trunk/src/lib/actions.py

Modified: trunk/src/gui/adddialog.py
==============================================================================
--- trunk/src/gui/adddialog.py	(original)
+++ trunk/src/gui/adddialog.py	Sun Sep 28 02:14:56 2008
@@ -244,7 +244,10 @@
 
     def _populate_fields(self):
         # Format the amount field
-        self.amount.set_text(utils.float_to_currency(self.currentrecord.AmountDue))
+        if self.currentrecord.AmountDue:
+            self.amount.set_text(utils.float_to_currency(self.currentrecord.AmountDue))
+        else:
+            self.amount.set_text("")
         # Format the dueDate field
         dt = scheduler.datetime_from_timestamp(self.currentrecord.DueDate)
         self.calendar.select_day(dt.day)
@@ -385,10 +388,13 @@
         alarm = self.alarmbutton.get_date()  or -1
 
         # Validate form
-        if not payee.strip() or not self.amount.get_text().strip():
+        if not payee.strip():
             return None
 
-        amount = utils.currency_to_float(self.amount.get_text())
+        if self.amount.get_text().strip():
+            amount = utils.currency_to_float(self.amount.get_text())
+        else:
+            amount = None
 
         if self.currentrecord is None:
             # Verify how many bills will be inserted
@@ -476,10 +482,6 @@
                 message.ShowError(_("\"%s\" is required field.") % _("Payee"), self)
                 self.emit_stop_by_name("response")
                 self.payee.grab_focus()
-            elif not self.amount.get_text().strip():
-                message.ShowError(_("\"%s\" is required field.") % _("Amount"), self)
-                self.emit_stop_by_name("response")
-                self.amount.grab_focus()
 
     def _on_calendar_day_selected(self, widget):
         # Only reprogram alarm if it is not None

Modified: trunk/src/gui/widgets/charting.py
==============================================================================
--- trunk/src/gui/widgets/charting.py	(original)
+++ trunk/src/gui/widgets/charting.py	Sun Sep 28 02:14:56 2008
@@ -405,7 +405,7 @@
             context.show_text(data[i]["label"])
 
         # values for max min and average
-        max_label =  self.there_are_floats and "%.1f" % self.max or "%d" % self.max
+        max_label =  self.there_are_floats and "%.2f" % self.max or "%d" % self.max
         extent = context.text_extents(max_label) #x, y, width, height
 
         context.move_to(graph_x - extent[2] - 16, rect.y + 10)
@@ -441,7 +441,7 @@
 
         if self.values_on_bars:
             for i in range(records):
-                label = self.there_are_floats and "%.1f" % data[i]["value"] or "%d" % data[i]["value"]
+                label = self.there_are_floats and "%.2f" % data[i]["value"] or "%d" % data[i]["value"]
                 extent = context.text_extents(label) #x, y, width, height
                 
                 bar_size = graph_height * data[i]["factor"]
@@ -577,7 +577,7 @@
         set_color(context, '#000000')        
         if self.values_on_bars:
             for i in range(records):
-                label = "%.1f" % data[i]["value"] and self.there_are_floats or "%d" % data[i]["value"]
+                label = "%.2f" % data[i]["value"] and self.there_are_floats or "%d" % data[i]["value"]
                 extent = context.text_extents(label) #x, y, width, height
                 
                 bar_size = max_size * data[i]["factor"]
@@ -594,7 +594,7 @@
         else:
             # values for max min and average
             context.move_to(graph_x + graph_width + 10, graph_y + 10)
-            max_label = "%.1f" % self.max and self.there_are_floats or "%d" % self.max
+            max_label = "%.2f" % self.max and self.there_are_floats or "%d" % self.max
             context.show_text(max_label)
         
         
@@ -668,7 +668,7 @@
                 context.show_text(data[i]["label"])
 
         # values for max min and average
-        max_label = "%.1f" % self.max and self.there_are_floats or "%d" % self.max
+        max_label = "%.2f" % self.max and self.there_are_floats or "%d" % self.max
         extent = context.text_extents(max_label) #x, y, width, height
 
         context.move_to(graph_x - extent[2] - 16, rect.y + 10)

Modified: trunk/src/gui/widgets/viewbill.py
==============================================================================
--- trunk/src/gui/widgets/viewbill.py	(original)
+++ trunk/src/gui/widgets/viewbill.py	Sun Sep 28 02:14:56 2008
@@ -48,7 +48,11 @@
         cell.set_property('xalign', 0.5)
 
     def amountdue_cell_data_function(self, column, cell, model, iter):
-        amountDue = model.get_value(iter, 5).replace(',', '.')
+        amountDue = model.get_value(iter, 5)
+        if amountDue:
+            amountDue = model.get_value(iter, 5).replace(',', '.')
+        else:
+            amountDue = ""
         paid = int(model.get_value(iter, 7))
         amountDue = len(amountDue) > 0 and amountDue or 0
         amountDue = utils.float_to_currency(float(amountDue))

Modified: trunk/src/lib/actions.py
==============================================================================
--- trunk/src/lib/actions.py	(original)
+++ trunk/src/lib/actions.py	Sun Sep 28 02:14:56 2008
@@ -31,7 +31,9 @@
         # Determine status criteria
         status = status < 2 and ' = %s' % status or ' in (0,1)'
 
-        stmt = 'select categoryName, sum(amountDue) as amount, color' \
+        stmt = 'select categoryName, ' \
+            ' sum(case when amountDue is null then 0 else amountDue end) as amount, ' \
+            ' color' \
             ' from br_billstable, br_categoriestable where' \
             ' paid %s' \
             ' and dueDate >= ? and dueDate <= ?' \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]