diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 646c0d7b..6248d881 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -130,7 +130,7 @@ class Api::PaymentsController < Api::ApiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,sale,params[:card_no], item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Paid',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,sale,params[:account_no], item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Paid',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) render json: JSON.generate({:status => true, :balance_amount => card_balance_amount,:receipt_no => sale.receipt_no,:order_no => latest_order_no, :message => "complete", :paid_amount => sale.grand_total}) end end diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index 0fd51763..0549d253 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -48,7 +48,7 @@ class Foodcourt::FoodCourtController < ApplicationController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("sales.sale_status =? and sales.payment_status =? and orders.source='app' and DATE(bookings.created_at)=?",'completed','paid',Date.today).order("bookings.created_at desc").uniq.length + .where("bookings.booking_status !=? and sales.sale_status =? and sales.payment_status =? and orders.source='app' and DATE(bookings.created_at)=?",'completed','completed','paid',Date.today).order("bookings.created_at desc").uniq.length render "foodcourt/addorders/detail" end diff --git a/app/pdf/order_item_customise_pdf.rb b/app/pdf/order_item_customise_pdf.rb index 6277fbe1..7a99c1c5 100644 --- a/app/pdf/order_item_customise_pdf.rb +++ b/app/pdf/order_item_customise_pdf.rb @@ -58,7 +58,7 @@ class OrderItemCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 7475bb46..0d5c769a 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -59,8 +59,7 @@ class OrderItemPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) - + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left @@ -162,7 +161,6 @@ class OrderItemPdf < Prawn::Document .joins(" JOIN bookings b ON b.booking_id=bo.booking_id") .where("orders.order_id='#{order_no}'") .first() - return booking.booking_id end end diff --git a/app/pdf/order_item_slim_customise_pdf.rb b/app/pdf/order_item_slim_customise_pdf.rb index e1f0b0bc..51513f5f 100644 --- a/app/pdf/order_item_slim_customise_pdf.rb +++ b/app/pdf/order_item_slim_customise_pdf.rb @@ -58,7 +58,7 @@ class OrderItemSlimCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb index 31c8dac9..20b1c83a 100755 --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -59,7 +59,7 @@ class OrderItemSlimPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_item_star_pdf.rb b/app/pdf/order_item_star_pdf.rb index 2115f234..ee86606e 100644 --- a/app/pdf/order_item_star_pdf.rb +++ b/app/pdf/order_item_star_pdf.rb @@ -60,7 +60,7 @@ class OrderItemStarPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_set_item_customise_pdf.rb b/app/pdf/order_set_item_customise_pdf.rb index 47b9a155..7dff8d03 100644 --- a/app/pdf/order_set_item_customise_pdf.rb +++ b/app/pdf/order_set_item_customise_pdf.rb @@ -58,7 +58,7 @@ class OrderSetItemCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb index abffe96a..d2c611bd 100755 --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -57,7 +57,7 @@ class OrderSetItemPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_summary_customise_pdf.rb b/app/pdf/order_summary_customise_pdf.rb index c6bec6e1..8d167ce7 100644 --- a/app/pdf/order_summary_customise_pdf.rb +++ b/app/pdf/order_summary_customise_pdf.rb @@ -63,7 +63,7 @@ class OrderSummaryCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index b07699a1..cc6e3a08 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -60,7 +60,7 @@ class OrderSummaryPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_summary_set_customise_pdf.rb b/app/pdf/order_summary_set_customise_pdf.rb index 56008dd2..2c584757 100644 --- a/app/pdf/order_summary_set_customise_pdf.rb +++ b/app/pdf/order_summary_set_customise_pdf.rb @@ -62,7 +62,7 @@ class OrderSummarySetCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb index 6e905b47..73fcf6ea 100755 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -61,7 +61,7 @@ class OrderSummarySetPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_summary_slim_customise_pdf.rb b/app/pdf/order_summary_slim_customise_pdf.rb index 9f4ad23e..9c136ed4 100644 --- a/app/pdf/order_summary_slim_customise_pdf.rb +++ b/app/pdf/order_summary_slim_customise_pdf.rb @@ -62,7 +62,7 @@ class OrderSummarySlimCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb index ac1bc87f..b97659c7 100755 --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -61,7 +61,7 @@ class OrderSummarySlimPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) #booking ID - booking_id = get_booking_id(order_no) + booking_id = Order.find_by_order_id(order_no).booking.booking_id y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index b1ff0dc8..efdf7713 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -45,19 +45,19 @@ class ReceiptBillA5Pdf < Prawn::Document if sale_data.orders[0].source =='app' move_down 3 y_position = cursor - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "Mobile Order", :size => self.header_font_size,:align => :left + text "Mobile Order", :size => self.header_font_size,:align => :center, :style=>:bold + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left end if !sale_data.bookings[0].dining_facility.nil? - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right,:style=>:bold + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ sale_data.bookings[0].dining_facility.type } -#{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right end end move_down 1 - text "Customer Ph : #{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left - move_down 1 end - stroke_horizontal_rule cashier_info(sale_data, customer_name, latest_order_no) line_items(sale_items,precision,delimiter) @@ -117,11 +117,10 @@ class ReceiptBillA5Pdf < Prawn::Document move_down line_move text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center move_down line_move - - stroke_horizontal_rule end def cashier_info(sale_data, customer_name, latest_order_no) + stroke_horizontal_rule if latest_order_no.nil? move_down line_move text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+5,:align => :left diff --git a/app/pdf/receipt_bill_order_pdf.rb b/app/pdf/receipt_bill_order_pdf.rb index b3c8b24e..ce3a12fc 100644 --- a/app/pdf/receipt_bill_order_pdf.rb +++ b/app/pdf/receipt_bill_order_pdf.rb @@ -46,20 +46,19 @@ class ReceiptBillOrderPdf < Prawn::Document if sale_data.orders[0].source =='app' move_down 3 y_position = cursor - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "Mobile Order", :size => self.header_font_size,:align => :left + text "Mobile Order", :size => self.header_font_size,:align => :center, :style=>:bold + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left end if !sale_data.bookings[0].dining_facility.nil? - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right,:style=>:bold + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ sale_data.bookings[0].dining_facility.type } -#{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right end end move_down 1 - text "Customer Ph : #{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left - move_down 1 end - stroke_horizontal_rule - cashier_info(sale_data, customer_name, latest_order_no,order_reservation) line_items(sale_items,precision,delimiter,order_reservation) all_total(sale_data,precision,delimiter,order_reservation) @@ -80,6 +79,7 @@ class ReceiptBillOrderPdf < Prawn::Document end def cashier_info(sale_data, customer_name, latest_order_no,order_reservation) + stroke_horizontal_rule move_down line_move # move_down 2 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index bfeb6e98..d735ec9a 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -22,6 +22,7 @@ class ReceiptBillPdf < Prawn::Document self.description_width = 150 self.price_num_width = 50 self.line_move = 2 + # @item_width = self.page_width.to_i / 2 # @qty_width = @item_width.to_i / 3 # @double = @qty_width * 1.3 @@ -48,19 +49,19 @@ class ReceiptBillPdf < Prawn::Document if sale_data.orders[0].source =='app' move_down 3 y_position = cursor - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "Mobile Order", :size => self.header_font_size,:align => :left + text "Mobile Order", :size => self.header_font_size,:align => :center, :style=>:bold + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left end if !sale_data.bookings[0].dining_facility.nil? - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right,:style=>:bold + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ sale_data.bookings[0].dining_facility.type } -#{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right end end move_down 1 - text "Customer Ph : #{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left - move_down 1 end - stroke_horizontal_rule cashier_info(sale_data, customer_account, latest_order_no) line_items(sale_items,precision,delimiter) @@ -126,11 +127,10 @@ class ReceiptBillPdf < Prawn::Document move_down line_move text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center move_down line_move - - stroke_horizontal_rule end def cashier_info(sale_data, customer_account, latest_order_no) + stroke_horizontal_rule if latest_order_no.nil? move_down line_move text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left @@ -456,7 +456,8 @@ class ReceiptBillPdf < Prawn::Document def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule - #move_down line_move + # move_down 2 + move_down line_move # sql = "SELECT SUM(payment_amount) # FROM sale_payments where payment_method='creditnote' # and sale_id='#{sale_data.sale_id}'" diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb index a7c65b09..f0116cab 100644 --- a/app/pdf/receipt_bill_star_pdf.rb +++ b/app/pdf/receipt_bill_star_pdf.rb @@ -47,19 +47,19 @@ class ReceiptBillStarPdf < Prawn::Document if sale_data.orders[0].source =='app' move_down 3 y_position = cursor - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "Mobile Order", :size => self.header_font_size,:align => :left + text "Mobile Order", :size => self.header_font_size,:align => :center, :style=>:bold + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left end if !sale_data.bookings[0].dining_facility.nil? - bounding_box([0,y_position], :width =>self.description_width + self.price_num_width) do - text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right,:style=>:bold + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{ sale_data.bookings[0].dining_facility.type } -#{ sale_data.bookings[0].dining_facility.name }" , :size => self.header_font_size,:align => :right end end move_down 1 - text "Customer Ph : #{sale_data.customer.contact_no}", :size => self.header_font_size,:align => :left - move_down 1 end - stroke_horizontal_rule cashier_info(sale_data, customer_name, latest_order_no) line_items(sale_items,precision,delimiter) @@ -119,10 +119,10 @@ class ReceiptBillStarPdf < Prawn::Document text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center move_down line_move - stroke_horizontal_rule end def cashier_info(sale_data, customer_name, latest_order_no) + stroke_horizontal_rule if latest_order_no.nil? move_down line_move text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left @@ -391,7 +391,7 @@ class ReceiptBillStarPdf < Prawn::Document def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule - #move_down line_move + move_down line_move # sql = "SELECT SUM(payment_amount) # FROM sale_payments where payment_method='creditnote' # and sale_id='#{sale_data.sale_id}'" diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder index 714f2127..bf482111 100755 --- a/app/views/api/restaurant/menu/_menu.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu.json.jbuilder @@ -19,6 +19,7 @@ if (menu.menu_categories) if category.menu_items json.items category.menu_items do |item| + next if item.menu_item_instances.empty? json.partial! 'api/restaurant/menu/menu_item', item: item, request_url: request_url end end