diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb
new file mode 100644
index 00000000..8d805771
--- /dev/null
+++ b/app/controllers/origami/room_invoices_controller.rb
@@ -0,0 +1,40 @@
+class Origami::RoomInvoicesController < BaseOrigamiController
+ def index
+ @room = DiningFacility.find(params[:room_id])
+ puts "room bookig lenght"
+ @sale_array = Array.new
+ @room.bookings.each do |booking|
+ puts booking.sale_id
+
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+ end
+
+ def show
+ @room = DiningFacility.find(params[:room_id])
+ @sale_array = Array.new
+ @room.bookings.each do |booking|
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+
+ @sale = Sale.find(params[:invoice_id])
+ @date = @sale.created_at
+ @status_sale = 'sale'
+ @customer = @sale.customer
+ end
+
+end
diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb
new file mode 100644
index 00000000..32e0ef7f
--- /dev/null
+++ b/app/controllers/origami/table_invoices_controller.rb
@@ -0,0 +1,40 @@
+class Origami::TableInvoicesController < BaseOrigamiController
+ def index
+ @table = DiningFacility.find(params[:table_id])
+ puts "table bookig lenght"
+ @sale_array = Array.new
+ @table.bookings.each do |booking|
+ puts booking.sale_id
+
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+ end
+
+ def show
+ @table = DiningFacility.find(params[:table_id])
+ @sale_array = Array.new
+ @table.bookings.each do |booking|
+ if booking.sale_id.nil?
+ else
+ sale = Sale.find(booking.sale_id)
+
+ if sale.sale_status != "completed"
+ @sale_array.push(sale)
+ end
+ end
+ end
+
+ @sale = Sale.find(params[:invoice_id])
+ @date = @sale.created_at
+ @status_sale = 'sale'
+ @customer = @sale.customer
+ end
+
+end
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index 73f298ec..c25c1b2f 100644
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -126,7 +126,7 @@
<%= @customer.customer_id %>
@@ -241,18 +241,18 @@
%>
- <%
- end
- @sale_array.each do |sale|
+ <% end %>
+
+ Pending Payment
+ <% @sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
-
- Pending Payment
+
| Receipt No - <%= sale.receipt_no %> |
- |
+ |
<%
@@ -298,6 +298,11 @@
diff --git a/app/views/origami/room_invoices/index.html.erb b/app/views/origami/room_invoices/index.html.erb
new file mode 100644
index 00000000..011aff11
--- /dev/null
+++ b/app/views/origami/room_invoices/index.html.erb
@@ -0,0 +1,82 @@
+
+
+ <% @sale_array.each do |sale| %>
+
+
+ <%= sale.receipt_no %>
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
Receipt No:
+ <%= @sale.receipt_no rescue '' %>
+
+
+
+
Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/origami/room_invoices/show.html.erb b/app/views/origami/room_invoices/show.html.erb
new file mode 100644
index 00000000..46e9a892
--- /dev/null
+++ b/app/views/origami/room_invoices/show.html.erb
@@ -0,0 +1,147 @@
+
+
+
+ <% @sale_array.each do |sale| %>
+
+ <% if sale.id == @sale.id %>
+
+ <%= sale.receipt_no %>
+
+ <% else %>
+
+ <%= sale.receipt_no %>
+
+ <% end %>
+
+ <% end %>
+
+
+
+
+
+
+
+
+
Receipt No:
+ <%= @sale.receipt_no rescue '' %>
+
+
+
+
Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+
+
+
+
+
+
<%= @customer.customer_id %>
+
Customer : <%= @customer.name %>
+
+
+
+
+
+
+
+
+ | # |
+ Items |
+ QTY
+ | Price
+ |
+
+
+ <%
+ count = 0
+ sub_total = 0
+ if @status_sale == "sale"
+ @sale.sale_items.each do |sale_item|
+ count += 1
+ sub_total = sub_total + sale_item.price
+ %>
+
+ <%
+ # Can't check for discount
+ unless sale_item.price == 0
+ %>
+
+ | <%= count %> |
+ <%= sale_item.product_name %> |
+ <%= sale_item.qty %> |
+ <%= sale_item.price %> |
+
+ <%
+ end
+ end
+ end
+
+ if @status_order == 'order' && @status_sale != 'sale'
+ unless @order_items.nil?
+ count = 0
+ @order_items.each do |order_item |
+ count += 1
+ sub_total = sub_total + order_item.price
+
+ unless order_item.price == 0 %>
+
+ | <%= count %> |
+ <%= order_item.item_name %> |
+ <%= order_item.qty %> |
+ <%= order_item.qty*order_item.price %> |
+
+ <%
+ end
+ end
+ end
+ end
+ %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/origami/table_invoices/index.html.erb b/app/views/origami/table_invoices/index.html.erb
new file mode 100644
index 00000000..d5cbe84d
--- /dev/null
+++ b/app/views/origami/table_invoices/index.html.erb
@@ -0,0 +1,82 @@
+
+
+ <% @sale_array.each do |sale| %>
+
+
+ <%= sale.receipt_no %>
+
+
+ <% end %>
+
+
+
+
+
+
+
+
+
+
Receipt No:
+ <%= @sale.receipt_no rescue '' %>
+
+
+
+
Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb
new file mode 100644
index 00000000..065c7f8d
--- /dev/null
+++ b/app/views/origami/table_invoices/show.html.erb
@@ -0,0 +1,147 @@
+
+
+
+ <% @sale_array.each do |sale| %>
+
+ <% if sale.id == @sale.id %>
+
+ <%= sale.receipt_no %>
+
+ <% else %>
+
+ <%= sale.receipt_no %>
+
+ <% end %>
+
+ <% end %>
+
+
+
+
+
+
+
+
+
Receipt No:
+ <%= @sale.receipt_no rescue '' %>
+
+
+
+
Date: <%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>
+
+
+
+
+
+
<%= @customer.customer_id %>
+
Customer : <%= @customer.name %>
+
+
+
+
+
+
+
+
+ | # |
+ Items |
+ QTY
+ | Price
+ |
+
+
+ <%
+ count = 0
+ sub_total = 0
+ if @status_sale == "sale"
+ @sale.sale_items.each do |sale_item|
+ count += 1
+ sub_total = sub_total + sale_item.price
+ %>
+
+ <%
+ # Can't check for discount
+ unless sale_item.price == 0
+ %>
+
+ | <%= count %> |
+ <%= sale_item.product_name %> |
+ <%= sale_item.qty %> |
+ <%= sale_item.price %> |
+
+ <%
+ end
+ end
+ end
+
+ if @status_order == 'order' && @status_sale != 'sale'
+ unless @order_items.nil?
+ count = 0
+ @order_items.each do |order_item |
+ count += 1
+ sub_total = sub_total + order_item.price
+
+ unless order_item.price == 0 %>
+
+ | <%= count %> |
+ <%= order_item.item_name %> |
+ <%= order_item.qty %> |
+ <%= order_item.qty*order_item.price %> |
+
+ <%
+ end
+ end
+ end
+ end
+ %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index c93beb92..6466b664 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -109,6 +109,12 @@ Rails.application.routes.draw do
get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index"
get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index"
+ #---------Multiple Invoices --------------#
+ get 'table/:table_id/table_invoices' => "table_invoices#index" , :as => "table_invoice_index"
+ get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show" , :as => "table_invoice_show"
+ get 'room/:room_id/room_invoices' => "room_invoices#index" , :as => "room_invoice_index"
+ get 'room/:room_id/room_invoice/:invoice_id' => "room_invoices#show" , :as => "room_invoice_show"
+
#---------Add Customer --------------#
#resources :customers
get '/:sale_id/customers', to: "customers#add_customer"