From 6a6b7eae292b0a91bf55188b2f0893cd39f4517b Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 2 Aug 2017 16:58:34 +0630 Subject: [PATCH 1/4] update total tax when other charges --- .../origami/other_charges_controller.rb | 3 ++- app/models/sale.rb | 3 +-- app/views/origami/rooms/show.html.erb | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index b0e6472c..9b94781d 100644 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -45,7 +45,8 @@ class Origami::OtherChargesController < BaseOrigamiController end # Re-calc All Amount in Sale - sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) + # sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) + sale.compute_without_void end dining = {:table_id => table_id, :table_type => table_type } diff --git a/app/models/sale.rb b/app/models/sale.rb index b23c630b..462c8c73 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -232,7 +232,6 @@ class Sale < ApplicationRecord end #compute rounding adjustment # adjust_rounding - sale.save! end @@ -315,7 +314,7 @@ class Sale < ApplicationRecord total_tax_amount = 0 #tax_profile - list by order_by tax_profiles = TaxProfile.all.order("order_by asc") - + # #Creat new tax records tax_profiles.each do |tax| sale_tax = SaleTax.new(:sale => self) diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 2a069af9..27f73619 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -294,6 +294,7 @@ + @@ -304,6 +305,7 @@ + @@ -429,6 +431,25 @@ $(document).ready(function(){ 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 From 3bbf60b3ef319f4c7d6350e5bb1fb05849e43ca6 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 2 Aug 2017 17:31:43 +0630 Subject: [PATCH 2/4] update total tax when other charges --- app/controllers/origami/other_charges_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index 9b94781d..b0e6472c 100644 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -45,8 +45,7 @@ class Origami::OtherChargesController < BaseOrigamiController end # Re-calc All Amount in Sale - # sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) - sale.compute_without_void + sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount) end dining = {:table_id => table_id, :table_type => table_type } From 39a314bc9a43a1caa036d04f90c40d4a784b422d Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 3 Aug 2017 11:22:23 +0630 Subject: [PATCH 3/4] update rome check all fun --- .../origami/moveroom_controller.rb | 15 ++++ app/controllers/origami/rooms_controller.rb | 63 ++++++++++--- app/views/origami/rooms/show.html.erb | 90 +++++++++---------- 3 files changed, 112 insertions(+), 56 deletions(-) diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb index ef1c286a..dea36463 100644 --- a/app/controllers/origami/moveroom_controller.rb +++ b/app/controllers/origami/moveroom_controller.rb @@ -35,5 +35,20 @@ class Origami::MoveroomController < BaseOrigamiController end end end + + def moving + change_to = params[:change_to] #new + change_from = params[:change_from] #original + bookings = Booking.where('dining_facility_id=?',change_from) + + booking_array = Array.new + bookings.each do | booking | + if booking.sale_id.nil? && booking.booking_status != 'moved' + booking_array.push(booking) + end + end + + @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) + end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 823136b9..d7092692 100644 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -1,36 +1,77 @@ class Origami::RoomsController < BaseOrigamiController + 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 @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') @room = DiningFacility.find(params[:room_id]) + + @status = "" @sale_array = Array.new - @room.bookings.each do |booking| - if booking.sale_id.nil? + + @room.bookings.active.each do |booking| + if booking.sale_id.nil? && booking.booking_status != 'moved' @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) + if (order.status == "new") + @obj = order + @customer = order.customer + @date = order.created_at + order.order_items.each do |item| + @order_items.push(item) + end end end @status = 'order' else - sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" - @sale_array.push(sale) + if sale.sale_status != "completed" && sale.sale_status != 'void' + @sale_array.push(sale) + if @status == 'order' + @status = 'sale' + end + @date = sale.created_at @status = 'sale' @obj = sale @customer = sale.customer 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 diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 27f73619..c72ded6e 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -207,7 +207,7 @@ <%= sub_total %> - <%if @obj != nil && @status_sale == 'sale' && @obj.discount_type == 'member_discount'%> + <%if @obj != nil && @status == 'sale' && @obj.discount_type == 'member_discount'%> Member Discount: <%else%> Discount: @@ -232,52 +232,52 @@
- <% - if @status == 'sale' - unless @order_items.nil? - %> - Pending New Order - - <% - count = 0 - @order_items.each do |order_item | - count += 1 - %> - - - - - - - - <% - end + <% + if @status == 'sale' + unless @order_items.nil? + %> + Pending New Order +
<%= count %> - <%= order_item.item_name %><%= order_item.qty %><%= order_item.qty*order_item.price %>
+ <% + count = 0 + @order_items.each do |order_item | + count += 1 %> -
- - <% end %> - <% if @sale_array.size > 1 %> -

- Pending Payment - <% end %> - <% @sale_array.each do |sale| - if @sale_array.size > 1 - unless sale.receipt_no == @sale_array[0].receipt_no - %> - - - - - -
Receipt No - <%= sale.receipt_no %>
- <% - end - end - end - end - %> + + <%= count %> + <%= order_item.item_name %> + <%= order_item.qty %> + <%= order_item.qty*order_item.price %> + + + <% + end + %> + + + <% end %> + <% if @sale_array.size > 1 %> +

+ Pending Payment + <% end %> + <% @sale_array.each do |sale| + if @sale_array.size > 1 + unless sale.receipt_no == @sale_array[0].receipt_no + %> + + + + + + +
Receipt No - <%= sale.receipt_no %>
+ <% + end + end + end + end + %> From 518314c772803a074b805780d78db1c0d51c4150 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 3 Aug 2017 12:05:54 +0630 Subject: [PATCH 4/4] update room in origami --- app/controllers/origami/moveroom_controller.rb | 15 --------------- app/controllers/origami/rooms_controller.rb | 14 +++++++++++--- app/views/origami/moveroom/moving.json.jbuilder | 2 ++ 3 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 app/views/origami/moveroom/moving.json.jbuilder diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb index dea36463..ef1c286a 100644 --- a/app/controllers/origami/moveroom_controller.rb +++ b/app/controllers/origami/moveroom_controller.rb @@ -35,20 +35,5 @@ class Origami::MoveroomController < BaseOrigamiController end end end - - def moving - change_to = params[:change_to] #new - change_from = params[:change_from] #original - bookings = Booking.where('dining_facility_id=?',change_from) - - booking_array = Array.new - bookings.each do | booking | - if booking.sale_id.nil? && booking.booking_status != 'moved' - booking_array.push(booking) - end - end - - @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) - end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index d7092692..de06ef62 100644 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -1,5 +1,7 @@ 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') @@ -7,18 +9,19 @@ class Origami::RoomsController < BaseOrigamiController @orders = Order.all.order('date desc') # @shift = ShiftSale.current_open_shift(current_user.id) end - + def show @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') - @room = DiningFacility.find(params[:room_id]) + + # @room = DiningFacility.find(params[:room_id]) @status = "" @sale_array = Array.new - @room.bookings.active.each do |booking| + @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new booking.booking_orders.each do |booking_order| @@ -74,5 +77,10 @@ class Origami::RoomsController < BaseOrigamiController # end end + private + +def set_dining + @dining = DiningFacility.find(params[:room_id]) +end end diff --git a/app/views/origami/moveroom/moving.json.jbuilder b/app/views/origami/moveroom/moving.json.jbuilder new file mode 100644 index 00000000..acdac2e9 --- /dev/null +++ b/app/views/origami/moveroom/moving.json.jbuilder @@ -0,0 +1,2 @@ +json.status true +json.get_type @get_type \ No newline at end of file