diff --git a/README.md b/README.md index ef68d0b7..5ff1aeda 100755 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ ruby 2.4.1p111 Campaign Id => {"campaign_type_id": 1} - +java -jar ~/Documents/Jade.jar http://192.168.1.88:3002 * ToDo list diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 64e207ab..6068b53f 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -61,7 +61,7 @@ $(document).on('turbolinks:load', function() { if (data[field]["options"] == "[]" || data[field]["options"] == "") { var options = ""; }else{ - var options = data.options; + var options = data[field]["options"]; } var date = new Date(data[field]["created_at"]); @@ -80,7 +80,7 @@ $(document).on('turbolinks:load', function() { +' [x'+ data[field]["qty"] +'] ' +'

' - +'

'+ options +'

' + +'

'+ options +'

' +'' +'Order at - ' @@ -223,8 +223,9 @@ $(document).on('turbolinks:load', function() { var params = { 'options':options }; $.ajax({ - type: 'GET', + type: 'POST', url: '/oqs/print/print/'+assigned_item_id, + data: params, success: function(data){ } }); }); diff --git a/app/assets/javascripts/channels/check_in_booking.js b/app/assets/javascripts/channels/check_in_booking.js index 4f5300ee..18597f4d 100644 --- a/app/assets/javascripts/channels/check_in_booking.js +++ b/app/assets/javascripts/channels/check_in_booking.js @@ -5,10 +5,12 @@ App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', { disconnected: function() {}, - received: function(data) { - $('.table_'+data.table.id).removeClass('green'); - $('.table_'+data.table.id).addClass('blue'); - $('.new_text_'+data.table.id).removeClass('hide') + received: function(data) { + if($('.table_'+data.table.id).hasClass('green')){ + $('.table_'+data.table.id).removeClass('green'); + $('.table_'+data.table.id).addClass('blue'); + } + $('.new_text_'+data.table.id).removeClass('hide'); } }); diff --git a/app/assets/javascripts/channels/checkin.js b/app/assets/javascripts/channels/checkin.js index d4a71d5e..03159170 100644 --- a/app/assets/javascripts/channels/checkin.js +++ b/app/assets/javascripts/channels/checkin.js @@ -6,21 +6,21 @@ App.order = App.cable.subscriptions.create('CheckinChannel', { disconnected: function() {}, received: function(data) { - $.each(data.table,function(key,value){ - if($('.table_'+value.table_id).hasClass('blue')){ - $('.table_'+value.table_id).removeClass('blue'); - $('.table_'+value.table_id).addClass('orange'); - } - else if($('.table_'+value.table_id).hasClass('red')){ - $('.table_'+value.table_id).removeClass('red'); - $('.table_'+value.table_id).addClass('orange'); - } - else { - $('.table_'+value.table_id).removeClass('green'); - $('.table_'+value.table_id).addClass('orange'); - } - $('.new_text_'+value.table_id).removeClass('hide'); - }); + $.each(data.table,function(key,value){ + if($('.table_'+value.table_id).hasClass('blue')){ + $('.table_'+value.table_id).removeClass('blue'); + $('.table_'+value.table_id).addClass('orange'); + } + else if($('.table_'+value.table_id).hasClass('red')){ + $('.table_'+value.table_id).removeClass('red'); + $('.table_'+value.table_id).addClass('orange'); + } + else { + $('.table_'+value.table_id).removeClass('green'); + $('.table_'+value.table_id).addClass('orange'); + } + $('.new_text_'+value.table_id).removeClass('hide'); + }); } }); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index a95a0eb6..d2b502d4 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -14,7 +14,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann if (items[field]["options"] == "[]" || items[field]["options"] == "") { var options = ""; }else{ - var options = items.options; + var options = items[field]["options"]; } //for count test = document.getElementsByClassName("oqs_count"); @@ -49,7 +49,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann +' [x'+ items[field]["qty"] +'] ' +'

' - +'

'+ options +'

' + +'

'+ options +'

