Typica is a free program for professional coffee roasters. https://typica.us
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

editinvoiceitem.xml 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <window id="invoiceitemdetail">
  2. <layout type="vertical">
  3. <layout type="grid">
  4. <row>
  5. <column><label>Name</label></column>
  6. <column><line id="name" /></column>
  7. </row>
  8. <row>
  9. <column><label>Reference</label></column>
  10. <column><line id="reference" /></column>
  11. </row>
  12. <row>
  13. <column><label>Unit Cost</label></column>
  14. <column><line validator="numeric" id="cost" /></column>
  15. </row>
  16. <row>
  17. <column><label>Quantity</label></column>
  18. <column><line validator="numeric" id="quantity" /></column>
  19. </row>
  20. <row>
  21. <column><label>Bags</label></column>
  22. <column><line validator="numeric" id="bags" /></column>
  23. </row>
  24. </layout>
  25. <button name="Submit" type="push" id="submit" />
  26. </layout>
  27. <program>
  28. <![CDATA[
  29. window = this;
  30. this.windowTitle = 'Typica - Item Detail';
  31. var nameField = findChildObject(this, 'name');
  32. var referenceField = findChildObject(this, 'reference');
  33. var costField = findChildObject(this, 'cost');
  34. var quantityField = findChildObject(this, 'quantity');
  35. var bagsField = findChildObject(this, 'bags');
  36. this.dataSet = function() {
  37. nameField.text = window.rowData[2];
  38. referenceField.text = window.rowData[3];
  39. costField.text = window.rowData[4];
  40. quantityField.text = window.rowData[5];
  41. bagsField.text = window.rowData[6];
  42. };
  43. button = findChildObject(this, 'submit');
  44. button.clicked.connect(function() {
  45. var query = new QSqlQuery();
  46. if(nameField.text != window.rowData[2]) {
  47. query.prepare("UPDATE items SET name = :name WHERE id = :id");
  48. query.bind(":name", nameField.text);
  49. query.bind(":id", Number(window.rowData[1]));
  50. query.exec();
  51. query.prepare("UPDATE invoice_items SET description = :name WHERE item_id = :id");
  52. query.bind(":name", nameField.text);
  53. query.bind(":id", Number(window.rowData[1]));
  54. query.exec();
  55. window.rowData[2] = nameField.text;
  56. }
  57. if(referenceField.text != window.rowData[3]) {
  58. query.prepare("UPDATE items SET reference = :ref WHERE id = :id");
  59. query.bind(":ref", referenceField.text);
  60. query.bind(":id", Number(window.rowData[1]));
  61. query.exec();
  62. window.rowData[3] = referenceField.text;
  63. }
  64. var cqupdated = false;
  65. var qbupdated = false;
  66. if(costField.text != window.rowData[4]) {
  67. cqupdated = true;
  68. query.prepare("UPDATE purchase SET cost = :cost WHERE item = :id");
  69. query.bind(":cost", Number(costField.text));
  70. query.bind(":id", Number(window.rowData[1]));
  71. query.exec();
  72. window.rowData[4] = costField.text;
  73. }
  74. if(quantityField.text != window.rowData[5]) {
  75. cqupdated = true;
  76. qbupdated = true;
  77. query.prepare("UPDATE purchase SET quantity = :qty WHERE item = :id");
  78. query.bind(":qty", Number(quantityField.text));
  79. query.bind(":id", Number(window.rowData[1]));
  80. query.exec();
  81. window.rowData[5] = quantityField.text;
  82. query.prepare("UPDATE items SET quantity = (SELECT balance FROM item_history(:id) WHERE time = (SELECT max(time) FROM item_history(:id2))) WHERE id = :id3");
  83. query.bind(":id", Number(window.rowData[1]));
  84. query.bind(":id2", Number(window.rowData[1]));
  85. query.bind(":id3", Number(window.rowData[1]));
  86. query.exec();
  87. }
  88. if(bagsField.text != window.rowData[6]) {
  89. qbupdated = true;
  90. window.rowData[6] = bagsField.text;
  91. }
  92. if(cqupdated) {
  93. query.prepare("UPDATE invoice_items SET cost = :total WHERE item_id = :id");
  94. query.bind(":total", Number(window.rowData[5]) * Number(window.rowData[4]));
  95. query.bind(":id", Number(window.rowData[1]));
  96. query.exec();
  97. }
  98. if(qbupdated) {
  99. query.prepare("UPDATE lb_bag_conversion SET conversion = :conv WHERE item = :id");
  100. query.bind(":conv", Number(window.rowData[5]) / Number(window.rowData[6]));
  101. query.bind(":id", Number(window.rowData[1]));
  102. query.exec();
  103. }
  104. query = query.invalidate();
  105. window.close();
  106. });
  107. ]]>
  108. </program>
  109. </window>