{% extends "base.html" %} {% from "partials/ui.html" import page_header, subtabs %} {% block content %} {{ page_header('POS / Inventory', 'Simple sub-tabs for sales, inventory, batches/traceability, meals, activities, and history. Reservation POS posts to folio immediately; walk-in cart commits atomically.') }} {{ subtabs([ {'key':'sell','href':'/pos?tab=sell','label':'Sell'}, {'key':'inventory','href':'/pos?tab=inventory','label':'Inventory'}, {'key':'batches','href':'/pos?tab=batches','label':'Batches & Traceability'}, {'key':'meals','href':'/pos?tab=meals','label':'Meals & Recipes'}, {'key':'activities','href':'/pos?tab=activities','label':'Activities'}, {'key':'history','href':'/pos?tab=history','label':'History'} ], active_tab, 'POS and inventory sections') }} {% if active_tab == 'sell' %}
Scan barcodes/lots, charge reservations, or run a walk-in cart sale.
How to use Sell / Scan

Barcode scan / lookup (item or batch/lot)

Resolves item SKU/barcode or lot code and shows batch data. Embedded QR payloads are decoded if present.

{% if scan_result %} {% if scan_result.type == 'batch' %}
Batch/Lot found: {{scan_result.batch.lot_code}} — {{scan_result.item.item_name if scan_result.item else ''}} (item #{{scan_result.batch.item_id}})
LotReceived (bought)ExpiryRemainingUnit costSupplierStatus
{{scan_result.batch.lot_code}}{{scan_result.batch.received_at}}{{scan_result.batch.expiry_date or '—'}} {% if scan_result.batch.expiry_state=='expired' %}EXPIRED{% elif scan_result.batch.expiry_state=='expiring' %}expiring{% endif %}{{scan_result.batch.quantity_remaining}}{{"%.2f"|format(scan_result.batch.unit_cost or 0)}}{{scan_result.batch.supplier}}{{scan_result.batch.status}}
View batches
{% elif scan_result.type == 'item' %}
Item found: {{scan_result.item.item_name}} (#{{scan_result.item.id}}) SKU {{scan_result.item.sku or '—'}} Barcode {{scan_result.item.barcode or '—'}}
View batches
{% elif scan_result.type == 'unknown' %}
No item or batch matched code: {{scan_result.code}}
{% else %}
Scan/resolve error: {{scan_result.error or scan_result}}
{% endif %} {% endif %}

Add POS item to reservation (immediate, batch-aware)

Tip: scan/lookup above to resolve a lot, or choose a batch for traceable deduction; leave empty for auto-FEFO on tracked items.

Walk-in cart ({{ cart|length }} items)

{% for it in cart %} {% else %} {% endfor %}
ItemLot/Batch traceQtyUnitTaxGross
{{it.desc}}{% if it.inv_id %} [inv {{it.inv_id}}]{% endif %} {{ it.lot_code or ('#' ~ it.batch_id if it.batch_id else '—') }} {% if it.batch_id %}batch #{{it.batch_id}}{% endif %} {% if it.batch_received_at or it.received_at %}Received: {{ it.batch_received_at or it.received_at }}{% endif %} {% if it.batch_expiry_date or it.expiry_date %}Expiry: {{ it.batch_expiry_date or it.expiry_date }} {% if (it.batch_expiry_state or it.expiry_state)=='expired' %}EXPIRED{% elif (it.batch_expiry_state or it.expiry_state)=='expiring' %}EXPIRING{% endif %} {% endif %} {% if not (it.lot_code or it.batch_id) %}No specific batch (manual/auto at sale){% endif %} {{it.qty}}{{"%.2f"|format(it.price)}}{{"%.2f"|format(it.tax)}}{{"%.2f"|format(it.gross)}}
Cart is empty. Add items below.
TOTAL{{"%.2f"|format(cart_total)}} EGP

Checkout (atomic: all items + one payment)

Add custom item to walk-in cart

Quick add from inventory

Search and add to cart quickly. Full item management is in Inventory; specific lots in Batches.

{% for i in inv %} {% else %}{% endfor %}
IDNameSellStock
{{i['id']}} {{i['item_name']}}{% if i.get('recipe_components') %} recipe{% endif %}
SKU {{i.get('sku') or '—'}} · {{i.get('barcode') or '—'}}
{{"%.2f"|format(i['selling_price'] or 0)}}{{i['stock_qty']}}
Batches
No items
{% elif active_tab == 'inventory' %}
Manage inventory items, barcodes/SKU, and restocking. Use Batches for received lots and expiry traceability.
How to use Inventory

Inventory items

Quick sale actions go to Sell tab; select Batches to manage/choose specific lots.

{% for i in inv %} {% else %}{% endfor %}
IDName / BarcodeSellStockNext expiryRecipeActions
{{i['id']}} {{i['item_name']}}
SKU: {{i.get('sku') or '—'}} · Code: {{i.get('barcode') or '—'}}
{{"%.2f"|format(i['selling_price'] or 0)}}{{i['stock_qty']}} {{i.get('next_expiry') or '—'}} {% if i.get('recipe_components') %}{{i['recipe_components']}} ingr.{% else %}—{% endif %}
Batches
No items

Restock item (password)

Restock records a received batch with time bought/received for traceability.

Add inventory item (password)

{% elif active_tab == 'batches' %}
Receive lots with time bought/received and expiry, review traceability, and print/select specific batches.
How to use Batches & Traceability

Expiring / expired batches

Active batches with remaining stock near/after expiry. “Received” = time bought/received.

{% for b in expiring_batches or [] %} {% else %}{% endfor %}
ItemLotReceivedExpiryRemainingState
{{b.item_name}} #{{b.item_id}}{{b.lot_code}}{{b.received_at}}{{b.expiry_date or '—'}}{{b.quantity_remaining}}{% if b.expiry_state=='expired' %}EXPIRED ({{b.days_to_expiry}}d){% elif b.expiry_state=='expiring' %}Expiring ({{b.days_to_expiry}}d){% else %}{{b.expiry_state}}{% endif %}
No expiring/expired batches.

Receive batch / lot (password)

Filter batches

View all active batches or filter to a specific item.

{% if batch_item %}

Show all active batches

{% endif %}

Tip: from Inventory/Sell you can click “Batches” on an item to jump here.

Active batches / lots {% if batch_item %}(item #{{batch_item}}){% endif %}

{% for b in batches or [] %} {% else %}{% endfor %}
IDItemLotReceivedExpiryRem/RecvCostActions
{{b.id}} {{b.item_name}} (#{{b.item_id}}) {{b.lot_code}} {{b.received_at}} {{b.expiry_date or '—'}} {% if b.expiry_state=='expired' %}EXPIRED{% elif b.expiry_state=='expiring' %}expiring soon{% endif %} {{b.quantity_remaining}} / {{b.quantity_received}} {{"%.2f"|format(b.unit_cost or 0)}}
Res
No batches shown (receive a batch or choose an item filter).
{% elif active_tab == 'meals' %}
Register meals and recipes so ingredients auto-deduct when ordered via POS (batch-aware where applicable).
How to use Meals & Recipes

Registered Meals

Register a meal once. When staff orders it in POS using its linked Inventory/POS ID, ingredients are deducted from inventory automatically.

Register / update meal (password)
{% for m in meals or [] %} {% else %}{% endfor %}
MealPOS IDPriceIngredientsPreparationAction
{{m['name']}}
{{m.get('description') or ''}}
{% if m.get('linked_inventory_id') %}{{m['linked_inventory_id']}}{% else %}—{% endif %} {{"%.2f"|format(m.get('selling_price') or 0)}} {% for ing in m.get('ingredients') or [] %}
{{ing['item_name']}}: {{ing['qty_per_sale']}} {{ing.get('unit') or ''}}{% if ing.get('note') %} ({{ing['note']}}){% endif %}
{% else %}No ingredients{% endfor %}
{{(m.get('preparation') or '')[:120]}}{% if (m.get('preparation') or '')|length > 120 %}…{% endif %}
No meals registered yet.

Recipe / auto ingredient deduction by inventory ID (password)

Define ingredients for a sellable meal/menu inventory item directly. When sold in POS by Inventory ID, ingredients auto-deduct and meal stock is not deducted. Components: one per line ingredient_id,qty_per_sale.

Clearing restores normal stock deduction for that item when sold.

{% elif active_tab == 'activities' %}
Register bookable activities/trips and view booking statistics. Bookings post to reservation folio/invoice from the Reservations page.
How to use Activities

Register new activity / trip

Booking statistics (real data)

{% for s in (activity_stats or []) %} {% else %}{% endfor %}
ActivityCatActiveBookingsQtyRevenue
{{s.activity_name}} #{{s.activity_id}}{{s.category}}{{'Yes' if s.active else 'No'}}{{s.bookings}}{{s.total_qty}}{{"%.2f"|format(s.gross_revenue or 0)}}
No activity bookings/stats yet.

Registered activities

{% for a in (activities or []) %} {% else %}{% endfor %}
IDNameCategoryPriceActiveDescription
{{a.id}}{{a.name}}{{a.category}}{{"%.2f"|format(a.unit_price or 0)}}{{'Yes' if a.active else 'No'}}{{a.description}}
No activities registered yet.
{% elif active_tab == 'history' %}
Recent walk-in POS lines and payments (non-reservation). Voids require unlock/password as configured.

Recent walk-in POS lines (no reservation)

{% for p in walkin_pos %}{% if not p['voided_at'] %} {% endif %}{% else %}{% endfor %}
IDAtItemBatch / Lot traceQtyGross-ishAction
{{p['id']}}{{p['created_at']}}{{p['item_description']}} {{ p.get('lot_code') or p.get('batch_lot_code') or ('#' ~ p.get('batch_id') if p.get('batch_id') else '—') }} {% if p.get('batch_id') %}batch #{{ p.get('batch_id') }}{% endif %} {% if p.get('received_at') or p.get('batch_received_at') %}Received: {{ p.get('received_at') or p.get('batch_received_at') }}{% endif %} {% if p.get('expiry_date') or p.get('batch_expiry_date') %}Expiry: {{ p.get('expiry_date') or p.get('batch_expiry_date') }} {% if (p.get('expiry_state') or p.get('batch_expiry_state')) == 'expired' %}EXPIRED{% elif (p.get('expiry_state') or p.get('batch_expiry_state')) == 'expiring' %}EXPIRING{% endif %} {% endif %} {{p['quantity']}} {{"%.2f"|format((p['quantity']*p['unit_price']) + (p['tax_amount'] or 0))}}
None

Recent walk-in payments

{% for p in walkin_payments %}{% if not p['voided_at'] %} {% endif %}{% else %}{% endfor %}
IDAtAmountMethodNotes
{{p['id']}}{{p['at']}}{{"%.2f"|format(p['amount'])}}{{p['method']}}{{p['notes']}}
None
{% endif %} {% endblock %}