diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 9cc2f774..b0c51031 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -46,8 +46,8 @@ $(function() { + product[field].name +"' data-promotion-price = '"+ 1 +"' data-attributes = '" + JSON.stringify(item_attributes) +"' data-options = '" + options +"' data-image='"+image_path+"'>" - +"" - +'add' + +"" + +'view_list' +'' +'' @@ -146,7 +146,7 @@ $(function() { promotion_price = menu_items[field].promotion_price; }else{ fa_plus = 'material-icons'; - add = 'add' + add = 'view_list' menu_item_box = 'menu_item_box'; data_target = 'sx_item_detailModal'; data_modal = '' @@ -984,19 +984,19 @@ $(function() { $("#back").on("click", function(){ var table_id = $('#table_id').text(); var table_type = $('#table_type').text(); - type = window.location.href.indexOf("quick_service"); - if (type == 'true') { + type = window.location.href.includes("quick_service"); + if (type == true) { var table_type = $('#table_id').find("option:selected").data('type'); var table_id = $('#table_id').val(); - window.location.href = "/origami/dashboard" + window.location.href = "/origami/dashboard"; }else{ var table_type = $('#table_type').text(); var table_id = $('#table_id').text(); if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id + window.location.href = "/origami/table/" + table_id; }else { - window.location.href = "/origami/room/" + table_id + window.location.href = "/origami/room/" + table_id; } } }); diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index f33f6d11..a2011022 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -20,33 +20,33 @@ $(document).ready(function() { borderRadius: '0', railBorderRadius: '0' }); - - $('.delete').click(function(){ - var method = $(this).attr('data-method'); - var url = $(this).attr('data-ref'); - var html_text = $(this).siblings( "#delete_text" ).html(); - //var page = url.substring(url.lastIndexOf('/') + 1); - swal({ - title: "Confirmation", - text: html_text, - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - html: true - }, function (isConfirm) { - if (isConfirm) { - $.ajax({ - type: method, - url: url , - success: function(data) { - location.href = data.url; - } - }); - } else { - swal("Cancelled", "Your imaginary file is safe :)", "error"); - } - }); - }); + + // $('.delete').click(function(){ + // var method = $(this).attr('data-method'); + // var url = $(this).attr('data-ref'); + // var html_text = $(this).siblings( "#delete_text" ).html(); + // //var page = url.substring(url.lastIndexOf('/') + 1); + // swal({ + // title: "Confirmation", + // text: html_text, + // type: "warning", + // showCancelButton: true, + // confirmButtonColor: "#DD6B55", + // html: true + // }, function (isConfirm) { + // if (isConfirm) { + // $.ajax({ + // type: method, + // url: url , + // success: function(data) { + // location.href = data.url; + // } + // }); + // } else { + // swal("Cancelled", "Your imaginary file is safe :)", "error"); + // } + // }); + // }); // for Notificaiotn message var placementFrom = $("#notify_message").attr('data-placement-from'); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 0f5380a7..418b6ebe 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -255,14 +255,14 @@ function setCommPorts(comPortLists) { } /** pay with CB bank **/ -function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no) { +function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) { $("#loading_wrapper").show(); var com_port = $("#com_port_name").val(); - reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port); + reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type); } //add req data to card_sale_trans table -function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port) { +function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) { var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port}; $.ajax({ type: "POST", @@ -272,14 +272,14 @@ function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, rece success: function(data) { if (data.status == "success"){ card_sale_trans_id = data.card_sale_trans_id; - resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port); + resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type); } } }); } //add res data to card_sale_trans table -function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port) { +function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) { var resMsg = ""; var card_payment_type=""; @@ -306,7 +306,7 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo dataType: "json", success: function(data) { if(data.status == "success"){ - resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port); + resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type); } } }); @@ -317,7 +317,7 @@ function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amo } -function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port) { +function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) { $("#loading_wrapper").hide(); var jobj = $.parseJSON(resMsg); if(jobj.STATUS == "Approved"){ @@ -334,7 +334,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun closeOnCancel: false, allowOutsideClick: false }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/payment"; + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment"; }); } } @@ -352,7 +352,7 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun closeOnCancel: false, allowOutsideClick: false }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment/"+payment_type; + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/"+payment_type; }); } } diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 42ea4b2f..eb9dc653 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -167,7 +167,7 @@ class Crm::CustomersController < BaseCrmController status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' } else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} end @@ -186,21 +186,21 @@ class Crm::CustomersController < BaseCrmController if response["message"] == "Account has not exist." customer.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer cannot created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]} else format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] } end end if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response["message"] } end end else if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created. noted'} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } end @@ -209,7 +209,7 @@ class Crm::CustomersController < BaseCrmController if params[:sale_id] flash[:errors] = @crm_customers.errors - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page]} format.json { render json: @crm_customers.errors, status: :unprocessable_entity } else flash[:errors] = @crm_customers.errors diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d59a5af3..147b2ee4 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -92,13 +92,15 @@ class HomeController < ApplicationController @sale_data = Array.new @total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to) - @total_payment_methods.each do |payment| - if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" - pay = Sale.payment_sale('card', today, current_user,@from,@to) - @sale_data.push({'card' => pay.payment_amount}) - else - pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to) - @sale_data.push({payment.payment_method => pay.payment_amount}) + if !@total_payment_methods.nil? + @total_payment_methods.each do |payment| + if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" + pay = Sale.payment_sale('card', today, current_user,@from,@to) + @sale_data.push({'card' => pay.payment_amount}) + else + pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to) + @sale_data.push({payment.payment_method => pay.payment_amount}) + end end end @summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to) @@ -111,10 +113,12 @@ class HomeController < ApplicationController @total_order = Sale.total_order(today,current_user,@from,@to) @total_accounts = Sale.total_account(today,current_user,@from,@to) @account_data = Array.new - @total_accounts.each do |account| - acc = Sale.account_data(account.account_id, today,current_user,@from,@to) - if !acc.nil? - @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) + if !@total_accounts.nil? + @total_accounts.each do |account| + acc = Sale.account_data(account.account_id, today,current_user,@from,@to) + if !acc.nil? + @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) + end end end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index c3e6766e..3b05856f 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -103,10 +103,15 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController } # begin + if params[:order_source] == "quick_service" + customer_id = "CUS-000000000002" # for no customer id from mobile + else + customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + end @order = Order.new @order.source = params[:order_source] @order.order_type = params[:order_type] - @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + @order.customer_id = customer_id @order.items = items_arr @order.guest = params[:guest_info] @order.table_id = params[:table_id] # this is dining facilities's id diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index d93e5040..234a1dc5 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -50,6 +50,7 @@ class Origami::CustomersController < BaseOrigamiController @sale_id = params[:sale_id] @cashier_type = params[:type] + @page = params[:page] if(@sale_id[0,3] == "SAL") @booking = Booking.find_by_sale_id(@sale_id) @@ -62,7 +63,11 @@ class Origami::CustomersController < BaseOrigamiController else @booking_order = BookingOrder.find_by_order_id(@sale_id) @booking = Booking.find(@booking_order.booking_id) - @dining_facility = DiningFacility.find(@booking.dining_facility_id) + if @booking.dining_facility_id.to_i > 0 + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + else + @dining_facility = nil + end end filter = params[:filter] diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 14a2a93b..184daca4 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -30,33 +30,33 @@ class Origami::HomeController < BaseOrigamiController bookings = Booking.all if !bookings.today.nil? @order_items_count = Hash.new - bookings.each do |booking| - if booking.sale_id.nil? && booking.booking_status != 'moved' - if !booking.booking_orders.empty? - booking.booking_orders.each do |booking_order| - order = Order.find(booking_order.order_id) - if !order.order_items.empty? - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, order.order_items.count) - else - @order_items_count[booking.dining_facility_id] += order.order_items.count - end - end - end - end - else - if !booking.sale_id.nil? - sale = Sale.find(booking.sale_id) - if sale.sale_status !='completed' - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) - else - @order_items_count[booking.dining_facility_id] = sale.sale_items.count - end - end - end - end - end + # bookings.each do |booking| + # if booking.sale_id.nil? && booking.booking_status != 'moved' + # if !booking.booking_orders.empty? + # booking.booking_orders.each do |booking_order| + # order = Order.find(booking_order.order_id) + # if !order.order_items.empty? + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, order.order_items.count) + # else + # @order_items_count[booking.dining_facility_id] += order.order_items.count + # end + # end + # end + # end + # else + # if !booking.sale_id.nil? + # sale = Sale.find(booking.sale_id) + # if sale.sale_status !='completed' + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + # else + # @order_items_count[booking.dining_facility_id] = sale.sale_items.count + # end + # end + # end + # end + # end end @dining.bookings.active.each do |booking| diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 64b0bde5..6a726199 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -28,8 +28,21 @@ class Origami::PaymentsController < BaseOrigamiController end if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf # Print for First Bill to Customer unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + #shop detail shop_details = Shop::ShopDetail # customer= Customer.where('customer_id=' +.customer_id) @@ -95,7 +108,6 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") - render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "}) rebate_amount = nil # For Cashier by Zone @@ -118,7 +130,20 @@ class Origami::PaymentsController < BaseOrigamiController # For Print if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + customer= Customer.find(saleObj.customer_id) # get member information @@ -151,7 +176,9 @@ class Origami::PaymentsController < BaseOrigamiController 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,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data) + + render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) if params[:type] == "quick_service" booking = Booking.find_by_sale_id(sale_id) @@ -437,5 +464,31 @@ class Origami::PaymentsController < BaseOrigamiController end end end - + + #print function for receipt + def print + filename = params[:filename] + receipt_no = params[:receipt_no] + printer_name = params[:printer_name] + + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) + + render :json => {status: true} + end end \ No newline at end of file diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index f3b11556..3aa98282 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -26,33 +26,33 @@ class Origami::RoomsController < BaseOrigamiController bookings = Booking.all if !bookings.today.nil? @order_items_count = Hash.new - bookings.each do |booking| - if booking.sale_id.nil? && booking.booking_status != 'moved' - if !booking.booking_orders.empty? - booking.booking_orders.each do |booking_order| - order = Order.find(booking_order.order_id) - if !order.order_items.empty? - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, order.order_items.count) - else - @order_items_count[booking.dining_facility_id] += order.order_items.count - end - end - end - end - else - if !booking.sale_id.nil? - sale = Sale.find(booking.sale_id) - if sale.sale_status !='completed' - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) - else - @order_items_count[booking.dining_facility_id] = sale.sale_items.count - end - end - end - end - end + # bookings.each do |booking| + # if booking.sale_id.nil? && booking.booking_status != 'moved' + # if !booking.booking_orders.empty? + # booking.booking_orders.each do |booking_order| + # order = Order.find(booking_order.order_id) + # if !order.order_items.empty? + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, order.order_items.count) + # else + # @order_items_count[booking.dining_facility_id] += order.order_items.count + # end + # end + # end + # end + # else + # if !booking.sale_id.nil? + # sale = Sale.find(booking.sale_id) + # if sale.sale_status !='completed' + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + # else + # @order_items_count[booking.dining_facility_id] = sale.sale_items.count + # end + # end + # end + # end + # end end @room.bookings.active.each do |booking| diff --git a/app/models/ability.rb b/app/models/ability.rb index 33372ac9..95c6005f 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -65,7 +65,8 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment - can :foc, :payment + can :foc, :payment + can :print, :payment can :move_dining, :movetable can :moving, :movetable @@ -111,10 +112,10 @@ class Ability can :index, :other_charge can :create, :other_charge - # can :index, :discount - # can :create, :discount - # can :remove_discount_items, :discount - # can :remove_all_discount, :discount + can :index, :discount + can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount can :member_discount, :discount can :first_bill, :payment @@ -122,6 +123,7 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment + can :print, :payment can :move_dining, :movetable can :moving, :movetable @@ -180,6 +182,7 @@ class Ability can :show, :payment can :reprint, :payment can :rounding_adj, :payment + can :print, :payment can :manage, Commission can :manage, Commissioner @@ -191,6 +194,26 @@ class Ability elsif user.role == "waiter" can :index, :home can :show, :home + + can :manage, Customer + can :get_customer, Customer + can :add_customer, Customer + can :update_sale_by_customer, Customer + + can :index, :other_charge + can :create, :other_charge + can :index, :discount + can :create, :discount + can :remove_discount_items, :discount + can :remove_all_discount, :discount + can :member_discount, :discount + + #ability for move table + can :move_dining, :movetable + can :moving, :movetable + + can :move_dining, :moveroom + #ability for split_bill can :index, :split_bill can :create, :split_bill diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 0cf6526f..d544c908 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -197,17 +197,28 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker print_settings.print_copies = 1 print_settings.save! + directory_name = 'public/receipts' + Dir.mkdir(directory_name) unless File.exists?(directory_name) + begin if count == 1 - pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf" - self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name) + filename = "/receipts/receipt_bill_#{sale_data.receipt_no}.pdf" + pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf" + if printed_status != 'Paid' + self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name) + end else - pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" - self.print("tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name) + filename = "/receipts/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" + pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" + if printed_status != 'Paid' + self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name) + end end count -= 1 end until count == 0 + + return filename, sale_data.receipt_no, cashier_terminal.printer_name end # stock check @@ -247,4 +258,23 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print("tmp/print_call_waiter.pdf") end + #print receipt pdf from js + def print_receipt_pdf(filename,receipt_no,print_copies,printer_name) + count = print_copies.to_i + # if count == 0 + # self.print("public"+filename, printer_name) + # else + begin + if count == 1 + self.print("public"+filename, printer_name) + else + filename = "public/receipts/receipt_bill_#{receipt_no}_#{count}.pdf" + self.print(filename, printer_name) + end + + count -= 1 + end until count == 0 + # end + end + end diff --git a/app/models/sale.rb b/app/models/sale.rb index b652d883..29e32c14 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -548,11 +548,22 @@ class Sale < ApplicationRecord #Generate new Receipt No when it is not assigned def generate_receipt_no + #shop_code and client_code + shop_details = Shop::ShopDetail + #Date-Shift- if self.receipt_no.nil? prefix = DateTime.now().utc #self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s - self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + if !shop_details.nil? + if !shop_details.shop_code.nil? + self.receipt_no = shop_details.shop_code + "-" + prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + else + self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + end + else + self.receipt_no = prefix.strftime("%Y%m%d") + "-" + SeedGenerator.new_receipt_no().to_s + end self.receipt_date = prefix Rails.logger.debug "Receipt No #{self.receipt_no} | Date #{ self.receipt_date.to_s}" @@ -1170,7 +1181,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).sum("grand_total") else shift = ShiftSale.current_open_shift(current_user.id) @@ -1184,7 +1195,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).sum("grand_total") else shift = ShiftSale.current_open_shift(current_user.id) @@ -1202,7 +1213,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and receipt_date between ? and ?',from,to).count else shift = ShiftSale.current_open_shift(current_user.id) @@ -1215,7 +1226,7 @@ end if current_user.nil? total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' total = Sale.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today).count else shift = ShiftSale.current_open_shift(current_user.id) @@ -1234,7 +1245,7 @@ end .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") @@ -1253,7 +1264,7 @@ end .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") @@ -1276,7 +1287,7 @@ end .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and s.receipt_date between ? and ?',from,to) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") @@ -1295,7 +1306,7 @@ end .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(s.receipt_date,"%Y-%m-%d") = ?',today) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") @@ -1318,7 +1329,7 @@ end .where('sale_status = "completed" and receipt_date between ? and ?',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') .where('sale_status = "completed" and receipt_date between ? and ?',from,to) .first() @@ -1337,7 +1348,7 @@ end .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax') .where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today) .first() @@ -1360,7 +1371,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct sp.payment_method") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") @@ -1379,7 +1390,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct sp.payment_method") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") @@ -1406,7 +1417,7 @@ end end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") if payment_method == 'card' query = query.where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',from,to) @@ -1437,7 +1448,7 @@ end end query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") if payment_method == 'card' query = query.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay")',today) @@ -1482,7 +1493,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to) @@ -1504,7 +1515,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_dinein_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Dinein" and c.membership_id is null',today) @@ -1530,7 +1541,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to) @@ -1552,7 +1563,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_take_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type = "Takeaway" and c.membership_id is null',today) @@ -1578,7 +1589,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',from,to) @@ -1600,7 +1611,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today) @@ -1626,7 +1637,7 @@ end .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ? and c.customer_type is null and c.membership_id is null',from,to) @@ -1648,7 +1659,7 @@ end .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today) @@ -1675,7 +1686,7 @@ end .where('b.status = "billed" and sales.receipt_date between ? and ?',from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") @@ -1700,7 +1711,7 @@ end .where('b.status = "billed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(distinct a.order_id) as total_order") .joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id") .joins("JOIN orders as b ON b.order_id = a.order_id") @@ -1728,7 +1739,7 @@ end .joins("JOIN accounts as b ON b.id = a.account_id") .where('sales.sale_status = "completed" and sales.receipt_date between ? and ?',from,to) else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") @@ -1750,7 +1761,7 @@ end .joins("JOIN accounts as b ON b.id = a.account_id") .where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ?',today) else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("distinct b.id as account_id, b.title as title") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") @@ -1776,7 +1787,7 @@ end .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and sales.receipt_date between ? and ?",from,to) @@ -1798,7 +1809,7 @@ end .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) @@ -1826,7 +1837,7 @@ end .order("SUM(a.qty) DESC") .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and sales.receipt_date between ? and ?",from,to) @@ -1854,7 +1865,7 @@ end .order("SUM(a.qty) DESC") .first() else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) @@ -1883,7 +1894,7 @@ end .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to) .sum("a.qty") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and sales.receipt_date between ? and ?",from,to) .sum("a.qty") @@ -1902,7 +1913,7 @@ end .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .sum("a.qty") else - if current_user.role == 'administrator' + if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .sum("a.qty") diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index bb74c2f2..1866a630 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -356,10 +356,10 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) - + if check_foc update_shift - elsif paid_amount != "0.0" + elsif paid_amount.to_f > 0 #|| paid_amount != "0.0" update_shift end end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index ee9a1bda..206c7a0a 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -112,6 +112,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end + if sale_data.bookings[0].dining_facility_id.to_i > 0 bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right @@ -121,10 +122,16 @@ class ReceiptBillA5Pdf < Prawn::Document move_down line_move y_position = cursor - bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do + if sale_data.bookings[0].dining_facility_id.to_i > 0 + bounding_box([0, y_position], :width => self.item_description_width, :height => self.item_height) do + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left + end + end + + bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left end - bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do + bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end move_down line_move diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 0f02d506..efc85c7f 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -108,9 +108,10 @@ class ReceiptBillPdf < Prawn::Document move_down line_move # move_down 2 y_position = cursor - bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left end + if sale_data.bookings[0].dining_facility_id.to_i > 0 bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right @@ -120,7 +121,13 @@ class ReceiptBillPdf < Prawn::Document move_down line_move y_position = cursor - bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do + if sale_data.bookings[0].dining_facility_id.to_i > 0 + bounding_box([0,y_position], :width => self.label_width, :height => self.item_height) do + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left + end + end + + bounding_box([self.label_width, y_position], :width =>self.label_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index d05af387..372c05e9 100755 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -23,10 +23,10 @@ - + - - + + <% end %> @@ -145,7 +145,8 @@ $(function() { $("#qr_code").on('click', function(e){ var code = ""; setTimeout(function(){ - var hi=getQRCode(); + code=getQRCode(); + setQRCode(code); },100); }); diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 50673b5f..aee947c7 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -228,16 +228,15 @@ <% else %>
<% end %> + <% if !@total_customer.nil? && @total_customer.to_i > 0 %>
<%= t :customer %>
- <% if !@total_customer.nil? %> - <% end %> <% if !@total_dinein.nil? %> @@ -265,6 +264,7 @@
<%= t("views.right_panel.detail.total") %> <%= t :customer %> : <%= @total_customer %>
<%= t("views.right_panel.detail.dine_in") %> :
+ <% end %>
<% if current_user.role == 'administrator' || current_user.role == 'manager' %> @@ -316,9 +316,10 @@ - - - + + <% if current_user.role == 'administrator' || current_user.role == 'manager' %> + + <% end %> <% end %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 15dfdfbe..e3e7adda 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -16,7 +16,11 @@ <%if current_login_employee.role !="waiter" %> - + <% if current_login_employee.role != "cashier" %> + + <% else %> + + <% end %> <% else %> <%end%> @@ -56,13 +60,11 @@ <% end %>
  • - - -

    +

    exit_to_app Logout

    @@ -79,9 +81,39 @@ + \ No newline at end of file diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index eebaabbf..87ff1144 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -34,12 +34,14 @@ -
    - -
    + + + + + <% end %> @@ -114,6 +116,8 @@ + + <%if !@dining_facility.nil?%> @@ -262,7 +266,8 @@ \ No newline at end of file diff --git a/app/views/origami/pending_order/show.html.erb b/app/views/origami/pending_order/show.html.erb index d94a81d5..fade7ccb 100644 --- a/app/views/origami/pending_order/show.html.erb +++ b/app/views/origami/pending_order/show.html.erb @@ -153,6 +153,14 @@ <% if current_user.role != "waiter" || @status != "sale"%> <%end%> + <% if current_user.role != "waiter" && @status != "order"%> <%end%> @@ -163,6 +171,7 @@ diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 4cd6a846..1edb07cf 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -50,11 +50,11 @@ <% end %>
    <%= table.name %> - <% if !@order_items_count.nil? %> + billed
    @@ -66,11 +66,11 @@ <% end %>
    <%= table.name %> - <% if !@order_items_count.nil? %> + new
    @@ -97,11 +97,11 @@
    <%= room.name %> - <% if !@order_items_count.nil? %> + billed
    @@ -110,11 +110,11 @@
    <%= room.name %> - <% if !@order_items_count.nil? %> + new
    @@ -193,12 +193,15 @@
    <% if @status_sale == 'sale' %> -
    +
      Receipt No: <%= @obj_sale.receipt_no rescue '' %>
    +
    + Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
    <% else %>
      Order No: @@ -206,17 +209,10 @@ <%= @obj_order.order_id rescue '' %>
    - <% end %> - <% if @status_sale == 'sale' %> -
    - Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> -
    - <% else %> -
    +
    Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-'%>
    <% end %> -
    @@ -396,10 +392,7 @@ - <% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %> - <% end %> - <% if current_login_employee.role != "waiter" %> <% if @room.bookings.length >= 1 %> <% if @status_order == 'order' && @status_sale != 'sale' %> @@ -423,14 +416,14 @@ <% if current_login_employee.role != "waiter" %> + + @@ -485,11 +478,11 @@ <% end %> <% end %> - <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index 340dc914..a406fb0c 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -165,6 +165,7 @@ scope "(:locale)", locale: /en|mm/ do post 'sale/:sale_id/rounding_adj' => 'payments#rounding_adj', :as => "calculate_rouding_adjs" get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => {:format => 'json'} get 'sale/:sale_id/:type/payment' => 'payments#show' + post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt post 'payment/foc' => 'payments#foc', :defaults => {:format => 'json'} post 'payment/cash' => 'payments#create' @@ -198,9 +199,9 @@ scope "(:locale)", locale: /en|mm/ do #---------Add Customer --------------# #resources :customers - get '/:sale_id/:type/customers', to: "customers#add_customer" + get '/:sale_id/:type/customers/:page', to: "customers#add_customer" get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details" - post '/:sale_id/:type/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table + post '/:sale_id/:type/customers/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table post '/:sale_id/get_customer' => "customers#get_customer" diff --git a/db/migrate/20170530072247_create_shops.rb b/db/migrate/20170530072247_create_shops.rb index bd25c970..1c87b505 100755 --- a/db/migrate/20170530072247_create_shops.rb +++ b/db/migrate/20170530072247_create_shops.rb @@ -3,6 +3,9 @@ class CreateShops < ActiveRecord::Migration[5.1] create_table :shops do |t| t.string :logo t.string :name, :null => false + t.string :shop_code, :null => false + t.string :client_name, :null => false + t.string :client_code, :null => false t.string :address, :null => false t.string :township, :null => false t.string :city, :null => false diff --git a/db/migrate/20170628103624_create_print_settings.rb b/db/migrate/20170628103624_create_print_settings.rb index 329d3a7c..672953fc 100755 --- a/db/migrate/20170628103624_create_print_settings.rb +++ b/db/migrate/20170628103624_create_print_settings.rb @@ -6,7 +6,9 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1] t.string :template t.string :font, :default => "" t.string :printer_name, :null => false - t.string :api_settings + t.string :api_settings, + t.string :brand_name + t.string :type t.decimal :page_width, :null => false, :default => 210 t.decimal :page_height, :null => false, :default => 1450 t.integer :print_copies, :null => false, :default => 1 diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 17dcde74..43ba291e 100755 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -17,6 +17,7 @@ namespace :clear do Survey.delete_all DiningFacility.update_all(status:'available') CashierTerminal.update_all(is_currently_login: 0) + SeedGenerator.where("id > 1").update(:current => 0, :next => 1) puts "Clear Data Done." end end