02 · 2026

ระบบสต็อกสินค้า + สั่งซื้อInventory & Purchasing

คุมสต็อกร้าน/คลังวัตถุดิบ — รับเข้า เบิกออก ต้นทุนถัวเฉลี่ย แจ้งเตือนของใกล้หมด สร้างใบสั่งซื้อแยกตามผู้ขายอัตโนมัติ รับของบางส่วน ตรวจนับ และบัตรสต็อกStock control for shops and stock rooms — in/out, moving-average cost, low-stock alerts, auto-drafted POs per supplier, partial receiving, stock counts and stock cards.

tools/inventory.ts
// ถึงจุดสั่งซื้อหรือยัง — นับรวมของที่สั่งแล้วรอรับconst position = onHand + onOrder.get(p.id);if (position > p.reorderPoint) continue;// สั่งให้พ้นจุดสั่งซื้อ ปัดขึ้นเป็นทวีคูณของแพ็กconst need = p.reorderPoint - position + 1;const suggest = Math.max(pack, Math.ceil(need / pack) * pack);
02TESTS8

ปัญหา

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

ทำอะไรได้

  • สินค้า/วัตถุดิบ — รหัส หมวด หน่วยนับ จุดสั่งซื้อ จำนวนต่อแพ็ก ผู้ขายหลัก และยอดยกมาตอนเริ่มใช้
  • รับเข้า / เบิกออก — ระบุเหตุผล (ขาย เบิกใช้ เสียหาย คืนผู้ขาย) และกันเบิกเกินของที่มี
  • ควรสั่งซื้อ — แสดงรายการที่ถึงจุดสั่งซื้อ โดยนับรวมของที่สั่งแล้วรอรับ (ไม่สั่งซ้ำ) แล้วกดครั้งเดียวได้ ใบสั่งซื้อฉบับร่างแยกตามผู้ขาย พร้อมวันที่ต้องการรับตามระยะส่งของของผู้ขาย
  • ใบสั่งซื้อ — แก้ไขได้ระหว่างเป็นร่าง พิมพ์/บันทึก PDF ส่งผู้ขาย รับของบางส่วน ได้ ห้ามรับเกินที่สั่ง ปิดยอดค้างเมื่อผู้ขายส่งไม่ครบ
  • ตรวจนับ — กรอกยอดที่นับได้ ระบบบันทึกผลต่างเป็นรายการปรับยอดและบอกมูลค่าที่ขาด/เกิน
  • บัตรสต็อก — ประวัติทุกการเคลื่อนไหวของสินค้าแต่ละตัวพร้อมยอดคงเหลือสะสม

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

  • ยอดคงเหลือไม่ถูกเก็บซ้ำ — คำนวณจากรายการเคลื่อนไหวทั้งหมดทุกครั้ง จึงตรวจย้อนหลังได้และดูยอด ณ วันใดก็ได้
  • ต้นทุนถัวเฉลี่ยเคลื่อนที่ (moving average) ทุกครั้งที่รับเข้า มูลค่าสต็อกและต้นทุนของที่ใช้ไปจึงตรงกับวิธีที่ SME ส่วนใหญ่ใช้ทำบัญชี
  • "พอใช้อีกกี่วัน" จากปริมาณใช้เฉลี่ย 30 วันล่าสุด
  • logic ทั้งหมดเป็นฟังก์ชันบริสุทธิ์ แยกจาก UI มี test ครอบคลุมต้นทุนเฉลี่ย การแนะนำสั่งซื้อ การรับบางส่วน และการตรวจนับ

ข้อมูล

เก็บในเบราว์เซอร์เครื่องนี้ ไม่มี server — ส่งออกยอดคงเหลือเป็น CSV และสำรอง/กู้คืนเป็นไฟล์ได้

The problem

Cafés, small restaurants and shops often find out something has run out the moment they need it. They reorder from memory, don't know the real cost of what they used this month, and never find out how much went missing because stock is never counted against the records.

What it does

  • Products & materials — SKU, category, unit, reorder point, pack size, main supplier and opening stock
  • Stock in / out — with a reason (sold, used, damaged, returned) and a guard against issuing more than you have
  • Reorder now — lists items at their reorder point counting what's already on order (so nothing is ordered twice), then drafts one purchase order per supplier in one click, with a needed-by date from each supplier's lead time
  • Purchase orders — editable as drafts, printable/PDF for the supplier, partial receiving (never more than ordered), and closing out what a supplier couldn't deliver
  • Stock counts — enter what you counted; differences are saved as adjustments with the value gained or lost
  • Stock cards — every movement of an item with its running balance

Details I cared about

  • Balances are never stored — they're computed from the full movement history every time, so everything is auditable and you can see stock as of any date
  • Moving-average cost on every receipt, so stock value and cost of goods used match how most small businesses keep their books
  • Days of cover from the average usage of the last 30 days
  • All logic is pure functions separate from the UI, with tests for averaging, reorder suggestions, partial receiving and counts

Data

Stored in this browser, no server — export stock as CSV and back up/restore as a file.