updated migration code
This commit is contained in:
@@ -28,7 +28,7 @@ class Api::OrdersController < Api::ApiController
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id]
|
||||
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||
@order.items = params[:order_items]
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id]
|
||||
|
||||
@@ -38,7 +38,7 @@ class Oqs::HomeController < BaseOqsController
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
|
||||
.joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
|
||||
left join dining_facilities as df on df.zone_id = oqpz.zone_id
|
||||
left join order_queue_stations as oqs ON oqs.order_queue_stations_id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code
|
||||
left join customers as cus ON cus.customer_id = od.customer_id")
|
||||
|
||||
@@ -40,7 +40,7 @@ class Order < ApplicationRecord
|
||||
|
||||
self.adding_line_items
|
||||
#Add Order Table and Room relation afrer order creation
|
||||
BookingOrder.create({:booking_id => booking.id, :order => self})
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
|
||||
|
||||
#Send order to queue one it done!
|
||||
process_order_queue
|
||||
|
||||
@@ -46,6 +46,6 @@ class OrderItem < ApplicationRecord
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
self.order_item_id = SeedGenerator.generate_id(self.class.name, "ODI")
|
||||
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,9 +14,9 @@ class SeedGenerator < ApplicationRecord
|
||||
seed.current = current_no
|
||||
seed.save
|
||||
end
|
||||
padding_len = 12 - prefix.length
|
||||
padding_len = 15 - prefix.length
|
||||
|
||||
return prefix +"-"+ seed.current.to_s.to_s.rjust((12-prefix.length)+1,'0')
|
||||
return prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0')
|
||||
end
|
||||
|
||||
def self.new_receipt_no
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateCustomers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :customers, :id => false, :primary_key => :customer_id do |t|
|
||||
t.string :customer_id, :limit => 16, :null => false, :index => true, :unique => true #custom foreign_key to prevent conflict during sync
|
||||
create_table :customers, :id => false do |t|
|
||||
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
|
||||
t.string :name, :null => false
|
||||
t.string :company
|
||||
t.string :contact_no
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateOrders < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :orders, :id => false, :primary_key => :order_id do |t|
|
||||
t.string :order_id, :limit => 16, :null => false, :index => true, :unique => true #custom foreign_key to prevent conflict during sync
|
||||
create_table :orders, :id => false do |t|
|
||||
t.string :order_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
|
||||
t.datetime :date, :null => false
|
||||
t.string :source, :null => false, :default => "emenu"
|
||||
t.string :order_type, :null => false, :default => "dine-in"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateOrderItems < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :order_items, :id => false, :primary_key => :order_items_id do |t|
|
||||
t.string :order_items_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :order_items, :id => false do |t|
|
||||
t.string :order_items_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
t.string :order_id, foreign_key: true, :null => false, :limit => 16
|
||||
t.string :order_item_status, :null => false, :default => "new"
|
||||
t.string :item_order_by #person who order this
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateSales < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :sales, :id => false, :primary_key => :sale_id do |t|
|
||||
t.string :sale_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :sales, :id => false do |t|
|
||||
t.string :sale_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.integer :cashier_id, :index => true
|
||||
t.string :cashier_name
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateSaleItems < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :sale_items, :id => false, :primary_key => :sale_item_id do |t|
|
||||
t.string :sale_item_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :sale_items, :id => false do |t|
|
||||
t.string :sale_item_id, :limit => 16, :primary_key => true#custom primary key - to ensure consistence for cloud syncing
|
||||
t.string :sale_id, foreign_key: true, :limit => 16
|
||||
t.string :product_code, :null => false
|
||||
t.string :product_name, :null => false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateSaleTaxes < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :sale_taxes, :id => false, :primary_key => :sale_tax_id do |t|
|
||||
t.string :sale_tax_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :sale_taxes, :id => false do |t|
|
||||
t.string :sale_tax_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.string :sale_id, foreign_key: true, :limit => 16
|
||||
t.string :tax_name, :null => false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateSalePayments < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :sale_payments, :id => false, :primary_key => :sale_payment_id do |t|
|
||||
t.string :sale_payment_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :sale_payments, :id => false do |t|
|
||||
t.string :sale_payment_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.string :sale_id, foreign_key: true, :limit => 16
|
||||
t.string :payment_method, :null => false, :default => "cash"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class CreateSaleOrders < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :sale_orders, :id => false, :primary_key => :sale_order_id do |t|
|
||||
t.string :sale_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :sale_orders, :id => false do |t|
|
||||
t.primary_key :sale_order_id #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.string :sale, foreign_key: true,:limit => 16
|
||||
t.string :order, foreign_key: true, :limit => 16
|
||||
t.string :sale_id, foreign_key: true,:limit => 16
|
||||
t.string :order_id, foreign_key: true, :limit => 16
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateSaleAudits < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :sale_audits, :id => false, :primary_key => :sale_audit_id do |t|
|
||||
t.string :sale_audit_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :sale_audits, :id => false do |t|
|
||||
t.string :sale_audit_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.string :sale_id, foreign_key: true, :limit => 16
|
||||
t.string :action, :null => false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class CreateBookings < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :bookings, :id => false, :primary_key => :booking_id do |t|
|
||||
t.string :booking_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
create_table :bookings, :id => false do |t|
|
||||
t.string :booking_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.references :dining_facility, foreign_key: true
|
||||
t.string :type, :null => false, :default => "Table"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
class CreateBookingOrders < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :booking_orders, :id => false, :primary_key => :booking_order_id do |t|
|
||||
t.string :booking_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
|
||||
t.string :booking, foreign_key: true, :limit => 16
|
||||
t.string :order, foreign_key: true, :limit => 16
|
||||
create_table :booking_orders, :id => false do |t|
|
||||
#t.string :booking_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing
|
||||
t.primary_key :booking_order_id
|
||||
t.string :booking_id, foreign_key: true, :limit => 16
|
||||
t.string :order_id, foreign_key: true, :limit => 16
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user