Order Processing

This document covers the order processing system within the Restaurant & POS module, detailing how food orders are created, managed, and completed through various payment methods and order types. The order processing system handles the entire lifecycle from item selection to receipt generation.

For information about menu management and food item configuration, see Menu Management. For details about the POS interface components, see POS Interface.

Order Types and Workflow

The order processing system supports three distinct order types, each with specific requirements and workflow variations:

Order Initiation

Select Order Type

din-in
Restaurant Dining

takeway
Takeaway

hotel_customer
In-Room Service

Select Table
table_id required

Select Employee
employee_id required

Customer Information
Basic details only

Select Booking
booking_id required

Room Selection
room_id required

Cart Management

Payment Processing

Order Completion
    

Cart Management System

The cart management system uses browser localStorage to maintain order state and provides real-time updates for quantities, pricing, and tax calculations:

Product Selection

Product Selection
productpos_add

mainArray
localStorage

joinaddtocart()
Display Function

Cart Table UI
cartadd element

Quantity Controls
inc/dec buttons

forEverySelectedProduct()
Update Display

calculateTotalOutstanding()
Tax & Pricing

Tax Display Elements
pos_total_vat_rate

Order Validation
Before Submission

posOrdetdata()
Controller Method
    

The cart system maintains an array of product objects with the following structure:

Tax and Pricing Calculations

The system implements flexible tax calculations supporting both inclusive and exclusive tax models with percentage or fixed amount options:

inclusive

exclusive

Cart Total
totalprice_input

Apply Discount
discountInput value

Calculate Subtotal

Tax Type Check
taxType variable

Tax Amount =
total - (total * 100/(100 + rate))

Tax Amount =
total * rate / 100

Net = Total - Tax

Net = Total
Total = Total + Tax

Update Display Elements
pos_total_vat_rate, etc.

Validation Checks
totalgrandtotal_input
    

Tax configuration is retrieved from the hotel_booking_setup table and includes:

Payment Method Processing

The order processing system supports multiple payment methods with different validation requirements and status handling:

Payment Method Selection

draft
Save for Later

cash
Cash Payment

online
Card Payment

add_to_bill
Add to Room Bill

Basic Validation
Customer + Items

Full Validation
+ Payment Confirmation

posOrdetdata()
order_method = 'draft'

Receipt Generation Prompt
SweetAlert Dialog

posOrdetdata()
order_method != 'draft'

gernerateReciept()
PDF Generation
    

The validation process checks:

Order Database Schema and Status Management

Orders are stored in the hotel_booking_orders table with comprehensive tracking of order details and status progression:

Field Purpose Values
order_id Unique identifier Auto-generated (#001, #002, etc.)
order_method Payment method 'draft', 'cash', 'online', 'add_to_bill'
order_type Service type 'din-in', 'takeway', 'hotel_customer'
status Order status 'order_placed', 'completed', 'cancel'
cartdata Items JSON Serialized cart array
client_id Customer reference Foreign key to hotel_booking_clients
table_id Table assignment For dine-in orders
employee_id Staff assignment Waiter for dine-in
booking_id Room booking For hotel customer orders

Order Creation

Yes

No

Order Creation
posOrdetdata()

Generate order_id
orderIdNumber()

order_method
== 'draft'?

Save as Draft
status = 'saved'

Save as Complete
status = 'order_placed'

Draft Orders List
status filter

Complete Orders List
status filter

Edit Draft Order
openposedit class

View Order Details
Read-only
    

Customer Management Integration

The order processing system integrates with customer management to handle both existing and new customer information:

Customer Search

Customer Search
customersearch input

Search Dropdown
searchdropdown

select_customer
Event Handler

Customer Data
clientRecord()

Filter Bookings
client_id match

Add Customer
posaddcustomer

SweetAlert Modal
Customer Form

Form Field Mapping
Address, Contact Info

Hidden Form Inputs
customer_id_input, etc.

Order Submission
Complete Customer Data
    

Customer search functionality filters the hotel_booking_clients table by:

Order Editing and Status Updates

The system provides functionality to edit draft orders and update order statuses through the administrative interface:

Draft orders can be fully edited including: