remove conflict

This commit is contained in:
phyusin
2018-07-09 09:44:36 +06:30
35 changed files with 257 additions and 126 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

@@ -111,6 +111,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,6 @@ class AssignedOrderItem < ApplicationRecord
belongs_to :order_queue_station
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
AssignedOrderItem.transaction do
assigned_order_item = AssignedOrderItem.new()
assigned_order_item.order = order
assigned_order_item.item_code = item_code
@@ -17,7 +16,6 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.print_status = false
assigned_order_item.delivery_status = false
assigned_order_item.save!
end
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,10 @@ class SaleOrder < ApplicationRecord
belongs_to :order
def create_sale_order(sale, order)
SaleOrder.transaction do
sale_order = SaleOrder.new
sale_order.sale_id = sale
sale_order.order_id = order
sale_order.save!
end
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

@@ -289,7 +289,6 @@
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY
@@ -299,6 +298,48 @@
</tr>
</thead>
<tbody>
<% if @status_order == 'order' && @status_sale != 'sale'
puts
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<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 %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]'
JSON.parse(order_item.set_menu_items).each do |item_instance|
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && !item_instance["options"].empty? %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end
sub_total += set_item_prices
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
</tr>
<%
count = 0
sub_total = 0
@@ -340,6 +381,15 @@
<%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
=======
%>
<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 %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
>>>>>>> 146f727f462174b1daa31972b597448c12e26d8c
<br><span class="font-13">
<%= option %>
</span>
@@ -747,7 +797,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);
@@ -942,33 +992,68 @@
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
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");
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
}else{
calculate_member_discount(sale_id,"Cash");
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
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",tax_type);
}else{
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
});
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
location.reload();
}
});
});
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
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){
}
});
}
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
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");
}else{
calculate_member_discount(sale_id,"Cash");
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
location.reload();
}
});
});
function calculate_member_discount(sale_id,type) {
var sub_total = $('#sub-total').text();
@@ -1301,7 +1386,7 @@ $('#pay').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 = "<%= @dining.id rescue "" %> ";
@@ -1320,15 +1405,15 @@ $('#pay').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);
window.location.href = '/origami/table/'+dining_id;
}
}
});
}
});
}else{
swal.close();
}

View File

@@ -674,7 +674,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)))
@@ -700,7 +700,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 %>";
@@ -792,8 +792,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);
}
@@ -1059,7 +1058,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

@@ -323,7 +323,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 %>
@@ -427,7 +427,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 %>
@@ -742,7 +742,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);
@@ -963,14 +963,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";
@@ -992,7 +992,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
@@ -1002,12 +1002,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() {
@@ -1369,7 +1368,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 "" %> ";
@@ -1388,11 +1387,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