瀏覽代碼

Limit precision on quantities to 3 places.

Neal Wilson 9 年之前
父節點
當前提交
9cc675fb7f
共有 1 個文件被更改,包括 18 次插入16 次删除
  1. 18
    16
      config/Reports/itemtransactions.xml

+ 18
- 16
config/Reports/itemtransactions.xml 查看文件

@@ -201,30 +201,32 @@
201 201
 					var prev_balance = "0";
202 202
 					var prev_prec = 0;
203 203
 					var cur_prec = 0;
204
+                                        var max_prec = 3;
204 205
 					while(query.next()) {
205 206
 						output.writeStartElement("tr");
206 207
 						output.writeAttribute("class", query.value(1));
207 208
 						output.writeTextElement("td", query.value(0));
208 209
 						output.writeTextElement("td", query.value(1));
210
+                                                var split = prev_balance.split('.');
211
+                                                if(split.length > 1) {
212
+                                                    prev_prec = split[1].length;
213
+                                                } else {
214
+                                                    prev_prec = 0;
215
+                                                }
216
+                                                split = query.value(2).split('.');
217
+                                                if(split.length > 1) {
218
+                                                    cur_prec = split[1].length;
219
+                                                } else {
220
+                                                    cur_prec = 0;
221
+                                                }
222
+                                                var prec = prev_prec > cur_prec ? prev_prec : cur_prec;
223
+                                                var prec = (prec > max_prec ? max_prec : prec);
209 224
 						if(query.value(1) == "INVENTORY") {
210
-							var split = prev_balance.split('.');
211
-							if(split.length > 1) {
212
-								prev_prec = split[1].length;
213
-							} else {
214
-								prev_prec = 0;
215
-							}
216
-							split = query.value(2).split('.');
217
-							if(split.length > 1) {
218
-								cur_prec = split[1].length;
219
-							} else {
220
-								cur_prec = 0;
221
-							}
222
-							var prec = prev_prec > cur_prec ? prev_prec : cur_prec;
223
-							output.writeTextElement("td", (Number(query.value(2)) - Number(prev_balance)).toFixed(prec));
225
+                                                    output.writeTextElement("td", (Number(query.value(2)) - Number(prev_balance)).toFixed(prec));
224 226
 						} else {
225
-							output.writeTextElement("td", query.value(2));
227
+                                                    output.writeTextElement("td", (Number(query.value(2)).toFixed(prec)));
226 228
 						}
227
-						output.writeTextElement("td", query.value(3));
229
+						output.writeTextElement("td", (Number(query.value(3)).toFixed(prec)));
228 230
 						prev_balance = query.value(3);
229 231
 						if(query.value(1) == "PURCHASE") {
230 232
 							output.writeStartElement("td");

Loading…
取消
儲存