diff --git a/app/assets/javascripts/channels/check_new_order.js b/app/assets/javascripts/channels/check_new_order.js index 92e0e715..4aa0f1b0 100644 --- a/app/assets/javascripts/channels/check_new_order.js +++ b/app/assets/javascripts/channels/check_new_order.js @@ -34,19 +34,19 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', { // swal.close(); // } // }); - $("#notify_new_order_lists").text(order_lists); - // if($("#notify_new_order").hasClass("hidden")){ - $("#notify_new_order").removeClass("hidden"); + // $("#notify_new_order_lists").text(order_lists); + // if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){ + // $("#"+shop_code+"_notify_new_order").removeClass("hidden"); // } - $("#notify_new_order").on('shown.bs.modal', function(e){ - $(document).off('focusin.modal'); - $("#notify_new_order").focus(); - $("#"+shop_code+"_doemal_new_order").addClass("hidden"); - $("#notify_order_send_to_kitchen").addClass("hidden"); - $("#notify_order_ready_to_delivery").addClass("hidden"); - }).on('hide.bs.modal', function (e) { - $("#notify_new_order").addClass("hidden"); - }).modal({show: true, keyboard: false, backdrop: false}); + // $("#"+shop_code+"_notify_new_order").on('shown.bs.modal', function(e){ + // // $(document).off('focusin.modal'); + // $("#"+shop_code+"_notify_new_order").focus(); + // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden"); + // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden"); + // }).on('hide.bs.modal', function (e) { + // $("#"+shop_code+"_notify_new_order").addClass("hidden"); + // }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/channels/check_order_ready_to_delivery.js b/app/assets/javascripts/channels/check_order_ready_to_delivery.js index 05a257b3..dc406d5e 100644 --- a/app/assets/javascripts/channels/check_order_ready_to_delivery.js +++ b/app/assets/javascripts/channels/check_order_ready_to_delivery.js @@ -34,19 +34,19 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe // swal.close(); // } // }); - $("#notify_order_ready_to_delivery_lists").text(order_lists); + // $("#notify_order_ready_to_delivery_lists").text(order_lists); // if($("#notify_order_ready_to_delivery").hasClass("hidden")){ - $("#notify_order_ready_to_delivery").removeClass("hidden"); + // $("#"+shop_code+"_notify_order_ready_to_delivery").removeClass("hidden"); // } - $("#notify_order_ready_to_delivery").on('shown.bs.modal', function(e){ - // $(document).off('focusin.modal'); - $("#notify_order_ready_to_delivery").focus(); - $("#"+shop_code+"_doemal_new_order").addClass("hidden"); - $("#notify_new_order").addClass("hidden"); - $("#notify_order_send_to_kitchen").addClass("hidden"); - }).on('hide.bs.modal', function (e) { - $("#notify_order_ready_to_delivery").addClass("hidden"); - }).modal({show: true, keyboard: false, backdrop: false}); + // $("#"+shop_code+"_notify_order_ready_to_delivery").on('shown.bs.modal', function(e){ + // // $(document).off('focusin.modal'); + // $("#"+shop_code+"_notify_order_ready_to_delivery").focus(); + // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden"); + // }).on('hide.bs.modal', function (e) { + // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden"); + // }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/channels/check_order_send_to_kitchen.js b/app/assets/javascripts/channels/check_order_send_to_kitchen.js index f9432810..0d11207e 100644 --- a/app/assets/javascripts/channels/check_order_send_to_kitchen.js +++ b/app/assets/javascripts/channels/check_order_send_to_kitchen.js @@ -34,19 +34,19 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend // swal.close(); // } // }); - $("#notify_order_send_to_kitchen_lists").text(order_lists); + // $("#notify_order_send_to_kitchen_lists").text(order_lists); // if($("#notify_order_send_to_kitchen").hasClass("hidden")){ - $("#notify_order_send_to_kitchen").removeClass("hidden"); + // $("#"+shop_code+"_notify_order_send_to_kitchen").removeClass("hidden"); // } - $("#notify_order_send_to_kitchen").on('shown.bs.modal', function(e){ - // $(document).off('focusin.modal'); - $("#notify_order_send_to_kitchen").focus(); - $("#"+shop_code+"_doemal_new_order").addClass("hidden"); - $("#notify_new_order").addClass("hidden"); - $("#notify_order_ready_to_delivery").addClass("hidden"); - }).on('hide.bs.modal', function (e) { - $("#notify_order_send_to_kitchen").addClass("hidden"); - }).modal({show: true, keyboard: false, backdrop: false}); + // $("#"+shop_code+"_notify_order_send_to_kitchen").on('shown.bs.modal', function(e){ + // // $(document).off('focusin.modal'); + // $("#"+shop_code+"_notify_order_send_to_kitchen").focus(); + // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden"); + // }).on('hide.bs.modal', function (e) { + // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden"); + // }).modal({show: true, keyboard: false, backdrop: false}); } } }); diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index d674926a..54069cc4 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -160,10 +160,25 @@ $(function() { // $('button[data-dismiss="modal"]').on('click', function(){ $(this).parent().parent().parent().parent().modal('hide'); }); - // $(".new_order_close").on("click",function(){ - // var code = $(this).attr("data-value"); - // $("#"+code+"_doemal_new_order").modal("hide"); - // }); + $(".new_order_close").on("click",function(){ + var code = $(this).attr("data-value"); + $("#"+code+"_doemal_new_order").modal("hide"); + }); + + $(".notify_new_close").on("click",function(){ + var code = $(this).attr("data-value"); + $("#"+code+"_notify_new_order").modal("hide"); + }); + + $(".notify_order_send_close").on("click",function(){ + var code = $(this).attr("data-value"); + $("#"+code+"_notify_order_send_to_kitchen").modal("hide"); + }); + + $(".notify_order_ready_close").on("click",function(){ + var code = $(this).attr("data-value"); + $("#"+code+"_notify_order_ready_to_delivery").modal("hide"); + }); // $("[data-dismiss='modal']").on('click', function() { // $('body').addClass('modal-open-fix'); @@ -477,17 +492,17 @@ function showNewOrder(order_reservation,shop_code){ $("#new_order").text(order_reservation.order_reservation_id); $("#new_order_date").text(requested_date); // if($("#"+shop_code+"_doemal_new_order").hasClass("hidden")){ - $("#"+shop_code+"_doemal_new_order").removeClass("hidden"); + // $("#"+shop_code+"_doemal_new_order").removeClass("hidden"); // } - $("#"+shop_code+"_doemal_new_order").on('shown.bs.modal', function(e){ - // $(document).off('focusin.modal'); - $("#"+shop_code+"_doemal_new_order").focus(); - $("#notify_new_order").addClass("hidden"); - $("#notify_order_send_to_kitchen").addClass("hidden"); - $("#notify_order_ready_to_delivery").addClass("hidden"); - }).on('hide.bs.modal', function (e) { - $("#"+shop_code+"_doemal_new_order").addClass("hidden"); - }).modal({show: true, keyboard: false, backdrop: false}); + // $("#"+shop_code+"_doemal_new_order").on('shown.bs.modal', function(e){ + // // $(document).off('focusin.modal'); + // $("#"+shop_code+"_doemal_new_order").focus(); + // $("#"+shop_code+"_notify_new_order").addClass("hidden"); + // $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden"); + // $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden"); + // }).on('hide.bs.modal', function (e) { + // $("#"+shop_code+"_doemal_new_order").addClass("hidden"); + // }).modal({show: true, keyboard: false, backdrop: false}); // swal({ // title: 'Information', // target: document.getElementById(shop_code+"_notify_new_order"), diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index 441cd94e..1207d486 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -11,7 +11,30 @@ class Origami::CashInsController < BaseOrigamiController p_jour = PaymentJournal.new p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user.id) shift = ShiftSale.current_open_shift(current_user.id) - shift.cash_in = shift.cash_in + amount.to_i + + current_shift = ShiftSale.current_shift + + # set cashier + if shift != nil + shift = shift + else + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") + if open_cashier.count>0 + + shift = ShiftSale.current_open_shift(open_cashier[0].id) + + if shift + shift = ShiftSale.current_open_shift(shift.id) + else + shift = ShiftSale.current_open_shift(current_shift.id) + end + else + shift = Employee.find(current_shift.employee_id).name + + end + end + + shift.cash_in = shift.cash_in + amount.to_f shift.save end diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index 8c81b5cb..d3716915 100755 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -9,6 +9,28 @@ class Origami::CashOutsController < BaseOrigamiController p_jour = PaymentJournal.new p_jour.cash_out(reference, remark, amount, current_user.id) shift = ShiftSale.current_open_shift(current_user.id) + + current_shift = ShiftSale.current_shift + + # set cashier + if shift != nil + shift = shift + else + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") + if open_cashier.count>0 + + shift = ShiftSale.current_open_shift(open_cashier[0].id) + + if shift + shift = ShiftSale.current_open_shift(shift.id) + else + shift = ShiftSale.current_open_shift(current_shift.id) + end + else + shift = Employee.find(current_shift.employee_id).name + + end + end shift.cash_out = shift.cash_out + amount.to_i shift.save end diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index aa1dd8bd..2e43da0b 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -5,18 +5,25 @@ authorize_resource :class => false from, to = get_date_range_from_params - @shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + @shift_sale_range = '' @shift = '' if params[:shift_name].to_i != 0 - shift_sale = ShiftSale.find(params[:shift_name]) - if to.blank? - @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at) - else - @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) + + @shift_sale = ShiftSale.find(params[:shift_name]) + if to.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) + else + if @shift_sale.shift_closed_at.blank? + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at) + else + @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at) + end end end + payment_type = params[:payment_type] @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type) @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) @@ -42,18 +49,18 @@ authorize_resource :class => false def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) - date_arr = Array.new - @sale_data.each do |sale| - local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") - local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") - opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc - closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc - shift_id = sale.id.nil? ? '-' : sale.id - str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} - date_arr.push(str) - end + date_arr = Array.new + @sale_data.each do |sale| + local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") + local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p") + opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc + closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc + shift_id = sale.id.nil? ? '-' : sale.id + str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date} + date_arr.push(str) + end out = {:status => 'ok', :message => date_arr} diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 92604b04..c49ba894 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -24,7 +24,7 @@ class Reports::SaleitemController < BaseReportController end @type = params[:sale_type] - @sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type) + @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type) @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @@ -62,7 +62,6 @@ class Reports::SaleitemController < BaseReportController def show from, to, report_type = get_date_range_from_params -puts "aaaaaaaaaaaaaaaaaaaaaaaaaa" @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 21ca498b..300e1079 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -28,7 +28,7 @@ class Reports::ShiftsaleController < BaseReportController def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 39b9b021..e3c9376a 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -99,10 +99,10 @@ class Settings::MenusController < ApplicationController sheet.add_row ["Name",menu.name], :style=>title sheet.add_row - sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Price", "Is Default"], :style=>header_text + sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default"], :style=>header_text menu.menu_categories.each do |mc| - mc.menu_items.each do |mi| - attributes = "" + mc.menu_items.each do |mi| + attributes = "" i=0 if mi.item_attributes.length > 0 mi.item_attributes.each do |mia| @@ -119,8 +119,8 @@ class Settings::MenusController < ApplicationController options = "" i=0 if mi.item_options.length > 0 - mi.item_options.each do |mia| - option = MenuItemOption.find(mia) + mi.item_options.each do |mio| + option = MenuItemOption.find(mio) if i == mi.item_options.length - 1 options = options + option.name else @@ -131,68 +131,15 @@ class Settings::MenusController < ApplicationController end mi.menu_item_instances.each do |mii| - sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, mii.price, mii.is_default], :style=>wrap_text + attribute = "" + if mii.item_attributes.length > 0 + attribute = MenuItemAttribute.find(mii.item_attributes[0]).name + end + sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, attribute, mii.price, mii.is_default], :style=>wrap_text end end - end - - - # # Category - # menu.menu_categories.each do |mc| - # sheet.add_row ["Category"], :style=>wrap_text - # sheet.add_row %w(id menu_id code name alt_name order_by created_by menu_category_id is_available), :style=>header_text - # sheet.add_row [mc.id, mc.menu_id, mc.code, mc.name, mc.alt_name, mc.order_by, mc.created_by, mc.menu_category_id, mc.is_available], :style=>wrap_text - # sheet.add_row - - # # Menu Item - # mc.menu_items.each do |mi| - # sheet.add_row ["Menu Item"], :style=>wrap_text - # sheet.add_row %w(id item_code name alt_name image_path description information unit type menu_category_id item_attributes item_options account_id min_qty taxable is_sub_item is_available created_by), :style=>header_text - # sheet.add_row [mi.id,mi.item_code, mi.name, mi.alt_name, mi.image_path, mi.description, mi.information, mi.unit, mi.type, mi.menu_category_id, mi.item_attributes, mi.item_options, mi.account_id, mi.min_qty, mi.taxable, mi.is_sub_item, mi.is_available, mi.created_by], :style=>wrap_text - # sheet.add_row - - # # Menu Item Instance - # sheet.add_row ["Menu Item Instance"], :style=>wrap_text - # sheet.add_row %w(id menu_item_id item_instance_code item_instance_name item_attributes price is_on_promotion promotion_price is_available is_default), :style=>header_text - # mi.menu_item_instances.each do |mii| - # sheet.add_row [mii.id, mii.menu_item_id, mii.item_instance_code, mii.item_instance_name, mii.item_attributes, mii.price, mii.is_on_promotion, mii.promotion_price, mii.is_available, mii.is_default], :style=>wrap_text - # end - # sheet.add_row - # end - # end - end - - # # Account - # wb.add_worksheet(name: "Account") do |sheet| - # sheet.add_row %w(id title account_type discount point bonus rebate), :style=>header_text - # Account.all.each do |acc| - # sheet.add_row [acc.id, acc.title,acc.account_type,acc.discount,acc.point,acc.bonus,acc.rebate], :style=>wrap_text - # end - # end - - # # Item set - # wb.add_worksheet(name: "Item Set") do |sheet| - # sheet.add_row %w(id name alt_name min_selectable_qty max_selectable_qty), :style=>header_text - # ItemSet.all.each do |set| - # sheet.add_row [set.id,set.name, set.alt_name, set.min_selectable_qty, set.max_selectable_qty], :style=>wrap_text - # end - # end - - # # Item Options - # wb.add_worksheet(name: "Menu Item Options") do |sheet| - # sheet.add_row %w(id option_type name value), :style=>header_text - # MenuItemOption.all.each do |option| - # sheet.add_row [option.id, option.option_type, option.name, option.value], :style=>wrap_text - # end - # end - - # # Item Attributes - # wb.add_worksheet(name: "Menu Item Attributes") do |sheet| - # sheet.add_row %w(id attribute_type name value), :style=>header_text - # MenuItemAttribute.all.each do |attr| - # sheet.add_row [attr.id, attr.attribute_type,attr.name,attr.value], :style=>wrap_text - # end - # end + end + end end directory_name = "public/menus" diff --git a/app/models/menu.rb b/app/models/menu.rb index a9b88a85..98102789 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -148,9 +148,7 @@ class Menu < ApplicationRecord row = Hash[[sheet.row(3),sheet.row(ii)].transpose] menu_cat = MenuCategory.find_by_code(row["Category Code"]) if !menu_cat - menu_cat = MenuCategory.create({menu_id: imported_menu.id, code: row["Category Code"], name: row["Category Name"], alt_name: '', order_by: (ii - 3), created_by: created_by, menu_category_id: nil, is_available: 1}) - # else - # status = status + "Category Code already exists." + menu_cat = MenuCategory.create({menu_id: imported_menu.id, code: row["Category Code"], name: row["Category Name"], alt_name: '', order_by: (ii - 3), created_by: created_by, menu_category_id: nil, is_available: 1}) end # Menu Item Attributes @@ -191,20 +189,37 @@ class Menu < ApplicationRecord # status = status + "Item Code already exists for " + row["Item Name"] + "." end + instance_attr = [] menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"]) if !menu_inst instance_name = '' if !row["Instance Name"].nil? instance_name = row["Instance Name"] end - imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: instance_name, item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"]) - # else - # status = status + "Instance Code already exists for " + row["Instance Name"] + "." + + if !row["Attributes"].nil? + if !row["Instance Attribute"].nil? + attributes = row["Attributes"].split(',') + instance_attributes = row["Instance Attribute"].split(',') + attributes.each do |attr| + if attr == instance_attributes[0] + ins_attr = MenuItemAttribute.find_by_name(attr) + instance_attr.push(ins_attr.id) + end + end + end + end + + is_default = 0 + if !row["Is Default"].nil? + is_default = row["Is Default"] + end + imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: instance_name, item_attributes: instance_attr, price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: is_default) end end end # if status == '' - status="Menu Imported!" + status="Menu Imported!" # end return status diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 84209845..477ef631 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -62,7 +62,7 @@ class OrderReservation < ApplicationRecord end if order_reserve[:reservation_info] order_reservation.total_customer = order_reserve[:reservation_info][:total_user] - order_reservation.order_remark = order_reserve[:reservation_info][:reservation_note] + # order_reservation.order_remark = order_reserve[:reservation_info][:reservation_note] end order_reservation.save! if order_reserve[:order_info][:items] @@ -89,7 +89,7 @@ class OrderReservation < ApplicationRecord count = 1 order.order_reservation_items.each { |i| i.item_instance_code = i.item_instance_code.downcase.to_s - items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": []} + items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": i.options} count += 1 items_arr.push(items) } @@ -178,6 +178,17 @@ class OrderReservation < ApplicationRecord end Rails.logger.debug "Doemal URL" + base_url post_url = base_url + url + + if status == 'processed' + status = 'send_to_kitchen' + elsif status == 'delivered' + status = 'ready_to_deliver' + elsif status == 'completed' + status = 'delivered' + else + status = status + end + if waiting_time != "" send_params = {id: ref_no,type: min_type, waiting_time: waiting_time, status: status} elsif reason != "" diff --git a/app/models/sale.rb b/app/models/sale.rb index 0e19e65f..9e621737 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -906,7 +906,7 @@ def self.get_item_query(type) query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" + " JOIN menu_item_instances mii ON i.item_instance_code = mii.item_instance_code" + " JOIN menu_items mi ON mi.id = mii.menu_item_id" + - " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" + + " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id" + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ") query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id") @@ -942,10 +942,12 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) total_grand_total = 0 other_charges = self.get_other_charges() + product = self.get_product_sale() if shift.present? query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount, @@ -966,6 +968,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) elsif shift_sale_range.present? query = query.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) + product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount, @@ -986,6 +989,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) else query = query.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) + product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount, @@ -1004,7 +1008,17 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) end - return query,other_charges, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount + return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount +end + +def self.get_product_sale() + query = Sale.select("i.account_id as account_id, " + + "SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," + + "i.status as status_type,"+ + " i.unit_price as unit_price,i.product_name as product_name,i.product_code as product_code") + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id") + query = query.joins("JOIN products p ON p.`item_code` = i.product_code") + query = query.group("i.product_code") end #product sale report query diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 4108fe82..1295746f 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -122,6 +122,10 @@ + <% elsif @cashier_type == 'quick_service' %> + + + <%else%> diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb index c44fe3bf..45bbfb6f 100644 --- a/app/views/origami/order_reservation/index.html.erb +++ b/app/views/origami/order_reservation/index.html.erb @@ -584,7 +584,6 @@