move multiple order and sales
This commit is contained in:
@@ -19,8 +19,9 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
@dining.bookings.each do |booking|
|
@dining.bookings.each do |booking|
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
booking.booking_orders.each do |booking_order|
|
|
||||||
@order_items = Array.new
|
@order_items = Array.new
|
||||||
|
booking.booking_orders.each do |booking_order|
|
||||||
|
|
||||||
order = Order.find(booking_order.order_id)
|
order = Order.find(booking_order.order_id)
|
||||||
@obj_order = order
|
@obj_order = order
|
||||||
@date = order.created_at
|
@date = order.created_at
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ class Origami::MovetableController < BaseOrigamiController
|
|||||||
@rooms = Room.all.active.order('status desc')
|
@rooms = Room.all.active.order('status desc')
|
||||||
@complete = Sale.all
|
@complete = Sale.all
|
||||||
@orders = Order.all.order('date desc')
|
@orders = Order.all.order('date desc')
|
||||||
|
@dining = DiningFacility.find(params[:dining_id])
|
||||||
|
|
||||||
@status_order = ""
|
@status_order = ""
|
||||||
@dining = DiningFacility.find(params[:dining_id])
|
@status_sale = ""
|
||||||
@order_items = Array.new
|
@sale_array = Array.new
|
||||||
@dining.bookings.each do |booking|
|
@dining.bookings.each do |booking|
|
||||||
|
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
|
@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)
|
||||||
@@ -26,6 +26,7 @@ class Origami::MovetableController < BaseOrigamiController
|
|||||||
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_array.push(sale)
|
||||||
if @status_order == 'order'
|
if @status_order == 'order'
|
||||||
@status_order = 'sale'
|
@status_order = 'sale'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,19 +15,6 @@ class Booking < ApplicationRecord
|
|||||||
booking.dining_facility_id = newd
|
booking.dining_facility_id = newd
|
||||||
booking.save
|
booking.save
|
||||||
end
|
end
|
||||||
# table = DiningFacility.find(newd)
|
|
||||||
# if table
|
|
||||||
# booking = table.get_current_booking
|
|
||||||
# if booking
|
|
||||||
# newtablebookingID= booking.booking_id
|
|
||||||
# booking_arr.each do |booking|
|
|
||||||
# booking.booking_orders.each do |booking_order|
|
|
||||||
# booking_order.booking_id = newtablebookingID
|
|
||||||
# booking_order.save
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
new_dining = DiningFacility.find(newd)
|
new_dining = DiningFacility.find(newd)
|
||||||
new_dining.make_occupied
|
new_dining.make_occupied
|
||||||
old_dining = DiningFacility.find(old)
|
old_dining = DiningFacility.find(old)
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||||
<p> Receipt No: <span id="receipt_no">
|
<p> Receipt No: <span id="receipt_no">
|
||||||
<% if @status_sale == 'sale' %>
|
<% if @status_sale == 'sale' %>
|
||||||
<%= @obj_sale.receipt_no rescue '' %>
|
<%= @sale_array[0].receipt_no rescue '' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span></p>
|
</span></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -126,6 +126,7 @@
|
|||||||
<table class="table table-striped" id="order-items-table">
|
<table class="table table-striped" id="order-items-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
<th class="item-name">Items</th>
|
<th class="item-name">Items</th>
|
||||||
<th class="item-attr">QTY</td>
|
<th class="item-attr">QTY</td>
|
||||||
<th class="item-attr">Price</td>
|
<th class="item-attr">Price</td>
|
||||||
@@ -133,14 +134,18 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<%
|
<%
|
||||||
|
count = 0
|
||||||
sub_total = 0
|
sub_total = 0
|
||||||
if @status_sale == "sale"
|
if @status_sale == "sale"
|
||||||
@obj_sale.sale_items.each do |sale_item|
|
puts @sale_array[0]
|
||||||
|
@sale_array[0].sale_items.each do |sale_item|
|
||||||
|
count += 1
|
||||||
sub_total = sub_total + sale_item.price
|
sub_total = sub_total + sale_item.price
|
||||||
%>
|
%>
|
||||||
<input type="hidden" id="sale_id" value="<%= @obj_sale.sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
|
||||||
<% unless sale_item.price <= 0 %>
|
<% unless sale_item.price <= 0 %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><%= count %></td>
|
||||||
<td class='item-name'><%= sale_item.product_name %></td>
|
<td class='item-name'><%= sale_item.product_name %></td>
|
||||||
<td class='item-attr'><%= sale_item.qty %></td>
|
<td class='item-attr'><%= sale_item.qty %></td>
|
||||||
<td class='item-attr'><%= sale_item.price %></td>
|
<td class='item-attr'><%= sale_item.price %></td>
|
||||||
@@ -152,11 +157,16 @@
|
|||||||
|
|
||||||
if @status_order == 'order' && @status_sale != 'sale'
|
if @status_order == 'order' && @status_sale != 'sale'
|
||||||
unless @order_items.nil?
|
unless @order_items.nil?
|
||||||
|
count = 0
|
||||||
@order_items.each do |order_item |
|
@order_items.each do |order_item |
|
||||||
|
puts @order_items.size
|
||||||
|
puts "view"
|
||||||
|
count += 1
|
||||||
sub_total = sub_total + order_item.price
|
sub_total = sub_total + order_item.price
|
||||||
|
|
||||||
unless order_item.price <= 0 %>
|
unless order_item.price <= 0 %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><%= count %></td>
|
||||||
<td class='item-name'><%= order_item.item_name %></td>
|
<td class='item-name'><%= order_item.item_name %></td>
|
||||||
<td class='item-attr'><%= order_item.qty %></td>
|
<td class='item-attr'><%= order_item.qty %></td>
|
||||||
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
|
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
|
||||||
@@ -220,14 +230,13 @@
|
|||||||
else
|
else
|
||||||
@sale_array.each do |sale|
|
@sale_array.each do |sale|
|
||||||
if @sale_array.size > 1
|
if @sale_array.size > 1
|
||||||
|
unless sale.receipt_no == @sale_array[0].receipt_no
|
||||||
%>
|
%>
|
||||||
Pending New Invoice
|
Pending New Invoice
|
||||||
<%
|
|
||||||
unless sale.receipt_no == @obj_sale.receipt_no
|
|
||||||
%>
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= sale.receipt_no %></td>
|
<td>Receipt No - <%= sale.receipt_no %></td>
|
||||||
|
<td><button class='btn btn-sm btn-primary '>Show Detail </button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<%
|
<%
|
||||||
|
|||||||
@@ -81,7 +81,7 @@
|
|||||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||||
<p> Receipt No: <span id="receipt_no">
|
<p> Receipt No: <span id="receipt_no">
|
||||||
<% if @status_sale == 'sale' %>
|
<% if @status_sale == 'sale' %>
|
||||||
<%= @obj_sale.receipt_no rescue '' %>
|
<%= @sale_array[0].receipt_no rescue '' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</span></p>
|
</span></p>
|
||||||
</div>
|
</div>
|
||||||
@@ -110,11 +110,12 @@
|
|||||||
count = 0
|
count = 0
|
||||||
sub_total = 0
|
sub_total = 0
|
||||||
if @status_sale == "sale"
|
if @status_sale == "sale"
|
||||||
@obj_sale.sale_items.each do |sale_item|
|
puts @sale_array[0]
|
||||||
sub_total = sub_total + sale_item.price
|
@sale_array[0].sale_items.each do |sale_item|
|
||||||
count += 1
|
count += 1
|
||||||
|
sub_total = sub_total + sale_item.price
|
||||||
%>
|
%>
|
||||||
<input type="hidden" id="sale_id" value="<%= @obj_sale.sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
|
||||||
<% unless sale_item.price <= 0 %>
|
<% unless sale_item.price <= 0 %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
@@ -126,12 +127,16 @@
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
count = 0
|
|
||||||
if @status_order == 'order' && @status_sale != 'sale'
|
if @status_order == 'order' && @status_sale != 'sale'
|
||||||
unless @order_items.nil?
|
unless @order_items.nil?
|
||||||
|
count = 0
|
||||||
@order_items.each do |order_item |
|
@order_items.each do |order_item |
|
||||||
sub_total = sub_total + order_item.price
|
puts @order_items.size
|
||||||
|
puts "view"
|
||||||
count += 1
|
count += 1
|
||||||
|
sub_total = sub_total + order_item.price
|
||||||
|
|
||||||
unless order_item.price <= 0 %>
|
unless order_item.price <= 0 %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
@@ -155,13 +160,10 @@
|
|||||||
Pending New Order
|
Pending New Order
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<%
|
<%
|
||||||
count = 0
|
|
||||||
@order_items.each do |order_item |
|
@order_items.each do |order_item |
|
||||||
count += 1
|
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
|
||||||
<td class='item-name'><%= order_item.item_name %></td>
|
<td class='item-name'><%= order_item.item_name %></td>
|
||||||
<td class='item-attr'><%= order_item.qty %></td>
|
<td class='item-attr'><%= order_item.qty %></td>
|
||||||
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
|
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
|
||||||
@@ -171,7 +173,24 @@
|
|||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
</table>
|
</table>
|
||||||
|
<button class='btn btn-primary'> Add to existing invoice </button>
|
||||||
<%
|
<%
|
||||||
|
else
|
||||||
|
@sale_array.each do |sale|
|
||||||
|
if @sale_array.size > 1
|
||||||
|
unless sale.receipt_no == @sale_array[0].receipt_no
|
||||||
|
%>
|
||||||
|
Pending New Invoice
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tr>
|
||||||
|
<td>Receipt No - <%= sale.receipt_no %></td>
|
||||||
|
<td><button class='btn btn-sm btn-primary '>Show Detail </button></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<%
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
|
|||||||
Reference in New Issue
Block a user