diff --git a/README.md b/README.md index ad112488..fcc35040 100755 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ For Extra Time For Order Item & Order Summary Slim *** change OrderItemPdf to OrderItemSlimPdf and OrderSummaryPdf to OrderSummarySlimPdf 1) settings/print_settings + (a) Font is present => {Header font size:11, Item Font Size:9} + (b) Font is blank => {Header font size:12, Item Font Size:10} 2) settings/lookups => { type:print_settings, name:OrderSlimPdf, value:1 } * no need to change these files { app/controllers/oqs/edit_controller.rb @@ -53,7 +55,7 @@ For Order Item & Order Summary Slim For ReceiptBillA5Pdf *** change ReceiptBillPdf to ReceiptBillA5Pdf - 1) settings/print_settings , width:680, height:1450 + 1) settings/print_settings , width:680, height:1450, Header font Size:16, Item font size:14 2) settings/lookups => { type:print_settings, name:ReceiptBillA5Pdf, value:1 } For ReceiptBillAltName options @@ -62,6 +64,9 @@ For ReceiptBillAltName options For OrderSetPdf options *** change OrderItemPdf to OrderSetItemPdf and OrderSummaryPdf to OrderSummarySetPdf 1) settings/lookups => { type:print_settings, name:OrderSetPdf, value:1 } + 2) settings/print_settings + (a) Font is present => {Header font size:11, Item Font Size:9} + (b) Font is blank => {Header font size:12, Item Font Size:10} For Bank Integration setting 1) rake db:migrate for card_sale_trans, card_settle_trans diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 8319dc10..fb3f966b 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -27,6 +27,7 @@ _MPU_ = "/   MPU PAYMENT"; _ALIPAY_ = "/   Alipay"; _JUNCTIONPAY_ = "/   JunctionPay"; _PAYMAL_ = "/   PAYMAL"; +_DINGA_ = "/   DINGA PAYMENT"; _OTHER_CHARGES_ = "/   CHARGES"; _OTHER_PAYMENTS_ = "/   OTHER PAYMENT"; _PAYMENTS_ = "/   PAYMENT"; diff --git a/app/assets/stylesheets/login.scss b/app/assets/stylesheets/login.scss index ed0b36f9..a1058d25 100755 --- a/app/assets/stylesheets/login.scss +++ b/app/assets/stylesheets/login.scss @@ -101,3 +101,11 @@ font-size: 111px; padding : 20px 0 20px 0; } + +/* Shop Name in Login Page */ +.current-shop-name{ + color : #FFFFFF; + font-size: 21px; + font-weight: bold; + margin : 0 0 20px 0; +} \ No newline at end of file diff --git a/app/controllers/api/bookings_controller.rb b/app/controllers/api/bookings_controller.rb index 24973d63..797583f0 100755 --- a/app/controllers/api/bookings_controller.rb +++ b/app/controllers/api/bookings_controller.rb @@ -1,5 +1,5 @@ class Api::BookingsController < Api::ApiController - skip_before_action :authenticate + # skip_before_action :authenticate #Show customer by ID def index @customer = Customer.find_by(params[:id]) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 6f32c613..3d375eee 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -1,5 +1,5 @@ class Api::CheckInProcessController < Api::ApiController - + # before_action :authenticate def check_in_time if params[:dining_id] dining_facility = DiningFacility.find(params[:dining_id]) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 383a6606..d937c6c3 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -1,5 +1,5 @@ class Api::OrdersController < Api::ApiController - skip_before_action :authenticate + # skip_before_action :authenticate #Description # This API show current order details # Input Params - order_id diff --git a/app/controllers/api/restaurant/item_sets_controller.rb b/app/controllers/api/restaurant/item_sets_controller.rb index a7ad9efc..99581550 100755 --- a/app/controllers/api/restaurant/item_sets_controller.rb +++ b/app/controllers/api/restaurant/item_sets_controller.rb @@ -1,5 +1,4 @@ class Api::Restaurant::ItemSetsController < Api::ApiController - #Description # Pull the default menu details and also other available (active) menus # Input Params - order_id diff --git a/app/controllers/api/restaurant/menu_categories_controller.rb b/app/controllers/api/restaurant/menu_categories_controller.rb index f1f3e6d0..644a38a8 100755 --- a/app/controllers/api/restaurant/menu_categories_controller.rb +++ b/app/controllers/api/restaurant/menu_categories_controller.rb @@ -1,5 +1,4 @@ -class Api::Restaurant::MenuCategoriesController < Api::ApiController - skip_before_action :authenticate +class Api::Restaurant::MenuCategoriesController < Api::ApiController #Description # Pull the default menu details and also other available (active) menus # Input Params - order_id diff --git a/app/controllers/api/restaurant/menu_controller.rb b/app/controllers/api/restaurant/menu_controller.rb index ad8ad7f9..96ba3cc0 100755 --- a/app/controllers/api/restaurant/menu_controller.rb +++ b/app/controllers/api/restaurant/menu_controller.rb @@ -1,5 +1,4 @@ class Api::Restaurant::MenuController < Api::ApiController - skip_before_action :authenticate #Description # Pull the default menu details and also other available (active) menus # Input Params - order_id diff --git a/app/controllers/api/restaurant/menu_item_attributes_controller.rb b/app/controllers/api/restaurant/menu_item_attributes_controller.rb index 37719c37..d0469924 100755 --- a/app/controllers/api/restaurant/menu_item_attributes_controller.rb +++ b/app/controllers/api/restaurant/menu_item_attributes_controller.rb @@ -1,5 +1,4 @@ -class Api::Restaurant::MenuItemAttributesController < Api::ApiController - skip_before_action :authenticate +class Api::Restaurant::MenuItemAttributesController < Api::ApiController #Description # Pull the default menu details and also other available (active) menus # Input Params - order_id diff --git a/app/controllers/api/restaurant/menu_item_instances_controller.rb b/app/controllers/api/restaurant/menu_item_instances_controller.rb index be38f782..cfe75b19 100755 --- a/app/controllers/api/restaurant/menu_item_instances_controller.rb +++ b/app/controllers/api/restaurant/menu_item_instances_controller.rb @@ -1,5 +1,4 @@ -class Api::Restaurant::MenuItemInstancesController < Api::ApiController - skip_before_action :authenticate +class Api::Restaurant::MenuItemInstancesController < Api::ApiController #Description # Pull the default menu details and also other available (active) menus # Input Params - order_id diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb index 23f9c699..04480864 100644 --- a/app/controllers/api/survey_controller.rb +++ b/app/controllers/api/survey_controller.rb @@ -1,4 +1,5 @@ class Api::SurveyController < Api::ApiController + # before_action :authenticate def index diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 86fb4ec3..66cc2880 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -15,19 +15,16 @@ class BaseOrigamiController < ActionController::Base redirect_to origami_dashboard_path end - def check_user - token_status = false - authenticate_with_http_token do |token, options| - if token - token_status = true - session[:webview] = true - session[:session_token] = token - end - end - - if !token_status + def check_user + if check_mobile if current_user.nil? - redirect_to root_path + return render status: 401, json: { + message: "User using other device!" + }.to_json + end + else + if current_user.nil? + redirect_to root_path end end end @@ -49,9 +46,13 @@ class BaseOrigamiController < ActionController::Base #check webview def check_mobile status = false - puts "check mobile" - puts session[:session_token] - puts session[:webview] + authenticate_with_http_token do |token, options| + if token + session[:webview] = true + session[:session_token] = token + end + end + if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i status = true end diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb index 66658b6a..1d700c8b 100755 --- a/app/controllers/concerns/token_verification.rb +++ b/app/controllers/concerns/token_verification.rb @@ -9,7 +9,7 @@ module TokenVerification protected # Authenticate the user with token based authentication - def authenticate + def authenticate authenticate_token || render_unauthorized end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index e720444f..1aa2738c 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -125,7 +125,7 @@ class HomeController < ApplicationController 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" || payment.payment_method == "unionpay" + if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" || payment.payment_method == "paymal" || payment.payment_method == "dinga" || payment.payment_method == "JunctionPay" pay = Sale.payment_sale('card', today, current_user,@from,@to,@from_time,@to_time) @sale_data.push({'card' => pay.payment_amount}) else diff --git a/app/controllers/origami/dinga_controller.rb b/app/controllers/origami/dinga_controller.rb new file mode 100644 index 00000000..b98b3408 --- /dev/null +++ b/app/controllers/origami/dinga_controller.rb @@ -0,0 +1,102 @@ +class Origami::DingaController < BaseOrigamiController + def index + @sale_id = params[:sale_id] + payment_method = params[:payment_method] + @cashier_type = params[:type] + @membership_rebate_balance=0 + sale_data = Sale.find_by_sale_id(@sale_id) + + @shop = Shop::ShopDetail + # if @shop.is_rounding_adj + # new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + # else + # new_total = sale_data.grand_total + # end + # @rounding_adj = new_total-sale_data.grand_total + @rounding_adj = sale_data.rounding_adjustment + + @dingacount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "dinga" + @dingacount = @dingacount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @redeem_prices = sale_data.grand_total - @dingacount -others + + + if sale_data + if sale_data.customer_id + customer_data= Customer.find_by_customer_id(sale_data.customer_id) + if customer_data + @membership_id = customer_data.membership_id + if !@membership_id.nil? + membership_setting = MembershipSetting.find_by_membership_type("dinga_url") + if membership_setting.gateway_url + member_actions =MembershipAction.find_by_membership_type("get_account_balance") + if member_actions.gateway_url + @campaign_type_id = member_actions.additional_parameter["campaign_type_id"] + url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s + merchant_uid= member_actions.merchant_account_id + auth_token = member_actions.auth_token.to_s + membership_data = SalePayment.get_dinga_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token) + if membership_data["status"]==true + @membership_rebate_balance=membership_data["balance"] + @out = true, @membership_rebate_balance,@membership_id + end + else + @out =false,0 + end + else + @out = false,0 + end + + + else + @out = false, 0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + @out = false, 0 + end + + def create + sale_id = params[:sale_id] + @cashier_type = params[:type] + redeem_amount = params[:redeem_amount] + membership_id = params[:membership_id] + payment_method = "dinga" + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + shop_details = Shop::ShopDetail + + # 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) + end + + sale_payment = SalePayment.new + status,msg =sale_payment.process_payment(saleObj, @user, redeem_amount,payment_method) + if status == true + @out = true, "Success!" + else + @out =false, "Please try again payment!" + end + else + @out = false, "There has no sale record!" + end + + end + +end diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 20aaf0c5..3844293e 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -62,9 +62,19 @@ class Origami::MovetableController < BaseOrigamiController bookings = Booking.where('dining_facility_id=?',change_from) booking_array = Array.new - bookings.each do | booking | - if booking.sale_id.nil? && booking.booking_status != 'moved' - booking_array.push(booking) + order_items = Array.new + if !bookings.nil? + bookings.each do | booking | + if booking.sale_id.nil? && booking.booking_status != 'moved' + booking_array.push(booking) + end + + booking.booking_orders.each do |booking_order| + order = Order.find(booking_order.order_id) + order.order_items.each do |order_item| + order_items.push(order_item) + end + end end end @@ -82,12 +92,13 @@ class Origami::MovetableController < BaseOrigamiController #print_settings = PrintSetting.find_by_unique_code(unique_code) printer_array = [] printer_array = PrintSetting.where(:unique_code => unique_code) + for i in 0..pdf_no if i != pdf_no print_settings = printer_array[i] - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by) + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items) end end - end + end end diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 7d3ded34..6bd06b5a 100644 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -65,7 +65,7 @@ class Origami::MpuController < BaseOrigamiController # saleObj = Sale.find(sale_id) sale_payment = SalePayment.new - @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "alipay",ref_no) + @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "mpu",ref_no) end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 943fc3e9..baa5d2ec 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -230,11 +230,13 @@ class Origami::PaymentsController < BaseOrigamiController @junctionpaycount = 0.0 @credit = 0.0 @paymalcount = 0.0 + @dingacount = 0.0 @sale_data = Sale.find_by_sale_id(sale_id) @balance = 0 @accountable_type = '' @table_no = '' @dining = '' + @other_payment = 0.0 @shop = Shop::ShopDetail #show shop info @@ -332,26 +334,29 @@ class Origami::PaymentsController < BaseOrigamiController if spay.payment_method == "cash" @cash = spay.payment_amount end - if spay.payment_method == "mpu" - @other += spay.payment_amount - elsif spay.payment_method == "paypar" - @ppamount += spay.payment_amount - elsif spay.payment_method == "visa" - @visacount += spay.payment_amount - elsif spay.payment_method == "jcb" - @jcbcount += spay.payment_amount - elsif spay.payment_method == "master" - @mastercount += spay.payment_amount - elsif spay.payment_method == "unionpay" - @unionpaycount += spay.payment_amount - elsif spay.payment_method == "JunctionPay" - @junctionpaycount += spay.payment_amount - elsif spay.payment_method == "creditnote" - @credit += spay.payment_amount - elsif spay.payment_method == "paymal" - @paymalcount += spay.payment_amount - elsif spay.payment_method == "alipay" - @alipaycount += spay.payment_amount + @other_payment += spay.payment_amount + if spay.payment_method == "mpu" + @other += spay.payment_amount + elsif spay.payment_method == "paypar" + @ppamount += spay.payment_amount + elsif spay.payment_method == "visa" + @visacount += spay.payment_amount + elsif spay.payment_method == "jcb" + @jcbcount += spay.payment_amount + elsif spay.payment_method == "master" + @mastercount += spay.payment_amount + elsif spay.payment_method == "unionpay" + @unionpaycount += spay.payment_amount + elsif spay.payment_method == "JunctionPay" + @junctionpaycount += spay.payment_amount + elsif spay.payment_method == "creditnote" + @credit += spay.payment_amount + elsif spay.payment_method == "paymal" + @paymalcount += spay.payment_amount + elsif spay.payment_method == "alipay" + @alipaycount += spay.payment_amount + elsif spay.payment_method == "dinga" + @dingacount += spay.payment_amount end end end diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index 991f4ad2..3bf37ae8 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -85,7 +85,7 @@ class PrintSettingsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def print_setting_params - params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space) + params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font,:header_font_size, :item_font_size, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space) end #Shop Name in Navbor diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 928f17d6..97965167 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -4,7 +4,9 @@ class Reports::PaymentMethodController < BaseReportController @payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"], - ["Master Payment","master"], ["JCB Payment","jcb"], ["Redeem Payment","paypar"]] + ["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"], + ["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"], + ["JunctionPay","junctionpay"],["Redeem Payment","paypar"]] from, to = get_date_range_from_params diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 7e9a2247..8562fca6 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -264,11 +264,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Move Table Print - def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by) + def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) #Use CUPS service #Generate PDF #Print - pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by) + pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) pdf.render_file "tmp/print_move_table.pdf" self.print("tmp/print_move_table.pdf") end diff --git a/app/models/sale.rb b/app/models/sale.rb old mode 100755 new mode 100644 index 363ff77b..b9c0717e --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -687,6 +687,10 @@ def self.daily_sales_list(from,to) SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount, SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, + SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount, + SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount, + SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount, + SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount, SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") @@ -724,6 +728,10 @@ def self.daily_sales_list(from,to) :jcb_amount => pay.jcb_amount, :paypar_amount => pay.paypar_amount, :unionpay_amount => pay.unionpay_amount, + :alipay_amount => pay.alipay_amount, + :paymal_amount => pay.paymal_amount, + :dinga_amount => pay.dinga_amount, + :junctionpay_amount => pay.junctionpay_amount, :cash_amount => pay.cash_amount, :credit_amount => pay.credit_amount, :foc_amount => pay.foc_amount, @@ -882,7 +890,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) discount_query = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:total_discount) change_amount = Sale.where("sales.shift_sale_id in (?) and sale_status= 'completed' ", shift.to_a).sum(:amount_changed) - sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay') then (sale_payments.payment_amount) else 0 end) as card_amount, + sale_cash = Sale.select("SUM(case when (sale_payments.payment_method ='mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") @@ -902,7 +910,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) - sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay') then (sale_payments.payment_amount) else 0 end) as card_amount, + sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") @@ -922,7 +930,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type) other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) - sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay') then (sale_payments.payment_amount) else 0 end) as card_amount, + sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") @@ -970,7 +978,7 @@ def self.get_shift_sales_by_receipt_no(shift_sale_range,shift,from,to,payment_ty payment_type = '' else if payment_type == 'card' - payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay'" + payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay'" else payment_type = " and sale_payments.payment_method = '#{payment_type}'" end @@ -1034,7 +1042,7 @@ def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type) # payment_type = '' # else # if payment_type == 'card' - # payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar'" + # payment_type = " and sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay'" # else # payment_type = " and sale_payments.payment_method = '#{payment_type}'" # end @@ -1075,6 +1083,10 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount, SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, + SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount, + SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount, + SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount, + SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount, SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='cash') then sales.amount_changed else 0 end) as total_change_amount, SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount, @@ -1189,7 +1201,7 @@ end .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") if !from_time.nil? && !to_time.nil? query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") + " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") else query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ " and sale_status= 'completed'") @@ -1203,7 +1215,7 @@ end .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") if !from_time.nil? && !to_time.nil? query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") + " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") else query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ " and sale_status= 'completed'") @@ -1218,7 +1230,7 @@ end .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") if !from_time.nil? && !to_time.nil? query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and sale_status= 'completed' and shift_sale_id='#{shift.id}'") + " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed' and shift_sale_id='#{shift.id}'") else query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ " and sale_status= 'completed' and shift_sale_id='#{shift.id}'") @@ -1270,7 +1282,7 @@ end .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") if !from_time.nil? && !to_time.nil? query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") + " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") else query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ " and sale_status= 'completed'") @@ -1284,7 +1296,7 @@ end .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") if !from_time.nil? && !to_time.nil? query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") + " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed'") else query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ " and sale_status= 'completed'") @@ -1299,7 +1311,7 @@ end .joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code") if !from_time.nil? && !to_time.nil? query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'"+ - " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and sale_status= 'completed' and shift_sale_id='#{shift.id}'") + " and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and sale_status= 'completed' and shift_sale_id='#{shift.id}'") else query = query.where("(i.qty > 0 and i.price > 0) and DATE_FORMAT(CONVERT_TZ(receipt_date,'+00:00','+06:30') between '#{from}' and '#{to}'"+ " and sale_status= 'completed' and shift_sale_id='#{shift.id}'") @@ -1409,22 +1421,22 @@ end query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'") + query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'") else query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'") end - query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name") + query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") else if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'") + query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'") else query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}'") end - query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name") + query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") else shift = ShiftSale.current_open_shift(current_user.id) @@ -1432,11 +1444,11 @@ end query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}' and shift_sale_id='#{shift.id}'") + query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}' and shift_sale_id='#{shift.id}'") else query = query.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and shift_sale_id='#{shift.id}'") end - query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name") + query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") end end @@ -1446,14 +1458,14 @@ end query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") .where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'") - .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name") + .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") else if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") .where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'") - .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name") + .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") else shift = ShiftSale.current_open_shift(current_user.id) @@ -1461,7 +1473,7 @@ end query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id") .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") .where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}' and shift_sale_id='#{shift.id}'") - .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay') THEN 'card' ELSE sp.payment_method END)","e.name") + .group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay') THEN 'card' ELSE sp.payment_method END)","e.name") .order("e.name") end end @@ -1473,14 +1485,14 @@ end if !from.nil? && !to.nil? if current_user.nil? if !from_time.nil? && !to_time.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time).sum("grand_total") + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).sum("grand_total") else total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to).sum("grand_total") end else if current_user.role == 'administrator' || current_user.role == 'manager' if !from_time.nil? && !to_time.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time).sum("grand_total") + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).sum("grand_total") else total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to).sum("grand_total") end @@ -1488,7 +1500,7 @@ end shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? if !from_time.nil? && !to_time.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id) + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id) .sum("grand_total") else total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id=?',from,to,shift.id) @@ -1518,14 +1530,14 @@ end if !from.nil? && !to.nil? if current_user.nil? if !from_time.nil? && !to_time.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time).count + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).count else total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',from,to).count end else if current_user.role == 'administrator' || current_user.role == 'manager' if !from_time.nil? && !to_time.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time).count + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time).count else total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ?',from,to).count end @@ -1533,7 +1545,7 @@ end shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? if !from_time.nil? && !to_time.nil? - total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%M") between ? and ? and shift_sale_id = ?',from,to,from_time,to_time,shift.id).count + total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ? and shift_sale_id = ?',from,to,from_time,to_time,shift.id).count else total = Sale.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and shift_sale_id = ?',from,to,shift.id).count end @@ -1560,22 +1572,22 @@ end if !from.nil? && !to.nil? if current_user.nil? if !from_time.nil? && !to_time.nil? - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") 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,from_time,to_time) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") end else if current_user.role == 'administrator' || current_user.role == 'manager' if !from_time.nil? && !to_time.nil? - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") 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,from_time,to_time) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") end @@ -1583,11 +1595,11 @@ end shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? if !from_time.nil? && !to_time.nil? - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") 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") and shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',from,to,from_time,to_time,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else - query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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") and shift_sale_id=?',from,to,shift.id) + query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',from,to,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") end @@ -1596,18 +1608,18 @@ end end else if current_user.nil? - 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) + 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else 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) + 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") else shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? - 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") and shift_sale_id=?',today,shift.id) + 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and shift_sale_id=?',today,shift.id) .joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id") .sum("sp.payment_amount") end @@ -1620,7 +1632,7 @@ end if !from.nil? && !to.nil? if current_user.nil? if !from_time.nil? && !to_time.nil? - query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else @@ -1631,7 +1643,7 @@ end else if current_user.role == 'administrator' || current_user.role == 'manager' if !from_time.nil? && !to_time.nil? - query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else @@ -1643,7 +1655,7 @@ end shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? if !from_time.nil? && !to_time.nil? - query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and s.shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and s.shift_sale_id=?',from,to,from_time,to_time,shift.id) .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .sum("payment_amount") else @@ -1681,7 +1693,7 @@ end if current_user.nil? if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .first() else 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') @@ -1692,7 +1704,7 @@ end if current_user.role == 'administrator' || current_user.role == 'manager' if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .first() else 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') @@ -1704,7 +1716,7 @@ end if !shift.nil? if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id) + .where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and shift_sale_id=?',from,to,from_time,to_time,shift.id) .first() else 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') @@ -1741,7 +1753,7 @@ end if current_user.nil? if !from_time.nil? && !to_time.nil? query = Sale.select("distinct sp.payment_method") - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else query = Sale.select("distinct sp.payment_method") @@ -1752,7 +1764,7 @@ end if current_user.role == 'administrator' || current_user.role == 'manager' if !from_time.nil? && !to_time.nil? query = Sale.select("distinct sp.payment_method") - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else query = Sale.select("distinct sp.payment_method") @@ -1764,7 +1776,7 @@ end if !shift.nil? if !from_time.nil? && !to_time.nil? query = Sale.select("distinct sp.payment_method") - .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%M") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) .joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id") else query = Sale.select("distinct sp.payment_method") @@ -1799,22 +1811,22 @@ end def self.payment_sale(payment_method, today, current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) time_query = '' if !from_time.nil? && !to_time.nil? - time_query = " and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%M') between '#{from_time}' and '#{to_time}'" + time_query = " and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'" end if !from.nil? && !to.nil? if current_user.nil? if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%M") 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,from_time,to_time) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") 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" or sp.payment_method="alipay" or sp.payment_method="paymal" or sp.payment_method="dinga" or sp.payment_method="JunctionPay")',from,to,from_time,to_time) else - query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) 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 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(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") 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) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to) else query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ?",from,to) end @@ -1825,9 +1837,9 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%M") 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,from_time,to_time) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time) else - query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) 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 @@ -1845,15 +1857,15 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%M") 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") and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) else - query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%M') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) + query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) 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 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(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") 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") and sales.shift_sale_id=?',from,to,shift.id) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and sales.shift_sale_id=?',from,to,shift.id) else query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) end @@ -1866,7 +1878,7 @@ end if current_user.nil? 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) + 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) else query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) end @@ -1875,7 +1887,7 @@ end 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) + 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today) else query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) end @@ -1885,7 +1897,7 @@ end if !shift.nil? 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") and sales.shift_sale_id=?',today,shift.id) + 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" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay") and sales.shift_sale_id=?',today,shift.id) else query = query.where("sales.sale_status = 'completed' and sp.payment_method = '#{payment_method}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? and sales.shift_sale_id=?",today,shift.id) end @@ -1915,7 +1927,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to,from_time,to_time) .first() else query = Sale.select("count(sales.customer_id) as total_dinein_cus") @@ -1928,7 +1940,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null',from,to,from_time,to_time) .first() else query = Sale.select("count(sales.customer_id) as total_dinein_cus") @@ -1942,7 +1954,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Dinein" and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) .first() else query = Sale.select("count(sales.customer_id) as total_dinein_cus") @@ -1984,7 +1996,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZsales.receipt_date,"%H:%M") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZsales.receipt_date,"%H:%i") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to,from_time,to_time) .first() else query = Sale.select("count(sales.customer_id) as total_take_cus") @@ -1997,7 +2009,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null',from,to,from_time,to_time) .first() else query = Sale.select("count(sales.customer_id) as total_take_cus") @@ -2011,7 +2023,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type = "Takeaway" and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) .first() else query = Sale.select("count(sales.customer_id) as total_take_cus") @@ -2053,7 +2065,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") 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,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") 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,from_time,to_time) .first() else query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") @@ -2066,7 +2078,7 @@ end if !from_time.nil? && !to_time.nil? 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(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") 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,from_time,to_time) + .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") 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,from_time,to_time) .first() else query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") @@ -2080,7 +2092,7 @@ end query = Sale.select("count(distinct sales.customer_id) as total_memb_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") 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)) and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id).first() + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") 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)) and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id).first() else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") 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)) and sales.shift_sale_id=?',from,to,shift.id).first() end @@ -2118,7 +2130,7 @@ end query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time) .first() else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null',from,to) @@ -2129,7 +2141,7 @@ end query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null',from,to,from_time,to_time) .first() else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null',from,to) @@ -2141,7 +2153,7 @@ end query = Sale.select("count(sales.customer_id) as total_cus") .joins("JOIN customers as c ON c.customer_id = sales.customer_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) .first() else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and c.customer_type is null and c.membership_id is null and sales.shift_sale_id=?',from,to,shift.id) @@ -2182,7 +2194,7 @@ end .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") if !from_time.nil? && !to_time.nil? - query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .first() else query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) @@ -2194,7 +2206,7 @@ end .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") if !from_time.nil? && !to_time.nil? - query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) .first() else query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) @@ -2207,7 +2219,7 @@ end .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") if !from_time.nil? && !to_time.nil? - query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) .first() else query = query.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and sales.shift_sale_id=?',from,to,shift.id) @@ -2251,7 +2263,7 @@ end .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to,from_time,to_time) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) end @@ -2261,7 +2273,7 @@ end .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time) else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to) end @@ -2272,7 +2284,7 @@ end .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") .joins("JOIN accounts as b ON b.id = a.account_id") if !from_time.nil? && !to_time.nil? - query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) + query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id) else query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and sales.shift_sale_id=?',from,to,shift.id) end @@ -2310,7 +2322,7 @@ end 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") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) .first() else query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) @@ -2321,7 +2333,7 @@ end 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") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) .first() else query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) @@ -2333,7 +2345,7 @@ end 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") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) + query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) .first() else query = query.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) @@ -2373,7 +2385,7 @@ end 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") if !from_time.nil? && !to_time.nil? - query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) else query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) end @@ -2385,7 +2397,7 @@ end 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") if !from_time.nil? && !to_time.nil? - query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) else query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) end @@ -2398,7 +2410,7 @@ end 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") if !from_time.nil? && !to_time.nil? - query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) + query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) else query = query.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) end @@ -2444,7 +2456,7 @@ end if current_user.nil? query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) .sum("a.qty") else query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) @@ -2454,7 +2466,7 @@ end if current_user.role == 'administrator' || current_user.role == 'manager' query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ?",from,to,from_time,to_time) + query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) .sum("a.qty") else query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) @@ -2465,7 +2477,7 @@ end if !shift.nil? query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") if !from_time.nil? && !to_time.nil? - query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%M') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) + query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ? and sales.shift_sale_id=?",from,to,from_time,to_time,shift.id) .sum("a.qty") else query = query.where("sales.sale_status = 'completed' and a.remark='foc' and a.product_name not like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and sales.shift_sale_id=?",from,to,shift.id) @@ -2598,6 +2610,10 @@ end SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, + SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount, + SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount, + SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount, + SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount, SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount, SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc, diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5cd7ea40..035bb792 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -41,6 +41,8 @@ class SalePayment < ApplicationRecord payment_status = external_terminal_card_payment(:mpu) when "unionpay" payment_status = external_terminal_card_payment(:unionpay) + when "alipay" + payment_status = external_terminal_card_payment(:alipay) when "vochure" payment_status = vochure_payment when "giftcard" @@ -53,8 +55,8 @@ class SalePayment < ApplicationRecord payment_status = paymal_payment when "JunctionPay" payment_status = junction_pay_payment - when "alipay" - payment_status = external_terminal_card_payment(:alipay) + when "dinga" + payment_status = dinga_payment else puts "it was something else" end @@ -255,7 +257,7 @@ class SalePayment < ApplicationRecord payment_status = false # add to sale item with foc - sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and status is null") + sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'") sale_items.each do|item| SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price) @@ -402,6 +404,35 @@ class SalePayment < ApplicationRecord return payment_status end + def dinga_payment + payment_status = false + + #Next time - validate if the vochure number is valid - within + customer_data = Customer.find_by_customer_id(self.sale.customer_id) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") + membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) + + #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, 1) + + if membership_data["status"]==true + self.payment_method = "dinga" + self.payment_amount = self.received_amount + self.payment_reference = self.voucher_no + self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f + self.payment_status = "pending" + payment_method = self.save! + SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid') + sale_update_payment_status(self.received_amount.to_f) + + else + sale_update_payment_status(0) + end + return payment_status + + end + 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 diff --git a/app/pdf/call_waiter_pdf.rb b/app/pdf/call_waiter_pdf.rb index a1ea756b..9ab43985 100644 --- a/app/pdf/call_waiter_pdf.rb +++ b/app/pdf/call_waiter_pdf.rb @@ -3,6 +3,8 @@ class CallWaiterPdf < Prawn::Document def initialize(printer_settings, table,time,shop_detail) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 5 self.price_width = 35 self.qty_width = 20 @@ -27,9 +29,6 @@ class CallWaiterPdf < Prawn::Document 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) @@ -68,4 +67,4 @@ class CallWaiterPdf < Prawn::Document # end -end +end \ No newline at end of file diff --git a/app/pdf/close_cashier_customise_pdf.rb b/app/pdf/close_cashier_customise_pdf.rb index bcc27724..84311caa 100644 --- a/app/pdf/close_cashier_customise_pdf.rb +++ b/app/pdf/close_cashier_customise_pdf.rb @@ -5,6 +5,8 @@ class CloseCashierCustomisePdf < Prawn::Document def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 5 self.price_width = 60 self.qty_width = 20 @@ -36,8 +38,6 @@ class CloseCashierCustomisePdf < Prawn::Document end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 10 - self.item_font_size = 8 #precision checked if printer_settings.precision.to_i > 2 diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 7ac7a130..a1c92637 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -5,6 +5,8 @@ class CloseCashierPdf < Prawn::Document def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 5 self.price_width = 60 self.qty_width = 20 @@ -36,8 +38,6 @@ class CloseCashierPdf < Prawn::Document end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 10 - self.item_font_size = 8 #precision checked if printer_settings.precision.to_i > 2 diff --git a/app/pdf/crm_order_pdf.rb b/app/pdf/crm_order_pdf.rb index a33b5fce..f9367907 100755 --- a/app/pdf/crm_order_pdf.rb +++ b/app/pdf/crm_order_pdf.rb @@ -3,6 +3,8 @@ class CrmOrderPdf < Prawn::Document def initialize(booking,order_items,printer_settings) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 10 # self.price_width = self.p_width / 2 self.price_width=80 @@ -31,9 +33,6 @@ class CrmOrderPdf < Prawn::Document font "#{printer_settings.font}" fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end - - self.header_font_size = 10 - self.item_font_size = 9 header( printer_settings.printer_name, printer_settings.name) stroke_horizontal_rule diff --git a/app/pdf/move_table_pdf.rb b/app/pdf/move_table_pdf.rb index 7b4ad8e4..9940c42d 100644 --- a/app/pdf/move_table_pdf.rb +++ b/app/pdf/move_table_pdf.rb @@ -1,16 +1,19 @@ class MoveTablePdf < 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,to,from,shop_detail,date,type,moved_by) + 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(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) 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 + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i + 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 => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) @@ -27,9 +30,6 @@ class MoveTablePdf < Prawn::Document fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end - self.header_font_size = 10 - self.item_font_size = 8 - header(printer_settings.name,type) call_move_table(to,from,date,type,moved_by) @@ -38,6 +38,12 @@ class MoveTablePdf < Prawn::Document stroke_horizontal_rule move_down 5 + add_lining_item(order_items, printer_settings.precision) + + move_down 5 + stroke_horizontal_rule + move_down 5 + end def header (name,type) @@ -55,5 +61,57 @@ class MoveTablePdf < Prawn::Document text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size end + def add_lining_item(order_items, precision) + y_position = cursor -end \ No newline at end of file + bounding_box([0,y_position], :width => self.item_width) do + text "Item", :size => self.item_font_size,:align => :left + end + + bounding_box([self.item_width,y_position], :width => self.qty_width) do + text "Qty", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + move_down 5 + + add_item(order_items, precision) + end + + # Add order items under order info + def add_item(order_items, precision) + y_position = cursor + + move_down 5 + + order_items.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 + 60, :height => self.item_height) do + # text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left + # end + bounding_box([0,y_position], :width => self.item_width) do + text "#{odi.item_code} - #{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_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left + end + + 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 + end + +end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 58682d8a..9f7ce125 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -4,6 +4,8 @@ class OrderItemPdf < Prawn::Document def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height + self.header_font_size = print_settings.header_font_size.to_i + self.item_font_size = print_settings.item_font_size.to_i self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 @@ -26,13 +28,7 @@ class OrderItemPdf < Prawn::Document }) 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 + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb index 05add2c9..118927f6 100755 --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -4,6 +4,8 @@ class OrderItemSlimPdf < Prawn::Document def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 @@ -26,13 +28,7 @@ class OrderItemSlimPdf < Prawn::Document }) 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 + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb index ce06081f..1e7b9c7f 100755 --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -4,6 +4,8 @@ class OrderSetItemPdf < Prawn::Document def initialize(print_settings,order_set_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 @@ -26,13 +28,7 @@ class OrderSetItemPdf < Prawn::Document }) 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 + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 17cf905c..5feb337e 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -4,6 +4,8 @@ class OrderSummaryPdf < Prawn::Document def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height + self.header_font_size = print_settings.header_font_size.to_i + self.item_font_size = print_settings.item_font_size.to_i self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 @@ -25,13 +27,7 @@ class OrderSummaryPdf < Prawn::Document }) 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 + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end # font "public/fonts/Zawgyi-One.ttf" diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb index 14b2f796..316bbe44 100755 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -4,6 +4,8 @@ class OrderSummarySetPdf < Prawn::Document def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height + self.header_font_size = print_settings.header_font_size.to_i + self.item_font_size = print_settings.item_font_size.to_i self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 @@ -26,12 +28,6 @@ class OrderSummarySetPdf < Prawn::Document 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" diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb index c88061ea..1e93fc0d 100755 --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -4,6 +4,8 @@ class OrderSummarySlimPdf < Prawn::Document def initialize(print_settings,order, print_status, order_items = nil,alt_name,before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height + self.header_font_size = print_settings.header_font_size.to_i + self.item_font_size = print_settings.item_font_size.to_i self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 @@ -26,12 +28,6 @@ class OrderSummarySlimPdf < Prawn::Document 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" diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb index cce7eb94..89cca4ca 100755 --- a/app/pdf/queue_no_pdf.rb +++ b/app/pdf/queue_no_pdf.rb @@ -3,6 +3,8 @@ class QueueNoPdf < Prawn::Document def initialize(printer_settings, queue) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 5 self.price_width = 35 self.qty_width = 20 @@ -27,9 +29,6 @@ class QueueNoPdf < Prawn::Document fallback_fonts ["Courier", "Helvetica", "Times-Roman"] end - self.header_font_size = 10 - self.item_font_size = 8 - header( "Beauty In the Pot", printer_settings.name) queue_no(queue) diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 604d99dd..7253bfe1 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -5,6 +5,8 @@ class ReceiptBillA5Pdf < 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,card_data) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 15 self.price_width = 120 self.qty_width = 50 @@ -43,8 +45,6 @@ class ReceiptBillA5Pdf < Prawn::Document end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 16 - self.item_font_size = 14 if printer_settings.delimiter delimiter = "," diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index c0299033..a04cfcad 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -6,6 +6,8 @@ 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,card_data) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 0 self.price_width = 60 self.qty_width = 25 @@ -44,8 +46,6 @@ class ReceiptBillPdf < Prawn::Document end # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - self.header_font_size = 10 - self.item_font_size = 8 if printer_settings.delimiter delimiter = "," diff --git a/app/pdf/stock_result_pdf.rb b/app/pdf/stock_result_pdf.rb index 510ab317..1da06dd2 100755 --- a/app/pdf/stock_result_pdf.rb +++ b/app/pdf/stock_result_pdf.rb @@ -4,6 +4,8 @@ class StockResultPdf < Prawn::Document def initialize(printer_settings, stockcheck, stockcheck_items, checker_name, shop_details) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height + self.header_font_size = printer_settings.header_font_size.to_i + self.item_font_size = printer_settings.item_font_size.to_i self.margin = 5 self.price_width = 40 self.qty_width = 20 @@ -35,9 +37,7 @@ class StockResultPdf < Prawn::Document end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - self.header_font_size = 10 - self.item_font_size = 8 +# font "public/fonts/padauk.ttf" header(shop_details) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 372c05e9..70523063 100755 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -142,7 +142,7 @@ $(function() { }); // QR Code Reader - $("#qr_code").on('click', function(e){ + $("#qr_code").on('sclick', function(e){ var code = ""; setTimeout(function(){ code=getQRCode(); @@ -281,4 +281,8 @@ $(document).on('click',".customer_tr",function(){ return false; }); + $("#sxModal .btn_cancel").on('click',function(){ + $("#sxModal").hide(); + }); + diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb index e83a11d0..d6c6c955 100755 --- a/app/views/layouts/login.html.erb +++ b/app/views/layouts/login.html.erb @@ -79,6 +79,13 @@ Version - 1.0.1

+
+
+
+ <%= shop_detail.name %> +
+
+
<%= simple_form_for(@login_form, url: login_path, method: "post") do |f| %>
diff --git a/app/views/layouts/login_dashboard.html.erb b/app/views/layouts/login_dashboard.html.erb index 329e9240..5db72f79 100755 --- a/app/views/layouts/login_dashboard.html.erb +++ b/app/views/layouts/login_dashboard.html.erb @@ -65,6 +65,13 @@

+
+
+
+ <%= shop_detail.name %> +
+
+
diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 59badabe..e5de4885 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -360,9 +360,42 @@ // QR Code Reader $("#qr_code").on('click', function(e){ var code = ""; + var customer_id = ''; + var customer_name = ''; + var sale_id = $("#sale_id").val() || 0; + var customer_mamber_card_no = 0; + setTimeout(function(){ - code=getQRCode(); - setQRCode(code); + code=getQRCode(); + setQRCode(code); + + customer_mamber_card_no = $("#search").val(); + + if(sale_id != 0 && customer_mamber_card_no != 0){ + $.ajax({ + type: "POST", + url: "/origami/"+sale_id+"/get_customer" , + data: { filter : customer_mamber_card_no ,type :"card"}, + dataType: "json", + success: function(data) { + if (data[0].customer_id == false) { + swal("Alert!", data[0].message, "error"); + // $.alert({ + // title: 'Alert!', + // content: data[0].message, + // type: 'red', + // typeAnimated: true, + // btnClass: 'btn-danger', + // }); + }else{ + customer_id = data[0].customer_id; + customer_name = data[0].name; + update_sale(customer_id, customer_name,sale_id); + } + + } + }); + } },100); }); diff --git a/app/views/origami/dinga/create.json.jbuilder b/app/views/origami/dinga/create.json.jbuilder new file mode 100644 index 00000000..f352b148 --- /dev/null +++ b/app/views/origami/dinga/create.json.jbuilder @@ -0,0 +1,2 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] \ No newline at end of file diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb new file mode 100644 index 00000000..1b35710f --- /dev/null +++ b/app/views/origami/dinga/index.html.erb @@ -0,0 +1,201 @@ +
+ +
+
+
+
+
+
+ + <%@redeem_prices = @redeem_prices +@rounding_adj%> + +
+
+
+ <% if @dingacount > 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+ +
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+ +
+
+ + +
+
+ +
+
+
+ diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a10d15ba..2af02ca8 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -507,9 +507,9 @@ - <% if current_login_employee.role != "waiter" %> - - <% end %> + <% end %> <% end %> diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 3e20fe8c..83f866fa 100755 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -10,14 +10,12 @@
-->
-
-
-
+
+
- <% @payment_method_setting.where("is_active = true").each do |payment_method|%> -
<%= payment_method.payment_method %>
- <% end %> -
+ <% @payment_method_setting.where("is_active = true").each do |payment_method|%> +
<%= payment_method.payment_method %>
+ <% end %>
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 965f1814..044d42f3 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -167,25 +167,22 @@
Credit
<%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
- <% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%> + <% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 %>
Other Payments
<%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
<% else %>
-
Other Payments
+
Other Payments
+
<%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
<% end %>
- <% if @other != 0.0 %> -
- <% else %> -