|
|
|
|
5
|
<daterange id="dates" initial="23" /><!-- Lifetime -->
|
5
|
<daterange id="dates" initial="23" /><!-- Lifetime -->
|
6
|
<label>Sort Order:</label>
|
6
|
<label>Sort Order:</label>
|
7
|
<sqldrop id="sort" />
|
7
|
<sqldrop id="sort" />
|
8
|
- <label>Weight Unit:</label>
|
|
|
9
|
- <sqldrop id="unit" />
|
|
|
|
|
8
|
+ <label>Weight Unit:</label>
|
|
|
9
|
+ <sqldrop id="unit" />
|
10
|
<stretch />
|
10
|
<stretch />
|
11
|
</layout>
|
11
|
</layout>
|
12
|
<webview id="report" />
|
12
|
<webview id="report" />
|
13
|
</layout>
|
13
|
</layout>
|
14
|
<menu name="File">
|
14
|
<menu name="File">
|
15
|
- <item id="print" shortcut="Ctrl+P">Print</item>
|
|
|
|
|
15
|
+ <item id="print" shortcut="Ctrl+P">Print...</item>
|
16
|
</menu>
|
16
|
</menu>
|
17
|
<program>
|
17
|
<program>
|
18
|
<![CDATA[
|
18
|
<![CDATA[
|
19
|
- this.windowTitle = "Typica - Average Use and Cost by Origin";
|
|
|
|
|
19
|
+ this.windowTitle = TTR("useandcostreport", "Typica - Average Use and Cost by Origin");
|
20
|
var report = findChildObject(this, 'report');
|
20
|
var report = findChildObject(this, 'report');
|
21
|
var printMenu = findChildObject(this, 'print');
|
21
|
var printMenu = findChildObject(this, 'print');
|
22
|
printMenu.triggered.connect(function() {
|
22
|
printMenu.triggered.connect(function() {
|
23
|
report.print();
|
23
|
report.print();
|
24
|
});
|
24
|
});
|
25
|
var sortBox = findChildObject(this, 'sort');
|
25
|
var sortBox = findChildObject(this, 'sort');
|
26
|
- sortBox.addItem("Origin A-Z");
|
|
|
27
|
- sortBox.addItem("Origin Z-A");
|
|
|
28
|
- sortBox.addItem("Avg. Rate Ascending");
|
|
|
29
|
- sortBox.addItem("Avg. Rate Descending");
|
|
|
30
|
- sortBox.addItem("Avg. Cost Ascending");
|
|
|
31
|
- sortBox.addItem("Avg. Cost Descending");
|
|
|
|
|
26
|
+ sortBox.addItem(TTR("useandcostreport","Origin A-Z"));
|
|
|
27
|
+ sortBox.addItem(TTR("useandcostreport", "Origin Z-A"));
|
|
|
28
|
+ sortBox.addItem(TTR("useandcostreport", "Avg. Rate Ascending"));
|
|
|
29
|
+ sortBox.addItem(TTR("useandcostreport", "Avg. Rate Descending"));
|
|
|
30
|
+ sortBox.addItem(TTR("useandcostreport", "Avg. Cost Ascending"));
|
|
|
31
|
+ sortBox.addItem(TTR("useandcostreport", "Avg. Cost Descending"));
|
32
|
sortBox.currentIndex = QSettings.value("auco_sort", 0);
|
32
|
sortBox.currentIndex = QSettings.value("auco_sort", 0);
|
33
|
var unitBox = findChildObject(this, 'unit');
|
33
|
var unitBox = findChildObject(this, 'unit');
|
34
|
- unitBox.addItem("Kg");
|
|
|
35
|
- unitBox.addItem("Lb");
|
|
|
|
|
34
|
+ unitBox.addItem(TTR("useandcostreport", "Kg"));
|
|
|
35
|
+ unitBox.addItem(TTR("useandcostreport", "Lb"));
|
36
|
unitBox.currentIndex = QSettings.value("script/report_unit", 1);
|
36
|
unitBox.currentIndex = QSettings.value("script/report_unit", 1);
|
37
|
unitBox['currentIndexChanged(int)'].connect(function() {
|
37
|
unitBox['currentIndexChanged(int)'].connect(function() {
|
38
|
QSettings.setValue("script/report_unit", unitBox.currentIndex);
|
38
|
QSettings.setValue("script/report_unit", unitBox.currentIndex);
|
|
|
|
|
68
|
output.writeStartElement("html");
|
68
|
output.writeStartElement("html");
|
69
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
69
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
70
|
output.writeStartElement("head");
|
70
|
output.writeStartElement("head");
|
71
|
- output.writeTextElement("title", "Recent Use and Cost by Origin");
|
|
|
|
|
71
|
+ output.writeTextElement("title", TTR("useandcostreport", "Recent Use and Cost by Origin"));
|
72
|
output.writeEndElement();
|
72
|
output.writeEndElement();
|
73
|
output.writeStartElement("body");
|
73
|
output.writeStartElement("body");
|
74
|
- output.writeTextElement("h1", "Average Use and Cost by Origin " + startDate + " - " + endDate);
|
|
|
|
|
74
|
+ output.writeTextElement("h1", TTR("useandcostreport", "Average Use and Cost by Origin ") + startDate + " - " + endDate);
|
75
|
switch(unitBox.currentIndex)
|
75
|
switch(unitBox.currentIndex)
|
76
|
{
|
76
|
{
|
77
|
case 0:
|
77
|
case 0:
|
78
|
- output.writeTextElement("p", "This is a report of average rate of use in kilograms per day and cost of unroasted coffee.");
|
|
|
|
|
78
|
+ output.writeTextElement("p", TTR("useandcostreport", "This is a report of average rate of use in kilograms per day and cost of unroasted coffee."));
|
79
|
break;
|
79
|
break;
|
80
|
case 1:
|
80
|
case 1:
|
81
|
- output.writeTextElement("p", "This is a report of average rate of use in pounds per day and cost of unroasted coffee.");
|
|
|
|
|
81
|
+ output.writeTextElement("p", TTR("useandcostreport", "This is a report of average rate of use in pounds per day and cost of unroasted coffee."));
|
82
|
break;
|
82
|
break;
|
83
|
}
|
83
|
}
|
84
|
output.writeStartElement("table");
|
84
|
output.writeStartElement("table");
|
|
|
|
|
88
|
output.writeStartElement("tr");
|
88
|
output.writeStartElement("tr");
|
89
|
output.writeStartElement("th");
|
89
|
output.writeStartElement("th");
|
90
|
output.writeAttribute("colspan", "9");
|
90
|
output.writeAttribute("colspan", "9");
|
91
|
- output.writeCharacters("Regular Coffees");
|
|
|
|
|
91
|
+ output.writeCharacters(TTR("useandcostreport", "Regular Coffees"));
|
92
|
output.writeEndElement();
|
92
|
output.writeEndElement();
|
93
|
output.writeEndElement();
|
93
|
output.writeEndElement();
|
94
|
output.writeStartElement("tr");
|
94
|
output.writeStartElement("tr");
|
95
|
- output.writeTextElement("th", "Origin");
|
|
|
96
|
- output.writeTextElement("th", "Avg. Rate");
|
|
|
97
|
- output.writeTextElement("th", "Avg. Cost");
|
|
|
98
|
- output.writeTextElement("th", "Last Cost");
|
|
|
99
|
- output.writeTextElement("th", "Last Purchase Date");
|
|
|
100
|
- output.writeTextElement("th", "Bag Size (min)");
|
|
|
101
|
- output.writeTextElement("th", "Bag Size (max)");
|
|
|
102
|
- output.writeTextElement("th", "Bag Size (mean)");
|
|
|
103
|
- output.writeTextElement("th", "Purchases");
|
|
|
|
|
95
|
+ output.writeTextElement("th", TTR("useandcostreport", "Origin"));
|
|
|
96
|
+ output.writeTextElement("th", TTR("useandcostreport", "Avg. Rate"));
|
|
|
97
|
+ output.writeTextElement("th", TTR("useandcostreport", "Avg. Cost"));
|
|
|
98
|
+ output.writeTextElement("th", TTR("useandcostreport", "Last Cost"));
|
|
|
99
|
+ output.writeTextElement("th", TTR("useandcostreport", "Last Purchase Date"));
|
|
|
100
|
+ output.writeTextElement("th", TTR("useandcostreport", "Bag Size (min)"));
|
|
|
101
|
+ output.writeTextElement("th", TTR("useandcostreport", "Bag Size (max)"));
|
|
|
102
|
+ output.writeTextElement("th", TTR("useandcostreport", "Bag Size (mean)"));
|
|
|
103
|
+ output.writeTextElement("th", TTR("useandcostreport", "Purchases"));
|
104
|
output.writeEndElement();
|
104
|
output.writeEndElement();
|
105
|
output.writeEndElement();
|
105
|
output.writeEndElement();
|
106
|
output.writeStartElement("tbody");
|
106
|
output.writeStartElement("tbody");
|
|
|
|
|
164
|
output.writeStartElement("tr");
|
164
|
output.writeStartElement("tr");
|
165
|
output.writeStartElement("th");
|
165
|
output.writeStartElement("th");
|
166
|
output.writeAttribute("colspan", "9");
|
166
|
output.writeAttribute("colspan", "9");
|
167
|
- output.writeCharacters("Decaffeinated Coffees");
|
|
|
|
|
167
|
+ output.writeCharacters(TTR("useandcostreport", "Decaffeinated Coffees"));
|
168
|
output.writeEndElement();
|
168
|
output.writeEndElement();
|
169
|
output.writeEndElement();
|
169
|
output.writeEndElement();
|
170
|
query.prepare("WITH q AS (SELECT id, origin, rate/:c1 AS rate, (SELECT cost*:c2 FROM purchase WHERE item = id) AS cost, (SELECT min(time) FROM purchase WHERE item = id) AS purchase_time, (SELECT conversion/:c3 FROM lb_bag_conversion WHERE item = id) AS bag_weight FROM coffee_history WHERE id IN (SELECT id FROM decaf_coffees) AND id IN (SELECT item FROM transactions WHERE time >= :startDate AND time < :endDate::date + interval '1 day')) SELECT DISTINCT origin, avg(rate)::numeric(10,2) AS rate, avg(cost)::numeric(10,2) AS cost, (SELECT (cost*:c4)::numeric(10,2) FROM purchase WHERE item = max(q.id)) AS last_cost, max(purchase_time)::date AS last_purchase, min(bag_weight)::numeric(10,2) AS min_weight, max(bag_weight)::numeric(10,2) AS max_weight, avg(bag_weight)::numeric(10,2) AS mean_weight, count(1) AS n FROM q GROUP BY origin ORDER BY " + orderClause);
|
170
|
query.prepare("WITH q AS (SELECT id, origin, rate/:c1 AS rate, (SELECT cost*:c2 FROM purchase WHERE item = id) AS cost, (SELECT min(time) FROM purchase WHERE item = id) AS purchase_time, (SELECT conversion/:c3 FROM lb_bag_conversion WHERE item = id) AS bag_weight FROM coffee_history WHERE id IN (SELECT id FROM decaf_coffees) AND id IN (SELECT item FROM transactions WHERE time >= :startDate AND time < :endDate::date + interval '1 day')) SELECT DISTINCT origin, avg(rate)::numeric(10,2) AS rate, avg(cost)::numeric(10,2) AS cost, (SELECT (cost*:c4)::numeric(10,2) FROM purchase WHERE item = max(q.id)) AS last_cost, max(purchase_time)::date AS last_purchase, min(bag_weight)::numeric(10,2) AS min_weight, max(bag_weight)::numeric(10,2) AS max_weight, avg(bag_weight)::numeric(10,2) AS mean_weight, count(1) AS n FROM q GROUP BY origin ORDER BY " + orderClause);
|
|
|
|
|
229
|
tableref = "decaf_coffees";
|
229
|
tableref = "decaf_coffees";
|
230
|
}
|
230
|
}
|
231
|
var origin = rowData[Number(url.slice(1, url.length))];
|
231
|
var origin = rowData[Number(url.slice(1, url.length))];
|
232
|
- var details = '<tr><td /><td colspan="6"><table><tr><th>Id</th><th>Name</th><th>Rate</th><th>Cost</th><th>Inventory</th><th>First Use</th><th>Last Use</th></tr>';
|
|
|
|
|
232
|
+ var details = '<tr><td /><td colspan="6"><table><tr><th>' +
|
|
|
233
|
+ TTR("useandcostreport", "Id") + '</th><th>' +
|
|
|
234
|
+ TTR("useandcostreport", "Name") + '</th><th>' +
|
|
|
235
|
+ TTR("useandcostreport", "Rate") + '</th><th>' +
|
|
|
236
|
+ TTR("useandcostreport", "Cost") + '</th><th>' +
|
|
|
237
|
+ TTR("useandcostreport", "Inventory") + '</th><th>' +
|
|
|
238
|
+ TTR("useandcostreport", "First Use") + '</th><th>' +
|
|
|
239
|
+ TTR("useandcostreport", "Last Use") + '</th></tr>';
|
233
|
var query = new QSqlQuery();
|
240
|
var query = new QSqlQuery();
|
234
|
query.prepare("SELECT id, name, (rate/:conversion1)::numeric(12,3), (SELECT (cost*:conversion2)::numeric(12,2) FROM purchase WHERE item = id), (stock/:conversion3)::numeric(12,3), (SELECT min(time)::date FROM use WHERE item = id) AS first_use, (SELECT max(time)::date FROM use WHERE item = id) AS last_use FROM coffee_history WHERE origin = :origin AND id IN (SELECT id FROM " + tableref + ") AND id IN (SELECT item FROM transactions WHERE time >= :startDate AND time < :endDate::date + interval '1 day') ORDER BY first_use DESC");
|
241
|
query.prepare("SELECT id, name, (rate/:conversion1)::numeric(12,3), (SELECT (cost*:conversion2)::numeric(12,2) FROM purchase WHERE item = id), (stock/:conversion3)::numeric(12,3), (SELECT min(time)::date FROM use WHERE item = id) AS first_use, (SELECT max(time)::date FROM use WHERE item = id) AS last_use FROM coffee_history WHERE origin = :origin AND id IN (SELECT id FROM " + tableref + ") AND id IN (SELECT item FROM transactions WHERE time >= :startDate AND time < :endDate::date + interval '1 day') ORDER BY first_use DESC");
|
235
|
var conversion = 1;
|
242
|
var conversion = 1;
|