change split bill process
This commit is contained in:
@@ -101,7 +101,7 @@ SQL Update after rake clear:data runned
|
||||
Change type in mysql
|
||||
*run if you got font error for Myanmar, Chinese, etc...
|
||||
=> ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table
|
||||
=> ALTER DATABASE [database_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database
|
||||
=> ALTER DATABASE [database_name] CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database
|
||||
|
||||
For split bill
|
||||
1) settings/lookups => { type:split_bill, name:SplitBill, value:1 }
|
||||
|
||||
@@ -38,6 +38,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -47,6 +49,8 @@ class Origami::HomeController < BaseOrigamiController
|
||||
if sale.sale_status !='completed'
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -116,9 +120,9 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
|
||||
#for split bill
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@spit_bill = 0
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@spit_bill = lookup_spit_bill[0][1]
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,6 +13,21 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
@orders.each do |order|
|
||||
order.order_items.each_with_index do |item, index|
|
||||
if !item.set_menu_items.nil?
|
||||
instance_item_sets = JSON.parse(item.set_menu_items)
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
end
|
||||
order.order_items[index].set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@order_items_count = Hash.new
|
||||
bookings = Booking.all
|
||||
if !bookings.nil?
|
||||
@@ -24,6 +39,8 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -33,6 +50,8 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
if sale.sale_status !='completed'
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,6 +34,8 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
if !order.order_items.empty?
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, order.order_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += order.order_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -43,6 +45,8 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
if sale.sale_status !='completed'
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -119,9 +123,9 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
lookup_spit_bill = Lookup.collection_of('split_bill')
|
||||
@spit_bill = 0
|
||||
@split_bill = 0
|
||||
if !lookup_spit_bill[0].nil?
|
||||
@spit_bill = lookup_spit_bill[0][1]
|
||||
@split_bill = lookup_spit_bill[0][1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,11 +28,40 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
arr_instance_item_sets = Array.new
|
||||
instance_item_sets.each do |instance_item|
|
||||
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
|
||||
item.price = item.price.to_f + instance_item["price"].to_f
|
||||
arr_instance_item_sets.push(item_instance_name)
|
||||
end
|
||||
item.set_menu_items = arr_instance_item_sets
|
||||
end
|
||||
@order_items.push(item)
|
||||
|
||||
arr_item = Hash.new
|
||||
if item.qty.to_i > 1
|
||||
i = 1
|
||||
while i <= item.qty.to_i do
|
||||
arr_item = {'order_items_id' => item.order_items_id,
|
||||
'order_id' => item.order_id,
|
||||
'order_item_status' => item.order_item_status,
|
||||
'item_order_by' => item.item_order_by,
|
||||
'item_code' => item.item_code,
|
||||
'item_instance_code' => item.item_instance_code,
|
||||
'item_name' => item.item_name,
|
||||
'alt_name' => item.alt_name,
|
||||
'account_id' => item.account_id,
|
||||
'qty' => '1.0',
|
||||
'price' => item.price,
|
||||
'remark' => item.remark,
|
||||
'options' => item.options,
|
||||
'set_menu_items' => item.set_menu_items,
|
||||
'taxable' => item.taxable,
|
||||
'completed_by' => item.completed_by,
|
||||
'created_at' => item.created_at,
|
||||
'updated_at' => item.updated_at}
|
||||
i += 1
|
||||
@order_items.push({@order.order_id => arr_item})
|
||||
end
|
||||
else
|
||||
@order_items.push({@order.order_id => item})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -186,8 +215,25 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
orderItem.order_id = order.order_id
|
||||
orderItem.save!
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
orderItem.item_instance_code,
|
||||
orderItem.item_name,
|
||||
orderItem.alt_name,
|
||||
orderItem.account_id,
|
||||
order_item['qty'],
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
orderItem.set_menu_items,
|
||||
orderItem.order_id,
|
||||
orderItem.item_order_by,
|
||||
orderItem.taxable)
|
||||
|
||||
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
|
||||
else
|
||||
orderItem.order_id = order.order_id
|
||||
end
|
||||
orderItem.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -386,9 +386,9 @@
|
||||
end
|
||||
%>
|
||||
</table>
|
||||
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice</button>
|
||||
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
|
||||
<% if !@spit_bill.nil? && @spit_bill == '1' %>
|
||||
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
|
||||
<button class='btn btn-primary btn-block waves-effect' id='split_bill'> Split Bill</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if @sale_array.size > 1 %>
|
||||
@@ -439,6 +439,11 @@
|
||||
<!-- <button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect" disabled>Charges</button> -->
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" id='move'>Move</button>
|
||||
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
|
||||
<% if !@split_bill.nil? %>
|
||||
<% if @split_bill == '1' %>
|
||||
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!-- <button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect" disabled>First Bill</button> -->
|
||||
<!-- <button type="button" id="pay" class="btn btn-block bg-blue waves-effect" disabled>Pay</button> -->
|
||||
<!-- <button type="button" class="btn btn-block bg-blue waves-effect" disabled> Void</button> -->
|
||||
@@ -711,30 +716,6 @@
|
||||
|
||||
// Bill Request
|
||||
$('#request_bills').click(function () {
|
||||
var lookup_split_bill = '<%= @spit_bill %>';
|
||||
if(lookup_split_bill == '1'){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Do you want to Split bill?",
|
||||
type: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#009900",
|
||||
confirmButtonText: "Yes, split it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
window.location.href = '/origami/table/' + dining_id + "/split_bills";
|
||||
}else{
|
||||
requestBillProcess();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
requestBillProcess();
|
||||
}
|
||||
});
|
||||
|
||||
function requestBillProcess(){
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
$.ajax({
|
||||
@@ -749,8 +730,14 @@
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//split bill process
|
||||
$('#split_bills').click(function(){
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
window.location.href = '/origami/table/' + dining_id + "/split_bills";
|
||||
});
|
||||
|
||||
$('#move').on('click', function () {
|
||||
var dining_id = "<%= @dining.id %>";
|
||||
|
||||
@@ -200,7 +200,14 @@
|
||||
%>
|
||||
<% unless sale_item.price <= 0 %>
|
||||
<tr>
|
||||
<td class='item-name'><%= sale_item.item_name %></td>
|
||||
<td class='item-name'>
|
||||
<%= sale_item.item_name %>
|
||||
<% if !sale_item.set_menu_items.nil?
|
||||
sale_item.set_menu_items.each do |item_instance| %>
|
||||
<br><span class="font-13"><%= item_instance %></span>
|
||||
<% end
|
||||
end %>
|
||||
</td>
|
||||
<td class='item-attr'><%= sale_item.qty %></td>
|
||||
<td class='item-attr'><%= sale_item.price %></td>
|
||||
</tr>
|
||||
|
||||
@@ -411,6 +411,11 @@
|
||||
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
|
||||
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
|
||||
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
|
||||
<% if !@split_bill.nil? %>
|
||||
<% if @split_bill == '1' %>
|
||||
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
|
||||
<!-- <button type="button" id="pay" class="btn bg-blue btn-block" disabled>Pay</button> -->
|
||||
<!-- <button type="button" class="btn bg-blue btn-block" disabled=""> Void </button> -->
|
||||
@@ -714,30 +719,6 @@ $('#pay').on('click',function() {
|
||||
});
|
||||
// Bill Request
|
||||
$('#request_bills').click(function() {
|
||||
var lookup_split_bill = '<%= @spit_bill %>';
|
||||
if(lookup_split_bill == '1'){
|
||||
swal({
|
||||
title: "Information!",
|
||||
text: "Do you want to Split bill?",
|
||||
type: "success",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#009900",
|
||||
confirmButtonText: "Yes, split it!",
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
var dining_id = "<%= @room.id %>";
|
||||
window.location.href = '/origami/room/' + dining_id + "/split_bills";
|
||||
}else{
|
||||
requestBillProcess();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
requestBillProcess();
|
||||
}
|
||||
});
|
||||
|
||||
function requestBillProcess(){
|
||||
var order_id = $('#save_order_id').attr('data-order');
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
$.ajax({
|
||||
@@ -753,7 +734,13 @@ function requestBillProcess(){
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//split bill process
|
||||
$('#split_bills').click(function(){
|
||||
var dining_id = "<%= @room.id %>";
|
||||
window.location.href = '/origami/room/' + dining_id + "/split_bills";
|
||||
});
|
||||
|
||||
$('#move').on('click',function(){
|
||||
var dining_id = "<%= @room.id %>"
|
||||
|
||||
@@ -59,32 +59,34 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if !order.order_items.nil? %>
|
||||
<% if !@order_items.nil? %>
|
||||
<% sub_total = 0 %>
|
||||
<% order.order_items.each do |order_item| %>
|
||||
<% @order_items.each do |order_item| %>
|
||||
<% if order_item.include? (order.order_id.to_s) %>
|
||||
<%
|
||||
sub_total += order_item.qty*order_item.price
|
||||
sub_total += order_item[order.order_id.to_s]['qty'].to_f * order_item[order.order_id.to_s]['price'].to_f
|
||||
%>
|
||||
<tr class="item-row" id=<%= order_item.order_items_id %> >
|
||||
<tr class="item-row" id=<%= order_item[order.order_id.to_s]['order_items_id'] %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-order-id" class="hidden"><%=order_item.order_id%></span>
|
||||
<span id="item-account-type" class="hidden"><%=order_item.account_id%></span>
|
||||
<span id="item-order-id" class="hidden"><%=order_item[order.order_id.to_s]['order_id'] %></span>
|
||||
<span id="item-account-type" class="hidden"><%=order_item[order.order_id.to_s]['account_id'] %></span>
|
||||
<span id="item-name-price">
|
||||
<%=order_item.item_name%>
|
||||
<% if !order_item.set_menu_items.nil?
|
||||
order_item.set_menu_items.each do |item_instance| %>
|
||||
<%=order_item[order.order_id.to_s]['item_name'] %>
|
||||
<% if !order_item[order.order_id.to_s]['set_menu_items'].nil?
|
||||
order_item[order.order_id.to_s]['set_menu_items'].each do |item_instance| %>
|
||||
<br><span class="font-13"><%= item_instance %></span>
|
||||
<% end
|
||||
end %>
|
||||
</span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-qty"><%=order_item.qty%></span>
|
||||
<span id="item-qty"><%=order_item[order.order_id.to_s]['qty']%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(order_item.qty*order_item.price)%></span>
|
||||
<span id="item-total-price"><%=(order_item[order.order_id.to_s]['qty'].to_f * order_item[order.order_id.to_s]['price'].to_f)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
@@ -148,9 +150,9 @@
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Action Panel -->
|
||||
<div>
|
||||
<button type="button" class="btn bg-default btn-block" id="back" ><i class="material-icons">reply</i> Back </button>
|
||||
<button id="order_split" class="btn btn-primary text-center action-btn" style="width:100%">Orders Split</button>
|
||||
<button id="order_item_split" class="btn btn-primary text-center action-btn">Order Items Split</button>
|
||||
<button type="button" class="btn bg-default btn-block waves-effect" id="back" ><i class="material-icons">reply</i> Back </button>
|
||||
<button id="order_split" class="btn btn-primary text-center action-btn waves-effect">By Order </button>
|
||||
<button id="order_item_split" class="btn btn-primary text-center action-btn waves-effect">By Order Item</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Column Three -->
|
||||
@@ -417,6 +419,7 @@ function get_selected_order_items(){
|
||||
order_item.order_id = $(this).find('#item-order-id').text().trim();
|
||||
order_item.name = $(this).find('#item-name-price').text().split('@')[0];
|
||||
order_item.account_id = $(this).find('#item-account-type').text();
|
||||
order_item.qty = $(this).find('#item-qty').text();
|
||||
order_item.price = $(this).find('#item-total-price').text();
|
||||
order_items.push(order_item);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user