diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 31209c99..a8de44b1 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -315,6 +315,7 @@ $(function() { $(".options-list").empty(); rowCount = $('.selected-instance'); + setCount = $('.selected-set'); item_options = $(this).data('option'); min_qty = $(this).data('min-qty'); @@ -335,19 +336,19 @@ $(function() { $(".options-list").append(row); } } - if($(this).hasClass('selected-instance') == true){ - sub_total = $('#set_total_price').text(); - name = $(this).data('name'); - price = $(this).data('price'); - // qty = $('#set_change_qty').val(); - qty = document.getElementById("set_count").value; - total = qty*price; - var total_price = +sub_total - +total; - $(this).removeClass('selected-instance'); - $(".options-list").empty(); - $(this).removeAttr('data-options'); - $('#instance_option').text('') - }else { + // if($(this).hasClass('selected-instance') == true){ + // sub_total = $('#set_total_price').text(); + // name = $(this).data('name'); + // price = $(this).data('price'); + // // qty = $('#set_change_qty').val(); + // qty = document.getElementById("set_count").value; + // total = qty*price; + // var total_price = +sub_total - +total; + // $(this).removeClass('selected-instance'); + // $(".options-list").empty(); + // $(this).removeAttr('data-options'); + // $('#instance_option').text('') + // }else { if (rowCount.length+1 <= max_qty) { sub_total = $('#set_total_price').text(); name = $(this).data('name'); @@ -358,12 +359,55 @@ $(function() { total = qty*price; var total_price = +sub_total + +total; $(this).addClass('selected-instance'); + + set = "
" + + +'
' + +' ' + +''+$(this).data('name')+'' + +'
' + +'
' + + +' ' + +'
' + // +'' + +'
' + $(".selected-set-list").append(set); + }else{ + swal("Alert !", 'Maximum Qty is ' + max_qty + " items", "warning"); } - } + // } $('#set_unit_price').text(price); $('#set_total_price').text(total_price); }); //End selecct attribute buttom + + // click add order + $(document).on('click', '#remove_set', function(event){ + code = $(this).parent().parent('.selected-set').attr('data-code'); + instance = $(".selected-instance"); + console.log(code) + $(instance).each(function(i){ + if ($(instance[i]).attr('data-code')==code){ + console.log($(instance[i])) + $(instance[i]).removeClass("selected-instance") + } + }); + $(this).parent().parent('.selected-set').remove(); + }); // click add order $(document).on('click', '.set_order', function(event){ @@ -637,15 +681,17 @@ $(function() { if(group == "set_menu"){ - - instance = $(".selected-instance"); - $(instance).each(function(i){ - if ($(instance[i]).attr('data-code')==code){ - option_arr = get_selected_attributes('selected-option'); - $(instance[i]).attr('data-options',JSON.stringify(option_arr)); - $(instance[i]).children().children('#instance_option').text(option_arr); - } - }); + option_arr = get_selected_attributes('selected-option'); + $(".selected-set:last").attr('data-options',JSON.stringify(option_arr)); + $(".selected-set:last").children().children('#instance_option').text(option_arr); + // instance = $(".selected-instance"); + // $(instance).each(function(i){ + // if ($(instance[i]).attr('data-code')==code){ + // option_arr = get_selected_attributes('selected-option'); + // $(instance[i]).attr('data-options',JSON.stringify(option_arr)); + // $(instance[i]).children().children('#instance_option').text(option_arr); + // } + // }); } if(group == "set_menu_default"){ diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index c6e6a47b..043fbb03 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -32,6 +32,26 @@ $(document).ready(function() { railBorderRadius: '0', touchScrollStep : 50 }); + + $('#modal-slimscroll').slimScroll({ + height: height-$('#modal-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 45 + }); + + $('#modal-set-slimscroll').slimScroll({ + height: height-$('#modal-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 45 + }); // $('.delete').click(function(){ // var method = $(this).attr('data-method'); diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 573f7c9e..a75779c3 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -387,3 +387,22 @@ function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amoun function setHeaderBreadCrumb(params){ $("#others_payment").html(params); } + +//show hide nav bar for webview +function showHideNavbar(webview,page=""){ + if(webview){ + $("nav.navbar").addClass("hidden"); + $("section").addClass("section-margin"); + $(".page-loader-wrapper").addClass("hidden"); + if(page!=""){ + $("#back").hide(); + } + }else{ + $("nav.navbar").removeClass("hidden"); + $("section").removeClass("section-margin"); + $(".page-loader-wrapper").removeClass("hidden"); + if(page!=""){ + $("#back").show(); + } + } +} diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index f882e526..601b8f89 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -431,4 +431,9 @@ iframe { width: 150%; height: 100%; } -/* End iframe */ \ No newline at end of file +/* End iframe */ + +/* section class for webview */ +.section-margin { + margin-top: -50px; +} \ No newline at end of file diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb new file mode 100644 index 00000000..23f9c699 --- /dev/null +++ b/app/controllers/api/survey_controller.rb @@ -0,0 +1,47 @@ +class Api::SurveyController < Api::ApiController + # before_action :authenticate + + def index + dining_facility = DiningFacility.find(params[:id]) + survey_data = Survey.find_by_dining_name(dining_facility.name) + countries = Lookup.collection_of("country") + if !countries.nil? || !survey_data.nil? + render :json => { :status => true, :data => { :countries => countries, :survey_data => survey_data} } + else + render :json => { :status => true, :error_message => "There is no data" } + end + end + + def create + dining_facility = DiningFacility.find(params[:id]) + cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id) + shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) + + if params[:survey_id] + survey = Survey.find(params[:survey_id]) + else + survey = Survey.new + end + survey.dining_name = dining_facility.name + survey.shift_id = shift_by_terminal.id + survey.child = params[:child] + survey.adult = params[:adult] + survey.male = params[:male] + survey.female = params[:female] + survey.local = params[:local] + survey.created_by = current_login_employee.name + survey.total_customer = params[:total_customer] + survey.total_amount = params[:total_amount] + survey.foreigner = params[:foreigner].to_json + survey.save! + + render :json => { :status => true } + end + + # private + # def survey_params + # params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, + # :dining_name,:created_by,:total_customer,:total_amount) + # end + +end \ No newline at end of file diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index e14a6959..ddcdc9e2 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -7,7 +7,8 @@ class BaseOrigamiController < ActionController::Base #before_action :check_installation protect_from_forgery with: :exception - helper_method :shop_detail + helper_method :shop_detail, :current_token + rescue_from CanCan::AccessDenied do |exception| flash[:warning] = exception.message # redirect_to origami_root_path @@ -33,5 +34,17 @@ class BaseOrigamiController < ActionController::Base def shop_detail @shop = Shop.first end - + + #check webview + def check_mobile + status = false + authenticate_with_http_token do |token, options| + session[:session_token] = token + end + + if session[:session_token] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i + status = true + end + return status + end end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 0e905724..4abab9c8 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -2,13 +2,23 @@ class Origami::AddordersController < BaseOrigamiController # before_action :set_dining, only: [:detail] def index - @tables = Table.all.active.order('zone_id asc').group("zone_id") - @rooms = Room.all.active.order('zone_id asc').group("zone_id") - @all_table = Table.all.active.order('status desc') - @all_room = Room.all.active.order('status desc') + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.all.active.order('zone_id asc').group("zone_id") + @rooms = Room.all.active.order('zone_id asc').group("zone_id") + @all_table = Table.all.active.order('status desc') + @all_room = Room.all.active.order('status desc') end def detail + @webview = false + if check_mobile + @webview = true + end + today = DateTime.now day = Date.today.wday @menus = Menu.all diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index c3a3d3b9..70e5260f 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -9,7 +9,6 @@ class Origami::CustomersController < BaseOrigamiController end def get_customer - filter = params[:filter] type = params[:type] @@ -47,7 +46,11 @@ class Origami::CustomersController < BaseOrigamiController end def add_customer - + @webview = false + if check_mobile + @webview = true + end + @sale_id = params[:sale_id] @cashier_type = params[:type] @page = params[:page] diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 6add4a12..0d3899bd 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -3,6 +3,11 @@ class Origami::DiscountsController < BaseOrigamiController #discount page show from origami index with selected order def index + @webview = false + if check_mobile + @webview = true + end + sale_id = params[:id] @cashier_type = params[:type] if Sale.exists?(sale_id) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 759cb1b6..427d2a86 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -3,6 +3,11 @@ class Origami::HomeController < BaseOrigamiController before_action :set_dining, only: [:show] def index + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @@ -14,6 +19,11 @@ class Origami::HomeController < BaseOrigamiController # origami table detail def show + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 09d9669e..20aaf0c5 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -56,19 +56,19 @@ class Origami::MovetableController < BaseOrigamiController end end - def moving - change_to = params[:change_to] #new - change_from = params[:change_from] #original - bookings = Booking.where('dining_facility_id=?',change_from) + def moving + change_to = params[:change_to] #new + change_from = params[:change_from] #original + 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) - end - end + booking_array = Array.new + bookings.each do | booking | + if booking.sale_id.nil? && booking.booking_status != 'moved' + booking_array.push(booking) + end + end - @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) + @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) # get printer info @from = (DiningFacility.find(change_from)).name @@ -78,9 +78,16 @@ class Origami::MovetableController < BaseOrigamiController @date = DateTime.now @shop = Shop::ShopDetail unique_code = "MoveTablePdf" - print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by) - end - + pdf_no = PrintSetting.where(:unique_code => unique_code).count + #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) + end + end + end end diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 3181d470..2a600294 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -1,5 +1,10 @@ class Origami::OrdersController < BaseOrigamiController def show + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index def94a1f..28ab2c06 100755 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -2,6 +2,11 @@ class Origami::OtherChargesController < BaseOrigamiController authorize_resource :class => false def index + @webview = false + if check_mobile + @webview = true + end + sale_id = params[:sale_id] @cashier_type = params[:type] if Sale.exists?(sale_id) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index da5f216b..943fc3e9 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -431,13 +431,17 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) + #calculate cash acmount + cash = saleObj.total_amount + if saleObj.discount_type == "member_discount" - saleObj.update_attributes(rounding_adjustment: 0) + saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0) saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source) end - saleObj.update_attributes(rounding_adjustment: 0) - + saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0) + puts "FOC" + puts saleObj.to_json sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark) # For Cashier by Zone diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index e2553a83..cdd1f442 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -16,7 +16,7 @@ class Origami::RequestBillsController < ApplicationController bk_order = BookingOrder.find_by_order_id(order_id) order = Order.find(order_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id) - + table = DiningFacility.find(check_booking.dining_facility_id) if check_booking.sale_id.nil? # Create Sale if it doesn't exist @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source) @@ -33,6 +33,8 @@ class Origami::RequestBillsController < ApplicationController # Promotion Activation Promotion.promo_activate(@sale) + #bill channel + ActionCable.server.broadcast "bill_channel",table: table if order.source == "quick_service" result = {:status=> @status, :data => @sale.sale_id } render :json => result.to_json diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 5c0cd454..505d747c 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -5,9 +5,18 @@ class Origami::RoomsController < BaseOrigamiController @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') # @shift = ShiftSale.current_open_shift(current_user.id) + @webview = false + if check_mobile + @webview = true + end end def show + @webview = false + if check_mobile + @webview = true + end + @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index e18828fc..8cd68d9c 100755 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -2,6 +2,11 @@ class Origami::SplitBillController < BaseOrigamiController authorize_resource :class => false def index + @webview = false + if check_mobile + @webview = true + end + dining_id = params[:dining_id] @cashier_type = params[:type] @table = DiningFacility.find(dining_id) diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index b30ff1b0..663fa805 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -1,6 +1,10 @@ class Origami::SurveysController < BaseOrigamiController def new - + @webview = false + if check_mobile + @webview = true + end + @survey = Survey.new @id = params[:id] @cashier_type = params[:type] diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 24c812eb..92604b04 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -3,18 +3,26 @@ class Reports::SaleitemController < BaseReportController def index from, to = get_date_range_from_params - shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) + + shift_sale_range = '' shift = '' if params[:shift_name].to_i != 0 + + shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) + shift_sale = ShiftSale.find(params[:shift_name]) - if to.blank? + if to.blank? shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at) else - - shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + if shift_sale.shift_closed_at.blank? + shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at) + else + shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at) + end end end + @type = params[:sale_type] @sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type) @@ -54,8 +62,8 @@ class Reports::SaleitemController < BaseReportController def show from, to, report_type = get_date_range_from_params - - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) +puts "aaaaaaaaaaaaaaaaaaaaaaaaaa" + @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| @@ -68,8 +76,8 @@ class Reports::SaleitemController < BaseReportController date_arr.push(str) end - @totalByAccount = Hash.new {|hash, key| hash[key] = 0} - @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} + # @totalByAccount = Hash.new {|hash, key| hash[key] = 0} + # @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} out = {:status => 'ok', :message => date_arr} diff --git a/app/models/license.rb b/app/models/license.rb index ac82721c..13931376 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -134,24 +134,36 @@ class License def verify_license api_token = read_license_no_decrypt("api_token") @params = { query: {lookup_type: "application", api_token: api_token} } - response = self.class.get("/verify", @params) + + begin + response = self.class.get("/verify", @params) + @varified = response.parsed_response + Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + if (@varified["status"]) + if (!check_expired(@varified["renewable_date"])) + return true + end + else + delete_license_file + end - rescue SocketError => e - Rails.logger.debug "In Socket errror" - return true - rescue => e - @varified = response.parsed_response - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s - if (@varified["status"]) - if (!check_expired(@varified["renewable_date"])) - return true - end - else - delete_license_file - end + rescue SocketError => e + Rails.logger.debug "In SocketError No Internet connection ! " + return true + rescue HTTParty::Error + Rails.logger.debug "Server Error HTTParty" + return true + rescue Net::OpenTimeout + Rails.logger.debug "connection Timeout" + return true + rescue OpenURI::HTTPError + Rails.logger.debug "Can't connect server" + return true + end return false end + # Check Expired before 30 days def check_expiring(renewal_date_str) if !renewal_date_str.empty? @@ -164,7 +176,6 @@ class License def check_expired(renewal_date_str) expired_date_str = read_license("renewable_date") renewal_date = DateTime.parse(renewal_date_str) - if(renewal_date_str != expired_date_str) update_license("renewable_date", renewal_date_str) end @@ -345,7 +356,8 @@ class License f.write("job.push.period.time.ms=10000\n") f.write("job.pull.period.time.ms=10000\n") f.write("initial.load.create.first=true\n") - f.write("initial.load.use.extract.job.enabled=true\n") + f.write("initial.load.use.extract.job.enabled=true\n") + f.write("rest.api.enable=true\n") f.close # read from license file @@ -368,7 +380,8 @@ class License f.write("external.id=001\n") f.write("job.routing.period.time.ms=5000\n") f.write("job.push.period.time.ms=10000\n") - f.write("job.pull.period.time.ms=10000\n") + f.write("job.pull.period.time.ms=10000\n") + f.write("rest.api.enable=true\n") # f.write("initial.load.create.first=true\n") # f.write("initial.load.use.extract.job.enabled=true\n") f.close diff --git a/app/models/print_setting.rb b/app/models/print_setting.rb index a3cfc597..0760b59f 100755 --- a/app/models/print_setting.rb +++ b/app/models/print_setting.rb @@ -1,6 +1,6 @@ class PrintSetting < ApplicationRecord # validations - validates_presence_of :name, :unique_code, :printer_name, :brand_name, :api_settings, :page_width, :page_height, :print_copies + validates_presence_of :name, :unique_code, :printer_name, :brand_name, :api_settings, :page_width, :page_height, :print_copies, :header_font_size, :item_font_size def self.get_precision_delimiter PrintSetting.find_by_unique_code("ReceiptBillPdf") diff --git a/app/models/sale.rb b/app/models/sale.rb index 883fbad4..363ff77b 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -361,6 +361,8 @@ class Sale < ApplicationRecord end end + compute_tax(sale, total_taxable, total_discount, order_source) + sale.total_amount = subtotal_price sale.total_discount = total_discount sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax @@ -371,8 +373,6 @@ class Sale < ApplicationRecord # adjust_rounding sale.rounding_adjustment = compute_adjust_rounding(sale.grand_total) - compute_tax(sale, total_taxable, total_discount, order_source) - sale.save! end @@ -806,6 +806,15 @@ def self.get_by_shift_sale(from,to,status) return query = query.where("shift_sales.shift_started_at >= ?" + " AND shift_sales.shift_closed_at <= ?", from,to) end +def self.get_by_shift_sale_by_item(from,to,status) + query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date, + shift_closed_at As closing_date," + + " grand_total AS grand_total, cash_sales AS cash," + + "total_taxes AS total_tax,total_discounts As total_discount") + .order("shift_sales.id DESC") + return query = query.where("shift_sales.shift_started_at >= ?" , from) +end + def self.get_item_query(type) if type == "revenue" || type.nil? diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index e43414b8..5cd7ea40 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -263,10 +263,12 @@ class SalePayment < ApplicationRecord self.payment_method = "foc" self.payment_amount = self.received_amount - self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f + # self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f + self.outstanding_amount = 0.00 self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) + # sale_update_payment_status(self.received_amount) + sale_update_payment_status(0) return payment_status end @@ -470,7 +472,7 @@ class SalePayment < ApplicationRecord elsif paid_amount.to_f > 0 #|| paid_amount != "0.0" table_update_status(sObj) update_shift - elsif method_status && paid_amount.to_f == 0 + elsif method_status && paid_amount.to_f == 0 && is_credit == 0 table_update_status(sObj) update_shift end diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 607f4c0e..6681a7f2 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -405,9 +405,15 @@

-
+ +
@@ -585,5 +591,12 @@ //end Ajax } //end show list function + + /* check webview loaded*/ + var webview = ''; + <%if @webview %> + var webview = <%= @webview %>; + showHideNavbar(webview); + <% end %> }); \ No newline at end of file diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 181319b9..59badabe 100755 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -274,6 +274,9 @@ var cashier_type = "<%= @cashier_type %>"; var page = "<%= @page %>"; $(function() { + /* check webview loaded*/ + var webview = <%= @webview %>; + showHideNavbar(webview); /*$('.datepicker').datepicker({ setDate: '12-12-1999', format : 'dd-mm-yyyy', diff --git a/app/views/origami/dashboard/index.html.erb b/app/views/origami/dashboard/index.html.erb index c50b92f9..2d7657f5 100644 --- a/app/views/origami/dashboard/index.html.erb +++ b/app/views/origami/dashboard/index.html.erb @@ -31,7 +31,7 @@
arrow_forward
-
<%= t :dine_in_order %>
+
<%= t :dine_in_cashier %>
diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index fc05b630..59341bcb 100755 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -257,6 +257,9 @@ var cashier_type = "<%= @cashier_type %>"; $(document).ready(function(){ setHeaderBreadCrumb(_DISCOUNTS_); + /* check webview loaded*/ + var webview = <%= @webview %>; + showHideNavbar(webview); $('#back').on('click',function(){ var id = $("#table_id").text(); diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index aa000aab..38f0cc79 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,7 +1,7 @@
-
+
-
+