menu, table,rooms, orders structure
This commit is contained in:
9
app/controllers/api/authenticate_controller.rb
Normal file
9
app/controllers/api/authenticate_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Api::AuthenticateController < ActionController::API
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
end
|
||||
10
app/controllers/api/customer_controller.rb
Normal file
10
app/controllers/api/customer_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Api::CustomersController < ActionController::API
|
||||
|
||||
#List all active customers by name
|
||||
def index
|
||||
end
|
||||
|
||||
#Show customer by ID
|
||||
def show
|
||||
end
|
||||
end
|
||||
24
app/controllers/api/restaurant/invoice_controller.rb
Normal file
24
app/controllers/api/restaurant/invoice_controller.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class Api::Restaurant::InvoiceController < ActionController::API
|
||||
before :authenticate_token
|
||||
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - order_id
|
||||
def show
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
|
||||
# Description
|
||||
# This API allow new invoice creation
|
||||
# Input Params
|
||||
# order_id
|
||||
# Output Params
|
||||
# Status [Success | Error | System Error] , order_id, error_message (*)
|
||||
def create
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
29
app/controllers/api/restaurant/menu_controller.rb
Normal file
29
app/controllers/api/restaurant/menu_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
class Api::Restaurant::MenuController < ActionController::API
|
||||
before :authenticate_token
|
||||
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
menu_detail()
|
||||
end
|
||||
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - menu_id
|
||||
def show
|
||||
menu_detail(params[:menu_id])
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def menu_detail
|
||||
if (menu_id)
|
||||
#Pull this menu
|
||||
else
|
||||
#Pull Default menu
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
36
app/controllers/api/restaurant/order_controller.rb
Normal file
36
app/controllers/api/restaurant/order_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Api::Restaurant::OrderController < ActionController::API
|
||||
before :authenticate_token
|
||||
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - order_id
|
||||
def show
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
|
||||
# Description
|
||||
# This API allow new order creation
|
||||
# Input Params
|
||||
# order_source [* default - emenu] | table_id (*require for Dine-In) | order_type [* Default - Dine-in]
|
||||
# | guest_info (optional) | customer_id (optional)
|
||||
# order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
# Output Params
|
||||
# Status [Success | Error | System Error] , order_id, error_message (*)
|
||||
def create
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API - allow order to add new items to existing orders, does not allow you to remove confirm items
|
||||
# Update customer info, Guest Info
|
||||
# Input Params
|
||||
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
21
app/controllers/api/restaurant/rooms_controller.rb
Normal file
21
app/controllers/api/restaurant/rooms_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Api::Restaurant::RoomsController < ActionController::API
|
||||
def index
|
||||
render json: SeatTable.order("order_by")
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
|
||||
# Output
|
||||
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
#Input Params
|
||||
# table_id: table_id
|
||||
# Output
|
||||
# status: error | success, error_message: <Problem with moving table>
|
||||
def update
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class Api::Restaurant::SeatTablesController < ActionController::API
|
||||
def index
|
||||
render json: SeatTable.order("order_by")
|
||||
end
|
||||
end
|
||||
21
app/controllers/api/restaurant/seatings_controller.rb
Normal file
21
app/controllers/api/restaurant/seatings_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Api::Restaurant::SeatingsController < ActionController::API
|
||||
def index
|
||||
render json: Zone.order("order_by")
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
|
||||
# Output
|
||||
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
#Input Params
|
||||
# table_id: table_id
|
||||
# Output
|
||||
# status: error | success, error_message: <Problem with moving table>
|
||||
def update
|
||||
|
||||
end
|
||||
end
|
||||
21
app/controllers/api/restaurant/takeaway_controller.rb
Normal file
21
app/controllers/api/restaurant/takeaway_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Api::Restaurant::TakeawaysController < ActionController::API
|
||||
def index
|
||||
render json: SeatTable.order("order_by")
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
|
||||
# Output
|
||||
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
#Input Params
|
||||
# table_id: table_id
|
||||
# Output
|
||||
# status: error | success, error_message: <Problem with moving table>
|
||||
def update
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
class Api::Restaurant::ZonesController < ActionController::API
|
||||
|
||||
def index
|
||||
render json: Zone.where("is_active = true")
|
||||
end
|
||||
|
||||
9
app/models/customer.rb
Normal file
9
app/models/customer.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Customer < ApplicationRecord
|
||||
has_many :orders
|
||||
has_many :sales
|
||||
|
||||
validates_presence_of :name, :contact_no
|
||||
validates :contact_no, uniqueness: true
|
||||
|
||||
|
||||
end
|
||||
2
app/models/dining_facility.rb
Normal file
2
app/models/dining_facility.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class DiningFacility < ApplicationRecord
|
||||
end
|
||||
4
app/models/dining_in.rb
Normal file
4
app/models/dining_in.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class DiningIn < ApplicationRecord
|
||||
belongs_to :table
|
||||
belongs_to :order
|
||||
end
|
||||
@@ -1,5 +1,10 @@
|
||||
class MenuCategory < ApplicationRecord
|
||||
belongs_to :menu
|
||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
|
||||
end
|
||||
|
||||
7
app/models/menu_item.rb
Normal file
7
app/models/menu_item.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class MenuItem < ApplicationRecord
|
||||
belongs_to :menu_category
|
||||
has_many :menu_item_instances
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
|
||||
end
|
||||
4
app/models/menu_item_attribute.rb
Normal file
4
app/models/menu_item_attribute.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class MenuItemAttribute < ApplicationRecord
|
||||
validates_presence_of :attribute_type, :name, :value
|
||||
|
||||
end
|
||||
4
app/models/menu_item_instance.rb
Normal file
4
app/models/menu_item_instance.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class MenuItemInstance < ApplicationRecord
|
||||
belongs_to :menu_item
|
||||
|
||||
end
|
||||
4
app/models/menu_item_option.rb
Normal file
4
app/models/menu_item_option.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class MenuItemOption < ApplicationRecord
|
||||
validates_presence_of :name, :value
|
||||
|
||||
end
|
||||
12
app/models/order.rb
Normal file
12
app/models/order.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Order < ApplicationRecord
|
||||
before_create :set_order_date
|
||||
belongs_to :customer
|
||||
has_many :order_items, inverse_of: :order
|
||||
has_many :dining_ins
|
||||
|
||||
|
||||
private
|
||||
def set_order_date
|
||||
self.date = Time.now.utc
|
||||
end
|
||||
end
|
||||
10
app/models/order_item.rb
Normal file
10
app/models/order_item.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class OrderItem < ApplicationRecord
|
||||
#Associations
|
||||
belongs_to :order
|
||||
|
||||
#Validation
|
||||
validates_presence_of :item_code, :item_name, :qty
|
||||
validates :qty, numericality: { :greater_than 0 }
|
||||
validates_associated :orders
|
||||
|
||||
end
|
||||
@@ -1,6 +1,3 @@
|
||||
class Room < ApplicationRecord
|
||||
belongs_to :zone
|
||||
|
||||
validates_presence_of :name,:seater, :order_by, :created_by, :is_active
|
||||
class Room < DiningFacility
|
||||
|
||||
end
|
||||
|
||||
2
app/models/room_booking.rb
Normal file
2
app/models/room_booking.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class RoomBooking < ApplicationRecord
|
||||
end
|
||||
4
app/models/room_order.rb
Normal file
4
app/models/room_order.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class RoomOrder < ApplicationRecord
|
||||
belongs_to :room
|
||||
belongs_to :orders
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
class SeatTable < ApplicationRecord
|
||||
belongs_to :zone
|
||||
|
||||
# validations
|
||||
validates_presence_of :name,:order_by, :created_by
|
||||
end
|
||||
3
app/models/set_menu_item.rb
Normal file
3
app/models/set_menu_item.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class SetMenuItem < MenuItem
|
||||
|
||||
end
|
||||
3
app/models/simple_menu_item.rb
Normal file
3
app/models/simple_menu_item.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class SimpleMenuItem < MenuItem
|
||||
|
||||
end
|
||||
4
app/models/table.rb
Normal file
4
app/models/table.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Table < DiningFacility
|
||||
has_many :dining_ins
|
||||
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
class Zone < ApplicationRecord
|
||||
# model association
|
||||
has_many :seat_tables, dependent: :destroy
|
||||
has_many :tables, dependent: :destroy
|
||||
has_many :rooms, dependent: :destroy
|
||||
|
||||
# validations
|
||||
|
||||
Reference in New Issue
Block a user