diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 4eff8b2a..d8b4113c 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -64,9 +64,6 @@ class Api::CheckInProcessController < Api::ApiController end if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") - dining_facility.status = "occupied" - dining_facility.save! - if dining_facility.type == "Table" type = "TableBooking" else @@ -75,7 +72,10 @@ class Api::CheckInProcessController < Api::ApiController booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - booking.save! + if booking.save! + dining_facility.status = "occupied" + dining_facility.save! + end render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } else diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index 8e938a3a..d5ff6946 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -28,14 +28,15 @@ class Inventory::StockChecksController < BaseInventoryController stockcheck = StockCheck.find(stock_id) stockcheck_items = stockcheck.stock_check_items member_info = nil - unique_code = 'StockPrint' + unique_code = 'StockCheckPdf' shop_details = Shop.find(1) checker = Employee.find(stockcheck.check_by) print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::ReceiptPrinter.new(print_settings) - - printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details) + if !print_settings.nil? + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details) + end end #Shop Name in Navbor diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index a1750b7f..2ef98bf4 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -16,8 +16,6 @@ class Origami::CheckInProcessController < BaseOrigamiController if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p") @dining_facility = DiningFacility.find(params[:dining_id]) - @dining_facility.status = "occupied" - @dining_facility.save! if @dining_facility.type == "Table" type = "TableBooking" @@ -27,7 +25,11 @@ class Origami::CheckInProcessController < BaseOrigamiController @booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - @booking.save! + + if @booking.save! + @dining_facility.status = "occupied" + @dining_facility.save! + end end if ENV["SERVER_MODE"] != "cloud" #no print in cloud server diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 81724ff5..15811644 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -98,30 +98,44 @@ class Origami::HomeController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' - @sale_array.push(sale) - if @status_order == 'order' + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' + @sale_array.push(sale) + if @status_order == 'order' @status_order = 'sale' - end - @booking= booking - @date = sale.created_at - @status_sale = 'sale' - @obj_sale = sale - @customer = sale.customer - accounts = @customer.tax_profiles - @account_arr =[] - accounts.each do |acc| - account = TaxProfile.find(acc) - @account_arr.push(account) - end - end - end + end + @booking= booking + @date = sale.created_at + @status_sale = 'sale' + @obj_sale = sale + @customer = sale.customer + accounts = @customer.tax_profiles + @account_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc) + @account_arr.push(account) + end + end + @sale_taxes = [] + sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id) + if !sale_taxes.empty? + sale_taxes.each do |sale_tax| + @sale_taxes.push(sale_tax) + end + end + end end #for bank integration @checkout_time = Lookup.collection_of('checkout_time') @checkout_alert_time = Lookup.collection_of('checkout_alert_time') + accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") + @tax_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc.id) + @tax_arr.push(account.name) + end + lookup_spit_bill = Lookup.collection_of('split_bill') @split_bill = 0 if !lookup_spit_bill[0].nil? diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 54b6008c..cab68e3d 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -100,22 +100,30 @@ class Origami::RoomsController < BaseOrigamiController @status_order = 'order' else sale = Sale.find(booking.sale_id) - if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' - @sale_array.push(sale) - if @status_order == 'order' + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' + @sale_array.push(sale) + if @status_order == 'order' @status_order = 'sale' - end - @booking = booking - @date = sale.created_at - @status_sale = 'sale' - @obj_sale = sale - @customer = sale.customer - accounts = @customer.tax_profiles + end + @booking = booking + @date = sale.created_at + @status_sale = 'sale' + @obj_sale = sale + @customer = sale.customer + accounts = @customer.tax_profiles @account_arr =[] accounts.each do |acc| account = TaxProfile.find(acc) @account_arr.push(account) end + + @sale_taxes = [] + sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id) + if !sale_taxes.empty? + sale_taxes.each do |sale_tax| + @sale_taxes.push(sale_tax) + end + end end end end @@ -145,6 +153,17 @@ class Origami::RoomsController < BaseOrigamiController # end # end + #for bank integration + @checkout_time = Lookup.collection_of('checkout_time') + @checkout_alert_time = Lookup.collection_of('checkout_alert_time') + + accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") + @tax_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc.id) + @tax_arr.push(account.name) + end + lookup_spit_bill = Lookup.collection_of('split_bill') @split_bill = 0 if !lookup_spit_bill[0].nil? diff --git a/app/models/booking.rb b/app/models/booking.rb index 7e5470d0..7392d74c 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -60,6 +60,6 @@ class Booking < ApplicationRecord private def generate_custom_id - self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") + self.booking_id = SeedGenerator.generate_id("Booking", "BKI") #(self.class.name, "BKI") end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 4150eea4..cb4d8a19 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1822,18 +1822,23 @@ end total_dinein_takeaway = self.total_dinein_takeaway(today,current_user,from,to,from_time,to_time) dinein_cnt = 0 takeaway_cnt = 0 - if !total_dinein_takeaway[0].nil? - dinein_cnt = total_dinein_takeaway[0].total_dinein_cus - takeaway_cnt = total_dinein_takeaway[0].total_take_cus + if !total_dinein_takeaway.nil? + if total_dinein_takeaway[0] + dinein_cnt = total_dinein_takeaway[0].total_dinein_cus + takeaway_cnt = total_dinein_takeaway[0].total_take_cus + end end membership_cnt = self.total_membership(today,current_user,from,to,from_time,to_time) - + member_cnt = 0 + if !membership_cnt.nil? + member_cnt = membership_cnt.total_memb_cus + end total_cus = 0 - if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil? - total_cus = dinein_cnt.to_int + takeaway_cnt.to_int + membership_cnt.total_memb_cus.to_int + if dinein_cnt > dinein_cnt || takeaway_cnt > 0 || !membership_cnt.nil? + total_cus = dinein_cnt.to_int + takeaway_cnt.to_int + member_cnt.to_int end - return total_cus, dinein_cnt, takeaway_cnt, membership_cnt.total_memb_cus + return total_cus, dinein_cnt, takeaway_cnt, member_cnt end def self.total_dinein_takeaway(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) diff --git a/app/views/inventory/stock_checks/show.html.erb b/app/views/inventory/stock_checks/show.html.erb index 68cd965e..acf4535d 100755 --- a/app/views/inventory/stock_checks/show.html.erb +++ b/app/views/inventory/stock_checks/show.html.erb @@ -96,8 +96,16 @@ url: '<%= inventory_save_to_journal_path %>', data: 'data=' + check_id, success: function () { - alert('Successfully saved to journal.'); - window.location.href = '/inventory'; + swal({ + title: "Information!", + text: "Successfully saved to journal", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/inventory'; + }); } }) }); @@ -107,7 +115,19 @@ $.ajax({ type: 'post', url: '<%= inventory_print_stock_check_path %>', - data: 'stock_check_id=' + check_id + data: 'stock_check_id=' + check_id, + success: function(){ + swal({ + title: "Information!", + text: "Print successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.reload(); + }); + } }) }); diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 58ba3838..8a1a2673 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -94,7 +94,11 @@ <% @rooms.each do |room| %> <% if room.status == 'occupied' %> <% if room.get_booking.nil? %> + <% if room.get_checkout_booking.nil? %>