An easy point of sale system with automatic inventory tracking. https://netsyms.biz/apps/nickelbox/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pos.js 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. */
  6. var nickelbridge = false;
  7. var receiptwidth = 48;
  8. function recalculate() {
  9. removezero();
  10. var total = 0.0;
  11. var paid = 0.0;
  12. var remaining = 0.0;
  13. var change = 0.0;
  14. $("#pos-lines-box .list-group-item").each(function () {
  15. var each = $(".item-price", this).val() * 1.0;
  16. var qty = $(".item-qty", this).val() * 1.0;
  17. var line = each * qty;
  18. $(".line-total", this).text(line.toFixed(2));
  19. $(".item-price", this).val(each.toFixed(2));
  20. console.log(each.toFixed(2));
  21. total += line;
  22. });
  23. $("#payment-lines .list-group-item").each(function () {
  24. var line = $(".payment-entry", this).val() * 1.0;
  25. paid += line;
  26. });
  27. var discountpercent = $("#discountpercentbtn").data("percent");
  28. if (discountpercent > 0 && discountpercent < 100) {
  29. total *= 1.0 - ((discountpercent * 1.0) / 100);
  30. }
  31. remaining = total - paid;
  32. change = (total - paid) * -1.0;
  33. if (remaining <= 0) {
  34. remaining = 0.0;
  35. $("#owed-amount").parent().removeClass("font-weight-bold");
  36. } else {
  37. $("#owed-amount").parent().addClass("font-weight-bold");
  38. }
  39. if (change <= 0) {
  40. change = 0.0;
  41. $("#change-amount").parent().removeClass("font-weight-bold");
  42. } else {
  43. $("#change-amount").parent().addClass("font-weight-bold");
  44. }
  45. $("#grand-total").text(total.toFixed(2));
  46. $("#paid-amount").text(paid.toFixed(2));
  47. $("#owed-amount").text(remaining.toFixed(2));
  48. $("#change-amount").text(change.toFixed(2));
  49. $("#receiptchange").text(change.toFixed(2));
  50. }
  51. $("#deletetxbtn").click(function () {
  52. bsalert("Confirm", "Really delete transaction?", "Yes", "No", function () {
  53. window.location.href = "app.php?page=pos";
  54. });
  55. });
  56. // Make sure the session doesn't expire
  57. setInterval(function () {
  58. $.get("action.php", {action: "session_keepalive"});
  59. }, 1000 * 60);
  60. $(document).ready(function () {
  61. if ($("#txid").length) {
  62. recalculate();
  63. $("#paymentui").removeClass("d-none");
  64. }
  65. if ($("#return").length) {
  66. recalculate();
  67. }
  68. $.get('http://127.0.0.1:64269/status', {}, function (resp) {
  69. if (resp.status == "OK") {
  70. nickelbridge = true;
  71. receiptwidth = resp.width;
  72. }
  73. });
  74. });