Typica is a free program for professional coffee roasters. https://typica.us
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

fypurchase.xml 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <window id="fypurchase">
  2. <reporttitle>Purchase:->Coffee Purchase Previous Years Comparison</reporttitle>
  3. <layout type="vertical">
  4. <layout type="horizontal">
  5. <label>Start Date:</label>
  6. <calendar id="startdate" />
  7. <label>End Date:</label>
  8. <calendar id="enddate" />
  9. <stretch />
  10. </layout>
  11. <webview id="report" />
  12. </layout>
  13. <menu name="File">
  14. <item id="print" shortcut="Ctrl+P">Print</item>
  15. </menu>
  16. <program>
  17. <![CDATA[
  18. this.windowTitle = "Typica - Coffee Purchase Previous Years Comparison";
  19. var startDateField = findChildObject(this, 'startdate');
  20. var query = new QSqlQuery();
  21. query.exec("SELECT EXTRACT(YEAR FROM time) FROM purchase WHERE time = (SELECT min(time) FROM purchase)");
  22. query.next();
  23. startDateField.setDate(query.value(0), 1, 1);
  24. var endDateField = findChildObject(this, 'enddate');
  25. endDateField.setDate(endDateField.year(), 12, 31);
  26. var view = findChildObject(this, 'report');
  27. var printMenu = findChildObject(this, 'print');
  28. printMenu.triggered.connect(function() {
  29. view.print();
  30. });
  31. function refresh() {
  32. var buffer = new QBuffer;
  33. buffer.open(3);
  34. var output = new XmlWriter(buffer);
  35. output.writeStartDocument("1.0");
  36. output.writeDTD('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg.dtd">');
  37. output.writeStartElement("html");
  38. output.writeAttribute("xmlns", "http://www.w3.org/1999/xhtml");
  39. output.writeStartElement("head");
  40. output.writeTextElement("title", "Coffee Purchase Previous Years Comparison");
  41. output.writeEndElement();
  42. output.writeStartElement("body");
  43. output.writeTextElement("h1", "Coffee Purchase Previous Years Comparison");
  44. output.writeStartElement("table");
  45. output.writeAttribute("style", "page-break-after:auto;");
  46. output.writeAttribute("rules", "groups");
  47. output.writeAttribute("cellpadding", "3px");
  48. output.writeStartElement("thead");
  49. output.writeStartElement("tr");
  50. output.writeEmptyElement("th");
  51. for(var i = startDateField.year(); i <= endDateField.year(); i++)
  52. {
  53. output.writeTextElement("th", i);
  54. }
  55. output.writeEndElement();
  56. output.writeEndElement();
  57. output.writeStartElement("tbody");
  58. output.writeStartElement("tr");
  59. output.writeTextElement("th", "Sacks Purchased");
  60. var j = 0;
  61. var sacks = new Array;
  62. for(var i = startDateField.year(); i <= endDateField.year(); i++)
  63. {
  64. var q = "SELECT sum(quantity/(SELECT conversion FROM lb_bag_conversion WHERE item = purchase.item)) FROM purchase WHERE time >= '" + i + "-01-01' AND time < '" + (i+1) + "-01-01'";
  65. query.exec(q);
  66. query.next();
  67. output.writeTextElement("td", query.value(0));
  68. sacks[j] = query.value(0);
  69. j++;
  70. }
  71. output.writeEndElement();
  72. output.writeStartElement("tr");
  73. output.writeTextElement("th", "Pounds Purchased");
  74. j = 0;
  75. var pounds = new Array;
  76. for(var i = startDateField.year(); i <= endDateField.year(); i++)
  77. {
  78. var q = "SELECT sum(quantity) FROM purchase WHERE time >= '" + i + "-01-01' AND time < '" + (i+1) + "-01-01'";
  79. query.exec(q);
  80. query.next();
  81. output.writeTextElement("td", query.value(0));
  82. pounds[j] = query.value(0);
  83. j++;
  84. }
  85. output.writeEndElement();
  86. output.writeStartElement("tr");
  87. output.writeTextElement("th", "Cost");
  88. j = 0;
  89. var cost = new Array;
  90. for(var i = startDateField.year(); i <= endDateField.year(); i++)
  91. {
  92. var q = "SELECT sum(cost*quantity)::numeric(12,2) FROM purchase WHERE time >= '" + i + "-01-01' AND time < '" + (i+1) + "-01-01'";
  93. query.exec(q);
  94. query.next();
  95. output.writeTextElement("td", query.value(0));
  96. cost[j] = query.value(0);
  97. j++;
  98. }
  99. output.writeEndElement();
  100. output.writeEndElement();
  101. output.writeStartElement("tfoot");
  102. output.writeEndElement();
  103. output.writeEndElement();
  104. output.writeEndElement();
  105. output.writeEndElement();
  106. output.writeEndDocument();
  107. view.setContent(buffer);
  108. buffer.close();
  109. }
  110. refresh();
  111. startDateField.dateChanged.connect(function() {
  112. refresh();
  113. });
  114. endDateField.dateChanged.connect(function() {
  115. refresh();
  116. });
  117. ]]>
  118. </program>
  119. </window>