diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 2ba6fe52..e0a59dc7 100644 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -72,6 +72,7 @@ } .action-btn { + white-space: normal !important; height: 60px; margin-bottom: 5px; } @@ -168,6 +169,8 @@ background-color: blue } +/* End Colors */ + .left{ margin-left:1px; } @@ -175,6 +178,7 @@ .bottom{ margin-bottom: 1px; } + /*----- Reset -----*/ select.form-control { @@ -197,6 +201,7 @@ tr.discount-item-row:hover { .required abbr{ color: red !important; } + /* Jquery Confirm */ .jconfirm-box-container{ diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index c61b5bc2..5b60b5df 100644 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -1,6 +1,6 @@ class Api::ApiController < ActionController::API include TokenVerification - helper_method :current_token, :current_login_employee + helper_method :current_token, :current_login_employee, :get_cashier private @@ -13,6 +13,11 @@ class Api::ApiController < ActionController::API end end + # Get current Cashier + def get_cashier + @cashier = Employee.where("role = 'cashier' AND token_session <> ''") + end + def current_login_employee @employee = Employee.find_by_token_session(current_token) end diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 9671ba47..c611016f 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -13,7 +13,7 @@ class Api::BillController < Api::ApiController if booking if booking.sale_id.nil? @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) else @status = true @sale_id = booking.sale_id @@ -22,23 +22,31 @@ class Api::BillController < Api::ApiController elsif (params[:order_id]) @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) + @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) end - @sale_data = Sale.find_by_sale_id(@sale_id) - @sale_items = SaleItem.where("sale_id=?",@sale_id) +# Not Use for these printed bill cannot give customer + # @sale_data = Sale.find_by_sale_id(@sale_id) + # @sale_items = SaleItem.where("sale_id=?",@sale_id) - unique_code = "ReceiptBillPdf" - customer= Customer.find(@sale_data.customer_id) + # unique_code = "ReceiptBillPdf" + # #shop detail + # shop_details = Shop.find(1) - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) + # customer= Customer.find(@sale_data.customer_id) + # # get member information + # member_info = Customer.get_member_account(customer) - # Calculate Price by accounts - item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) + + # # Calculate Price by accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + + + # printer = Printer::ReceiptPrinter.new(print_settings) + # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) - printer = Printer::ReceiptPrinter.new(print_settings) - # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts) end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 1eba8c56..e3184ecc 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -67,32 +67,58 @@ class Api::OrdersController < Api::ApiController if booking if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' if !booking.sale_id.nil? - check_order_with_booking(booking) + sale_status = check_order_with_booking(booking) + puts "WWwwWWWWWWww" + puts sale_status + if sale_status + return false , @message = "bill requested" + end else @order.new_booking = false @order.booking_id = params[:booking_id] end else - check_order_with_table(params[:table_id]) + sale_status = check_order_with_table(params[:table_id]) + puts "OOOOOOOOO" + puts sale_status + if sale_status + return false , @message = "bill requested" + end end end #booking exists else - check_order_with_table(params[:table_id]) - end + sale_status = check_order_with_table(params[:table_id]) + puts "MMMMMMMM" + puts sale_status + if sale_status + return false , @message = "bill requested" + end + end @status, @booking = @order.generate end + # render json for http status code 202 + def return_json_status_with_code(code, msg, booking_id) + render status: code, json: { + message: msg, + booking_id: booking_id + }.to_json + end + def check_order_with_table(table_id) table = DiningFacility.find(table_id) if table booking = table.get_current_booking + puts booking if booking if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" @order.new_booking = true + return true else @order.new_booking = false @order.booking_id = booking.booking_id + return false end end end @@ -101,9 +127,11 @@ class Api::OrdersController < Api::ApiController def check_order_with_booking(booking) if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" @order.new_booking = true + return true else @order.new_booking = false @order.booking_id = params[:booking_id] + return false end end # Description diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 463f6dc6..6c76c27a 100644 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -29,7 +29,6 @@ class Origami::DiscountsController < BaseOrigamiController if discount_items.length > 0 #save sale item for discount discount_items.each do |di| - puts di origin_sale_item = SaleItem.find(di["id"]) sale_item = SaleItem.new @@ -53,6 +52,59 @@ class Origami::DiscountsController < BaseOrigamiController render :json => dining.to_json end + # Remove selected discount Items + def remove_discount_items + sale_id = params[:sale_id] + discount_items = JSON.parse(params[:discount_items]) + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type + + if discount_items.length > 0 + #destroy sale item for discount + discount_items.each do |di| + sale_item = SaleItem.find(di["id"]) + sale.total_amount = (sale.total_amount + sale_item.price.abs) + sale_item.destroy + end + end + + sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + sale.save + end + + dining = {:table_id => table_id, :table_type => table_type } + + render :json => dining.to_json + end + + # Remove all discount Items + def remove_all_discount + sale_id = params[:id] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type + + #destroy all discount sale item + sale.sale_items.each do |si| + if si.remark == "Discount" && si.price < 0 + sale.total_amount = (sale.total_amount + si.price.abs) + si.destroy + end + end + + sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + sale.save + end + + dining = {:table_id => table_id, :table_type => table_type } + + render :json => dining.to_json + end + #discount for selected order # def create # sale_id = params[:sale_id] diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f5a0023e..1d26438e 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -4,6 +4,34 @@ class Origami::PaymentsController < BaseOrigamiController def index end + def first_bill + sale_id = params[:sale_id] # sale_id + sale_data = Sale.find_by_sale_id(sale_id) + sale_items = SaleItem.where("sale_id=?",sale_id) + + # Print for First Bill to Customer + unique_code = "ReceiptBillPdf" + #shop detail + shop_details = Shop.find(1) + # customer= Customer.where('customer_id=' +.customer_id) + customer= Customer.find(sale_data.customer_id) + # get member information + member_info = Customer.get_member_account(customer) + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # find order id by sale id + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + + printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details) + end + def create cash = params[:cash] sale_id = params[:sale_id] @@ -26,9 +54,10 @@ class Origami::PaymentsController < BaseOrigamiController print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end end @@ -104,10 +133,9 @@ class Origami::PaymentsController < BaseOrigamiController # Calculate price_by_accounts item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details) + printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) end - - end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index a04936fc..cfea9d37 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -10,9 +10,9 @@ class Origami::RequestBillsController < BaseOrigamiController check_booking = Booking.find_by_booking_id(bk_order.booking_id) if check_booking.sale_id.nil? # Create Sale if it doesn't exist - puts "current_login_employee" - puts current_login_employee.name - @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee) + # puts "current_login_employee" + # puts current_login_employee.name + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) else @@ -20,26 +20,26 @@ class Origami::RequestBillsController < BaseOrigamiController @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id) end - unique_code = "ReceiptBillPdf" - #shop detail - shop_details = Shop.find(1) - # customer= Customer.where('customer_id=' +.customer_id) - customer= Customer.find(@sale_data.customer_id) - # get member information - member_info = Customer.get_member_account(customer) - # get printer info - print_settings=PrintSetting.find_by_unique_code(unique_code) +# Not Use for these printed bill cannot give customer + # unique_code = "ReceiptBillPdf" + # #shop detail + # shop_details = Shop.find(1) + # # customer= Customer.where('customer_id=' +.customer_id) + # customer= Customer.find(@sale_data.customer_id) + # # get member information + # member_info = Customer.get_member_account(customer) + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) - # find order id by sale id - # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + # # find order id by sale id + # # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) - # Calculate price_by_accounts - item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + # # Calculate price_by_accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + + # printer = Printer::ReceiptPrinter.new(print_settings) - printer = Printer::ReceiptPrinter.new(print_settings) # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) - # redirect_to origami_path(@sale_data.sale_id) - end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index 70a5a380..975ae73f 100644 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -18,6 +18,7 @@ class Origami::SaleEditController < BaseOrigamiController @newsaleitem.save @newsaleitem.qty = saleitemObj.qty * -1 @newsaleitem.price = saleitemObj.price * -1 + @newsaleitem.is_taxable = 0 @newsaleitem.product_name = saleitemObj.product_name + " - void" @newsaleitem.save end diff --git a/app/models/ability.rb b/app/models/ability.rb index 5e5fb4f3..2c110e77 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -40,6 +40,8 @@ class Ability can :index, :discount can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount can :show, :payment can :create, :payment @@ -63,6 +65,8 @@ class Ability can :index, :discount can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount can :show, :payment can :create, :payment diff --git a/app/models/order.rb b/app/models/order.rb index b3a70f37..6474fe7c 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -25,9 +25,8 @@ class Order < ApplicationRecord booking = nil if self.new_booking - booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", - :checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name, + :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) table = DiningFacility.find(self.table_id) table.status = "occupied" @@ -55,7 +54,7 @@ class Order < ApplicationRecord end - return false + return false, @message = "booking fail" end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index f80ee72d..f946e17b 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -33,13 +33,13 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order=print_query('order_summary', order_id) # For Print Per Item if oqs.cut_per_item - order_items.each do|odi| + order.each do|odi| filename = "tmp/order_item_#{odi.item_name}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options # check for item not to show - if odi.price != 0 || odi.price != 10 + if odi.price != 0 pdf = OrderItemPdf.new(odi, print_status, options) # pdf.render_file "tmp/order_item.pdf" pdf.render_file filename diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 8e389e79..f8eb46d6 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -65,14 +65,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details) + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details) - pdf.render_file "tmp/receipt_bill.pdf" - self.print("tmp/receipt_bill.pdf") + # print as print copies in printer setting + count = printer_settings.print_copies + begin + pdf.render_file "tmp/receipt_bill.pdf" + self.print("tmp/receipt_bill.pdf") + count -= 1 + end until count == 0 end #Queue No Print diff --git a/app/models/sale.rb b/app/models/sale.rb index cac1308b..bf3bc216 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -25,7 +25,7 @@ class Sale < ApplicationRecord SALE_STATUS_OUTSTANDING = "outstanding" SALE_STATUS_COMPLETED = "completed" - def generate_invoice_from_booking(booking_id, requested_by) + def generate_invoice_from_booking(booking_id, requested_by, cashier) booking = Booking.find(booking_id) status = false Rails.logger.debug "Booking -> " + booking.id.to_s @@ -35,9 +35,9 @@ class Sale < ApplicationRecord booking.booking_orders.each do |order| if booking.sale_id - status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by, cashier) else - status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by, cashier) end booking.sale_id = sale_id end @@ -47,7 +47,7 @@ class Sale < ApplicationRecord end end - def generate_invoice_from_order (order_id, sale_id, booking, requested_by) + def generate_invoice_from_order (order_id, sale_id, booking, requested_by, cashier = nil) taxable = true #if sale_id is exsit and validate #add order to that invoice @@ -66,12 +66,19 @@ class Sale < ApplicationRecord #Default Tax - Values self.tax_type = "exclusive" - # set cashier by current login - self.cashier_id = requested_by.id - self.cashier_name = requested_by.name + # set cashier + if cashier != nil + self.cashier_id = cashier[0].id + self.cashier_name = cashier[0].name + else + self.cashier_id = requested_by.id + self.cashier_name = requested_by.name + end + + # set waiter self.requested_by = requested_by.name - self.requested_at = DateTime.now.utc + self.requested_at = DateTime.now.utc.getlocal Rails.logger.debug "Order -> #{order.id} | order_status -> #{order.status}" if order diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 8881efea..90222976 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,11 +30,13 @@ class SaleItem < ApplicationRecord # end end + # Get Prices for each accounts (eg: food, beverage) def self.calculate_price_by_accounts(sale_items) price_accounts = [] Account.all.each do |a| account_price = {:name => a.title, :price => 0} + # Check for actual sale items sale_items.each do |si| if si.account_id == a.id account_price[:price] = account_price[:price] + si.price @@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord return price_accounts end + # Get discount Prices for each accounts (eg: food, beverage) + def self.get_discount_price_by_accounts(sale_items) + discount_accounts = [] + Account.all.each do |a| + discount_account = {:name => a.title, :price => 0} + + # Check for actual sale items + sale_items.where("is_taxable = 0 AND remark = 'Discount'").find_each do |si| + if si.account_id == a.id + discount_account[:price] = (discount_account[:price] + si.price) * -1 + end + end + discount_accounts.push(discount_account) + end + + return discount_accounts + end + # Calculate rebate_by_account def self.calculate_rebate_by_account(sale_items) rebateacc = Account.where("rebate=?",true) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 4ae0a67d..b9bb7e31 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details) self.page_width = 210 self.page_height = 7000 self.margin = 5 @@ -39,6 +39,10 @@ class ReceiptBillPdf < Prawn::Document customer(customer_name) + if discount_price_by_accounts.length > 0 + discount_account(discount_price_by_accounts) + end + items_account(item_price_by_accounts) footer @@ -158,7 +162,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Discount", :size => self.item_font_size,:align => :left + text "Overall Discount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right @@ -302,6 +306,22 @@ class ReceiptBillPdf < Prawn::Document end end + def discount_account(discount_price_by_accounts) + move_down 5 + stroke_horizontal_rule + move_down 5 + y_position = cursor + discount_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "(" + "#{ ipa[:price] }" + ")" , :size => self.item_font_size,:align => :right + end + end + end + def items_account(item_price_by_accounts) move_down 5 stroke_horizontal_rule diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 9979c32f..fbbff065 100644 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -138,7 +138,7 @@
-
20%
+
15%
7
@@ -149,7 +149,7 @@
-
30%
+
20%
0
@@ -160,7 +160,7 @@
-
50%
+
30%
@@ -172,7 +172,7 @@
- +
@@ -187,6 +187,8 @@
+ +
@@ -358,6 +360,64 @@ $(document).ready(function(){ } }); }); + + // Remove selected given discount item + $("#remove-item-discount").on('click', function(e){ + e.preventDefault(); + var sale_id = $('#sale-id').text(); + var discount_items = []; + + // Selected Items + var sale_items = get_selected_sale_items(); + if(sale_items.length == 0){ + alert("You have no selected item!"); + return; + } + + for(var i=0;i < sale_items.length;i++){ + if(sale_items[i].price < 0){ + discount_items.push(sale_items[i]); + } + else { + alert("You have selected no discount item!"); + return; + } + } + + var params = { 'sale_id': sale_id, 'discount_items': JSON.stringify(discount_items) }; + $.ajax({ + type: "POST", + url: "/origami/" + sale_id + "/remove_discount_items", + data: params, + success: function(result){ + alert('Removed Discount'); + if(result.table_type == "Table"){ + window.location.href = "/origami/table/" + result.table_id + } + else { + window.location.href = "/origami/room/" + result.table_id + } + } + }); + }); + + $("#remove-all").on('click', function(e){ + e.preventDefault(); + var sale_id = $('#sale-id').text(); + $.ajax({ + type: "GET", + url: "/origami/" + sale_id + "/remove_all_discount", + success: function(result){ + alert('Removed All Discount'); + if(result.table_type == "Table"){ + window.location.href = "/origami/table/" + result.table_id + } + else { + window.location.href = "/origami/room/" + result.table_id + } + } + }); + }); }); /* Remove Selection */ diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 9dbb6884..7e977b7e 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -302,6 +302,7 @@ + <% else %> @@ -310,6 +311,7 @@ + <% end %> @@ -405,7 +407,18 @@ $(document).ready(function(){ }); - +// Print for first bill +$("#first_bill").on('click', function(){ + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/"+ sale_id + "/first_bill"; + $.ajax({ + type: "GET", + url: ajax_url, + success:function(result){ + location.reload(); + } + }); +}); $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); @@ -417,9 +430,9 @@ $('#request_bills').click(function() { var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; $.ajax({ - type: "POST", + type: "GET", url: ajax_url, - data: 'order_id='+ order_id, + // data: 'order_id='+ order_id, success:function(result){ location.reload(); @@ -483,29 +496,30 @@ function show_customer_details(customer_id){ } }); //End Ajax -} + } -$('#edit').on('click',function(){ - var dining_id = "<%= @dining.id %>" - var sale_id = "<%= @obj_sale.sale_id rescue "" %>" - window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit"; -}) + $('#edit').on('click',function(){ + var dining_id = "<%= @dining.id %>" + var sale_id = "<%= @obj_sale.sale_id rescue "" %>" + window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit"; + }); - $('#void').on('click',function () { - var sure = confirm("Are you sure want to Void"); - if (sure == true) { - var sale_id = $('#sale_id').val(); - var ajax_url = "/origami/sale/" + sale_id + '/void'; - $.ajax({ - type: 'POST', - url: ajax_url, - success: function () { - window.location.href = '/origami/'; - } - }) - } else { + $('#void').on('click',function () { + var sure = confirm("Are you sure want to Void"); + if (sure == true) { + var sale_id = $('#sale_id').val(); + var ajax_url = "/origami/sale/" + sale_id + '/void'; + $.ajax({ + type: 'POST', + url: ajax_url, + success: function () { + window.location.href = '/origami/'; + } + }) + } else { - } + } + }); }) diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 4d9089b5..4004e9cf 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -136,13 +136,13 @@ <% if @ppamount != 0.0 %>
-
Paypar
+
Redeem
<%= @ppamount %>
<% else %> <% end %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index d8c05393..36ae77c5 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -268,61 +268,128 @@
- - - - - + <% if @dining.bookings.length >= 1 %> + + + <% if @status_order == 'order' && @status_sale != 'sale' %> + + + + + + + + + <% else %> + + + + + + + + + <% end %> - - - - + + + <% end %>
diff --git a/config/application.rb b/config/application.rb index 5ce0a92a..0e323d22 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,7 +13,7 @@ module SXRestaurants # -- all .rb files in that directory are automatically loaded. config.active_record.time_zone_aware_types = [:datetime, :time] config.active_job.queue_adapter = :sidekiq - # config.time_zone = 'Asia/Rangoon' + config.time_zone = 'Asia/Rangoon' end end diff --git a/config/routes.rb b/config/routes.rb index a56cd2e1..4fc6ba62 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -95,8 +95,10 @@ Rails.application.routes.draw do get "/:id/discount" => "discounts#index" post "/:id/discount" => "discounts#create" + get "/:id/remove_all_discount" => "discounts#remove_all_discount" + post "/:id/remove_discount_items" => "discounts#remove_discount_items" - post "/:id/request_bills" => "request_bills#print",:as => "request_bill" ,:defaults => { :format => 'json' } + get "/:id/request_bills" => "request_bills#print",:as => "request_bill" get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } #---------Shift ---------------# @@ -114,6 +116,7 @@ Rails.application.routes.draw do #payment - Outing payments - Cash only [ *Misc expeness tracking] #--------- Payment ------------# + get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' } get 'sale/:sale_id/payment' => 'payments#show' post 'payment/cash' => 'payments#create'