Преглед на файлове

Update invoice info on line item change

Neal Wilson преди 6 години
родител
ревизия
d7abb31de1
променени са 4 файла, в които са добавени 27 реда и са изтрити 18 реда
  1. 0
    12
      config/Reports/invoices.xml
  2. 1
    0
      config/Windows/editfee.xml
  3. 4
    1
      config/Windows/editinvoiceitem.xml
  4. 22
    5
      config/Windows/invoiceinfo.xml

+ 0
- 12
config/Reports/invoices.xml Целия файл

@@ -44,18 +44,6 @@
44 44
             view.scriptLinkClicked.connect(function(url) {
45 45
                 var info = createWindow("invoiceinfo");
46 46
                 info.setInvoiceID(url);
47
-                var invquery = new QSqlQuery();
48
-                invquery.exec("SELECT time, invoice, vendor FROM invoices WHERE id = " + url);
49
-                invquery.next();
50
-                var timefield = findChildObject(info, 'date');
51
-                timefield.text = invquery.value(0);
52
-                var vendorfield = findChildObject(info, 'vendor');
53
-                vendorfield.text = invquery.value(2);
54
-                var invoicefield = findChildObject(info, 'invoice');
55
-                invoicefield.text = invquery.value(1);
56
-                var itemtable = findChildObject(info, 'itemtable');
57
-                itemtable.setQuery("SELECT record_type, item_id, description, (SELECT reference FROM items WHERE id = item_id) AS reference, (SELECT cost FROM purchase WHERE item = item_id) AS unit_cost, (SELECT quantity FROM purchase WHERE item = item_id) AS quantity, ((SELECT quantity FROM purchase WHERE item = item_id)/(SELECT conversion FROM lb_bag_conversion WHERE item = item_id))::numeric(12,2) AS sacks, cost FROM invoice_items WHERE invoice_id = " + url + " AND record_type = 'PURCHASE' UNION SELECT record_type, NULL, description, NULL, NULL, NULL, NULL, cost FROM invoice_items WHERE invoice_id = " + url + " AND record_type = 'FEE' ORDER BY item_id");
58
-                invquery = invquery.invalidate();
59 47
             });
60 48
             function refresh() {
61 49
                 var dateRange = dateSelect.currentRange();

+ 1
- 0
config/Windows/editfee.xml Целия файл

@@ -35,6 +35,7 @@
35 35
 				query.bind(":oldcost", window.rowData[7]);
36 36
 				query.exec();
37 37
 				query = query.invalidate();
38
+				window.pWindow.refresh();
38 39
 				window.close();
39 40
 			});
40 41
 		]]>

+ 4
- 1
config/Windows/editinvoiceitem.xml Целия файл

@@ -96,7 +96,9 @@
96 96
                     query.exec();
97 97
                 }
98 98
                 if(qbupdated) {
99
-                    query.exec("SELECT 1 FROM lb_bag_conversion WHERE item = :id");
99
+                    query.prepare("SELECT 1 FROM lb_bag_conversion WHERE item = :id");
100
+					query.bind(":id", Number(window.rowData[1]));
101
+					query.exec();
100 102
                     if(query.next()) {
101 103
                         query.prepare("UPDATE lb_bag_conversion SET conversion = :conv WHERE item = :id");
102 104
                     } else {
@@ -107,6 +109,7 @@
107 109
                     query.exec();
108 110
                 }
109 111
                 query = query.invalidate();
112
+				window.pWindow.refresh();
110 113
                 window.close();
111 114
             });
112 115
         ]]>

+ 22
- 5
config/Windows/invoiceinfo.xml Целия файл

@@ -14,12 +14,27 @@
14 14
 	<program>
15 15
 		<![CDATA[
16 16
 			var window = this;
17
-                        var invoiceID = 0;
17
+            var invoiceID = 0;
18 18
 			var table = findChildObject(this, 'itemtable');
19
+			var timefield = findChildObject(this, 'date');
20
+			var vendorfield = findChildObject(this, 'vendor');
21
+			var invoicefield = findChildObject(this, 'invoice');
22
+			var w = window;
19 23
 			this.setInvoiceID = function(arg) {
20
-				window.invoiceID = arg;
21
-                                invoiceID = arg;
22
-				window.windowTitle = TTR("invoiceinfo", "Typica - Invoice Details ") + arg;
24
+				w.invoiceID = arg;
25
+                invoiceID = arg;
26
+				w.windowTitle = TTR("invoiceinfo", "Typica - Invoice Details ") + arg;
27
+                var query = new QSqlQuery();
28
+                query.exec("SELECT time, invoice, vendor FROM invoices WHERE id = " + arg);
29
+                query.next();
30
+                timefield.text = query.value(0);
31
+                vendorfield.text = query.value(2);
32
+                invoicefield.text = query.value(1);
33
+                table.setQuery("SELECT record_type, item_id, description, (SELECT reference FROM items WHERE id = item_id) AS reference, (SELECT cost FROM purchase WHERE item = item_id) AS unit_cost, (SELECT quantity FROM purchase WHERE item = item_id) AS quantity, ((SELECT quantity FROM purchase WHERE item = item_id)/(SELECT conversion FROM lb_bag_conversion WHERE item = item_id))::numeric(12,2) AS sacks, cost FROM invoice_items WHERE invoice_id = " + arg + " AND record_type = 'PURCHASE' UNION SELECT record_type, NULL, description, NULL, NULL, NULL, NULL, cost FROM invoice_items WHERE invoice_id = " + arg + " AND record_type = 'FEE' ORDER BY item_id");
34
+                query = query.invalidate();
35
+			};
36
+			this.refresh = function() {
37
+				w.setInvoiceID(w.invoiceID);
23 38
 			};
24 39
 			button = findChildObject(this, 'edit');
25 40
 			button.clicked.connect(function() {
@@ -34,6 +49,7 @@
34 49
 				if(table.data(arg, 0) == 'PURCHASE') {
35 50
 					var itemWindow = createWindow("invoiceitemdetail");
36 51
 					itemWindow.rowData = [];
52
+					itemWindow.pWindow = w;
37 53
 					for(var i = 0; i < 8; i++) {
38 54
 						itemWindow.rowData[i] = table.data(arg, i);
39 55
 					}
@@ -42,10 +58,11 @@
42 58
 				else {
43 59
 					var feeWindow = createWindow("invoicefeedetail");
44 60
 					feeWindow.rowData = [];
61
+					feeWindow.pWindow = w;
45 62
 					for(var i = 0; i < 8; i++) {
46 63
 						feeWindow.rowData[i] = table.data(arg, i);
47 64
 					}
48
-                                        feeWindow.invoiceID = invoiceID;
65
+                    feeWindow.invoiceID = invoiceID;
49 66
 					feeWindow.dataSet();
50 67
 				}
51 68
 			});

Loading…
Отказ
Запис