Merge branch 'staging' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-08-03 12:10:51 +06:30
4 changed files with 130 additions and 59 deletions

View File

@@ -1,37 +1,86 @@
class Origami::RoomsController < BaseOrigamiController class Origami::RoomsController < BaseOrigamiController
before_action :set_dining, only: [:show]
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
# @shift = ShiftSale.current_open_shift(current_user.id)
end
def show def show
@tables = Table.all.active.order('status desc') @tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc') @rooms = Room.all.active.order('status desc')
@complete = Sale.where("sale_status != 'new'") @complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc') @orders = Order.all.order('date desc')
@room = DiningFacility.find(params[:room_id])
# @room = DiningFacility.find(params[:room_id])
@status = ""
@sale_array = Array.new @sale_array = Array.new
@room.bookings.each do |booking|
if booking.sale_id.nil? @dining.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new @order_items = Array.new
booking.booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
@obj = order if (order.status == "new")
@customer = order.customer @obj = order
order.order_items.each do |item| @customer = order.customer
@order_items.push(item) @date = order.created_at
order.order_items.each do |item|
@order_items.push(item)
end
end end
end end
@status = 'order' @status = 'order'
else else
sale = Sale.find(booking.sale_id) sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" if sale.sale_status != "completed" && sale.sale_status != 'void'
@sale_array.push(sale) @sale_array.push(sale)
if @status == 'order'
@status = 'sale'
end
@date = sale.created_at
@status = 'sale' @status = 'sale'
@obj = sale @obj = sale
@customer = sale.customer @customer = sale.customer
end end
end end
end end
# @room.bookings.each do |booking|
# if booking.sale_id.nil?
# @order_items = Array.new
# booking.booking_orders.each do |booking_order|
# order = Order.find(booking_order.order_id)
# @obj = order
# @customer = order.customer
# order.order_items.each do |item|
# @order_items.push(item)
# end
# end
# @status = 'order'
# else
# sale = Sale.find(booking.sale_id)
# if sale.sale_status != "completed"
# @sale_array.push(sale)
# @status = 'sale'
# @obj = sale
# @customer = sale.customer
# end
# end
# end
end end
private
def set_dining
@dining = DiningFacility.find(params[:room_id])
end
end end

View File

@@ -232,7 +232,6 @@ class Sale < ApplicationRecord
end end
#compute rounding adjustment #compute rounding adjustment
# adjust_rounding # adjust_rounding
sale.save! sale.save!
end end
@@ -315,7 +314,7 @@ class Sale < ApplicationRecord
total_tax_amount = 0 total_tax_amount = 0
#tax_profile - list by order_by #tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc") tax_profiles = TaxProfile.all.order("order_by asc")
# #Creat new tax records # #Creat new tax records
tax_profiles.each do |tax| tax_profiles.each do |tax|
sale_tax = SaleTax.new(:sale => self) sale_tax = SaleTax.new(:sale => self)

View File

@@ -0,0 +1,2 @@
json.status true
json.get_type @get_type

View File

@@ -207,7 +207,7 @@
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td> <td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr> </tr>
<tr> <tr>
<%if @obj != nil && @status_sale == 'sale' && @obj.discount_type == 'member_discount'%> <%if @obj != nil && @status == 'sale' && @obj.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td> <td class="charges-name"><strong>Member Discount:</strong></td>
<%else%> <%else%>
<td class="charges-name"><strong>Discount:</strong></td> <td class="charges-name"><strong>Discount:</strong></td>
@@ -232,52 +232,52 @@
</table> </table>
</div> </div>
<br> <br>
<% <%
if @status == 'sale' if @status == 'sale'
unless @order_items.nil? unless @order_items.nil?
%> %>
Pending New Order Pending New Order
<table class="table table-striped"> <table class="table table-striped">
<% <%
count = 0 count = 0
@order_items.each do |order_item | @order_items.each do |order_item |
count += 1 count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%> %>
</table>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice </button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
Pending Payment
<% end %>
<% @sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
<table class="table table-striped"> <tr>
<tr> <td><%= count %>
<td>Receipt No - <%= sale.receipt_no %></td> <td class='item-name'><%= order_item.item_name %></td>
<td><button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show Detail </button></td> <td class='item-attr'><%= order_item.qty %></td>
</tr> <td class='item-attr'><%= order_item.qty*order_item.price %></td>
</table> </tr>
<%
end <%
end end
end %>
end </table>
%> <button class='btn btn-primary' id='add_invoice'> Add to existing invoice </button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
Pending Payment
<% end %>
<% @sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
<td><button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show Detail </button></td>
</tr>
</table>
<%
end
end
end
end
%>
</div> </div>
</div> </div>
@@ -294,6 +294,7 @@
<button type="button" id="customer" class="btn btn-primary btn-block" disabled>Customer</button> <button type="button" id="customer" class="btn btn-primary btn-block" disabled>Customer</button>
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button> <button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button> <button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button> <button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button> <button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button> <button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
@@ -304,6 +305,7 @@
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button> <button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button> <button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button> <button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button> <button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button> <button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button> <button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
@@ -429,6 +431,25 @@ $(document).ready(function(){
return false; return false;
}); });
// Add Other Charges
$('#other-charges').click(function() {
var sale = $('#sale_id').val();
if (sale!="") {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
}
if(sale_id!=""){
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
}
return false;
});
}); });
// Print for first bill // Print for first bill