|
|
|
|
14
|
</menu>
|
14
|
</menu>
|
15
|
<program>
|
15
|
<program>
|
16
|
<![CDATA[
|
16
|
<![CDATA[
|
17
|
- this.windowTitle = "Typica - Inventory Change Summary";
|
|
|
|
|
17
|
+ this.windowTitle = TTR("invchange", "Typica - Inventory Change Summary");
|
18
|
var dateSelect = findChildObject(this, 'dates');
|
18
|
var dateSelect = findChildObject(this, 'dates');
|
19
|
var dateQuery = new QSqlQuery();
|
19
|
var dateQuery = new QSqlQuery();
|
20
|
dateQuery.exec("SELECT time::date FROM transactions WHERE time = (SELECT min(time) FROM transactions) OR time = (SELECT max(time) FROM transactions) ORDER BY time ASC");
|
20
|
dateQuery.exec("SELECT time::date FROM transactions WHERE time = (SELECT min(time) FROM transactions) OR time = (SELECT max(time) FROM transactions) ORDER BY time ASC");
|
|
|
|
|
29
|
dateSelect.setLifetimeRange(lifetimeStartDate, lifetimeEndDate);
|
29
|
dateSelect.setLifetimeRange(lifetimeStartDate, lifetimeEndDate);
|
30
|
dateQuery = dateQuery.invalidate();
|
30
|
dateQuery = dateQuery.invalidate();
|
31
|
var unitBox = findChildObject(this, 'unit');
|
31
|
var unitBox = findChildObject(this, 'unit');
|
32
|
- unitBox.addItem("Kg");
|
|
|
33
|
- unitBox.addItem("Lb");
|
|
|
|
|
32
|
+ unitBox.addItem(TTR("invchange", "Kg"));
|
|
|
33
|
+ unitBox.addItem(TTR("invchange", "Lb"));
|
34
|
unitBox.currentIndex = QSettings.value("script/report_unit", 1);
|
34
|
unitBox.currentIndex = QSettings.value("script/report_unit", 1);
|
35
|
unitBox['currentIndexChanged(int)'].connect(function() {
|
35
|
unitBox['currentIndexChanged(int)'].connect(function() {
|
36
|
QSettings.setValue("script/report_unit", unitBox.currentIndex);
|
36
|
QSettings.setValue("script/report_unit", unitBox.currentIndex);
|
|
|
|
|
50
|
output.writeStartElement("html");
|
50
|
output.writeStartElement("html");
|
51
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
51
|
output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
52
|
output.writeStartElement("head");
|
52
|
output.writeStartElement("head");
|
53
|
- output.writeTextElement("title", "Inventory Change Summary");
|
|
|
|
|
53
|
+ output.writeTextElement("title", TTR("invchange", "Inventory Change Summary"));
|
54
|
output.writeEndElement();
|
54
|
output.writeEndElement();
|
55
|
output.writeStartElement("body");
|
55
|
output.writeStartElement("body");
|
56
|
var dateRange = dateSelect.currentRange();
|
56
|
var dateRange = dateSelect.currentRange();
|
57
|
var startDate = dateRange[0];
|
57
|
var startDate = dateRange[0];
|
58
|
var endDate = dateRange[dateRange.length - 1];
|
58
|
var endDate = dateRange[dateRange.length - 1];
|
59
|
- output.writeTextElement("h1", "Inventory Change Summary: " + startDate + " – " + endDate);
|
|
|
|
|
59
|
+ output.writeTextElement("h1", TTR("invchange", "Inventory Change Summary: ") + startDate + " – " + endDate);
|
60
|
var conversion = 1;
|
60
|
var conversion = 1;
|
61
|
if(unitBox.currentIndex == 0) {
|
61
|
if(unitBox.currentIndex == 0) {
|
62
|
conversion = 2.2;
|
62
|
conversion = 2.2;
|
63
|
}
|
63
|
}
|
64
|
- var unitText = "Lb";
|
|
|
|
|
64
|
+ var unitText = TTR("invchange", "Lb");
|
65
|
if(unitBox.currentIndex == 0) {
|
65
|
if(unitBox.currentIndex == 0) {
|
66
|
- unitText = "Kg";
|
|
|
|
|
66
|
+ unitText = TTR("invchange", "Kg");
|
67
|
}
|
67
|
}
|
68
|
var query = new QSqlQuery();
|
68
|
var query = new QSqlQuery();
|
69
|
var q = "WITH q AS (SELECT id, name, reference, COALESCE((SELECT balance FROM item_history(id) WHERE time = (SELECT max(time) FROM item_history(id) WHERE time < :sd1)), 0)/:c1 AS starting_balance, COALESCE((SELECT sum(quantity) FROM purchase WHERE item = id AND time >= :sd2 AND time < :ed1 ::date + interval '1 day'), 0)/:c2 AS purchase, COALESCE((SELECT sum(quantity) FROM use WHERE item = id AND time >= :sd3 AND time < :ed2 ::date + interval '1 day'), 0)/:c3 AS use, COALESCE((SELECT sum(quantity) FROM sale WHERE item = id AND time >= :sd4 AND time < :ed3 ::date + interval '1 day'), 0)/:c4 AS sale, (SElECT balance FROM item_history(id) WHERE time = (SELECT max(time) FROM item_history(id) WHERE time < :ed4 ::date + interval '1 day'))/:c5 AS quantity, (SELECT sum(cost * quantity) / sum(quantity) FROM purchase WHERE item = id) AS unit_cost FROM coffees WHERE id IN (SELECT item FROM purchase WHERE time >= :sd6 AND time < :ed5 ::date + interval '1 day') OR id IN (SELECT id FROM items WHERE (SELECT balance FROM item_history(id) WHERE time = (SELECT max(time) FROM item_history(id) WHERE time < :ed6 ::date + interval '1 day')) > 0) OR id IN (SELECT DISTINCT item FROM all_transactions WHERE time > :sd7 AND time < :ed7 ::date + interval '1 day')) SELECT *, (starting_balance + purchase - use - sale - quantity) AS adjustment, starting_balance * unit_cost * :c8 AS starting_cost, purchase * unit_cost * :c9 AS purchase_cost, use * unit_cost * :c10 AS use_cost, sale * unit_cost * :c11 AS sale_cost, quantity * unit_cost * :c12 AS quantity_cost, (starting_balance + purchase - use - sale - quantity) * unit_cost * :c13 AS adjustment_cost, (SELECT sum(quantity)/:c6 FROM purchase WHERE item = id) AS total_purchase FROM q ORDER BY name";
|
69
|
var q = "WITH q AS (SELECT id, name, reference, COALESCE((SELECT balance FROM item_history(id) WHERE time = (SELECT max(time) FROM item_history(id) WHERE time < :sd1)), 0)/:c1 AS starting_balance, COALESCE((SELECT sum(quantity) FROM purchase WHERE item = id AND time >= :sd2 AND time < :ed1 ::date + interval '1 day'), 0)/:c2 AS purchase, COALESCE((SELECT sum(quantity) FROM use WHERE item = id AND time >= :sd3 AND time < :ed2 ::date + interval '1 day'), 0)/:c3 AS use, COALESCE((SELECT sum(quantity) FROM sale WHERE item = id AND time >= :sd4 AND time < :ed3 ::date + interval '1 day'), 0)/:c4 AS sale, (SElECT balance FROM item_history(id) WHERE time = (SELECT max(time) FROM item_history(id) WHERE time < :ed4 ::date + interval '1 day'))/:c5 AS quantity, (SELECT sum(cost * quantity) / sum(quantity) FROM purchase WHERE item = id) AS unit_cost FROM coffees WHERE id IN (SELECT item FROM purchase WHERE time >= :sd6 AND time < :ed5 ::date + interval '1 day') OR id IN (SELECT id FROM items WHERE (SELECT balance FROM item_history(id) WHERE time = (SELECT max(time) FROM item_history(id) WHERE time < :ed6 ::date + interval '1 day')) > 0) OR id IN (SELECT DISTINCT item FROM all_transactions WHERE time > :sd7 AND time < :ed7 ::date + interval '1 day')) SELECT *, (starting_balance + purchase - use - sale - quantity) AS adjustment, starting_balance * unit_cost * :c8 AS starting_cost, purchase * unit_cost * :c9 AS purchase_cost, use * unit_cost * :c10 AS use_cost, sale * unit_cost * :c11 AS sale_cost, quantity * unit_cost * :c12 AS quantity_cost, (starting_balance + purchase - use - sale - quantity) * unit_cost * :c13 AS adjustment_cost, (SELECT sum(quantity)/:c6 FROM purchase WHERE item = id) AS total_purchase FROM q ORDER BY name";
|
|
|
|
|
99
|
output.writeAttribute("cellpadding", "3px");
|
99
|
output.writeAttribute("cellpadding", "3px");
|
100
|
output.writeStartElement("thead");
|
100
|
output.writeStartElement("thead");
|
101
|
output.writeStartElement("tr");
|
101
|
output.writeStartElement("tr");
|
102
|
- output.writeTextElement("th", "ID"); // 0
|
|
|
103
|
- output.writeTextElement("th", "Coffee"); // 1
|
|
|
104
|
- output.writeTextElement("th", "Reference"); // 2
|
|
|
105
|
- output.writeTextElement("th", "Starting (" + unitText + ")"); // 3
|
|
|
106
|
- output.writeTextElement("th", "Cost"); // 10
|
|
|
107
|
- output.writeTextElement("th", "Purchase (" + unitText + ")"); // 4
|
|
|
108
|
- output.writeTextElement("th", "Cost"); // 11
|
|
|
109
|
- output.writeTextElement("th", "Use (" + unitText + ")"); // 5
|
|
|
110
|
- output.writeTextElement("th", "Cost"); // 12
|
|
|
111
|
- output.writeTextElement("th", "Sale (" + unitText + ")"); // 6
|
|
|
112
|
- output.writeTextElement("th", "Cost"); // 13
|
|
|
113
|
- output.writeTextElement("th", "Adjustment (" + unitText + ")"); // 9
|
|
|
114
|
- output.writeTextElement("th", "Cost"); // 15
|
|
|
115
|
- output.writeTextElement("th", "Ending (" + unitText + ")"); // 7
|
|
|
116
|
- output.writeTextElement("th", "Cost"); // 14
|
|
|
|
|
102
|
+ output.writeTextElement("th", TTR("invchange", "ID")); // 0
|
|
|
103
|
+ output.writeTextElement("th", TTR("invchange", "Coffee")); // 1
|
|
|
104
|
+ output.writeTextElement("th", TTR("invchange", "Reference")); // 2
|
|
|
105
|
+ output.writeTextElement("th", TTR("invchange", "Starting (") + unitText + ")"); // 3
|
|
|
106
|
+ output.writeTextElement("th", TTR("invchange", "Cost")); // 10
|
|
|
107
|
+ output.writeTextElement("th", TTR("invchange", "Purchase (") + unitText + ")"); // 4
|
|
|
108
|
+ output.writeTextElement("th", TTR("invchange", "Cost")); // 11
|
|
|
109
|
+ output.writeTextElement("th", TTR("invchange", "Use (") + unitText + ")"); // 5
|
|
|
110
|
+ output.writeTextElement("th", TTR("invchange", "Cost")); // 12
|
|
|
111
|
+ output.writeTextElement("th", TTR("invchange", "Sale (") + unitText + ")"); // 6
|
|
|
112
|
+ output.writeTextElement("th", TTR("invchange", "Cost")); // 13
|
|
|
113
|
+ output.writeTextElement("th", TTR("invchange", "Adjustment (") + unitText + ")"); // 9
|
|
|
114
|
+ output.writeTextElement("th", TTR("invchange", "Cost")); // 15
|
|
|
115
|
+ output.writeTextElement("th", TTR("invchange", "Ending (") + unitText + ")"); // 7
|
|
|
116
|
+ output.writeTextElement("th", TTR("invchange", "Cost")); // 14
|
117
|
output.writeEndElement();
|
117
|
output.writeEndElement();
|
118
|
output.writeEndElement();
|
118
|
output.writeEndElement();
|
119
|
output.writeStartElement("tbody");
|
119
|
output.writeStartElement("tbody");
|
|
|
|
|
189
|
output.writeStartElement("tr");
|
189
|
output.writeStartElement("tr");
|
190
|
output.writeTextElement("td", "");
|
190
|
output.writeTextElement("td", "");
|
191
|
output.writeTextElement("td", "");
|
191
|
output.writeTextElement("td", "");
|
192
|
- output.writeTextElement("th", "Total:");
|
|
|
|
|
192
|
+ output.writeTextElement("th", TTR("invchange", "Total:"));
|
193
|
output.writeTextElement("td", sum3.toFixed(2));
|
193
|
output.writeTextElement("td", sum3.toFixed(2));
|
194
|
output.writeTextElement("td", sum10.toFixed(2));
|
194
|
output.writeTextElement("td", sum10.toFixed(2));
|
195
|
output.writeTextElement("td", sum4.toFixed(2));
|
195
|
output.writeTextElement("td", sum4.toFixed(2));
|