From a226a39d0816726bec552c96bbe65de721a8d94f Mon Sep 17 00:00:00 2001 From: yarzar_code Date: Wed, 26 Aug 2020 10:41:13 +0630 Subject: [PATCH] split bill fixed --- app/controllers/origami/home_controller.rb | 14 ++++++++------ app/views/origami/home/show.html.erb | 14 +++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index ad135e03..eaf3bab7 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -35,19 +35,21 @@ class Origami::HomeController < BaseOrigamiController @shop = shop_detail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - @dining_booking = @dining.current_bookings @order_items = Array.new - @dining_booking.each do |booking| + @dining.current_bookings.each do |booking| if @obj_sale || @booking.blank? @booking = booking end if booking.sale_id - @obj_sale = booking.sale - @sale_array.push(@obj_sale) - @sale_taxes = @obj_sale.sale_taxes - @status_sale = 'sale' + @sale_array.push(booking.sale) + + if @obj_sale.blank? + @obj_sale = booking.sale + @sale_taxes = @obj_sale.sale_taxes + @status_sale = 'sale' + end else @order_items += booking.order_items @obj_order = booking.orders.first diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index b49523d6..7e92ac0d 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -239,7 +239,7 @@
  Receipt No: <% if @status_sale == 'sale' %> - <%= @sale_array[0].receipt_no rescue '' %> + <%= @obj_sale.receipt_no rescue '' %> <% end %>
@@ -266,8 +266,8 @@
<% if @status_sale == 'sale' %> - -   Customer : <%= @sale_array[0].customer.name rescue '' %> + +   Customer : <%= @obj_sale.customer.name rescue '' %> <% elsif @status_order == 'order' %> @@ -291,9 +291,9 @@ <% count = 0 sub_total = 0 if @status_sale == "sale" - @sale_array[0].sale_items.each do |sale_item| + @obj_sale.sale_items.each do |sale_item| sub_total = sub_total + sale_item.price%> - + <%count += 1 %> <%= count %> @@ -455,7 +455,7 @@ <% end %> <% @sale_array.each do |sale| if @sale_array.size > 1 - unless sale.receipt_no == @sale_array[0].receipt_no + unless sale.receipt_no == @obj_sale.receipt_no %> @@ -529,7 +529,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' && (!(@order_items.nil?) || !(@order_items.empty?)) %> + <% if @split_bill == '1' && (@orde_items.present?) %> <% end %> <% end %>