05 · 2026

ระบบขายหน้าร้าน (POS)Point of Sale (POS)

ระบบขายหน้าร้านครบวงจร — ขาย ตัดสต็อก รับเงินสด/QR พร้อมเพย์ พิมพ์ใบเสร็จ ดูยอดขายรายชั่วโมง/7 วัน และสินค้าขายดี ใช้บนแท็บเล็ตได้A complete shop till — sell, track stock, take cash or PromptPay QR, print receipts, and see hourly/7-day sales and best sellers. Tablet-friendly.

tools/pos.ts
// คิดเป็นสตางค์ (จำนวนเต็ม) กันเศษทศนิยมเพี้ยนconst s = (baht: number) => Math.round(baht * 100);const t = totals(cart, discount);if (method === "cash" && change(t.total, received) === null)  throw new Error("รับเงินไม่พอ");// ขายแล้วตัดสต็อก / ยกเลิกบิลแล้วคืนสต็อกreturn { products: adjustStock(products, cart, -1), sale };
05VIEWS5

ปัญหา

ร้านเล็กๆ อย่างร้านกาแฟหรือร้านขนม มักจดยอดใส่สมุด ปิดร้านแล้วต้องมานั่งรวมเงิน ไม่รู้ว่าชั่วโมงไหนขายดี ของอะไรใกล้หมด ส่วนโปรแกรม POS ส่วนใหญ่ต้องสมัครสมาชิกรายเดือน

ทำอะไรได้

  • ขาย — ค้นหาสินค้า (กด /), กรองหมวด, กดเพิ่มลงตะกร้า ปรับจำนวน ใส่ส่วนลดเป็นบาทหรือ %
  • รับเงิน — เงินสดมีปุ่มแบงก์ลัด (เช่น 100 / 500 / 1000) คำนวณเงินทอนให้ หรือแสดง QR พร้อมเพย์ยอดตรงบิล ให้ลูกค้าสแกน
  • ใบเสร็จ — พิมพ์ได้ทันที (ขนาดกระดาษความร้อน 80 มม.) หรือเปิดดู/พิมพ์ซ้ำจากประวัติ
  • สินค้า & สต็อก — เลือกได้ว่าสินค้าไหนนับสต็อก ตั้งจุดเตือนใกล้หมด ระบบเตือนก่อนขายเกินของที่มี
  • ยกเลิกบิล — คืนสต็อกอัตโนมัติ และไม่นับในยอดขาย
  • รายงาน — ยอดขาย จำนวนบิล ค่าเฉลี่ยต่อบิล แยกเงินสด/พร้อมเพย์ กราฟรายชั่วโมง 7 วันล่าสุด สินค้าขายดี และส่งออก CSV

จุดที่ตั้งใจทำ

  • เงินทั้งหมดคำนวณเป็น สตางค์ (จำนวนเต็ม) ส่วนลด % ไม่ทำให้ยอดเพี้ยน 0.01
  • logic ทั้งหมดเป็นฟังก์ชันบริสุทธิ์ (ขาย ยกเลิก สรุปยอด) แยกจาก UI และมี test ครอบคลุม
  • ใช้คีย์บอร์ดได้ทั้งระบบ กล่องชำระเงินเป็น <dialog> ที่ดัก focus และปิดด้วย Esc
  • ปุ่มใหญ่ กดง่ายบนแท็บเล็ต แท็บจำไว้ใน URL กดย้อนกลับได้

ข้อมูล

เก็บในเบราว์เซอร์เครื่องนี้ (localStorage) ไม่มี server — มีปุ่มสำรอง/กู้คืนเป็นไฟล์ JSON

The problem

Small shops like cafés or bakeries often log sales in a notebook, count cash at closing, and never know which hour is busiest or what's about to run out. Most POS software wants a monthly subscription.

What it does

  • Sell — search products (press /), filter by category, tap to add, adjust quantities, apply a baht or % discount
  • Take payment — cash with quick-note buttons (100 / 500 / 1000) and automatic change, or a PromptPay QR for the exact bill for the customer to scan
  • Receipts — print instantly (80 mm thermal width) or reopen and reprint from history
  • Products & stock — choose which items track stock, set a low-stock alert, and get warned before overselling
  • Void a bill — stock goes back automatically and the bill is excluded from reports
  • Reports — sales, bill count, average bill, cash vs PromptPay, hourly and 7-day charts, best sellers, CSV export

Details I cared about

  • All money is computed in satang (integers), so percentage discounts never drift by 0.01
  • Selling, voiding and reporting are pure functions separate from the UI, with tests
  • Fully keyboard-usable; the checkout is a <dialog> that traps focus and closes with Esc
  • Big touch targets for tablets; the current tab lives in the URL so Back works

Data

Stored in this browser (localStorage), no server — back up and restore as a JSON file.