Browse Source

Plug database connection leak.

Neal Wilson 11 years ago
parent
commit
38326c3e27
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      config/Reports/fypurchase.xml

+ 5
- 2
config/Reports/fypurchase.xml View File

@@ -24,6 +24,7 @@
24 24
 			query.exec("SELECT EXTRACT(YEAR FROM time) FROM purchase WHERE time = (SELECT min(time) FROM purchase)");
25 25
 			query.next();
26 26
 			startDateField.setDate(query.value(0), 1, 1);
27
+			query = query.invalidate();
27 28
 			/* Set ending year to the current year. */
28 29
 			var endDateField = findChildObject(this, 'enddate');
29 30
 			endDateField.setDate(endDateField.year(), 12, 31);
@@ -79,12 +80,13 @@
79 80
 				var sacktotal = 0;
80 81
 				var unittotal = 0;
81 82
 				var costtotal = 0;
83
+				var query = new QSqlQuery();
82 84
 				for(var i = startDateField.year(); i <= endDateField.year(); i++)
83 85
 				{
84
-					output.writeStartElement("tr");
85
-					output.writeAttribute("id", "y"+i);
86 86
 					var q = "SELECT sum(quantity/(SELECT conversion FROM lb_bag_conversion WHERE item = purchase.item)), (sum(quantity) / :conversion)::numeric(12,2), sum(cost*quantity)::numeric(12,2) FROM purchase WHERE time >= '" + i + "-01-01' AND time < '" + (i+1) + "-01-01'";
87 87
 					query.prepare(q);
88
+					output.writeStartElement("tr");
89
+					output.writeAttribute("id", "y"+i);
88 90
 					query.bind(":conversion", unitBox.currentIndex == 0 ? 2.2 : 1);
89 91
 					query.exec();
90 92
 					query.next();
@@ -99,6 +101,7 @@
99 101
 					costtotal += Number(query.value(2));
100 102
 					output.writeEndElement(); //tr
101 103
 				}
104
+				query = query.invalidate();
102 105
 				output.writeEndElement(); //tbody
103 106
 				output.writeStartElement("tfoot");
104 107
 				output.writeTextElement("th", "Totals:");

Loading…
Cancel
Save