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.

greeninventory.xml 4.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <window id="inventory">
  2. <layout type="vertical">
  3. <layout type="horizontal">
  4. <label>Transaction type: </label>
  5. <sqldrop id="transactiontype" />
  6. <stretch />
  7. </layout>
  8. <layout type="horizontal">
  9. <sqldrop data="0" display="1" showdata="true" id="item">
  10. <query><![CDATA[SELECT id, name FROM coffees WHERE quantity <> 0 ORDER BY name ASC]]></query>
  11. </sqldrop>
  12. <line id="quantity" />
  13. <sqldrop id="units" />
  14. <layout type="stack" id="optional">
  15. <page />
  16. <page>
  17. <layout type="horizontal">
  18. <label id="reasonlabel">Reason: </label>
  19. <line id="reason" />
  20. </layout>
  21. </page>
  22. </layout>
  23. </layout>
  24. <layout type="horizontal">
  25. <button type="push" name="Update" id="update" />
  26. <stretch />
  27. </layout>
  28. <textarea id="current" />
  29. </layout>
  30. <program>
  31. <![CDATA[
  32. var types = findChildObject(this, 'transactiontype');
  33. types.addItem(TTR("inventory", "inventory"));
  34. types.addItem(TTR("inventory", "loss");
  35. var optionalDisplay = findChildObject(this, 'optional');
  36. var units = findChildObject(this, 'units');
  37. units.addItem(TTR("inventory", "bag"));
  38. units.addItem(TTR("inventory", "Lb"));
  39. units.addItem(TTR("inventory", "Kg"));
  40. var items = findChildObject(this, 'item');
  41. var status = findChildObject(this, 'current');
  42. function updateStatus() {
  43. query = new QSqlQuery();
  44. query.prepare("SELECT quantity, (quantity / 2.2)::numeric(12,3), (quantity / (SELECT conversion FROM lb_bag_conversion WHERE item = :id1))::numeric(12,2) FROM items WHERE id = :id2");
  45. query.bind(":id1", items.currentData());
  46. query.bind(":id2", items.currentData());
  47. query.exec();
  48. query.next();
  49. var text = items.currentText;
  50. text += " Current inventory: ";
  51. text += query.value(0);
  52. text += TTR("inventory", " Lb (");
  53. text += query.value(1);
  54. text += TTR("inventory", " Kg), ");
  55. text += query.value(2);
  56. text += (query.value(2) == "1" ? TTR("inventory", " bag") :
  57. TTR("inventory", " bags"));
  58. query = query.invalidate();
  59. status.plainText = text;
  60. }
  61. var button = findChildObject(this, 'update');
  62. var value = findChildObject(this, 'quantity');
  63. var reason = findChildObject(this, 'reason');
  64. var reasonlabel = findChildObject(this, 'reasonlabel');
  65. reason.enabled = false;
  66. button.clicked.connect(function() {
  67. q = "INSERT INTO ";
  68. q += (types.currentIndex == 0 ?
  69. "inventory (time, item, quantity)" :
  70. "loss (time, item, quantity, reason)");
  71. q += " VALUES ('now', ";
  72. q = q + items.currentData();
  73. q = q + ", ";
  74. if(units.currentText == TTR("inventory", "Lb")) {
  75. q = q + value.text;
  76. } else if (units.currentText == TTR("inventory", "Kg")) {
  77. q = q + (value.text * 2.2);
  78. }
  79. else {
  80. q = q + value.text;
  81. q = q + " * (SELECT conversion FROM lb_bag_conversion WHERE item = ";
  82. q = q + items.currentData();
  83. q = q + ")";
  84. }
  85. q += (types.currentIndex == 0 ?
  86. ")" :
  87. ", '" + reason.text + "')");
  88. query = new QSqlQuery();
  89. query.exec(q);
  90. updateStatus();
  91. });
  92. items['currentIndexChanged(int)'].connect(updateStatus);
  93. types['currentIndexChanged(int)'].connect(optionalDisplay.setCurrentIndex);
  94. updateStatus();
  95. ]]>
  96. </program>
  97. </window>