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
|
class Api::Restaurant::ZonesController < ActionController::API
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render json: Zone.where("is_active = true")
|
render json: Zone.where("is_active = true")
|
||||||
end
|
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
|
class MenuCategory < ApplicationRecord
|
||||||
belongs_to :menu
|
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
|
validates_presence_of :name
|
||||||
|
|
||||||
|
|
||||||
end
|
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
|
class Room < DiningFacility
|
||||||
belongs_to :zone
|
|
||||||
|
|
||||||
validates_presence_of :name,:seater, :order_by, :created_by, :is_active
|
|
||||||
|
|
||||||
end
|
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
|
class Zone < ApplicationRecord
|
||||||
# model association
|
# model association
|
||||||
has_many :seat_tables, dependent: :destroy
|
has_many :tables, dependent: :destroy
|
||||||
has_many :rooms, dependent: :destroy
|
has_many :rooms, dependent: :destroy
|
||||||
|
|
||||||
# validations
|
# validations
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
namespace :api, :defaults => { :format => 'json' } do
|
namespace :api, :defaults => { :format => 'json' } do
|
||||||
|
|
||||||
|
#Session Login and Logout
|
||||||
|
post 'autheticate' => "autheticate#create"
|
||||||
|
delete 'autheticate' => "autheticate#destroy"
|
||||||
|
|
||||||
namespace :restaurant do
|
namespace :restaurant do
|
||||||
get 'zones' => "zones#index"
|
get 'zones' => "zones#index"
|
||||||
get 'seat_tables' => "seat_tables#index"
|
get 'tables' => "#index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
class CreateSeatTables < ActiveRecord::Migration[5.0]
|
|
||||||
def change
|
|
||||||
create_table :seat_tables do |t|
|
|
||||||
t.references :zone, foreign_key: true
|
|
||||||
t.string :name, :null => false
|
|
||||||
t.integer :order_by
|
|
||||||
t.integer :no_of_seater, :null => false, :default => 2
|
|
||||||
t.string :table_type, :null => false, :default => "square"
|
|
||||||
t.float :position_x, :null => false, :default => 0.0
|
|
||||||
t.float :position_y, :null => false, :default => 0.0
|
|
||||||
t.string :created_by
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
class CreateRooms < ActiveRecord::Migration[5.0]
|
|
||||||
def change
|
|
||||||
create_table :rooms do |t|
|
|
||||||
t.string :name, :null => false
|
|
||||||
t.integer :seater, :null => false, :default => 4
|
|
||||||
t.string :created_by
|
|
||||||
t.boolean :is_active, :null => false, :default => true
|
|
||||||
t.integer :order_by
|
|
||||||
t.references :zone
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -2,7 +2,7 @@ class CreateMenus < ActiveRecord::Migration[5.0]
|
|||||||
def change
|
def change
|
||||||
create_table :menus do |t|
|
create_table :menus do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
t.boolean :is_active, :null => false
|
t.boolean :is_active, :null => false, :deafult => true
|
||||||
t.string :valid_days, :null => false, :default => "1,2,3,4,5,6,7"
|
t.string :valid_days, :null => false, :default => "1,2,3,4,5,6,7"
|
||||||
t.time :valid_time_from, :null => false, :default => "00:00:00"
|
t.time :valid_time_from, :null => false, :default => "00:00:00"
|
||||||
t.time :valid_time_to, :null => false, :default => "23:59:59"
|
t.time :valid_time_to, :null => false, :default => "23:59:59"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class CreateMenuCategories < ActiveRecord::Migration[5.0]
|
|||||||
t.string :name, :null => false
|
t.string :name, :null => false
|
||||||
t.string :alt_name
|
t.string :alt_name
|
||||||
t.integer :order_by
|
t.integer :order_by
|
||||||
t.integer :parent_category_id
|
t.references :menu_category, :null => true
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|||||||
19
db/migrate/20170331024749_create_menu_items.rb
Normal file
19
db/migrate/20170331024749_create_menu_items.rb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
class CreateMenuItems < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :menu_items do |t|
|
||||||
|
t.string :item_code, :null => false
|
||||||
|
t.string :name, :null => false
|
||||||
|
t.string :alt_name
|
||||||
|
t.string :type, :null => false, :default => "SimpleMenuItem"
|
||||||
|
t.references :menu_category, foreign_key: true
|
||||||
|
t.references :menu_item, foreign_key: true
|
||||||
|
t.integer :min_selectable_item, :null => false, :default => 1
|
||||||
|
t.integer :max_selectable_item, :null => false, :default => 1
|
||||||
|
t.json :options #save value
|
||||||
|
t.json :attributes #value IDS
|
||||||
|
t.string :created_by
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
11
db/migrate/20170402083337_create_menu_item_attributes.rb
Normal file
11
db/migrate/20170402083337_create_menu_item_attributes.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
class CreateMenuItemAttributes < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :menu_item_attributes do |t|
|
||||||
|
t.string :attribute_type, :null => false
|
||||||
|
t.string :name, :null => false
|
||||||
|
t.string :value, :null => false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
10
db/migrate/20170402083525_create_menu_item_options.rb
Normal file
10
db/migrate/20170402083525_create_menu_item_options.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CreateMenuItemOptions < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :menu_item_options do |t|
|
||||||
|
t.string :name, :null => false
|
||||||
|
t.string :value, :null => false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
14
db/migrate/20170402084230_create_menu_item_instances.rb
Normal file
14
db/migrate/20170402084230_create_menu_item_instances.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
class CreateMenuItemInstances < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :menu_item_instances do |t|
|
||||||
|
t.references :menu_item, :foreign_key => true, :null => false
|
||||||
|
t.string :item_instance_code, :null => false
|
||||||
|
t.json :attributes
|
||||||
|
t.decimal :price, :null => false
|
||||||
|
t.boolean :is_available, :null => false, :default => true
|
||||||
|
t.boolean :is_on_promotion, :null => false, :default => false
|
||||||
|
t.decimal :promotion_price, :null => false, :default => false
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
15
db/migrate/20170403135121_create_customers.rb
Normal file
15
db/migrate/20170403135121_create_customers.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
class CreateCustomers < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :customers do |t|
|
||||||
|
t.string :name, :null => false
|
||||||
|
t.string :company
|
||||||
|
t.string :contact_no
|
||||||
|
t.string :email
|
||||||
|
t.string :membership_id
|
||||||
|
t.string :membership_type
|
||||||
|
t.string :membership_authentication_code
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
17
db/migrate/20170403135934_create_orders.rb
Normal file
17
db/migrate/20170403135934_create_orders.rb
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
class CreateOrders < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :orders do |t|
|
||||||
|
t.datetime :date, :null => false
|
||||||
|
t.string :source, :null => false, :default => "emenu"
|
||||||
|
t.string :order_type, :null => false, :default => "dine-in"
|
||||||
|
t.references :customer, foreign_key: true
|
||||||
|
t.integer :item_count, :null => false, :default => 0
|
||||||
|
t.integer :quantity_count, :null => false, :default => 0
|
||||||
|
t.string :status, :null => false, :default => "new"
|
||||||
|
t.json :waiters
|
||||||
|
t.json :guest_info
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
18
db/migrate/20170403140820_create_order_items.rb
Normal file
18
db/migrate/20170403140820_create_order_items.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
class CreateOrderItems < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :order_items do |t|
|
||||||
|
t.references :order, foreign_key: true, :null => false
|
||||||
|
t.string :order_item_status, :null => false, :default => "new"
|
||||||
|
t.string :item_code, :null => false
|
||||||
|
t.string :item_name, :null => false
|
||||||
|
t.integer :qty, :null => false
|
||||||
|
t.string :item_order_by #person who order this
|
||||||
|
t.string :remark
|
||||||
|
t.string :options
|
||||||
|
t.string :variants
|
||||||
|
t.json :set_menu_items #this parameter is require to route the items correctly
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
16
db/migrate/20170403142424_create_dining_facilities.rb
Normal file
16
db/migrate/20170403142424_create_dining_facilities.rb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
class CreateDiningFacilities < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :dining_facilities do |t|
|
||||||
|
t.references :zone, foreign_key: true
|
||||||
|
t.string :name, :null => false
|
||||||
|
t.string :type, :null => false, :default => "table"
|
||||||
|
t.integer :seater, :null => false, :default => 2
|
||||||
|
t.integer :order_by
|
||||||
|
|
||||||
|
t.string :created_by
|
||||||
|
t.boolean :is_active, :null => false, :default => true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
11
db/migrate/20170403143526_create_dining_ins.rb
Normal file
11
db/migrate/20170403143526_create_dining_ins.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
class CreateDiningIns < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :dining_ins do |t|
|
||||||
|
t.references :table
|
||||||
|
t.references :order
|
||||||
|
t.boolean :currently_occupied, :default => false #there will only be 1 true - where table_id+order_id
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
15
db/migrate/20170403144732_create_room_bookings.rb
Normal file
15
db/migrate/20170403144732_create_room_bookings.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
class CreateRoomBookings < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :room_bookings do |t|
|
||||||
|
t.references :room, :null => false
|
||||||
|
t.datetime :checkin_at
|
||||||
|
t.datetime :checkout_at
|
||||||
|
t.string :checkout_by
|
||||||
|
t.datetime :reserved_at
|
||||||
|
t.string :reserved_by
|
||||||
|
t.string :status, :null => false, :default => "new"
|
||||||
|
t.boolean :is_currently_checkin, :default => false, :null => true
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
11
db/migrate/20170403145042_create_room_orders.rb
Normal file
11
db/migrate/20170403145042_create_room_orders.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
class CreateRoomOrders < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :room_orders do |t|
|
||||||
|
t.references :room, foreign_key: true
|
||||||
|
t.references :orders, foreign_key: true
|
||||||
|
t.string :order_by
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,14 +1,53 @@
|
|||||||
zone {name}
|
zone {name}
|
||||||
seat_tables {table_name, seater, table_type:[square, round, ], position-x, position-y}
|
seat_tables {table_name, seater, table_type:[square, round, ], position-x, position-y}
|
||||||
room {Name, seater, created_by, is_active, order_by}
|
room {name, seater, created_by, is_active, order_by}
|
||||||
|
|
||||||
menu {name, is_active, valid_days, valid_time_from, valid_time_to}
|
menu {name, is_active, valid_days, valid_time_from, valid_time_to}
|
||||||
menu_category {menu, name, alt_name, order_no, parent_category_id}
|
menu_category {menu, name, alt_name, order_by, parent_category_id}
|
||||||
menu_items { menu_category, order_no, product_code, picture, menu_name, alt_menu_name, price, menu_item_type:[simple| set| DIY], available_size:[],
|
|
||||||
variants:[{product_code, name, picture, add_on_price}], allow_multiple_variants_selection: boolean, set_menu_items:[menu_items], is_sold_out, is_on_promotion
|
|
||||||
promotion_price, promotion_qty}
|
|
||||||
|
|
||||||
order { id, date, order_source [tablet, order_station, emenu, api], order_type [dine-in, takeaway, delivery], item_count, quantity_count, status [new, processing, fulfilled], waiters[], guest_info: {customer_id, membership_id, }}
|
menu_item_attributes: {attribute_type, name, value}
|
||||||
|
menu_item_options: {option_type, name, value}
|
||||||
|
|
||||||
|
menu_item : {
|
||||||
|
category_code : "",
|
||||||
|
item_code : "",
|
||||||
|
name : "",
|
||||||
|
alt_name : "",
|
||||||
|
type : "[SIMPLE | SET | DIY]",
|
||||||
|
attributes : [],
|
||||||
|
parent_items : [],
|
||||||
|
child_items : [],
|
||||||
|
min_selectable_item : 0,
|
||||||
|
max_selectable_item : 0,
|
||||||
|
menu_item_instances : [],
|
||||||
|
options : [],
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_item_instance : {
|
||||||
|
item_instance_code : "",
|
||||||
|
menu_item_attribute_values : [],
|
||||||
|
item_code : "",
|
||||||
|
parent_item_code : "",
|
||||||
|
price : 0.00,
|
||||||
|
is_available : t/f,
|
||||||
|
is_on_promotion : t/f,
|
||||||
|
promotion_price : 0.00,
|
||||||
|
}
|
||||||
|
|
||||||
|
order_item : {
|
||||||
|
order_item_code : "",
|
||||||
|
item_instance_code : "",
|
||||||
|
quantity : 0,
|
||||||
|
option_values : [],
|
||||||
|
sub_order_items : [],
|
||||||
|
}
|
||||||
|
|
||||||
|
menu_items { menu_category, order_by, product_code, picture, menu_name, alt_menu_name, price, menu_item_type:[simple| set| DIY], available_size:[small: {product_code, price}, medium: {product_code, price}, large: {product_code, price}],
|
||||||
|
variants:[{product_code, name, picture, add_on_price, options {option_name, option_value} }], max_variants_selection: integer, set_menu_items:[menu_items], is_sold_out, is_on_promotion
|
||||||
|
promotion_price, options {option_name, option_value}}
|
||||||
|
|
||||||
|
|
||||||
|
order { id, date, order_ref, order_source [tablet, order_station, emenu, api], order_type [dine-in, takeaway, delivery],customer_id, item_count, quantity_count, status [new, processing, fulfilled], waiters[], guest_info: {adult_count, child_count, woman_count, man_count}}
|
||||||
order_items { order_item_status, product_code, name, qty, price, remark, options , variants: [], set_menu_items :[]}
|
order_items { order_item_status, product_code, name, qty, price, remark, options , variants: [], set_menu_items :[]}
|
||||||
order_delivery_info {name, address, contact_no, delivery-by [InHouse | YDoor2Door | Food2U], tracker-id, sale}
|
order_delivery_info {name, address, contact_no, delivery-by [InHouse | YDoor2Door | Food2U], tracker-id, sale}
|
||||||
dine-in-table {table, order, status}
|
dine-in-table {table, order, status}
|
||||||
|
|||||||
5
spec/models/customer_spec.rb
Normal file
5
spec/models/customer_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Customer, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/dining_facility_spec.rb
Normal file
5
spec/models/dining_facility_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe DiningFacility, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/dining_in_spec.rb
Normal file
5
spec/models/dining_in_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe DiningIn, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
@@ -4,4 +4,19 @@ RSpec.describe MenuCategory, type: :model do
|
|||||||
it { should validate_presence_of(:name) }
|
it { should validate_presence_of(:name) }
|
||||||
it { should belong_to(:menu) }
|
it { should belong_to(:menu) }
|
||||||
|
|
||||||
|
describe ' #parent & #children' do
|
||||||
|
it 'should be able to do parent tree' do
|
||||||
|
menu = Menu.new(:name => "Test Category Menu", :is_active => true )
|
||||||
|
menu.save!
|
||||||
|
|
||||||
|
c1 = MenuCategory.new(:name =>"Parent Category", :menu => menu)
|
||||||
|
c1.save!
|
||||||
|
c2 = MenuCategory.new(:name =>"Child Category", :menu => menu, :parent => c1)
|
||||||
|
c2.save
|
||||||
|
|
||||||
|
expect(c1.children).to include(c2)
|
||||||
|
expect(c2.parent).to eq c1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
7
spec/models/menu_item_attribute_spec.rb
Normal file
7
spec/models/menu_item_attribute_spec.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe MenuItemAttribute, type: :model do
|
||||||
|
it { should validate_presence_of(:attribute_type) }
|
||||||
|
it { should validate_presence_of(:name) }
|
||||||
|
it { should validate_presence_of(:value) }
|
||||||
|
end
|
||||||
5
spec/models/menu_item_instance_spec.rb
Normal file
5
spec/models/menu_item_instance_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe MenuItemInstance, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
6
spec/models/menu_item_option_spec.rb
Normal file
6
spec/models/menu_item_option_spec.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe MenuItemOption, type: :model do
|
||||||
|
it { should validate_presence_of(:name) }
|
||||||
|
it { should validate_presence_of(:value) }
|
||||||
|
end
|
||||||
5
spec/models/menu_item_spec.rb
Normal file
5
spec/models/menu_item_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe MenuItem, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/order_item_spec.rb
Normal file
5
spec/models/order_item_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe OrderItem, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/order_spec.rb
Normal file
5
spec/models/order_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Order, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/room_booking_spec.rb
Normal file
5
spec/models/room_booking_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe RoomBooking, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/room_order_spec.rb
Normal file
5
spec/models/room_order_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe RoomOrder, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Room, type: :model do
|
|
||||||
it { should belong_to(:zone) }
|
|
||||||
|
|
||||||
it { should validate_presence_of(:name) }
|
|
||||||
it { should validate_presence_of(:seater) }
|
|
||||||
it { should validate_presence_of(:is_active) }
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe SeatTable, type: :model do
|
|
||||||
# Association test
|
|
||||||
# ensure an item record belongs to a single todo record
|
|
||||||
it { should belong_to(:zone) }
|
|
||||||
# Validation test
|
|
||||||
# ensure column name is present before saving
|
|
||||||
it { should validate_presence_of(:name) }
|
|
||||||
it { should validate_presence_of(:order_by) }
|
|
||||||
it { should validate_presence_of(:created_by) }
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe 'Seat Table API', type: :request do
|
|
||||||
# initialize test data
|
|
||||||
let!(:seat_table) { create_list(:seat_table, 10) }
|
|
||||||
let(:seat_table_id) { seat_tables.first.id }
|
|
||||||
|
|
||||||
# Test suite for GET /todos
|
|
||||||
describe 'GET /api/restaurant/seat_tables' do
|
|
||||||
# make HTTP get request before each example
|
|
||||||
before { get '/api/restaurant/seat_tables' }
|
|
||||||
|
|
||||||
it 'returns Seat Tables' do
|
|
||||||
# Note `json` is a custom helper to parse JSON responses
|
|
||||||
expect(json).not_to be_empty
|
|
||||||
expect(json.size).to eq(10)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns status code 200' do
|
|
||||||
expect(response).to have_http_status(200)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user