Pull from master

This commit is contained in:
San Wai Lwin
2018-07-09 09:27:52 +06:30
35 changed files with 167 additions and 102 deletions

2
.gitignore vendored
View File

@@ -42,7 +42,7 @@ pickle-email-*.html
/config/initializers/*
config/deploy/config/*
config/puma.rb
#config/shops.json
config/shops.json
!/log/.keep
!/tmp/.keep
.ruby-version

View File

@@ -241,6 +241,8 @@ Menu Image (Import guideline)
=> Second, import [menu].xlsx file in /settings/menus and then checked image is uploaded into Application/[sxrestaurant]/public/image/menu_images and insert into menu_items table in database.
=> Last, if shop has shop_code, update marked/noted shop_code into shops table again.
For Edit Order Open & Close
1) settings/lookups => {type:edit_order, name:EditOrderOrigami, value: {1 or 0}}
* ToDo list

View File

@@ -1,6 +1,7 @@
$(function() {
var role = $('#role').val();
var second_display_lookup = $("#display_type");
console.log(second_display_lookup)
type = window.location.href.indexOf("quick_service");
modify_order = window.location.href.indexOf("modify_order");
@@ -428,7 +429,7 @@ $(function() {
var items = $('.selected-set');
if (items.length >= min_qty) {
if ($('#server_mode').val() != "cloud") {
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
item = get_set_item(items);
customer_display_view(item,"set_add");
}
@@ -756,7 +757,7 @@ $(function() {
$('.add_to_order').attr('data-options',JSON.stringify(option_arr));
$('.add_to_order').attr('data-opt',JSON.stringify(option_arr));
var item_data = $(this);
if ($('#server_mode').val() != "cloud") {
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
item = get_item(item_data,"add_to_order");
customer_display_view(item,"add");
}
@@ -768,7 +769,7 @@ $(function() {
// click plus icon for add
$(document).on('click', '.add_icon', function(event){
var item_data = $(this);
if ($('#server_mode').val() != "cloud") {
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2) {
item = get_item(item_data,"add_icon");
customer_display_view(item,"add");
}
@@ -895,7 +896,7 @@ $(function() {
window.location.href = "/origami/room/" + table_id
}
}
if ($('#server_mode').val() != "cloud") {
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
}

View File

@@ -18,7 +18,12 @@ class Origami::AddordersController < BaseOrigamiController
if check_mobile
@webview = true
end
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value==2
@display_type = display_type.value
else
@display_type = nil
end
# if params[:menu] == "true"
@menus = []
@menu = []

View File

@@ -109,6 +109,19 @@ class Origami::HomeController < BaseOrigamiController
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
end
#for edit order open & close
@edit_order_origami = true
lookup_edit_order = Lookup.collection_of('edit_order')
if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami"
if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter')
@edit_order_origami = false
end
end
end
end
end
def check_emp_access_code

View File

@@ -137,6 +137,19 @@ class Origami::RoomsController < BaseOrigamiController
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
end
#for edit order open & close
@edit_order_origami = true
lookup_edit_order = Lookup.collection_of('edit_order')
if !lookup_edit_order.empty?
lookup_edit_order.each do |edit_order|
if edit_order[0].downcase == "editorderorigami"
if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter')
@edit_order_origami = false
end
end
end
end
end
end

View File

@@ -8,24 +8,27 @@ class Origami::SecondDisplayController < BaseOrigamiController
end
def customer_view
if params[:status]!= "billed"
tax_profiles = TaxProfile.all.order("order_by asc")
else
tax_profiles = nil
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value==2
if params[:status]!= "billed"
tax_profiles = TaxProfile.all.order("order_by asc")
else
tax_profiles = nil
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from
end
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from
# end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
# helper_method :shop_detail
# def shop_detail
# @shop = Shop.first
# end
end

View File

@@ -8,7 +8,10 @@ class AssignedOrderItem < ApplicationRecord
belongs_to :order_queue_station
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
<<<<<<< HEAD
AssignedOrderItem.transaction do
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
assigned_order_item = AssignedOrderItem.new()
assigned_order_item.order = order
assigned_order_item.item_code = item_code
@@ -17,7 +20,10 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.print_status = false
assigned_order_item.delivery_status = false
assigned_order_item.save!
<<<<<<< HEAD
end
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
end
def self.assigned_order_item_by_job(order_id)

View File

@@ -207,7 +207,7 @@ class OrderQueueStation < ApplicationRecord
private
#Print order_items in 1 slip
def print_slip(oqs, order, order_items)
printer = PrintSetting.all
printer = PrintSetting.all.order("id ASC")
unique_code="OrderSummaryPdf"
if !printer.empty?
@@ -245,7 +245,7 @@ class OrderQueueStation < ApplicationRecord
#Print order_item in 1 slip per item
def print_slip_item(oqs, order, assigned_items)
printer = PrintSetting.all
printer = PrintSetting.all.order("id ASC")
unique_code="OrderItemPdf"
if !printer.empty?

View File

@@ -70,7 +70,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_settings.save!
end
print_setting = PrintSetting.all
print_setting = PrintSetting.all.order("id ASC")
order=print_query('order_summary', order_id)
# For Print Per Item
if oqs.cut_per_item
@@ -170,7 +170,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_settings.save!
end
print_setting = PrintSetting.all
print_setting = PrintSetting.all.order("id ASC")
order=print_query('booking_summary', booking_id)
# For Print Per Item

View File

@@ -8,12 +8,18 @@ class SaleOrder < ApplicationRecord
belongs_to :order
def create_sale_order(sale, order)
<<<<<<< HEAD
SaleOrder.transaction do
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
sale_order = SaleOrder.new
sale_order.sale_id = sale
sale_order.order_id = order
sale_order.save!
<<<<<<< HEAD
end
=======
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
end
private

View File

@@ -11,6 +11,7 @@
</div>
<input type="hidden" name="type" id="role" value="<%= current_user.role%>">
<input type="hidden" name="cashier_type" id="cashier_type" value="<%= type%>">
<input type="hidden" name="display_type" id="display_type" value="<%= @display_type%>">
<div class="row m-t--20">
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_data">
<li class="list-menu">

View File

@@ -298,7 +298,7 @@
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
@@ -402,7 +402,7 @@
set_item_prices = 0
count += 1
%>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
@@ -699,7 +699,7 @@
<script>
var cashier_type = "cashier";
$(document).ready(function () {
localStorage.removeItem("tax_type");
// localStorage.removeItem("tax_type");
/* check webview loaded*/
var webview = <%= @webview %>;
showHideNavbar(webview);
@@ -894,12 +894,14 @@
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
calculate_member_discount(sale_id,"Card");
calculate_member_discount(sale_id,"Card",tax_type);
}else{
calculate_member_discount(sale_id,"Cash");
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
@@ -920,7 +922,7 @@
});
});
function calculate_member_discount(sale_id,type) {
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
@@ -930,7 +932,7 @@
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier' },
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){
}
@@ -1251,7 +1253,7 @@
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var tax_type = $(this).attr("data-value");
var cashier_type = 'cashier';
var sale_id = $('#sale_id').text();
var dining_id = "<%= @dining.id rescue "" %> ";
@@ -1270,11 +1272,12 @@
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: tax_type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
alert(tax_type);
localStorage.setItem("tax_type", tax_type);
alert(localStorage.getItem("tax_type"));
window.location.href = '/origami/table/'+dining_id;
}
}

