From 209a453ca940b366b9e2344d9fe7eddb4bd9d40e Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 21 Jun 2017 11:39:53 +0630 Subject: [PATCH 1/7] other payments delete button doesn't work --- app/views/origami/jcb/index.html.erb | 1 + app/views/origami/master/index.html.erb | 1 + app/views/origami/mpu/index.html.erb | 1 + app/views/origami/payments/show.html.erb | 12 ++++++------ app/views/origami/redeem_payments/index.html.erb | 1 + app/views/origami/visa/index.html.erb | 1 + 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/views/origami/jcb/index.html.erb b/app/views/origami/jcb/index.html.erb index ac4b2438..e9cc09fa 100644 --- a/app/views/origami/jcb/index.html.erb +++ b/app/views/origami/jcb/index.html.erb @@ -134,6 +134,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); diff --git a/app/views/origami/master/index.html.erb b/app/views/origami/master/index.html.erb index 09fe02b1..6afc1081 100644 --- a/app/views/origami/master/index.html.erb +++ b/app/views/origami/master/index.html.erb @@ -133,6 +133,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); diff --git a/app/views/origami/mpu/index.html.erb b/app/views/origami/mpu/index.html.erb index eb2267e7..e8e25b2f 100644 --- a/app/views/origami/mpu/index.html.erb +++ b/app/views/origami/mpu/index.html.erb @@ -133,6 +133,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index fe36277b..ae642a9d 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -106,14 +106,14 @@
<%= @other %>
<% else %> -
+
Other Payments
<% end %> <% if @other != 0.0 %> -
+
MPU
<%= @other %>
@@ -127,7 +127,7 @@ <% end %> <% if @ppamount != 0.0 %> -
+
Paypar
<%= @ppamount %>
@@ -141,7 +141,7 @@ <% end %> <% if @visacount != 0.0 %> -
+
Visa
<%= @visacount %>
@@ -155,7 +155,7 @@ <% end %> <% if @jcbcount != 0.0 %> -
+
JCB
<%= @jcbcount %>
@@ -169,7 +169,7 @@ <% end %> <% if @mastercount != 0.0 %> -
+
Master
<%= @mastercount %>
diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 7789480f..023912ca 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -129,6 +129,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#used_amount').text(); $('#used_amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': alert($('#valid_amount').text()) $('#used_amount').text($('#valid_amount').text()); diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index 49f1290a..1589ca1b 100644 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -133,6 +133,7 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#amount').text(); $('#amount').text(cash.substr(0,cash.length-1)); + break; case 'nett': var remain_amount = $('#validamount').val(); $('#amount').text(remain_amount); From bd71cfd241eb379cb33cd5559798afe6d8c8f3d9 Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 21 Jun 2017 13:21:40 +0630 Subject: [PATCH 2/7] Clock Reality in Origami --- app/views/layouts/_header_orgiami.html.erb | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/views/layouts/_header_orgiami.html.erb b/app/views/layouts/_header_orgiami.html.erb index 9fc53f02..0ae18ff5 100644 --- a/app/views/layouts/_header_orgiami.html.erb +++ b/app/views/layouts/_header_orgiami.html.erb @@ -1,7 +1,7 @@
- Cashier Station 1 - <%= Time.now.strftime('%a, %d %b %Y %H:%M:%S %p') %> + Cashier Station 1 -
<% if current_login_employee %> @@ -10,3 +10,29 @@
+ +
From 51252b99e30ed1e7cf965b45225a45b6b1217084 Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 21 Jun 2017 17:01:44 +0630 Subject: [PATCH 3/7] Auto Refresh on/off --- app/views/origami/home/index.html.erb | 68 ++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index e1e530e8..08f53998 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -94,7 +94,7 @@
- +
@@ -117,4 +117,70 @@ $(document).ready(function(){ window.location.href = '/origami/order/' + order_id; }) }); +$(function() { + var timer; + + function start() { + timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 30000); //10000 + }; + + function stop() { + clearTimeout(timer); + }; + + if(localStorage.getItem("refreshflag") != null){ + if (localStorage.getItem("refreshflag") == 0) { + $('#refreshbutton').html("Refresh off"); + $('#refreshbutton').css("background-color","red"); + stop(); + } + else{ + $('#refreshbutton').html("Refresh on"); + $('#refreshbutton').css("background-color","green"); + start(); + } + } + else{ + localStorage.setItem("refreshflag", 0); + } + var url = location.href; + if (location.href.slice(-1) == "/"){ + url = url.substring(0, url.length - 1); + } + var arr = url.split("/"); + + if(arr[arr.length-1] != "origami"){ + stop(); + } + $('#refreshbutton').bind("click", function(){ + if(localStorage.getItem("refreshflag") == "0"){ + localStorage.setItem("refreshflag", 1); + $(this).html("Refresh on"); + $(this).css("background-color","green"); + // $(this).html("Auto Refresh on"); + start(); + } + else{ + stop(); + localStorage.setItem("refreshflag", 0); + $(this).html("Refresh off"); + $(this).css("background-color","red"); + } + }); + function refreshing(){ + if(localStorage.getItem("refreshflag") == "0"){ + localStorage.setItem("refreshflag", 1); + $(this).html("Refresh on"); + $(this).css("background-color","green"); + // $(this).html("Auto Refresh on"); + start(); + } + else{ + stop(); + localStorage.setItem("refreshflag", 0); + $(this).html("Refresh off"); + $(this).css("background-color","red"); + } + } +}); From 64210f30ac834a70af4c16d3e5843d39a15ba260 Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 21 Jun 2017 17:53:44 +0630 Subject: [PATCH 4/7] move table --- app/controllers/api/bill_controller.rb | 18 ++-- app/controllers/api/bookings_controller.rb | 10 +-- app/controllers/api/orders_controller.rb | 86 ++++++++++++++++--- app/controllers/origami/home_controller.rb | 3 +- .../origami/movetable_controller.rb | 3 +- app/controllers/origami/orders_controller.rb | 7 +- app/models/booking.rb | 13 +++ app/models/dining_facility.rb | 3 +- app/models/order.rb | 2 +- app/views/api/bookings/show.json.jbuilder | 4 +- .../api/orders/view_orders.json.jbuilder | 49 +++++++++++ .../api/restaurant/zones/index.json.jbuilder | 8 +- app/views/origami/home/show.html.erb | 2 + .../origami/movetable/move_dining.html.erb | 24 ++++++ app/views/origami/orders/show.html.erb | 23 ++++- config/routes.rb | 3 +- 16 files changed, 218 insertions(+), 40 deletions(-) create mode 100644 app/views/api/orders/view_orders.json.jbuilder diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 03909dc4..86d50556 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -9,15 +9,17 @@ class Api::BillController < Api::ApiController #create Bill by Booking ID if (params[:booking_id]) booking = Booking.find(params[:booking_id]) - if booking - if booking.sale_id.nil? - @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) - else - @status = true - @sale_id = booking.sale_id + + if booking + if booking.sale_id.nil? + @sale = Sale.new + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) + else + @status = true + @sale_id = booking.sale_id + end end - end + elsif (params[:order_id]) @sale = Sale.new @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) diff --git a/app/controllers/api/bookings_controller.rb b/app/controllers/api/bookings_controller.rb index 401cd4a8..24973d63 100644 --- a/app/controllers/api/bookings_controller.rb +++ b/app/controllers/api/bookings_controller.rb @@ -6,11 +6,9 @@ class Api::BookingsController < Api::ApiController end def show - @booking = Booking.find(params[:id]) + booking = Booking.find(params[:id]) + if booking.dining_facility_id.to_i == params[:table_id].to_i + @booking = booking + end end - - # private - # def Bookings_params - # params.permit(:id, :order_id) - # end end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index c383fafb..b42de7c5 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -7,11 +7,45 @@ class Api::OrdersController < Api::ApiController order = Order.find(params[:order_id]) order.order_items end + def get_order order = Order.find(params[:order_id]) order.order_items end + # API - This api will retrive current booking for android with table or room id + def view_orders + booking_id = params[:booking_id] + table_id = params[:table_id] + if Booking.exists?(booking_id) + booking = Booking.find(booking_id) + + if booking + if booking.dining_facility_id.to_i == table_id.to_i + @booking = booking + else + table = DiningFacility.find(table_id) + booking = table.get_current_booking + if booking + if booking.dining_facility_id.to_i == table_id.to_i + @booking = booking + end + end + end + end + else + puts "only table" + table = DiningFacility.find(table_id) + booking = table.get_current_booking + puts booking + if booking + if booking.dining_facility_id.to_i == table_id.to_i + @booking = booking + end + end + end + end + # Description # This API allow new order creation # Input Params @@ -38,18 +72,50 @@ class Api::OrdersController < Api::ApiController if !params["booking_id"].nil? # check booking id is already completed. booking = Booking.find(params[:booking_id]) - if !booking.sale_id.nil? - if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" - @order.new_booking = true + if booking + if booking.dining_facility_id.to_i == params[:table_id].to_i + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + end + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + puts "booking sale is null" + end else - @order.new_booking = false - @order.booking_id = params[:booking_id] + # booking.table id not equal current table + table = DiningFacility.find(params[:table_id]) + if table + booking = table.get_current_booking + if booking + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = booking.booking_id + end + end + end end - else - @order.new_booking = false - @order.booking_id = params[:booking_id] - puts "booking sale is null" - end + end #booking exists + else + #no booking id + table = DiningFacility.find(params[:table_id]) + if table + booking = table.get_current_booking + if booking + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = booking.booking_id + end + end + end end @status, @booking = @order.generate diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 3246ea44..a7fec897 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -15,9 +15,10 @@ class Origami::HomeController < BaseOrigamiController @complete = Sale.all @orders = Order.all.order('date desc') @status_order = "" + @order_items = Array.new @dining.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 = order diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 8199411c..74e5810e 100644 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -8,9 +8,10 @@ class Origami::MovetableController < BaseOrigamiController @status_order = "" @dining = DiningFacility.find(params[:dining_id]) + @order_items = Array.new @dining.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 = order diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 09e0c541..cc5fac3f 100644 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -4,7 +4,12 @@ class Origami::OrdersController < BaseOrigamiController @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @complete = Sale.all - @orders = Order.all.order('date desc') + @orders = Order.all.order('status desc') @order = Order.find(params[:order_id]) + sale_order = SaleOrder.find_by_order_id(@order.order_id) + if sale_order + sale = Sale.find(sale_order.sale_id) + @sale_status = sale.sale_status + end end end diff --git a/app/models/booking.rb b/app/models/booking.rb index 79fbad4a..2b3905ae 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -15,6 +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 new_dining = DiningFacility.find(newd) new_dining.make_occupied old_dining = DiningFacility.find(old) diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index c699a534..abf39d7a 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -19,11 +19,10 @@ class DiningFacility < ApplicationRecord end def get_current_booking - puts "enter booking" booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) if booking.count > 0 then - return booking[0].booking_id + return booking[0] else return nil end diff --git a/app/models/order.rb b/app/models/order.rb index 7ab39a4c..04015816 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -4,7 +4,7 @@ class Order < ApplicationRecord #primary key - need to be unique before_create :generate_custom_id before_create :set_order_date - + has_many :sale_orders belongs_to :customer has_many :order_items, autosave: true , inverse_of: :order has_many :assigned_order_items diff --git a/app/views/api/bookings/show.json.jbuilder b/app/views/api/bookings/show.json.jbuilder index e1ebd5a9..a8236f05 100644 --- a/app/views/api/bookings/show.json.jbuilder +++ b/app/views/api/bookings/show.json.jbuilder @@ -1,4 +1,5 @@ if (@booking) + json.success true json.id @booking.booking_id json.status @booking.booking_status if Sale.exists?(@booking.sale_id) @@ -43,5 +44,6 @@ if (@booking) json.sub_total @total_amount json.commerical_tax @total_amount * 0.05 json.total @total_amount + (@total_amount * 0.05) - +else + json.success false end diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder new file mode 100644 index 00000000..ef927af0 --- /dev/null +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -0,0 +1,49 @@ +if (@booking) + json.success true + json.booking_id @booking.booking_id + json.status @booking.booking_status + if Sale.exists?(@booking.sale_id) + json.sale_status Sale.find(@booking.sale_id).sale_status + else + json.sale_status "" + end + json.checkin_at @booking.checkin_at.strftime("%d-%m-%Y") + json.checkin_by @booking.checkin_by + json.table_name @booking.dining_facility.name + + if @booking.type == "TableBooking" + json.table_id @booking.dining_facility_id + else + json.room_id @booking.dining_facility_id + end + @total_amount = 0.00 + @total_tax = 0.00 + + if @booking.booking_orders + order_items = [] + @booking.booking_orders.each do |bo| + order = Order.find(bo.order_id) + #if (order.status == "new") + order_items = order_items + order.order_items + #end + end + + json.order_items order_items do |item| + json.item_instance_code item.item_code + json.item_name item.item_name + json.price item.price + json.qty item.qty + json.options item.options + json.remark item.remark + json.item_status item.order_item_status + @total_amount = @total_amount + (item.price * item.qty) + end + + end + + json.sub_total @total_amount + json.commerical_tax @total_amount * 0.05 + json.total @total_amount + (@total_amount * 0.05) +else + json.success false +end diff --git a/app/views/api/restaurant/zones/index.json.jbuilder b/app/views/api/restaurant/zones/index.json.jbuilder index cbcf1424..e2d040c6 100644 --- a/app/views/api/restaurant/zones/index.json.jbuilder +++ b/app/views/api/restaurant/zones/index.json.jbuilder @@ -8,7 +8,7 @@ if @zones json.name table.name json.status table.status json.zone_id table.zone_id #Add this zone_id to keep data structure consistance - json.current_booking table.get_current_booking + json.current_booking table.get_current_booking.booking_id rescue "" end json.rooms zone.rooms do |room| @@ -16,7 +16,7 @@ if @zones json.name room.name json.status room.status json.zone_id room.zone_id #Add this zone_id to keep data structure consistance - json.current_booking room.get_current_booking + json.current_booking room.get_current_booking.booking_id rescue "" end end @@ -26,7 +26,7 @@ else #list all tables and rooms with out zones json.name table.name json.status table.status json.zone_id table.zone_id #Add this zone_id to keep data structure consistance - json.current_booking table.get_current_booking + json.current_booking table.get_current_booking.booking_id rescue "" end @@ -35,7 +35,7 @@ else #list all tables and rooms with out zones json.name room.name json.status room.status json.zone_id room.zone_id #Add this zone_id to keep data structure consistance - json.current_booking room.get_current_booking + json.current_booking room.get_current_booking.booking_id rescue "" end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 07d0fa99..9ce6bdfc 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -229,6 +229,7 @@
+ <% if @dining.bookings.length >= 1 %> @@ -243,6 +244,7 @@ + <% end %>
diff --git a/config/routes.rb b/config/routes.rb index 8f9b7dea..dd5831ae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,10 +44,9 @@ Rails.application.routes.draw do #Order Controller resources :orders, only: [:create, :show, :update] do - post "bill" => "bill#create" - end + get 'view_orders' => "orders#view_orders" #Current active bookings resources :bookings, only: [:index, :show, :create, :update] From c7139609c422f0f49f0bc87e06658f0f575b9dd7 Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 21 Jun 2017 18:26:03 +0630 Subject: [PATCH 5/7] move table --- app/controllers/origami/home_controller.rb | 1 + app/controllers/origami/movetable_controller.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index a7fec897..84a46622 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -17,6 +17,7 @@ class Origami::HomeController < BaseOrigamiController @status_order = "" @order_items = Array.new @dining.bookings.each do |booking| + if booking.sale_id.nil? booking.booking_orders.each do |booking_order| diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 74e5810e..c5b2b2fc 100644 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -10,9 +10,11 @@ class Origami::MovetableController < BaseOrigamiController @dining = DiningFacility.find(params[:dining_id]) @order_items = Array.new @dining.bookings.each do |booking| + if booking.sale_id.nil? booking.booking_orders.each do |booking_order| + order = Order.find(booking_order.order_id) @obj_order = order @date = order.created_at From 168c571a23a78d417a69f42cd175050a84fa3c00 Mon Sep 17 00:00:00 2001 From: Nweni Date: Thu, 22 Jun 2017 05:24:31 +0630 Subject: [PATCH 6/7] multiple invoice --- app/controllers/origami/home_controller.rb | 11 ++++---- app/controllers/origami/orders_controller.rb | 2 +- app/controllers/origami/rooms_controller.rb | 2 +- app/controllers/origami/sales_controller.rb | 2 +- app/models/booking.rb | 26 +++++++++---------- app/views/origami/home/show.html.erb | 23 +++++++++++++--- .../origami/movetable/move_dining.html.erb | 14 +++++++--- 7 files changed, 53 insertions(+), 27 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 84a46622..dc61f7fb 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -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 diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index cc5fac3f..e5eb2808 100644 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -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) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 1ac7f41a..56030d4f 100644 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -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| diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index e9eb2edc..b5200114 100644 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -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 diff --git a/app/models/booking.rb b/app/models/booking.rb index 2b3905ae..4aa177fc 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -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) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 9ce6bdfc..d1629a04 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -97,7 +97,7 @@
- <% if @status_order == 'order' %> + <% if @status_order == 'order' && @status_sale != 'sale' %>
ORDER DETAILS
<% elsif @status_sale == 'sale' %>
INVOICE DETAILS
@@ -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 @@ <% + else + @sale_array.each do |sale| + if @sale_array.size > 1 + %> + Pending New Invoice + <% + unless sale.receipt_no == @obj_sale.receipt_no + %> + + + + +
<%= sale.receipt_no %>
+ <% + end + end + end + end end - end %>
diff --git a/app/views/origami/movetable/move_dining.html.erb b/app/views/origami/movetable/move_dining.html.erb index 2e03aaa2..7874f42b 100644 --- a/app/views/origami/movetable/move_dining.html.erb +++ b/app/views/origami/movetable/move_dining.html.erb @@ -99,6 +99,7 @@ + <% + 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 %> <% unless sale_item.price <= 0 %> + @@ -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 %> + @@ -150,10 +155,13 @@ Pending New Order
# Items QTY Price @@ -106,14 +107,17 @@
<%= count %> <%= sale_item.product_name %> <%= sale_item.qty %> <%= sale_item.price %>
<%= count %> <%= order_item.item_name %> <%= order_item.qty %> <%= order_item.qty*order_item.price %>
<% + count = 0 @order_items.each do |order_item | + count += 1 %> + From 0ff10f2f32684af9bf2951a5aafa86bf83a687c1 Mon Sep 17 00:00:00 2001 From: Nweni Date: Thu, 22 Jun 2017 05:51:42 +0630 Subject: [PATCH 7/7] move multiple order and sales --- app/controllers/origami/home_controller.rb | 3 +- .../origami/movetable_controller.rb | 9 ++-- app/models/booking.rb | 13 ------ app/views/origami/home/show.html.erb | 23 +++++++---- .../origami/movetable/move_dining.html.erb | 41 ++++++++++++++----- 5 files changed, 53 insertions(+), 36 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index dc61f7fb..4c35a918 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -19,8 +19,9 @@ class Origami::HomeController < BaseOrigamiController @sale_array = Array.new @dining.bookings.each do |booking| if booking.sale_id.nil? + @order_items = Array.new 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 diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index c5b2b2fc..cc6281ce 100644 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -5,14 +5,14 @@ class Origami::MovetableController < BaseOrigamiController @rooms = Room.all.active.order('status desc') @complete = Sale.all @orders = Order.all.order('date desc') + @dining = DiningFacility.find(params[:dining_id]) @status_order = "" - @dining = DiningFacility.find(params[:dining_id]) - @order_items = Array.new + @status_sale = "" + @sale_array = Array.new @dining.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) @@ -26,6 +26,7 @@ class Origami::MovetableController < 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 diff --git a/app/models/booking.rb b/app/models/booking.rb index 4aa177fc..79fbad4a 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -15,19 +15,6 @@ 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 new_dining = DiningFacility.find(newd) new_dining.make_occupied old_dining = DiningFacility.find(old) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index d1629a04..b6398686 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -108,7 +108,7 @@

Receipt No: <% if @status_sale == 'sale' %> - <%= @obj_sale.receipt_no rescue '' %> + <%= @sale_array[0].receipt_no rescue '' %> <% end %>

@@ -126,6 +126,7 @@
<%= count %> <%= order_item.item_name %> <%= order_item.qty %> <%= order_item.qty*order_item.price %>
+ <% + count = 0 sub_total = 0 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 %> - + <% unless sale_item.price <= 0 %> + @@ -152,11 +157,16 @@ if @status_order == 'order' && @status_sale != 'sale' unless @order_items.nil? + count = 0 @order_items.each do |order_item | + puts @order_items.size + puts "view" + count += 1 sub_total = sub_total + order_item.price unless order_item.price <= 0 %> + @@ -220,14 +230,13 @@ else @sale_array.each do |sale| if @sale_array.size > 1 + unless sale.receipt_no == @sale_array[0].receipt_no %> Pending New Invoice - <% - unless sale.receipt_no == @obj_sale.receipt_no - %>
# Items QTY Price @@ -133,14 +134,18 @@
<%= count %> <%= sale_item.product_name %> <%= sale_item.qty %> <%= sale_item.price %>
<%= count %> <%= order_item.item_name %> <%= order_item.qty %> <%= order_item.qty*order_item.price %>
- + +
<%= sale.receipt_no %>Receipt No - <%= sale.receipt_no %>
<% diff --git a/app/views/origami/movetable/move_dining.html.erb b/app/views/origami/movetable/move_dining.html.erb index 7874f42b..83419ca0 100644 --- a/app/views/origami/movetable/move_dining.html.erb +++ b/app/views/origami/movetable/move_dining.html.erb @@ -81,7 +81,7 @@

Receipt No: <% if @status_sale == 'sale' %> - <%= @obj_sale.receipt_no rescue '' %> + <%= @sale_array[0].receipt_no rescue '' %> <% end %>

@@ -110,11 +110,12 @@ count = 0 sub_total = 0 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 - count += 1 %> - + <% unless sale_item.price <= 0 %> <%= count %> @@ -126,12 +127,16 @@ end end end - count = 0 - if @status_order == 'order' && @status_sale != 'sale' + + if @status_order == 'order' && @status_sale != 'sale' unless @order_items.nil? + count = 0 @order_items.each do |order_item | + puts @order_items.size + puts "view" + count += 1 sub_total = sub_total + order_item.price - count += 1 + unless order_item.price <= 0 %> <%= count %> @@ -155,13 +160,10 @@ Pending New Order <% - count = 0 @order_items.each do |order_item | - count += 1 %> - @@ -171,9 +173,26 @@ end %>
<%= count %> <%= order_item.item_name %> <%= order_item.qty %> <%= order_item.qty*order_item.price %>
+ <% + else + @sale_array.each do |sale| + if @sale_array.size > 1 + unless sale.receipt_no == @sale_array[0].receipt_no + %> + Pending New Invoice + + + + + +
Receipt No - <%= sale.receipt_no %>
+ <% + end + end + end + end end - end %>