' +'' +'Order at - ' diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index f23d13c6..e649f4b4 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -143,3 +143,41 @@ $(document).on('turbolinks:load', function() { return false; }); }); + +/* start check first bill or not funs: */ +function checkReceiptNoInFirstBillData(receipt_no) { + var status = false; + if((receipt_no!=undefined) && (receipt_no!="")){ + if(localStorage.hasOwnProperty("receipt_lists")===true){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + if((arr_data.length) > (json_data.length)){ + status = true; + } + } + } + + return status; +} + +function createReceiptNoInFirstBillData(receipt_no) { + var arr_data = []; + var json_data = []; + if(localStorage.hasOwnProperty("receipt_lists")===true){ + arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); + } + if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){ + arr_data.push({'receipt_no':receipt_no}); + localStorage.setItem("receipt_lists",JSON.stringify(arr_data)); + } +} + +function deleteReceiptNoInFirstBillData(receipt_no) { + if(localStorage.hasOwnProperty("receipt_lists")===true){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + localStorage.setItem("receipt_lists",JSON.stringify(json_data)); + } +} +/* end check first bill or not funs: */ \ No newline at end of file diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index 2c45bbbe..a778af12 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -6,6 +6,14 @@ class Api::CallWaitersController < ActionController::API @time = params[:time] @table = DiningFacility.find(@table_id) CallWaiterJob.perform_later(@table,@time) + + # get printer info + # @shop = Shop::ShopDetail + # unique_code = "CallWaiterPdf" + # print_settings = PrintSetting.find_by_unique_code(unique_code) + # printer = Printer::ReceiptPrinter.new(print_settings) + # printer.print_call_waiter(print_settings,@table,@time,@shop) + end diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index f580a92f..1166a705 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -157,7 +157,11 @@ class Origami::DiscountsController < BaseOrigamiController is_card = params[:is_card] sub_total = params[:sub_total] sale = Sale.find(sale_id) - + if is_card == 'true' + is_card = true + else is_card.to_s == 'false' + is_card = false + end # Check for Card Payment is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments) @@ -178,9 +182,7 @@ class Origami::DiscountsController < BaseOrigamiController end end end - - generic_customer_id = sale.customer.membership_id - account_no = sale.customer.paypar_account_no + generic_customer_id = sale.customer.membership_id receipt_no = sale.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("member_discount") @@ -188,12 +190,13 @@ class Origami::DiscountsController < BaseOrigamiController campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + account_no = sale.customer.paypar_account_no rescue nil # Check for items for Paypar Cloud if acc_prices.length > 0 begin response = HTTParty.post(url, - :body => { account_no: nil, + :body => { account_no: account_no, generic_customer_id:generic_customer_id , campaign_type_id: campaign_type_id, receipt_no: receipt_no, @@ -220,8 +223,8 @@ class Origami::DiscountsController < BaseOrigamiController else response = {"status": false, "message": "You have no selected discount item" } end - puts "discountttttttttttt" - puts response.to_json + Rails.logger.debug "-------------- Member Discount Osaka ---------" + Rails.logger.debug response.to_json # Re-calc All Amount in Sale if response["status"] == true discount_amount = response["discount_earned"] diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 47ec2383..fdf00b29 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -22,6 +22,10 @@ class Origami::HomeController < BaseOrigamiController @status_sale = "" @sale_array = Array.new + @shop = Shop::ShopDetail + @membership = MembershipSetting::MembershipSetting + @payment_methods = PaymentMethodSetting.all + @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index eecb8dcf..02e0c4ef 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -26,12 +26,28 @@ class Origami::PaymentsController < BaseOrigamiController #shop detail shop_details = Shop::ShopDetail # customer= Customer.where('customer_id=' +.customer_id) - customer= Customer.find(sale_data.customer_id) + customer = Customer.find(sale_data.customer_id) + + # rounding adjustment + if shop_details.is_rounding_adj + a = sale_data.grand_total % 25 # Modulus + b = sale_data.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + rounding_adj = new_total-sale_data.grand_total + sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) + end + end + #end rounding adjustment + # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) - current_balance = SaleAudit.paymal_search(sale_id) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 end # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -59,9 +75,15 @@ class Origami::PaymentsController < BaseOrigamiController # rounding adjustment if shop_details.is_rounding_adj - new_total = Sale.get_rounding_adjustment(saleObj.grand_total) - rounding_adj = new_total-saleObj.grand_total - saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + end end #end rounding adjustment @@ -89,7 +111,9 @@ class Origami::PaymentsController < BaseOrigamiController # get member information rebate = MembershipSetting.find_by_rebate(1) - if customer.membership_id != nil && rebate + credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote') + + if customer.membership_id != nil && rebate && credit_data.nil? member_info = Customer.get_member_account(customer) rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) current_balance = SaleAudit.paymal_search(sale_id) @@ -278,14 +302,15 @@ class Origami::PaymentsController < BaseOrigamiController @shop = Shop.find_by_id(1) if @shop.is_rounding_adj - new_total = Sale.get_rounding_adjustment(saleObj.grand_total) - else - new_total = saleObj.grand_total + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + end end - - rounding_adj = new_total-saleObj.grand_total - - saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) - end -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 6c0b98c8..5e5b42cb 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -19,6 +19,10 @@ class Origami::RoomsController < BaseOrigamiController @status_sale = "" @sale_array = Array.new + @shop = Shop::ShopDetail + @membership = MembershipSetting::MembershipSetting + @payment_methods = PaymentMethodSetting.all + @room.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/models/customer.rb b/app/models/customer.rb index 85967e6a..8865448f 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -147,7 +147,7 @@ class Customer < ApplicationRecord response = self.rebat(Sale.find(sale.sale_id)) #record an payment in sale-audit remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.received_amount} " - sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, "CronJob") + sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1) if response["status"] == true status = sale.update_attributes(rebate_status: "true") diff --git a/app/models/membership_setting.rb b/app/models/membership_setting.rb index 89f9eb14..3b60c781 100755 --- a/app/models/membership_setting.rb +++ b/app/models/membership_setting.rb @@ -1,2 +1,3 @@ class MembershipSetting < ApplicationRecord + MembershipSetting = MembershipSetting.find_by_id(1) end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 495bf85a..499c718d 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -12,7 +12,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code) - filename = "tmp/order_item.pdf" + filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf" # check for item not to show # if order_item[0].price != 0 @@ -47,7 +47,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Per Item if oqs.cut_per_item order.each do|odi| - filename = "tmp/order_item.pdf" + filename = "tmp/order_item_#{order_id}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options @@ -68,7 +68,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/order_summary.pdf" + filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy @@ -96,7 +96,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Per Item if oqs.cut_per_item order.each do|odi| - filename = "tmp/order_item.pdf" + filename = "tmp/order_item_#{booking_id}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options @@ -120,7 +120,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/booking_summary.pdf" + filename = "tmp/booking_summary_#{booking_id}" + ".pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 78aa204e..adcb187e 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -117,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker pdf.render_file "tmp/print_crm_order.pdf" self.print("tmp/print_crm_order.pdf") end + + #Queue No Print + def print_call_waiter(printer_settings,table,time,shop_detail) + #Use CUPS service + #Generate PDF + #Print + pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail) + pdf.render_file "tmp/print_call_waiter.pdf" + self.print("tmp/print_call_waiter.pdf") + end + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 1598563f..b97c529e 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -659,7 +659,7 @@ def self.get_item_query() # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ") query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id") # query = query.where("i.item_instance_code IS NOT NULL") - query = query.group("i.product_name").order("mi.account_id asc","mi.menu_category_id asc") + query = query.group("i.product_name").order("mi.account_id desc") end def self.get_other_charges() @@ -1107,7 +1107,7 @@ end def self.top_items(today) 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("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) + .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) .group("a.product_code") .order("SUM(a.qty) DESC") .first() diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 236606c6..fdad964c 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -173,13 +173,20 @@ class SalePayment < ApplicationRecord private def cash_payment + status = false + sale_payments_data = SalePayment.find_by_sale_id(self.sale_id) + if sale_payments_data.nil? + status = true + end + payment_status = false self.payment_method = "cash" self.payment_amount = self.received_amount self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) + + sale_update_payment_status(self.received_amount,status) return payment_status end @@ -187,7 +194,7 @@ class SalePayment < ApplicationRecord payment_status = false # add to sale item with foc - sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'") + sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null") sale_items.each do|item| SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price) @@ -271,7 +278,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " - sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier") + sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1) if membership_data["status"]==true self.payment_method = "paypar" @@ -290,7 +297,7 @@ class SalePayment < ApplicationRecord end - def sale_update_payment_status(paid_amount) + def sale_update_payment_status(paid_amount,check_foc = false) #update amount_outstanding self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.save! @@ -328,7 +335,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " - sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier") + sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1) if !response.nil? if response["status"] == true @@ -349,8 +356,10 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) - - if paid_amount != "0.0" + + if check_foc + update_shift + elsif paid_amount != "0.0" update_shift end end diff --git a/app/pdf/call_waiter_pdf.rb b/app/pdf/call_waiter_pdf.rb new file mode 100644 index 00000000..a1ea756b --- /dev/null +++ b/app/pdf/call_waiter_pdf.rb @@ -0,0 +1,71 @@ +class CallWaiterPdf < Prawn::Document + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(printer_settings, table,time,shop_detail) + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height + self.margin = 5 + self.price_width = 35 + self.qty_width = 20 + self.total_width = 35 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.item_height = 15 + self.item_description_width = (self.page_width-20) / 2 + self.label_width = 100 + + super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + # db font setup + if printer_settings.font != "" + font_families.update("#{printer_settings.font}" => { + :normal => "public/fonts/#{printer_settings.font}.ttf", + :italic => "public/fonts/#{printer_settings.font}.ttf", + :bold => "public/fonts/#{printer_settings.font}.ttf", + :bold_italic => "public/fonts/#{printer_settings.font}.ttf" + }) + + font "#{printer_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + end + + self.header_font_size = 10 + self.item_font_size = 8 + + header( shop_detail.name, printer_settings.name) + + call_waiter(table) + stroke_horizontal_rule + + # date_info(queue) + + end + + def header (shop_name, name) + text "#{shop_name}", :left_margin => -10, :size => self.header_font_size,:align => :center + text "#{name}", :size => self.header_font_size,:align => :center + # move_down self.item_height + move_down 5 + stroke_horizontal_rule + move_down 5 + end + + def call_waiter (table) + move_down 3 + text "Table Name : #{table.name}",:align => :center + end + + # def date_info(queue) + # move_down 5 + + # y_position = cursor + # bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + # text "Date:", :size => self.item_font_size,:align => :left + # end + # bounding_box([self.label_width,y_position], :width => self.item_width) do + # text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left + # end + + # move_down 5 + + # end + +end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 4bc57878..e9887c62 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -40,7 +40,7 @@ class OrderItemPdf < Prawn::Document text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 stroke_horizontal_rule - move_down 5 + move_down 3 #order_info order_info(order_item.order_id, order_item.order_by,order_item.order_at) @@ -56,13 +56,13 @@ class OrderItemPdf < Prawn::Document text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left end - move_down 5 + move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end - move_down 5 + move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left @@ -105,18 +105,22 @@ class OrderItemPdf < Prawn::Document end if alt_name - move_down 4 - font("public/fonts/NotoSansCJKtc-Regular.ttf") do - text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + if !(order_item.alt_name).empty? + move_down 4 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end end end - move_down 5 + if !options.empty? + move_down 5 - # add option - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "#{options}", :size => self.item_font_size,:align => :left + # add option + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "#{options}", :size => self.item_font_size,:align => :left + end end move_down 5 diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb new file mode 100644 index 00000000..6887d201 --- /dev/null +++ b/app/pdf/order_item_slim_pdf.rb @@ -0,0 +1,129 @@ +class OrderItemSlimPdf < Prawn::Document + include ActionView::Helpers::NumberHelper + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order_item_slim, print_status, options, alt_name) + self.page_width = print_settings.page_width + self.page_height = print_settings.page_height + self.margin = 0 + self.price_width = 40 # No Need for item + self.qty_width = 40 + self.total_width = 40 # No Need for item + self.item_width = self.page_width - (self.qty_width - self.margin) + self.item_height = 15 + self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.label_width=90 + + super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) + + # db font setup + if print_settings.font != "" + font_families.update("#{print_settings.font}" => { + :normal => "public/fonts/#{print_settings.font}.ttf", + :italic => "public/fonts/#{print_settings.font}.ttf", + :bold => "public/fonts/#{print_settings.font}.ttf", + :bold_italic => "public/fonts/#{print_settings.font}.ttf" + }) + + font "#{print_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + + self.header_font_size = 11 + self.item_font_size = 9 + else + self.header_font_size = 12 + self.item_font_size = 10 + end + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" + + text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + stroke_horizontal_rule + move_down 1 + + #order_info + order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at) + + # order items slim + order_items_slim(order_item_slim, options, alt_name, print_settings.precision) + end + + # Write Order Information to PDF + def order_info(order_no, order_by, order_at) + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + + move_down 3 + end + + # Write Order items to PDF + def order_items_slim(order_item_slim, options, alt_name, precision) + y_position = cursor + + #Add Order Item + add_order_items_slim(order_item_slim, options, alt_name, precision) + + dash(1, :space => 1, :phase => 1) + stroke_horizontal_line 0, (self.page_width - self.margin) + move_down 1 + end + + # Add order items slim under order info + def add_order_items_slim(order_item_slim, options, alt_name, precision) + y_position = cursor + + move_down 1 + + bounding_box([0,y_position], :width => self.item_width) do + text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left + end + + bounding_box([self.item_width,y_position], :width => self.qty_width) do + text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + end + + bounding_box([0,y_position], :width => self.item_width) do + text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left + + end + + # if alt_name + # if !(order_item_slim.alt_name).empty? + # move_down 1 + # font("public/fonts/NotoSansCJKtc-Regular.ttf") do + # text "(#{order_item_slim.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + # end + # end + # end + + if !options.empty? + move_down 1 + + # add option + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "#{options}", :size => self.item_font_size,:align => :left + end + end + move_down 1 + + end + +end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index ea0d4502..f48564a9 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -122,19 +122,21 @@ class OrderSummaryPdf < Prawn::Document end if alt_name - move_down 4 - font("public/fonts/NotoSansCJKtc-Regular.ttf") do - text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + if !(odi.alt_name).empty? + move_down 4 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end end end - move_down 5 - # add option options = odi.options == "[]"? "" : odi.options if options != "" + move_down 5 + y_position = cursor bounding_box([0,y_position], :width => self.item_width) do text "#{options}", :size => self.item_font_size,:align => :left diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb new file mode 100644 index 00000000..87aba403 --- /dev/null +++ b/app/pdf/order_summary_slim_pdf.rb @@ -0,0 +1,155 @@ +class OrderSummarySlimPdf < Prawn::Document + include ActionView::Helpers::NumberHelper + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order, print_status, order_items = nil,alt_name) + self.page_width = print_settings.page_width + self.page_height = print_settings.page_height + self.margin = 0 + self.price_width = 40 # No Need for item + self.qty_width = 40 + self.total_width = 40 # No Need for item + self.item_width = self.page_width - (self.qty_width - self.margin) + self.item_height = 15 + self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.label_width=90 + + super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + # db font setup + if print_settings.font != "" + font_families.update("#{print_settings.font}" => { + :normal => "public/fonts/#{print_settings.font}.ttf", + :italic => "public/fonts/#{print_settings.font}.ttf", + :bold => "public/fonts/#{print_settings.font}.ttf", + :bold_italic => "public/fonts/#{print_settings.font}.ttf" + }) + + font "#{print_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + + self.header_font_size = 11 + self.item_font_size = 9 + else + self.header_font_size = 12 + self.item_font_size = 10 + end + + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + + text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + stroke_horizontal_rule + move_down 1 + + #order_info + order_info(order[0].order_id, order[0].order_by,order[0].order_at) + + # order items + if order_items == nil + order_items(order, alt_name, print_settings.precision) + else + order_items(order_items, alt_name, print_settings.precision) + end + end + + # Write Order Information to PDF + def order_info(order_no, order_by, order_at) + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + + move_down 1 + end + + # Write Order items to PDF + def order_items(order_item, alt_name, precision) + y_position = cursor + + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Item", :size => self.item_font_size,:align => :left + end + + bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do + text "Qty", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + move_down 1 + + #Add Order Item + add_order_items(order_item, alt_name, precision) + + end + + # Add order items under order info + def add_order_items(order_item, alt_name, precision) + y_position = cursor + + move_down 1 + + order_item.each do|odi| + # check for item not to show + # if odi.price != 0 + y_position = cursor + + bounding_box([0,y_position], :width => self.item_width) do + text "#{odi.item_name}", :size => self.item_font_size,:align => :left + + end + + bounding_box([self.item_width,y_position], :width => self.qty_width) do + text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + end + + bounding_box([0,y_position], :width => self.item_width) do + text "#{odi.item_name}", :size => self.item_font_size,:align => :left + + end + + if alt_name + if !(odi.alt_name).empty? + move_down 1 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end + end + end + + # add option + options = odi.options == "[]"? "" : odi.options + + if options != "" + move_down 1 + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width) do + text "#{options}", :size => self.item_font_size,:align => :left + end + + move_down 1 + end + + move_down 1 + + dash(1, :space => 1, :phase => 1) + stroke_horizontal_line 0, (self.page_width - self.margin) + move_down 1 + # end + end + end +end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index dfd67d89..ae02b22d 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,13 +4,13 @@ class ReceiptBillPdf < Prawn::Document def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height - self.margin = 5 - self.price_width = 40 - self.qty_width = 20 - self.total_width = 40 - self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.margin = 0 + self.price_width = 60 + self.qty_width = 25 + self.total_width = 60 + self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width)) self.item_height = 15 - self.item_description_width = (self.page_width-20) / 2 + self.item_description_width = (self.page_width-5) / 2 self.label_width = 100 self.description_width = 150 @@ -22,6 +22,11 @@ class ReceiptBillPdf < Prawn::Document #setting page margin and width super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + #precision checked + if printer_settings.precision.to_i > 2 + printer_settings.precision = 2 + end + # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { @@ -74,7 +79,7 @@ class ReceiptBillPdf < Prawn::Document end def header (shop_details) - move_down 7 + move_down 5 text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center move_down 5 text "#{shop_details.address}", :size => self.item_font_size,:align => :center @@ -124,15 +129,27 @@ class ReceiptBillPdf < Prawn::Document end def line_items(sale_items,precision,delimiter) + if precision.to_i > 0 + item_label_qty_front_width = (self.item_width+self.price_width) + 5 + item_label_qty_end_width = self.qty_width + 4 + item_label_total_front_width = (self.item_width+self.price_width) + 10 + item_label_total_end_width = self.total_width + 9 + else + self.item_width = self.item_width.to_i + 8 + item_label_qty_front_width = (self.item_width+self.price_width) + 8 + item_label_qty_end_width = self.qty_width + 7 + item_label_total_front_width = (self.item_width+self.price_width) + 5 + item_label_total_end_width = self.total_width + 4 + end move_down 5 y_position = cursor move_down 5 pad_top(15) { # @item_width.to_i + @half_qty.to_i text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down -5 stroke_horizontal_rule @@ -140,7 +157,19 @@ class ReceiptBillPdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) - item_name_width = (self.item_width+self.price_width) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end y_position = cursor move_down 5 sub_total = 0.0 @@ -162,8 +191,8 @@ class ReceiptBillPdf < Prawn::Document end # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 5 end @@ -469,7 +498,7 @@ class ReceiptBillPdf < Prawn::Document text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left + text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left end move_down 5 diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder index 268a6391..8dcdf6fe 100755 --- a/app/views/api/restaurant/menu/_menu.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu.json.jbuilder @@ -7,6 +7,8 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) json.categories menu.menu_categories do |category| json.id category.id + json.code category.code + json.order_by category.order_by json.name category.name json.alt_name category.alt_name json.order_by category.order_by diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 7f7f2d24..f5868fa5 100755 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -84,8 +84,8 @@ <%= qid.qty %> ]

