瀏覽代碼

Add percentages to weights in inventory change summary report.

Neal Wilson 11 年之前
父節點
當前提交
c413baa7b9
共有 1 個文件被更改,包括 26 次插入8 次删除
  1. 26
    8
      config/Reports/invchange.xml

+ 26
- 8
config/Reports/invchange.xml 查看文件

@@ -58,7 +58,7 @@
58 58
 					unitText = "Kg";
59 59
 				}
60 60
 				var query = new QSqlQuery();
61
-					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)/:c7 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 FROM q ORDER BY name";
61
+					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)/:c7 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";
62 62
 				query.prepare(q);
63 63
 				query.bind(":sd1", startDate);
64 64
 				query.bind(":sd2", startDate);
@@ -78,7 +78,7 @@
78 78
 				query.bind(":c3", conversion);
79 79
 				query.bind(":c4", conversion);
80 80
 				query.bind(":c5", conversion);
81
-
81
+				query.bind(":c6", conversion);
82 82
 				query.bind(":c7", conversion);
83 83
 				query.bind(":c8", conversion);
84 84
 				query.bind(":c9", conversion);
@@ -133,17 +133,35 @@
133 133
 					output.writeEndElement();
134 134
 					output.writeTextElement("td", query.value(1)); //Coffee
135 135
 					output.writeTextElement("td", query.value(2)); //Reference
136
-					output.writeTextElement("td", parseFloat(query.value(3)).toFixed(2)); //Starting Wt
136
+					output.writeStartElement("td"); //Starting Wt
137
+					output.writeAttribute("title", (parseFloat(query.value(3))/parseFloat(query.value(16)) * 100).toFixed(0) + "%");
138
+					output.writeCDATA(parseFloat(query.value(3)).toFixed(2));
139
+					output.writeEndElement(); //End of Starting Wt.
137 140
 					output.writeTextElement("td", parseFloat(query.value(10)).toFixed(2)); //Starting Cost
138
-					output.writeTextElement("td", parseFloat(query.value(4)).toFixed(2)); //Purchase Wt
141
+					output.writeStartElement("td"); //Purchase Wt
142
+					output.writeAttribute("title", (parseFloat(query.value(4))/parseFloat(query.value(16)) * 100).toFixed(0) + "%");
143
+					output.writeCDATA(parseFloat(query.value(4)).toFixed(2));
144
+					output.writeEndElement(); //End of Purchase Wt
139 145
 					output.writeTextElement("td", parseFloat(query.value(11)).toFixed(2)); //Purchase Cost
140
-					output.writeTextElement("td", parseFloat(query.value(5)).toFixed(2)); //Use Wt
146
+					output.writeStartElement("td"); //Use Wt
147
+					output.writeAttribute("title", (parseFloat(query.value(5))/parseFloat(query.value(16)) * 100).toFixed(0) + "%");
148
+					output.writeCDATA(parseFloat(query.value(5)).toFixed(2));
149
+					output.writeEndElement(); //End of Use Wt
141 150
 					output.writeTextElement("td", parseFloat(query.value(12)).toFixed(2)); //Use Cost
142
-					output.writeTextElement("td", parseFloat(query.value(6)).toFixed(2)); //Sale Wt
151
+					output.writeStartElement("td"); //Sale Wt
152
+					output.writeAttribute("title", (parseFloat(query.value(6))/parseFloat(query.value(16)) * 100).toFixed(0) + "%");
153
+					output.writeCDATA(parseFloat(query.value(6)).toFixed(2));
154
+					output.writeEndElement(); //End of Sale Wt
143 155
 					output.writeTextElement("td", parseFloat(query.value(13)).toFixed(2)); //Sale Cost
144
-					output.writeTextElement("td", parseFloat(query.value(9)).toFixed(2)); //Adjustment Wt
156
+					output.writeStartElement("td"); //Adjustment Wt
157
+					output.writeAttribute("title", (parseFloat(query.value(9))/parseFloat(query.value(16)) * 100).toFixed(0) + "%");
158
+					output.writeCDATA(parseFloat(query.value(9)).toFixed(2));
159
+					output.writeEndElement(); //Adjustment Wt
145 160
 					output.writeTextElement("td", parseFloat(query.value(15)).toFixed(2)); //Adjustment Cost
146
-					output.writeTextElement("td", parseFloat(query.value(7)).toFixed(2)); //Ending Wt
161
+					output.writeStartElement("td"); //Ending Wt
162
+					output.writeAttribute("title", (parseFloat(query.value(7))/parseFloat(query.value(16)) * 100).toFixed(0) + "%");
163
+					output.writeCDATA(parseFloat(query.value(7)).toFixed(2));
164
+					output.writeEndElement(); //End of Ending Wt
147 165
 					output.writeTextElement("td", parseFloat(query.value(14)).toFixed(2)); //Ending Cost
148 166
 					output.writeEndElement();
149 167
 					sum3 += parseFloat(query.value(3));

Loading…
取消
儲存