Commit 80ed6403 authored by Og B. Maciel's avatar Og B. Maciel

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

svn path=/trunk/; revision=656
parent 6b8a5983
2008-09-27 Og Maciel <ogmaciel@gnome.org>
* src/gui/adddialog.py: Allow bills to have a null amount. Fixes Bug #551953.
* src/gui/widgets/charting.py: Display 2 decimal places for labels. Fixes Bug #551953.
* src/gui/widgets/viewbill.py: Allow null values for amountDue. Fixes Bug #551953.
* src/lib/actions.py: Handle null values, returning a zero where needed. Fixes Bug #551953.
* src/gui/widgets/timeline.py: Added new timeline widget.
* data/Makefile.am: Make sure that gconf is run (if available) and register schema.
Partially fixes Bug #553694.
......
......@@ -244,7 +244,10 @@ class AddDialog(gtk.Dialog):
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 @@ class AddDialog(gtk.Dialog):
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 @@ class AddDialog(gtk.Dialog):
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
......
......@@ -405,7 +405,7 @@ class Chart(gtk.DrawingArea):
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 @@ class Chart(gtk.DrawingArea):
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 @@ class Chart(gtk.DrawingArea):
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 @@ class Chart(gtk.DrawingArea):
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 @@ class Chart(gtk.DrawingArea):
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)
......
......@@ -48,7 +48,11 @@ class ViewBill(GenericListView):
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))
......
......@@ -31,7 +31,9 @@ class Actions(object):
# 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 <= ?' \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment