Browse Source

Update invoice info on line item change

Neal Wilson 5 years ago
parent
commit
d7abb31de1

+ 0
- 12
config/Reports/invoices.xml View File

44
             view.scriptLinkClicked.connect(function(url) {
44
             view.scriptLinkClicked.connect(function(url) {
45
                 var info = createWindow("invoiceinfo");
45
                 var info = createWindow("invoiceinfo");
46
                 info.setInvoiceID(url);
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
             function refresh() {
48
             function refresh() {
61
                 var dateRange = dateSelect.currentRange();
49
                 var dateRange = dateSelect.currentRange();

+ 1
- 0
config/Windows/editfee.xml View File

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

+ 4
- 1
config/Windows/editinvoiceitem.xml View File

96
                     query.exec();
96
                     query.exec();
97
                 }
97
                 }
98
                 if(qbupdated) {
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
                     if(query.next()) {
102
                     if(query.next()) {
101
                         query.prepare("UPDATE lb_bag_conversion SET conversion = :conv WHERE item = :id");
103
                         query.prepare("UPDATE lb_bag_conversion SET conversion = :conv WHERE item = :id");
102
                     } else {
104
                     } else {
107
                     query.exec();
109
                     query.exec();
108
                 }
110
                 }
109
                 query = query.invalidate();
111
                 query = query.invalidate();
112
+				window.pWindow.refresh();
110
                 window.close();
113
                 window.close();
111
             });
114
             });
112
         ]]>
115
         ]]>

+ 22
- 5
config/Windows/invoiceinfo.xml View File

14
 	<program>
14
 	<program>
15
 		<![CDATA[
15
 		<![CDATA[
16
 			var window = this;
16
 			var window = this;
17
-                        var invoiceID = 0;
17
+            var invoiceID = 0;
18
 			var table = findChildObject(this, 'itemtable');
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
 			this.setInvoiceID = function(arg) {
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
 			button = findChildObject(this, 'edit');
39
 			button = findChildObject(this, 'edit');
25
 			button.clicked.connect(function() {
40
 			button.clicked.connect(function() {
34
 				if(table.data(arg, 0) == 'PURCHASE') {
49
 				if(table.data(arg, 0) == 'PURCHASE') {
35
 					var itemWindow = createWindow("invoiceitemdetail");
50
 					var itemWindow = createWindow("invoiceitemdetail");
36
 					itemWindow.rowData = [];
51
 					itemWindow.rowData = [];
52
+					itemWindow.pWindow = w;
37
 					for(var i = 0; i < 8; i++) {
53
 					for(var i = 0; i < 8; i++) {
38
 						itemWindow.rowData[i] = table.data(arg, i);
54
 						itemWindow.rowData[i] = table.data(arg, i);
39
 					}
55
 					}
42
 				else {
58
 				else {
43
 					var feeWindow = createWindow("invoicefeedetail");
59
 					var feeWindow = createWindow("invoicefeedetail");
44
 					feeWindow.rowData = [];
60
 					feeWindow.rowData = [];
61
+					feeWindow.pWindow = w;
45
 					for(var i = 0; i < 8; i++) {
62
 					for(var i = 0; i < 8; i++) {
46
 						feeWindow.rowData[i] = table.data(arg, i);
63
 						feeWindow.rowData[i] = table.data(arg, i);
47
 					}
64
 					}
48
-                                        feeWindow.invoiceID = invoiceID;
65
+                    feeWindow.invoiceID = invoiceID;
49
 					feeWindow.dataSet();
66
 					feeWindow.dataSet();
50
 				}
67
 				}
51
 			});
68
 			});

Loading…
Cancel
Save