multiple invoice

This commit is contained in:
Nweni
2017-06-22 05:24:31 +06:30
parent c7139609c4
commit 168c571a23
7 changed files with 53 additions and 27 deletions

View File

@@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@complete = Sale.complete_sale
@orders = Order.all.order('date desc')
end
@@ -12,15 +12,15 @@ class Origami::HomeController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@complete = Sale.complete_sale
@orders = Order.all.order('date desc')
@status_order = ""
@order_items = Array.new
@status_sale = ""
@sale_array = Array.new
@dining.bookings.each do |booking|
if booking.sale_id.nil?
booking.booking_orders.each do |booking_order|
@order_items = Array.new
order = Order.find(booking_order.order_id)
@obj_order = order
@date = order.created_at
@@ -32,6 +32,7 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end

View File

@@ -3,7 +3,7 @@ class Origami::OrdersController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@complete = Sale.complete_sale
@orders = Order.all.order('status desc')
@order = Order.find(params[:order_id])
sale_order = SaleOrder.find_by_order_id(@order.order_id)

View File

@@ -3,7 +3,7 @@ class Origami::RoomsController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@complete = Sale.complete_sale
@orders = Order.all.order('date desc')
@room = DiningFacility.find(params[:room_id])
@room.bookings.each do |booking|

View File

@@ -3,7 +3,7 @@ class Origami::SalesController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@complete = Sale.complete_sale
@orders = Order.all.order('date desc')
@sale = Sale.find(params[:sale_id])
end

View File

@@ -15,19 +15,19 @@ class Booking < ApplicationRecord
booking.dining_facility_id = newd
booking.save
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
# 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.make_occupied
old_dining = DiningFacility.find(old)

View File

@@ -97,7 +97,7 @@
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >
<div class="card-header">
<% if @status_order == 'order' %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div>
<% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong></div>
@@ -150,7 +150,7 @@
end
end
if @status_order == 'order'
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
@order_items.each do |order_item |
sub_total = sub_total + order_item.price
@@ -217,8 +217,25 @@
</table>
<button class='btn btn-primary'> Add to existing invoice </button>
<%
else
@sale_array.each do |sale|
if @sale_array.size > 1
%>
Pending New Invoice
<%
unless sale.receipt_no == @obj_sale.receipt_no
%>
<table class="table table-striped">
<tr>
<td><%= sale.receipt_no %></td>
</tr>
</table>
<%
end
end
end
end
end
end
%>
</div>

View File

@@ -99,6 +99,7 @@
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
@@ -106,14 +107,17 @@
</thead>
<tbody>
<%
count = 0
sub_total = 0
if @status_sale == "sale"
@obj_sale.sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
count += 1
%>
<input type="hidden" id="sale_id" value="<%= @obj_sale.sale_id %>">
<% unless sale_item.price <= 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
@@ -122,14 +126,15 @@
end
end
end
if @status_order == 'order'
count = 0
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
@order_items.each do |order_item |
sub_total = sub_total + order_item.price
count += 1
unless order_item.price <= 0 %>
<tr>
<td><%= count %></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*order_item.price %></td>
@@ -150,10 +155,13 @@
Pending New Order
<table class="table table-striped">
<%
count = 0
@order_items.each do |order_item |
count += 1
%>
<tr>
<td><%= count %></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*order_item.price %></td>