View File

@@ -652,7 +652,7 @@ var pdf_view = '<%=@pdf_view%>';
payment_type = '';
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
// console.log(payment_type)
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
@@ -678,7 +678,7 @@ var pdf_view = '<%=@pdf_view%>';
$("#card_payment").hide();
}
}
}
// }
/* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
@@ -770,8 +770,7 @@ var pdf_view = '<%=@pdf_view%>';
var credit = $('#credit').text();
var card = $('#card').text();
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : '';
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if (credit <= 0) {
calculate_member_discount(sale_id,tax_type);
}
@@ -1037,7 +1036,6 @@ var pdf_view = '<%=@pdf_view%>';
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
var item_row = $('.is_card');
if (member_id && member_discount) {
if (item_row.length < 1) {
is_card = false

View File

@@ -287,7 +287,7 @@
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<tr class="<%= @edit_order_origami== true ? 'edit_order' : ''%>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
@@ -391,7 +391,7 @@
set_item_prices = 0
count += 1
%>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<tr class="<%= @edit_order_origami== true ? 'edit_order' : ''%>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
@@ -694,7 +694,7 @@
<script>
var cashier_type = "cashier";
$(document).ready(function(){
localStorage.removeItem("tax_type");
// localStorage.removeItem("tax_type");
/* check webview loaded*/
var webview = <%= @webview %>;
showHideNavbar(webview);
@@ -913,14 +913,14 @@ $(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
// type = $('.payment_method').val();
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL", type)) != -1) {
calculate_member_discount(sale_id,"Card");
calculate_member_discount(sale_id,"Card",tax_type);
}else{
calculate_member_discount(sale_id,"Cash");
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
@@ -942,7 +942,7 @@ $(".choose_payment").on('click', function () {
}
});
});
function calculate_member_discount(sale_id,type) {
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
@@ -952,12 +952,11 @@ function calculate_member_discount(sale_id,type) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){
}
});
}
$('#pay').on('click',function() {
@@ -1319,7 +1318,7 @@ $('#add_invoice').on('click',function(){
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var tax_type = $(this).attr("data-value");
var cashier_type = 'cashier';
var sale_id = $('#sale_id').text();
var dining_id = "<%= @room.id rescue "" %> ";
@@ -1338,11 +1337,11 @@ $('#add_invoice').on('click',function(){
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: tax_type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
// console.log(tax_type);
localStorage.setItem("tax_type", tax_type);
window.location.href = '/origami/room/'+dining_id;
}
}

View File

@@ -1,7 +1,7 @@
class CreateMenuItems < ActiveRecord::Migration[5.1]
def change
create_table :menu_items do |t|
t.string :item_code, :null => false
t.string :item_code, :null => false, :index => true
t.string :name, :null => false
t.string :alt_name
t.string :image_path

View File

@@ -2,17 +2,18 @@ class CreateOrders < ActiveRecord::Migration[5.1]
def change
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.datetime :date, :index => true, :null => false
t.string :source, :index => true, :null => false, :default => "emenu"
t.string :order_type, :null => false, :default => "dine-in"
t.string :customer_id, foreign_key: true, :limit => 16
t.integer :item_count, :null => false, :default => 0
t.integer :quantity_count, :null => false, :default => 0
t.string :status, :null => false, :default => "new"
t.string :status, :index => true, :null => false, :default => "new"
t.json :waiters
t.json :guest_info
t.timestamps
end
add_index :orders, [:date, :source, :status], name: 'index_date_source_status'
end
end

View File

@@ -2,7 +2,7 @@ class CreateOrderItems < ActiveRecord::Migration[5.1]
def change
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_id, foreign_key: true, :index => true, :null => false, :limit => 16
t.string :order_item_status, :null => false, :default => "new"
t.string :item_order_by #person who order this
t.string :item_code, :null => false

View File

@@ -3,15 +3,16 @@ class CreateDiningFacilities < ActiveRecord::Migration[5.1]
create_table :dining_facilities do |t|
t.references :zone, foreign_key: true
t.string :name, :null => false
t.string :status, :null => false, :default => "available"
t.string :type, :null => false, :default => "Table"
t.string :status, :null => false, :default => "available", :index => true
t.string :type, :null => false, :default => "Table", :index => true
t.integer :seater, :null => false, :default => 2
t.integer :order_by
t.string :created_by
t.boolean :is_active, :null => false, :default => true
t.boolean :is_active, :null => false, :default => true, :index => true
t.timestamps
end
add_index :dining_facilities, [:status, :type, :is_active]
end
end

View File

@@ -3,15 +3,16 @@ class CreateEmployees < ActiveRecord::Migration[5.1]
create_table :employees do |t|
t.string :name, :null => false
t.string :role, :null => false, :default => "cashier"
t.boolean :is_active, :default => true
t.boolean :is_active, :default => true, :index=>true
t.string :emp_id, :null => false
t.string :password_digest, :null => false
t.string :token_session
t.string :token_session, :index=>true
t.datetime :session_expiry
t.datetime :session_last_login
t.string :created_by
t.string :image_path
t.timestamps
end
add_index :employees, [:is_active, :token_session]
end
end

View File

@@ -2,21 +2,22 @@ class CreateSaleItems < ActiveRecord::Migration[5.1]
def change
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 :sale_id, foreign_key: true, :limit => 16, :index => true
t.string :product_code, :null => false
t.string :item_instance_code
t.string :product_name, :null => false
t.string :product_alt_name, :null => false
t.integer :account_id, :limit => 8, :null => false, :default => 1
t.string :status
t.string :remark
t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :unit_price, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :taxable_price, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :price, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.boolean :is_taxable, :null => false, :default => true
t.integer :account_id, :index => true, :limit => 8, :null => false, :default => 1
t.string :status, :index => true
t.string :remark, :index => true
t.decimal :qty, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :unit_price, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :taxable_price, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :price, :index => true, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.boolean :is_taxable, :index => true, :null => false, :default => true
t.timestamps
end
add_index :sale_items, [:sale_id, :account_id, :status, :remark, :qty, :unit_price, :taxable_price, :price, :is_taxable], name: 'index_sale_items'
end
end

View File

@@ -3,7 +3,7 @@ class CreateSaleTaxes < ActiveRecord::Migration[5.1]
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 :sale_id, foreign_key: true, :limit => 16, :index => true, :null => false
t.string :tax_name, :null => false
t.decimal :tax_rate, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :tax_payable_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -3,8 +3,8 @@ class CreateSalePayments < ActiveRecord::Migration[5.1]
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"
t.string :sale_id, foreign_key: true, :limit => 16, :index => true
t.string :payment_method, :null => false, :default => "cash", :index => true
t.decimal :payment_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.string :payment_reference
@@ -12,5 +12,6 @@ class CreateSalePayments < ActiveRecord::Migration[5.1]
t.timestamps
end
add_index :sale_payments, [:sale_id, :payment_method]
end
end

View File

@@ -3,10 +3,11 @@ class CreateSaleOrders < ActiveRecord::Migration[5.1]
create_table :sale_orders, :id => false do |t|
t.string :sale_order_id, :limit => 16, :primary_key => true
t.string :sale_id, foreign_key: true,:limit => 16
t.string :order_id, foreign_key: true, :limit => 16
t.string :sale_id, foreign_key: true,:limit => 16, :index => true
t.string :order_id, foreign_key: true, :limit => 16, :index => true
t.timestamps
end
add_index :sale_orders, [:sale_id, :order_id], name: 'index_sale_id_order_id'
end
end

View File

@@ -1,7 +1,7 @@
class CreateLookups < ActiveRecord::Migration[5.1]
def change
create_table :lookups do |t|
t.string :lookup_type, :null => false
t.string :lookup_type, :null => false, :index => true
t.string :name, :null => false
t.string :value, :null => false
end

View File

@@ -5,17 +5,18 @@ class CreateBookings < ActiveRecord::Migration[5.1]
t.references :dining_facility, foreign_key: true
t.string :type, :null => false, :default => "Table"
t.datetime :checkin_at, :null => false
t.datetime :checkin_at, :index => true, :null => false
t.string :checkin_by
t.datetime :checkout_at
t.string :checkout_by
t.string :checkout_by, :index => true
t.datetime :reserved_at
t.string :reserved_by
t.string :booking_status, :null => false, :default => "new"
t.string :reserved_by, :index => true
t.string :booking_status, :index => true, :null => false, :default => "new"
t.string :sale_id, foreign_key: true, :limit => 16
t.string :customer_id, foreign_key: true, :limit => 16
t.timestamps
end
add_index :bookings, [:checkin_at, :checkout_by, :reserved_by, :booking_status], name: 'index_bookings'
end
end

View File

@@ -1,7 +1,7 @@
class CreateSeedGenerators < ActiveRecord::Migration[5.1]
def change
create_table :seed_generators do |t|
t.string :model, :null => false, :default => "sale"
t.string :model, :null => false, :default => "sale", :index => true
t.integer :increase_by, :null => false, :default => 1
t.bigint :current, :null => false ,:default => 1
t.bigint :next, :null => false, :default => 2

View File

@@ -4,12 +4,14 @@ class CreateAssignedOrderItems < ActiveRecord::Migration[5.1]
t.string :assigned_order_item_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing
t.string :item_code, :null => false, :index => true
t.string :instance_code, :null => false, :index => true
t.references :order_queue_station, foreign_key: true
t.references :order_queue_station, foreign_key: true, :index => true
t.string :order_id, foreign_key: true, :limit => 16
t.boolean :print_status
t.boolean :delivery_status
t.boolean :delivery_status, :index => true
t.timestamps
end
add_index :assigned_order_items, :created_at
add_index :assigned_order_items, [:item_code, :instance_code, :order_queue_station_id, :delivery_status, :created_at], name: 'index_assigned_order_items'
end
end

View File

@@ -3,10 +3,11 @@ class CreateBookingOrders < ActiveRecord::Migration[5.1]
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.string :booking_id, foreign_key: true, :index => true, :limit => 16
t.string :order_id, foreign_key: true, :index => true, :limit => 16
t.timestamps
end
add_index :booking_orders, [:booking_id, :order_id], name: 'index_booking_id_order_id'
end
end

View File

@@ -13,12 +13,13 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
t.string :address
t.string :card_no, :unique => true
t.string :paypar_account_no, :unique => true
t.string :membership_id
t.string :membership_id, :index => true
t.string :membership_type
t.string :membership_authentication_code
t.string :customer_type, :default => "Dinein"
t.string :customer_type, :default => "Dinein", :index => true
t.json :tax_profiles
t.string :image_path
end
add_index :customers, [:membership_id, :customer_type]
end
end

View File

@@ -2,8 +2,8 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
def change
create_table :shift_sales do |t|
t.references :cashier_terminal, foreign_key: true, :null => false
t.datetime :shift_started_at
t.datetime :shift_closed_at
t.datetime :shift_started_at, :index => true
t.datetime :shift_closed_at, :index => true
t.references :employee, foreign_key: true #cashier
t.decimal :opening_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :closing_balance, :precision => 10, :scale => 2, :null => false, :default => 0.00
@@ -26,5 +26,6 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
t.decimal :total_void, :default => 0
t.timestamps
end
add_index :shift_sales, [:shift_started_at, :shift_closed_at]
end
end

View File

@@ -2,7 +2,7 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1]
def change
create_table :print_settings do |t|
t.string :name, :null => false
t.string :unique_code, :null => false
t.string :unique_code, :null => false, :index => true
t.string :template
t.string :font, :default => ""
t.integer :header_font_size, :null => false, :default => 10

View File

@@ -8,10 +8,10 @@ class CreateSales < ActiveRecord::Migration[5.1]
t.string :requested_by, :null => false
t.datetime :requested_at, :null => false
t.string :receipt_no, :null => false
t.datetime :receipt_date, :null => false
t.datetime :receipt_date, :index => true, :null => false
t.string :customer_id, foreign_key: true, :limit => 16
t.string :payment_status, :null => false, :default => "outstanding"
t.string :sale_status, :null => false, :default => "new"
t.string :payment_status, :index => true, :null => false, :default => "outstanding"
t.string :sale_status, :index => true, :null => false, :default => "new"
t.decimal :total_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.string :discount_type, :default => "overall"
t.decimal :total_discount, :precision => 10, :scale => 2, :null => false, :default => 0.00
@@ -21,11 +21,13 @@ class CreateSales < ActiveRecord::Migration[5.1]
t.decimal :rounding_adjustment, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :amount_received, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :amount_changed, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.integer :shift_sale_id
t.integer :shift_sale_id, :index => true
t.decimal :old_grand_total
t.string :rebate_status
t.integer :equal_persons
t.timestamps
end
add_index :sales, :created_at, name: 'index_created_at'
add_index :sales, [:cashier_id, :receipt_date, :payment_status, :sale_status, :shift_sale_id, :created_at], name: 'index_sales'
end
end

View File

@@ -3,10 +3,10 @@ class CreatePromotion < ActiveRecord::Migration[5.1]
create_table :promotions do |t|
t.string :promo_code, :limit => 16
t.date :promo_start_date, :null => false
t.date :promo_end_date, :null => false
t.time :promo_start_hour, :null => false
t.time :promo_end_hour, :null => false
t.date :promo_start_date, :null => false, :index => true
t.date :promo_end_date, :null => false, :index => true
t.time :promo_start_hour, :null => false, :index => true
t.time :promo_end_hour, :null => false, :index => true
t.string :promo_day, :null => false, :default => "[0,1,2,3,4,5,6]"
t.string :promo_type, :null => false, :default => "Quantity"
t.string :original_product
@@ -14,5 +14,6 @@ class CreatePromotion < ActiveRecord::Migration[5.1]
t.string :created_by, :null => false
t.timestamps
end
add_index :promotions, [:promo_start_date, :promo_end_date, :promo_start_hour, :promo_end_hour], name: 'index_promotions'
end
end

View File

@@ -1,7 +1,7 @@
class CreateCardSaleTrans < ActiveRecord::Migration[5.1]
def change
create_table :card_sale_trans do |t|
t.string :sale_id
t.string :sale_id, :index=>true
t.date :req_date
t.time :req_time
t.float :req_amt, :limit=>50