- -

<%= qid.options == "[]"? "" : qid.options %>

+ +

<%= qid.options == "[]"? "" : qid.options %>

Order at - diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index e788a08f..03c73fea 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -32,7 +32,7 @@
- +
@@ -423,13 +423,13 @@ success: function(data) { if(data.status == true) { - var id = $("#table_id").val() - var type = $("#type").val() + var id = $("#table_id").val(); + var type = $("#type").val(); if (type=="Table") { window.location.href = '/origami/table/'+id }else{ - window.location.href = '/origami/room/'+id - } + window.location.href = '/origami/room/'+id + } }else{ swal("Alert!", "Record not found!", "error"); location.reload(); diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 2946791f..0fa545a3 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -1,4 +1,7 @@
+
@@ -153,8 +156,7 @@
  Receipt No: <% if @status_sale == 'sale' %> - <%= @sale_array[0].receipt_no rescue '' %> - + <%= @sale_array[0].receipt_no rescue '' %> <% end %>
@@ -264,7 +266,7 @@ - + <% if @obj_sale != nil && @obj_sale.discount_type == 'member_discount' %> @@ -291,7 +293,8 @@ + <%= @obj_sale.rounding_adjustment + %> @@ -387,8 +390,12 @@ - - + + <%if @membership.discount && @obj_sale.customer.membership_id %> + + <%else%> + + <%end%> <% end %> @@ -398,11 +405,51 @@ <% else %> <% end %> + + + + diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index b2ffe0c3..848a0b40 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -94,11 +94,11 @@ - + - + <%if @balance > 0%> @@ -124,7 +124,7 @@
- <%= @sale_data.grand_total + @rounding_adj rescue 0%> + <%= @sale_data.grand_total rescue 0%>
@@ -223,7 +223,7 @@
Balance
-
<%= @sale_data.grand_total+ @rounding_adj rescue 0 %>
+
<%= @sale_data.grand_total rescue 0 %>
@@ -389,11 +389,11 @@ }else{ $(this).off("click"); var sale_id = $('#sale_id').text(); - var item_row = $('.is_card'); + // var item_row = $('.is_card'); - if (item_row.length < 1) { + // if (item_row.length < 1) { calculate_member_discount(sale_id); - } + // } // payment var cash = $('#cash').text(); @@ -405,6 +405,12 @@ data: "cash="+ cash + "&sale_id=" + sale_id, async: false, success:function(result){ + /* start delete receipt no in first bill*/ + if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ + var receipt_no = ($("#receipt_no").html()).trim(); + deleteReceiptNoInFirstBillData(receipt_no); + } + /* end delete receipt no in first bill*/ localStorage.removeItem("cash"); if (result.status) { @@ -497,7 +503,7 @@ //$( "#loading_wrapper" ).hide(); - if (cash > 0) { + if (cash >= 0) { swal({ title: "Information!", text: 'Thank You !', @@ -517,15 +523,20 @@ var sub_total = $('#sub-total').text(); var member_id = $('#membership_id').text(); var member_discount = $('#member_discount').text(); + var item_row = $('.is_card'); if (member_id && member_discount) { + if (item_row.length < 1) { + is_card = false + }else{ + is_card = true + } $.ajax({ type: "POST", url: "/origami/" + sale_id + "/member_discount", - data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false }, + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card }, async: false, success:function(result){ - } }); } diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 600eaf73..fb512235 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -1,4 +1,7 @@
+
@@ -183,7 +186,7 @@
<% if @status_sale == 'sale' %> - +   Customer : <%= @obj_sale.customer.name rescue '-' %> <%else%> @@ -260,7 +263,7 @@
Sub Total:<%= sub_total %><%= sub_total %>
Rounding Adj: - <%= @obj_sale.rounding_adjustment rescue 0 %>
Grand Total:
Rounding Adj:<%=@rounding_adj rescue 0%><%= @sale_data.rounding_adjustment rescue 0%>
Grand Total<%=@sale_data.grand_total+ @rounding_adj rescue 0%><%=@sale_data.grand_total rescue 0%>
- + <%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%> @@ -358,7 +361,8 @@ - <% else %> + <% end %> + <% if @status_sale == 'sale' %> @@ -369,10 +373,43 @@ - + <%if @membership.discount && @obj_sale.customer.membership_id %> + + <%else%> + + <%end%> <% end %> + + + + + @@ -411,6 +448,19 @@ $(document).ready(function(){ // window.location.href = '/origami/order/' + order_id; // }) + /* start check first bill or not*/ + var receipt_no = ""; + if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ + receipt_no = ($("#receipt_no").html()).trim(); + } + // console.log(checkReceiptNoInFirstBillData(receipt_no)); + if(checkReceiptNoInFirstBillData(receipt_no)){ + $("#pay").show(); + }else{ + $("#pay").hide(); + } + /* end check first bill or not*/ + $('.invoicedetails').on('click',function(){ var dining_id = "<%= @room.id %>"; var sale_id = this.id; @@ -498,7 +548,7 @@ $(document).ready(function(){ window.location.href = '/origami/' + sale_id + '/discount' } else { - alert("Please select an table!"); + swal ( "Oops" , "Please select an table!" , "warning" ); } return false; @@ -517,7 +567,7 @@ $(document).ready(function(){ window.location.href = '/origami/' + sale_id + '/other_charges' } else { - alert("Please select an table!"); + swal ( "Oops" , "Please select an table!" , "warning" ); } return false; @@ -533,11 +583,54 @@ $("#first_bill").on('click', function(){ type: "GET", url: ajax_url, success:function(result){ + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no); + location.reload(); } }); }); +$(".choose_payment").on('click', function () { + $( "#loading_wrapper").show(); + var sale_id = $('#sale_id').val(); + type = $('.payment_method').val(); + + calculate_member_discount(sale_id,type); + + var ajax_url = "/origami/sale/" + sale_id + "/first_bill"; + $.ajax({ + type: "GET", + url: ajax_url, + success: function (result) { + $( "#loading_wrapper" ).hide(); + receipt_no = ($("#receipt_no").html()).trim(); + if((receipt_no!=undefined) && (receipt_no!="")) + createReceiptNoInFirstBillData(receipt_no); + + location.reload(); + } + }); +}); +function calculate_member_discount(sale_id,type) { + var sub_total = $('#sub-total').text(); + if (type == "Cash") { + is_card = false + }else{ + is_card = true +} +$.ajax({ + type: "POST", + url: "/origami/" + sale_id + "/member_discount", + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card }, + async: false, + success:function(result){ + } +}); + +} + $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); var url = '/origami/sale/'+ sale_id + "/rounding_adj" ; @@ -600,8 +693,16 @@ $('#add_invoice').on('click',function(){ url: ajax_url, data: 'dining_id='+ dining_id + "&sale_id=" + sale_id, success:function(result){ - alert("Invoice updated") - window.location.reload(); + swal({ + title: "Information!", + text: "Invoice updated", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.reload(); + }); } }); }); diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index d239e231..cf0bd605 100755 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -162,18 +162,18 @@ if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) && amount > 0){ $(this).off("click"); //start member discount 5% by pay card - var sub_total = $('#sub-total').text(); - var member_id = $('#membership_id').text(); - var member_discount = $('#member_discount').text(); - if (member_id && member_discount) { - $.ajax({ - type: "POST", - url: "/origami/" + sale_id + "/member_discount", - data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, - // success:function(result){ - // } - }); - } + // var sub_total = $('#sub-total').text(); + // var member_id = $('#membership_id').text(); + // var member_discount = $('#member_discount').text(); + // if (member_id && member_discount) { + // $.ajax({ + // type: "POST", + // url: "/origami/" + sale_id + "/member_discount", + // data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, + // success:function(result){ + // } + // }); + // } //end member discount $.ajax({type: "POST", url: "<%= origami_payment_visa_path %>", diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb index 51ee0eaa..38e55330 100755 --- a/app/views/print_settings/_form.html.erb +++ b/app/views/print_settings/_form.html.erb @@ -15,8 +15,8 @@ <%= f.input :api_settings %> <%= f.input :page_width %> <%= f.input :page_height %> - <%= f.input :print_copies, input_html: { min: '1', step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %> - <%= f.input :precision %> + <%= f.input :print_copies, input_html: { min: 1, step: '1', :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanOne(this.value);" } %> + <%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %> <%= f.input :delimiter %> <%= f.input :heading_space %> @@ -73,4 +73,8 @@ function greaterThanOne(val){ if(parseInt(val)==0) $("#print_setting_print_copies").val(1); } + + function greaterThanTwo(val){ + if(parseInt(val)>2) $("#print_setting_precision").val(2); + } \ No newline at end of file diff --git a/app/views/reports/credit_payment/index.html.erb b/app/views/reports/credit_payment/index.html.erb index 9037f03b..7c520fe3 100755 --- a/app/views/reports/credit_payment/index.html.erb +++ b/app/views/reports/credit_payment/index.html.erb @@ -123,7 +123,10 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var str = ''; diff --git a/app/views/reports/payment_method/index.html.erb b/app/views/reports/payment_method/index.html.erb index 2407e50a..0c48fe22 100755 --- a/app/views/reports/payment_method/index.html.erb +++ b/app/views/reports/payment_method/index.html.erb @@ -189,7 +189,10 @@ var shift = $('#shift_name'); shift.empty(); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } var str = ''; var param_shift = ''; var param_shift = '<%= params[:shift_name] rescue '-'%>'; diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 00622069..e82c3e3c 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -196,7 +196,10 @@ var str = ''; var param_shift = ''; var param_shift = '<%= params[:shift_name] rescue '-'%>'; - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } url = '<%= reports_get_shift_by_date_path %>'; $.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){ diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index 7fa72521..d0def563 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -49,6 +49,7 @@ <% acc_arr = Array.new %> <% cate_arr = Array.new %> + <% sub_qty = 0 %> <% sub_total = 0 %> <% other_sub_total = 0 %> <% count = 0 %> @@ -108,18 +109,23 @@ + <% @menu_cate_count.each do |key,value| %> <% if sale.menu_category_id == key %> <% count = count + 1 %> <% sub_total += sale.grand_total %> + <% sub_qty += sale.total_item %> <% if count == value %> - + + + <% sub_total = 0.0%> + <% sub_qty = 0 %> <% count = 0%> <% end %> <% end %> @@ -127,7 +133,7 @@ <% end %> - + <% if @other_charges.present? %> @@ -157,7 +163,7 @@ - + <%end%> @@ -291,12 +297,15 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var selected = ''; var str = ''; var param_shift = '<%= params[:shift_name]%>'; - + url = '<%= reports_get_shift_by_date_path %>'; $.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){ console.log(data) diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb index 2aeac1e5..8138007d 100755 --- a/app/views/reports/shiftsale/index.html.erb +++ b/app/views/reports/shiftsale/index.html.erb @@ -191,7 +191,10 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var str = ''; diff --git a/app/views/reports/void_sale/index.html.erb b/app/views/reports/void_sale/index.html.erb index 3bc48410..045df74d 100755 --- a/app/views/reports/void_sale/index.html.erb +++ b/app/views/reports/void_sale/index.html.erb @@ -144,7 +144,10 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var str = ''; diff --git a/app/views/settings/menu_categories/index.html.erb b/app/views/settings/menu_categories/index.html.erb index 870c19bc..8d8c044c 100755 --- a/app/views/settings/menu_categories/index.html.erb +++ b/app/views/settings/menu_categories/index.html.erb @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ - + @@ -51,8 +51,8 @@ <% end %>
Sub Total:<%= sub_total %><%= sub_total %>
<%= sale.grand_total rescue '-' %>
  Total <%= sale.account_name %> Qty <%= sub_qty %> <%= t("views.right_panel.detail.sub_total") %> <%= sub_total %>
Other Charges  <%= t("views.right_panel.detail.sub_total") %> <%= other_sub_total %>
 <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.alt_name") %> <%= t("views.right_panel.detail.is_available") %><%= t("views.right_panel.detail.order_by") %> <%= t("views.right_panel.detail.parent") %> <%= t("views.right_panel.detail.actions") %>
<%= link_to settings_menu_category.name, settings_menu_category_path(settings_menu_category) %> <%= settings_menu_category.alt_name rescue ''%> <%= settings_menu_category.is_available rescue false%><%= settings_menu_category.order_by rescue ''%> <%= settings_menu_category.parent.name rescue ''%> <%= link_to t("views.btn.edit"), edit_settings_menu_category_path(settings_menu_category),:class => 'btn btn-info btn-sm waves-effect' %>
+ <%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
- <%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
diff --git a/config/routes.rb b/config/routes.rb index a4bd24c6..9ffeb352 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -245,7 +245,7 @@ scope "(:locale)", locale: /en|mm/ do post "/:id", to: "edit#update" # Pass assigned_order_item_id - get 'print/print/:id', to: "print#print" + post 'print/print/:id', to: "print#print" get 'print/print_order_summary/:id', to: "print#print_order_summary" get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"