diff --git a/Capfile b/Capfile new file mode 100644 index 00000000..9cfa1807 --- /dev/null +++ b/Capfile @@ -0,0 +1,31 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require "capistrano/rvm" +require "capistrano/rbenv" +# require "capistrano/chruby" +require "capistrano/bundler" +require "capistrano/rails" +require "capistrano/rails/assets" +require "capistrano/rails/migrations" +# require "capistrano/passenger" + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } +Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } +Dir.glob('lib/capistrano/**/*.rb').each { |r| import r } + diff --git a/Gemfile b/Gemfile index 1432e3af..90182812 100755 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' - +ruby '2.4.1' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" @@ -43,7 +43,7 @@ gem 'carrierwave', '~> 1.0' gem 'mini_magick' #Report and Printing gems -gem 'cups', '~> 0.0.7' +gem 'cups' gem 'prawn' gem 'prawn-table' gem 'spreadsheet' @@ -89,10 +89,10 @@ gem 'cancancan', '~> 1.10' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development -group :development, :test do +#group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console - gem 'byebug', platform: :mri -end +# gem 'byebug', platform: :mri +#end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. @@ -103,6 +103,10 @@ group :development do gem 'spring-watcher-listen', '~> 2.0.0' gem 'rspec-rails', '~> 3.5' gem 'schema_to_scaffold' + gem 'capistrano' + gem 'capistrano-bundler' + gem 'capistrano-rails' + gem 'capistrano-rbenv', github: "capistrano/rbenv" end group :test do @@ -122,4 +126,4 @@ gem 'momentjs-rails' # for date-range selector # gem 'bootstrap-datepicker-rails' # date picker # gem 'jquery-datetimepicker-rails' # gem 'select2-rails' # for multi-select and auto-complete select box -gem "chartkick" #chart lib \ No newline at end of file +gem "chartkick" #chart lib diff --git a/Gemfile.lock b/Gemfile.lock index d29f4058..48c34ea2 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: https://github.com/capistrano/rbenv.git + revision: c029e4128e4a8f25adda35795f5729bd4f62e51f + specs: + capistrano-rbenv (2.1.3) + capistrano (~> 3.1) + sshkit (~> 1.3) + GEM remote: https://rubygems.org/ specs: @@ -39,12 +47,24 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) aescrypt (1.0.0) + airbrussh (1.3.0) + sshkit (>= 1.6.1, != 1.7.0) arel (8.0.0) bcrypt (3.1.11) bindex (0.5.0) builder (3.2.3) - byebug (9.1.0) cancancan (1.17.0) + capistrano (3.10.1) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-bundler (1.3.0) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-rails (1.3.1) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) carrierwave (1.2.1) activemodel (>= 4.0.0) activesupport (>= 4.0.0) @@ -61,7 +81,7 @@ GEM concurrent-ruby (1.0.5) connection_pool (2.2.1) crass (1.0.2) - cups (0.0.7) + cups (0.1.10) database_cleaner (1.6.2) diff-lcs (1.3) erubi (1.7.0) @@ -128,6 +148,9 @@ GEM multi_xml (0.6.0) mysql2 (0.4.9) nested_form (0.3.2) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (4.2.0) nio4r (2.1.0) nokogiri (1.8.1) mini_portile2 (~> 2.3.0) @@ -228,6 +251,9 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + sshkit (1.15.1) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) tether-rails (1.4.0) rails (>= 3.1) thor (0.20.0) @@ -260,12 +286,15 @@ PLATFORMS DEPENDENCIES aescrypt bcrypt (~> 3.1.7) - byebug cancancan (~> 1.10) + capistrano + capistrano-bundler + capistrano-rails + capistrano-rbenv! carrierwave (~> 1.0) chartkick coffee-rails (~> 4.2) - cups (~> 0.0.7) + cups database_cleaner factory_girl_rails (~> 4.0) faker @@ -306,5 +335,8 @@ DEPENDENCIES web-console (>= 3.3.0) whenever +RUBY VERSION + ruby 2.4.1p111 + BUNDLED WITH - 1.16.0 + 1.16.1 diff --git a/README.md b/README.md index ef68d0b7..3412e2ed 100755 --- a/README.md +++ b/README.md @@ -31,7 +31,23 @@ ruby 2.4.1p111 Campaign Id => {"campaign_type_id": 1} +java -jar ~/Documents/Jade.jar http://192.168.1.88:3002 +Person and Extra Time + category_code = SPL... //for menu categories + +Extra Time + instance_code = Extim30, Extim60 //for morning menu + instance_code = Extie30, Extie60 //for evening menu + +Order Item & Order Summary Slim + *** change OrderItemPdf to OrderItemSlimPdf and OrderSummaryPdf to OrderSummarySlimPdf + 1) settings/print_settings + 2) app/controllers/oqs/edit_controller.rb + 3) app/controllers/oqs/print_controller.rb + 4) app/models/order_queue_station.rb + 5) app/models/printer/order_queue_printer.rb + 6) app/models/printer/receipt_printer.rb * ToDo list diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 572d94b3..ffaae308 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -61,7 +61,7 @@ $(document).on('turbolinks:load', function() { if (data[field]["options"] == "[]" || data[field]["options"] == "") { var options = ""; }else{ - var options = data.options; + var options = data[field]["options"]; } var date = new Date(data[field]["created_at"]); @@ -80,7 +80,7 @@ $(document).on('turbolinks:load', function() { +' [x'+ data[field]["qty"] +'] ' +'

' - +'

'+ options +'

' + +'

'+ options +'

' +'' +'Order at - ' diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index aa84b398..ff899c13 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -206,6 +206,7 @@ $(function() { $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]); value = item_sets[field]["instances"]; + $(value).each(function(i){ $.ajax({ type: "GET", @@ -241,6 +242,11 @@ $(function() { }); } + $('.set-item').attr('data-code',instances[0]['code']); + $('.set-item').attr('data-name',instances[0]['name']); + $('.set-item').attr('data-price',instances[0]['price']); + $('.set-item').attr('data-options','[]'); + $('#set_change_qty').val(1); $('#set_item_instances').text(instances); $('#set_name').text(data.attr('data-name')); @@ -313,6 +319,8 @@ $(function() { item_name = $('#set_name').text(); min_qty = $(this).data('min-qty'); + default_instance = $('.set-item'); + var items = $('.selected-instance'); if (items.length >= min_qty) { @@ -342,6 +350,29 @@ $(function() { $(".summary-items tbody").append(row); rowCount = rowCount + 1; }); + + var rowCount = $('.summary-items tbody tr').length+1; + option_arr = [] + code = $('.set-item').attr('data-code'); + name = $('.set-item').attr('data-name'); + price = $('.set-item').attr('data-price'); + option = $('.set-item').attr('data-options'); + total = qty * price ; + option_arr.push(option); + row ="" + +''+rowCount+'' + +'' + item_name+ ' ' + name +'' + +'' + qty + '' + +'' + + parseFloat(total).toFixed(2) + +'' + +''; + $(".summary-items tbody").append(row); calculate_sub_total(); $(".sx_item_set_detailModal").css({ 'display': "none" }); }else{ @@ -526,7 +557,7 @@ $(function() { } }); if (active) { - $(this).revoveClass('selected-option'); + $(this).removeClass('selected-option'); }else{ $(this).addClass('selected-option'); } diff --git a/app/assets/javascripts/channels/check_in_booking.js b/app/assets/javascripts/channels/check_in_booking.js index 4f5300ee..18597f4d 100644 --- a/app/assets/javascripts/channels/check_in_booking.js +++ b/app/assets/javascripts/channels/check_in_booking.js @@ -5,10 +5,12 @@ App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', { disconnected: function() {}, - received: function(data) { - $('.table_'+data.table.id).removeClass('green'); - $('.table_'+data.table.id).addClass('blue'); - $('.new_text_'+data.table.id).removeClass('hide') + received: function(data) { + if($('.table_'+data.table.id).hasClass('green')){ + $('.table_'+data.table.id).removeClass('green'); + $('.table_'+data.table.id).addClass('blue'); + } + $('.new_text_'+data.table.id).removeClass('hide'); } }); diff --git a/app/assets/javascripts/channels/checkin.js b/app/assets/javascripts/channels/checkin.js index d4a71d5e..03159170 100644 --- a/app/assets/javascripts/channels/checkin.js +++ b/app/assets/javascripts/channels/checkin.js @@ -6,21 +6,21 @@ App.order = App.cable.subscriptions.create('CheckinChannel', { disconnected: function() {}, received: function(data) { - $.each(data.table,function(key,value){ - if($('.table_'+value.table_id).hasClass('blue')){ - $('.table_'+value.table_id).removeClass('blue'); - $('.table_'+value.table_id).addClass('orange'); - } - else if($('.table_'+value.table_id).hasClass('red')){ - $('.table_'+value.table_id).removeClass('red'); - $('.table_'+value.table_id).addClass('orange'); - } - else { - $('.table_'+value.table_id).removeClass('green'); - $('.table_'+value.table_id).addClass('orange'); - } - $('.new_text_'+value.table_id).removeClass('hide'); - }); + $.each(data.table,function(key,value){ + if($('.table_'+value.table_id).hasClass('blue')){ + $('.table_'+value.table_id).removeClass('blue'); + $('.table_'+value.table_id).addClass('orange'); + } + else if($('.table_'+value.table_id).hasClass('red')){ + $('.table_'+value.table_id).removeClass('red'); + $('.table_'+value.table_id).addClass('orange'); + } + else { + $('.table_'+value.table_id).removeClass('green'); + $('.table_'+value.table_id).addClass('orange'); + } + $('.new_text_'+value.table_id).removeClass('hide'); + }); } }); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index a95a0eb6..d2b502d4 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -14,7 +14,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann if (items[field]["options"] == "[]" || items[field]["options"] == "") { var options = ""; }else{ - var options = items.options; + var options = items[field]["options"]; } //for count test = document.getElementsByClassName("oqs_count"); @@ -49,7 +49,7 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann +' [x'+ items[field]["qty"] +'] ' +'

' - +'

'+ options +'

' + +'

'+ options +'

' +'' +'Order at - ' diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index f23d13c6..33252efa 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -143,3 +143,55 @@ $(document).on('turbolinks:load', function() { return false; }); }); + +/* start check first bill or not funs: */ +function checkReceiptNoInFirstBillData(receipt_no,payment) { + // localStorage.removeItem('receipt_lists'); + var status = false; + if((receipt_no!=undefined) && (receipt_no!="")){ + if(localStorage.hasOwnProperty("receipt_lists")===true){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + if (payment) { + var json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); + }else{ + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + } + + if((arr_data.length) > (json_data.length)){ + status = true; + } + } + } + if (payment) { + return json_data[0]["payment"]; + }else{ + return status; + } +} + +function createReceiptNoInFirstBillData(receipt_no,payment) { + var arr_data = []; + var json_data = []; + if(localStorage.hasOwnProperty("receipt_lists") === true){ + arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); + if (payment) { + jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + jdata.push({'receipt_no':receipt_no,'payment':payment}); + localStorage.setItem("receipt_lists",JSON.stringify(jdata)); + } + } + if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){ + arr_data.push({'receipt_no':receipt_no,'payment':payment}); + localStorage.setItem("receipt_lists",JSON.stringify(arr_data)); + } +} + +function deleteReceiptNoInFirstBillData(receipt_no) { + if(localStorage.hasOwnProperty("receipt_lists") ===true ){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + localStorage.setItem("receipt_lists",JSON.stringify(json_data)); + } +} +/* end check first bill or not funs: */ \ No newline at end of file diff --git a/app/controllers/api/call_waiters_controller.rb b/app/controllers/api/call_waiters_controller.rb index 2c45bbbe..bfb1023a 100644 --- a/app/controllers/api/call_waiters_controller.rb +++ b/app/controllers/api/call_waiters_controller.rb @@ -6,6 +6,13 @@ class Api::CallWaitersController < ActionController::API @time = params[:time] @table = DiningFacility.find(@table_id) CallWaiterJob.perform_later(@table,@time) + + # get printer info + @shop = Shop::ShopDetail + unique_code = "CallWaiterPdf" + print_settings = PrintSetting.find_by_unique_code(unique_code) + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_call_waiter(print_settings,@table,@time,@shop) end diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 4f1c4ae2..cf34700e 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -11,7 +11,19 @@ class Api::CheckInProcessController < Api::ApiController check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") - render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time } + extra_minutes = (booking.checkout_at - booking.reserved_at) / 1.minutes + + lookup_checkout_time = Lookup.collection_of("checkout_alert_time") + alert_time_min = 0 + if !lookup_checkout_time.nil? + if lookup_checkout_time[0][0] == 'min' + alert_time_min = (lookup_checkout_time[0][1]).to_i + else + alert_time_min = 15 + end + end + + render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes } else render :json => { :status => false, :error_message => "No current booking!" } end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index db6dd039..cd8c7ca2 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -49,7 +49,25 @@ class Api::OrdersController < Api::ApiController def create Rails.logger.debug "Order Source - " + params[:order_source].to_s Rails.logger.debug "Table ID - " + params[:table_id].to_s +#for extratime + is_extra_time = false + extra_time = '' + params[:order_items].each { |i| + if i["item_instance_code"] == 'Extim60' || i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie60' || i["item_instance_code"] == 'Extie30' + is_extra_time = true + if i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie30' + t = Time.now + time = 30*60*i["quantity"].to_i + extra_time = Time.at(time) + else + t = Time.now + time = 60*60*i["quantity"].to_i + extra_time = Time.at(time) + end + end + } +#end extra time # begin @order = Order.new @order.source = params[:order_source] @@ -61,6 +79,9 @@ class Api::OrdersController < Api::ApiController @order.new_booking = true @order.waiters = current_login_employee.name @order.employee_name = current_login_employee.name + + @order.is_extra_time = is_extra_time + @order.extra_time = extra_time #Create Table Booking or Room Booking if !params["booking_id"].nil? # check booking id is already completed. diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fcca34a7..7fafd6bd 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,21 +36,25 @@ class ApplicationController < ActionController::Base # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] end - else + else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end - def current_license(url) + def current_license(url) @license = License.new(url) - - if (@license.detail_with_local_file() == true) - puts "RUN SAY BYAR" + flag = @license.detail_with_local_file() + if (flag == 0) + flash[:notice] = 'Expired or No License!' + elsif (flag == 2) + flash[:notice] = 'Expiring! Please, License extend...' else - return nil + puts "RUN SAY BYAR" end end @@ -107,9 +111,8 @@ class ApplicationController < ActionController::Base def check_license if License.check_license_file return true - else - redirect_to activate_path end + return false end end diff --git a/app/controllers/base_controller.rb b/app/controllers/base_controller.rb index 9f0914c4..1bf5b4d4 100755 --- a/app/controllers/base_controller.rb +++ b/app/controllers/base_controller.rb @@ -1,4 +1,5 @@ class BaseController < ActionController::Base layout "installation" protect_from_forgery with: :exception + end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 51ddc9eb..f917538e 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -37,6 +37,8 @@ class Crm::CustomersController < BaseCrmController @crm_customer = Customer.new @count_customer = Customer.count_customer + @membership_types = Lookup.collection_of("member_group_type") + @taxes = TaxProfile.all.order("order_by asc") @filter = filter diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d3666a60..1ee30bab 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -3,7 +3,8 @@ class HomeController < ApplicationController skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy] def index - @employees = Employee.all_emp_except_waiter.order("name asc") + # @employees = Employee.all_emp_except_waiter.order("name asc") + @employees = Employee.all.order("name asc") @login_form = LoginForm.new() render "layouts/login_dashboard", layout: false end @@ -45,7 +46,7 @@ class HomeController < ApplicationController elsif @employee.role == "manager" session[:session_token] = @employee.token_session redirect_to dashboard_path - elsif @employee.role == "supervisor" + elsif @employee.role == "supervisor" || @employee.role == "waiter" session[:session_token] = @employee.token_session redirect_to origami_root_path elsif @employee.role == "account" diff --git a/app/controllers/install_controller.rb b/app/controllers/install_controller.rb index a386416a..fac74926 100755 --- a/app/controllers/install_controller.rb +++ b/app/controllers/install_controller.rb @@ -1,6 +1,6 @@ class InstallController < BaseController skip_before_action :verify_authenticity_token - before_action :check_license + # before_action :check_license def index end @@ -17,20 +17,20 @@ class InstallController < BaseController db_schema = params[:db_schema] db_user = params[:db_user] db_password = params[:db_password] - phrase = license_key + phrase = license_key # Check Exists IV - if flag == "<%= ENV['AES_IV'] %>" - # Export for Key - aes = MyAesCrypt.new - aes_key, aes_iv = aes.export_key(phrase) - else - aes_key = ENV["AES_KEY"] - aes_iv = ENV["AES_IV"] - end + # if flag == "<%= ENV['AES_IV'] %>" + # # Export for Key + # aes = MyAesCrypt.new + # aes_key, aes_iv = aes.export_key(phrase) + # else + # aes_key = ENV["AES_KEY"] + # aes_iv = ENV["AES_IV"] + # end @license = License.new(ENV["SX_PROVISION_URL"]) - response = @license.license_activate(aes_key, aes_iv, license_key, db_host, db_schema, db_user, db_password) + response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password) if response[:status] redirect_to root_url, notice: response["message"] else @@ -38,7 +38,7 @@ class InstallController < BaseController end end - def check_license + def check_license if License.check_license_file redirect_to root_url end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index d283b06e..1a9aaa9a 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -62,9 +62,21 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController def create Rails.logger.debug "Order Source - " + params[:order_source].to_s Rails.logger.debug "Table ID - " + params[:table_id].to_s - puts params[:order_items] + is_extra_time = false + extra_time = '' + items_arr = [] JSON.parse(params[:order_items]).each { |i| + if i["item_instance_code"] == 'Extim60' || i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie60' || i["item_instance_code"] == 'Extie30' + is_extra_time = true + if i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie30' + time = 30*60*i["quantity"].to_i + extra_time = Time.at(time) + else + time = 60*60*i["quantity"].to_i + extra_time = Time.at(time) + end + end items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]} items_arr.push(items) } @@ -80,36 +92,34 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController @order.new_booking = true @order.waiters = current_login_employee.name @order.employee_name = current_login_employee.name + + @order.is_extra_time = is_extra_time + @order.extra_time = extra_time #Create Table Booking or Room Booking if !params["booking_id"].nil? - # check booking id is already completed. - booking = Booking.find(params[:booking_id]) - if booking - if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' - if !booking.sale_id.nil? - sale_status = check_order_with_booking(booking) - # puts "WWwwWWWWWWww" - # puts sale_status - if sale_status - return return_json_status_with_code(400, "bill requested") + # check booking id is already completed. + booking = Booking.find(params[:booking_id]) + + if booking + if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' + if !booking.sale_id.nil? + sale_status = check_order_with_booking(booking) + if sale_status + return return_json_status_with_code(400, "bill requested") + end + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + end + else + sale_status = check_order_with_table(params[:table_id]) + if sale_status + return return_json_status_with_code(400, "bill requested") + end end - else - @order.new_booking = false - @order.booking_id = params[:booking_id] - end - else - sale_status = check_order_with_table(params[:table_id]) - # puts "OOOOOOOOO" - # puts sale_status - if sale_status - return return_json_status_with_code(400, "bill requested") - end - end - end #booking exists + end #booking exists else sale_status = check_order_with_table(params[:table_id]) - # puts "MMMMMMMM" - # puts sale_status if sale_status # return false , @message = "bill requested" return return_json_status_with_code(400, "bill requested") diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 58f70faa..d84dac92 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -75,7 +75,8 @@ class Origami::CustomersController < BaseOrigamiController # if flash["errors"] # @crm_customer.valid? # end - + @membership_types = Lookup.collection_of("member_group_type") + respond_to do |format| # format.html { render :template => "crm/customers/index" } format.html { render action: "index"} diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index f580a92f..1166a705 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -157,7 +157,11 @@ class Origami::DiscountsController < BaseOrigamiController is_card = params[:is_card] sub_total = params[:sub_total] sale = Sale.find(sale_id) - + if is_card == 'true' + is_card = true + else is_card.to_s == 'false' + is_card = false + end # Check for Card Payment is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments) @@ -178,9 +182,7 @@ class Origami::DiscountsController < BaseOrigamiController end end end - - generic_customer_id = sale.customer.membership_id - account_no = sale.customer.paypar_account_no + generic_customer_id = sale.customer.membership_id receipt_no = sale.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("member_discount") @@ -188,12 +190,13 @@ class Origami::DiscountsController < BaseOrigamiController campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + account_no = sale.customer.paypar_account_no rescue nil # Check for items for Paypar Cloud if acc_prices.length > 0 begin response = HTTParty.post(url, - :body => { account_no: nil, + :body => { account_no: account_no, generic_customer_id:generic_customer_id , campaign_type_id: campaign_type_id, receipt_no: receipt_no, @@ -220,8 +223,8 @@ class Origami::DiscountsController < BaseOrigamiController else response = {"status": false, "message": "You have no selected discount item" } end - puts "discountttttttttttt" - puts response.to_json + Rails.logger.debug "-------------- Member Discount Osaka ---------" + Rails.logger.debug response.to_json # Re-calc All Amount in Sale if response["status"] == true discount_amount = response["discount_earned"] diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 47ec2383..fdf00b29 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -22,6 +22,10 @@ class Origami::HomeController < BaseOrigamiController @status_sale = "" @sale_array = Array.new + @shop = Shop::ShopDetail + @membership = MembershipSetting::MembershipSetting + @payment_methods = PaymentMethodSetting.all + @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/controllers/origami/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb index fa88afb7..16c7edae 100755 --- a/app/controllers/origami/others_payments_controller.rb +++ b/app/controllers/origami/others_payments_controller.rb @@ -5,7 +5,7 @@ class Origami::OthersPaymentsController < BaseOrigamiController @payment_method_setting = PaymentMethodSetting.all @rebate = MembershipSetting.find_by_rebate(1) - + @sale_data = Sale.find_by_sale_id(@sale_id) # @sale_id = params[:sale_id] # sale_data = Sale.find_by_sale_id(@sale_id) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index efb8f0cf..ebc10789 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -22,6 +22,7 @@ class Origami::PaymentsController < BaseOrigamiController cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) # Print for First Bill to Customer +<<<<<<< HEAD # unique_code = "ReceiptBillPdf" # #shop detail # shop_details = Shop::ShopDetail @@ -45,6 +46,48 @@ class Origami::PaymentsController < BaseOrigamiController # printer = Printer::ReceiptPrinter.new(print_settings) # printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt") +======= + unique_code = "ReceiptBillPdf" + #shop detail + shop_details = Shop::ShopDetail + # customer= Customer.where('customer_id=' +.customer_id) + customer = Customer.find(sale_data.customer_id) + + # rounding adjustment + if shop_details.is_rounding_adj + a = sale_data.grand_total % 25 # Modulus + b = sale_data.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + rounding_adj = new_total-sale_data.grand_total + sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) + end + end + #end rounding adjustment + + # get member information + rebate = MembershipSetting.find_by_rebate(1) + if customer.membership_id != nil && rebate + member_info = Customer.get_member_account(customer) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 + end + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # find order id by sale id + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + + printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance) +>>>>>>> master end def create @@ -58,9 +101,15 @@ class Origami::PaymentsController < BaseOrigamiController # rounding adjustment if shop_details.is_rounding_adj - new_total = Sale.get_rounding_adjustment(saleObj.grand_total) - rounding_adj = new_total-saleObj.grand_total - saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + end end #end rounding adjustment @@ -234,6 +283,12 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) + + if saleObj.discount_type == "member_discount" + saleObj.update_attributes(rounding_adjustment: 0) + saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0) + end + sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "foc") @@ -280,14 +335,15 @@ class Origami::PaymentsController < BaseOrigamiController @shop = Shop.find_by_id(1) if @shop.is_rounding_adj - new_total = Sale.get_rounding_adjustment(saleObj.grand_total) - else - new_total = saleObj.grand_total + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + end end - - rounding_adj = new_total-saleObj.grand_total - - saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) - end -end +end \ No newline at end of file diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 6c0b98c8..5e5b42cb 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -19,6 +19,10 @@ class Origami::RoomsController < BaseOrigamiController @status_sale = "" @sale_array = Array.new + @shop = Shop::ShopDetail + @membership = MembershipSetting::MembershipSetting + @payment_methods = PaymentMethodSetting.all + @room.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index e5350706..bdf481c2 100755 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -15,9 +15,14 @@ class Origami::SalesController < BaseOrigamiController dining = params[:dining_id] sale_id = params[:sale_id] table = DiningFacility.find(dining) + existing_booking = Booking.find_by_sale_id(sale_id) table.bookings.each do |booking| + # if !booking.checkout_at.nil? + # existing_booking.update_attributes(checkout_at: checkout_at) + # end if booking.sale_id.nil? booking.booking_orders.each do |booking_order| + booking.booking_status = 'moved' order = Order.find(booking_order.order_id) order.status = 'billed' @@ -36,7 +41,7 @@ class Origami::SalesController < BaseOrigamiController order.save booking.save end - existing_booking = Booking.find_by_sale_id(sale_id) + booking_order = BookingOrder.where('booking_id=?',booking) booking_order.each do |bo| bo.booking_id = existing_booking.booking_id diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 5a0aa3b8..b7efec25 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -6,7 +6,11 @@ class Origami::VoidController < BaseOrigamiController if Sale.exists?(sale_id) sale = Sale.find_by_sale_id(sale_id) - + if sale.discount_type == "member_discount" + sale.update_attributes(total_discount: 0) + sale.compute_by_sale_items(sale_id, sale.sale_items,0) + end + # update count for shift sale if(sale.sale_status == "completed") if sale.shift_sale_id != nil @@ -21,7 +25,7 @@ class Origami::VoidController < BaseOrigamiController shift.save end end - + sale.payment_status = 'void' sale.sale_status = 'void' sale.save @@ -38,12 +42,14 @@ class Origami::VoidController < BaseOrigamiController table_avaliable = true table = sale.bookings[0].dining_facility table.bookings.each do |booking| - if booking.sale.sale_status == 'new' - table_avaliable = false + if !booking.sale.nil? + if booking.sale.sale_status == 'new' + table_avaliable = false + end end end - if table_avaliable == true + if table_avaliable table.status = 'available' table.save end diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb index aeaa0a11..e97a1a77 100755 --- a/app/controllers/reports/commission_controller.rb +++ b/app/controllers/reports/commission_controller.rb @@ -19,7 +19,8 @@ class Reports::CommissionController < BaseReportController @from = from_date @to = to_date - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() respond_to do |format| format.html format.xls diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index dd9b3987..3b716cc2 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -21,7 +21,8 @@ authorize_resource :class => false @from = from @to = to - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() if @shift.present? @shift.each do |sh| @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb index fc1f150f..e2102d87 100755 --- a/app/controllers/reports/dailysale_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -8,6 +8,8 @@ class Reports::DailysaleController < BaseReportController @from = from @to = to + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() respond_to do |format| format.html format.xls diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index bbff8900..01a904ae 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -23,7 +23,8 @@ class Reports::PaymentMethodController < BaseReportController @sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift_sale_range,@shift,from,to,@payment_type) @from = from @to = to - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() if @shift.present? @shift.each do |sh| @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 2bd5e813..faa12eae 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -23,7 +23,8 @@ authorize_resource :class => false @tax_profiles = TaxProfile.order('order_by asc') @from = from @to = to - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() if @shift.present? @shift.each do |sh| @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index 7e7469f9..a9d23797 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -25,7 +25,7 @@ class Reports::SaleitemController < BaseReportController @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} @menu_cate_count = Hash.new {|hash, key| hash[key] = 0} - @sale_data.each {|cate| @menu_cate_count[cate.menu_category_id] += 1} + @sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1} @totalByAccount = Hash.new {|hash, key| hash[key] = 0} @@ -34,6 +34,9 @@ class Reports::SaleitemController < BaseReportController @from = from @to = to + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + if shift.present? shift.each do |sh| @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") @@ -64,6 +67,9 @@ 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} + out = {:status => 'ok', :message => date_arr} respond_to do |format| diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 5bc2020c..f9373374 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -17,7 +17,8 @@ class Reports::ShiftsaleController < BaseReportController @shift_to = @shift.shift_closed_at.nil? ? '-' : @shift.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p") @shift_data = @shift end - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() respond_to do |format| format.html format.xls diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index c9622999..a9188f5d 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -16,7 +16,8 @@ class Reports::StockCheckController < BaseReportController @transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code) @from = from_date @to = to_date - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() respond_to do |format| format.html format.xls diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index 80526ad0..6169dadc 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -20,7 +20,8 @@ authorize_resource :class => false @from = from @to = to - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() if @shift.present? @shift.each do |sh| @shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p") diff --git a/app/controllers/sym_control_controller.rb b/app/controllers/sym_control_controller.rb new file mode 100644 index 00000000..816b8f2c --- /dev/null +++ b/app/controllers/sym_control_controller.rb @@ -0,0 +1,35 @@ +class SymControlController < BaseController + skip_before_action :verify_authenticity_token + + def run + sym_path = "/home/yan/symmetric/" + check_sym_proc_str = `#{"service SymmetricDS status"}` + # Check Sym Installed + # if sym_install_status[1] == "false" + # response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} + # end + + if check_sym_proc_str.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running" + # Create Sym Table + check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables") + if check_sym_table + sym_sql = Rails.root + "db/sym_master.sql" + + if File.exist? (sym_sql) + # Import Sym Sql to db and start sym + run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s) + stop_sym = system("service SymmetricDS stop") + run_sym = system("service SymmetricDS start") + if run_sym + render :text => "

Success!

" + end + else + render :text => "

Sym Sql file not found!

" + end + end + else + render :text => "

Sym not running!

" + end + end + +end \ No newline at end of file diff --git a/app/models/ability.rb b/app/models/ability.rb index 4470fb4b..02b2618f 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -58,6 +58,7 @@ class Ability can :create, :discount can :remove_discount_items, :discount can :remove_all_discount, :discount + can :member_discount, :discount can :first_bill, :payment can :show, :payment diff --git a/app/models/customer.rb b/app/models/customer.rb index 85967e6a..c228e3e6 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -146,8 +146,8 @@ class Customer < ApplicationRecord if sale.customer.membership_id response = self.rebat(Sale.find(sale.sale_id)) #record an payment in sale-audit - remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.received_amount} " - sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, "CronJob") + remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} " + sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1) if response["status"] == true status = sale.update_attributes(rebate_status: "true") @@ -157,66 +157,137 @@ class Customer < ApplicationRecord end def self.rebat(sObj) - rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items) - + rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items) generic_customer_id = sObj.customer.membership_id if generic_customer_id.present? - paypar = sObj.sale_payments + + paypar = sObj.sale_payments payparcost = 0 - credit = 0 + credit = 0 + paypar.each do |pp| if pp.payment_method == "paypar" payparcost = payparcost + pp.payment_amount - elsif pp.payment_method == "creditnote" + end + if pp.payment_method == "creditnote" credit = 1 end end - # overall_dis = SaleItem.get_overall_discount(sObj.id) - overall_dis = sObj.total_discount - - total_amount = rebate_prices - payparcost - overall_dis - - if credit == 1 - total_amount = 0 - end - if total_amount >= 0 - receipt_no = sObj.receipt_no - membership = MembershipSetting.find_by_membership_type("paypar_url") - memberaction = MembershipAction.find_by_membership_type("rebate") - merchant_uid = memberaction.merchant_account_id.to_s - campaign_type_id = memberaction.additional_parameter["campaign_type_id"] - auth_token = memberaction.auth_token.to_s - url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + overall_dis = sObj.total_discount + + if credit != 1 + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("get_member_campaign") + merchant_uid = memberaction.merchant_account_id.to_s + campaign_type_id = memberaction.additional_parameter["campaign_type_id"] + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s # Control for Paypar Cloud begin - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id , - total_sale_transaction_amount: sObj.grand_total, - merchant_uid:merchant_uid, - total_amount: total_amount, - campaign_type_id: campaign_type_id, - receipt_no: receipt_no, - auth_token:auth_token}.to_json, - :headers => { + response = HTTParty.get(url, + :body => { + member_group_id:sObj.customer.membership_type, + merchant_uid:merchant_uid, + campaign_type_id: campaign_type_id, + auth_token:auth_token + }.to_json, + :headers => { 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' - }, :timeout => 10) + 'Accept' => 'application/json; version=2' + }, :timeout => 10) rescue Net::OpenTimeout response = { "status": false , "message": "Connect To" } - - rescue OpenURI::HTTPError response = { "status": false, "message": "Can't connect server"} rescue SocketError response = { "status": false, "message": "Can't connect server"} + end + + redeem_amount = payparcost + overall_dis + + total_percentage = 0 + + type_arr = [] + Rails.logger.debug "Get Member Campaign" + Rails.logger.debug response.to_json + # Check for present response fields + if response["membership_campaign_data"].present? + response["membership_campaign_data"].each do |a| + data = {:type => a["rules_type"], :percentage => a["change_unit"].to_i * a["base_unit"].to_i} + total_percentage = total_percentage + a["change_unit"].to_i * a["base_unit"].to_i + type_arr.push(data) + end end - return response - Rails.logger.debug "--------Update Rebate response -------" - Rails.logger.debug response.to_json + + rebate_arr =[] + campaign_method.each do |a| + data = {:type => a[:type], :amount => a[:amount]} + type_arr.each do |si| + if si[:type] == a[:type] + if credit == 1 + data[:amount] = 0 + else + amount = (redeem_amount / total_percentage)*si[:percentage] + actual = a[:amount] - amount + data[:amount] = actual + end + + end + end + rebate_arr.push(data) end + + total_amount = rebate_prices - payparcost - overall_dis + + if credit == 1 + total_amount = 0 + end + + if total_amount >= 0 + receipt_no = sObj.receipt_no + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("rebate") + merchant_uid = memberaction.merchant_account_id.to_s + campaign_type_id = memberaction.additional_parameter["campaign_type_id"] + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + # Control for Paypar Cloud + begin + response = HTTParty.post(url, + :body => { + generic_customer_id:generic_customer_id , + total_sale_transaction_amount: sObj.grand_total, + merchant_uid:merchant_uid, + total_amount: total_amount, + campaign_type_id: campaign_type_id, + receipt_no: receipt_no, + campaign_method: rebate_arr.to_json, + auth_token:auth_token + }.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=2' + }, :timeout => 10) + rescue Net::OpenTimeout + response = { "status": false , "message": "Connect To" } + rescue OpenURI::HTTPError + response = { "status": false, "message": "Can't connect server"} + + rescue SocketError + response = { "status": false, "message": "Can't connect server"} + end + Rails.logger.debug "Rebage Response" + Rails.logger.debug response.to_json + return response + end + end + else + response = { "status": "no_member", "message": "Not membership"} end end diff --git a/app/models/license.rb b/app/models/license.rb index 0f2fd0ed..36ce9b29 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -68,22 +68,54 @@ class License end # For Local System - def detail_with_local_file() - has_license = true # verify_license() + def detail_with_local_file() + renewal_date_str = read_license("renewable_date") + + if check_expiring(renewal_date_str) + # return for all ok + return 1 + else + has_license = verify_license() - if has_license - puts "VERIFIED" + if has_license + # return for expiring + return 2 + else + return 0 + end end + # end end # License Activation - def license_activate (key, iv, license_key, db_host, db_schema, db_user, db_password) - @params = { query: { lookup_type: self.server_mode, iv_key: iv, license_key: license_key } } + def license_activate (shop, license_key, db_host, db_schema, db_user, db_password) + aes = MyAesCrypt.new + aes_key, aes_iv = aes.export_key(license_key) + + @params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } } response = self.class.get("/activate", @params) @activate = response.parsed_response - Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s if (@activate["status"]) + ##Check from local redis - if available load local otherwise get from remote + cache_key = "shop:#{@activate["shop_name"]}" + + cache_license = nil + + ##Get redis connection from connection pool + redis = Redis.new + cache_license = redis.get(cache_key) + + Rails.logger.info "Cache key - " + cache_key.to_s + + if cache_license.nil? + cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] } + redis = Redis.new + redis.set(cache_key, Marshal.dump(cache)) + end + + Rails.logger.info "License - " + response.parsed_response.to_s + response = create_license_file(@activate) if(response[:status]) sym_path = "/home/yan/symmetric/" @@ -115,9 +147,23 @@ class License return false end + # Check Expired before 30 days + def check_expiring(renewal_date_str) + if !renewal_date_str.empty? + renewal_date = DateTime.parse(renewal_date_str) + renewal_date > Date.today.advance(:days => 30) + end + end + # Check License expired date from PROVISION SERVER - def check_expired(renewal_date_str) + 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 + if (renewal_date < Date.today) return true else @@ -131,16 +177,18 @@ class License end # read line by key for license file - def read_license(key) - decrypted_line = "" + def read_license(key_name) + decrypted_line = "" + key, iv = get_redis_key() + if File.exist?("config/license.yml") File.open("config/license.yml").each do |line| - if line.include? (key) - decrypted_line_array = line.split(": ") - decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(ENV['AES_KEY']), decode_str(ENV['AES_IV']), ENV['CIPHER_TYPE']) + if line.include? (key_name) + decrypted_line_array = line.split(": ") + decrypted_line = AESCrypt.decrypt_data(decode_str(decrypted_line_array[1]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE']) end end - end + end return decrypted_line end @@ -158,183 +206,210 @@ class License return decrypted_line end - private + # Update license file for line + def update_license(content, new_content) + key, iv = get_redis_key() - def decode_str(str) - return Base64.decode64(str) + if !new_content.include? "==" + crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE']) + end + + content_str = read_license_no_decrypt(content) + if File.exist?("config/license.yml") + file_str = File.read("config/license.yml") + new_file_str = file_str.gsub(content_str, encode_str(crypted_str)) + + # To write changes to the file, use: + File.open("config/license.yml", "w") {|file| file.puts new_file_str } + + # File.open("config/license.yml").each do |line| + # new_file_str = line.gsub(content, crypted_str) + # f.put + # end + end + end + + private + def get_redis_key + iv = "" + key = "" + shop = read_license_no_decrypt("shop_name") + ##Check from local redis - if available load local otherwise get from remote + cache_key = "shop:#{shop.chomp}" + + cache_shop = nil + + ##Get redis connection from connection pool + redis = Redis.new + cache_shop = redis.get(cache_key) + + if !cache_shop.nil? + @shop = Marshal.load(cache_shop) + key = @shop["key"] + iv = @shop["iv"] + end + return key, iv + end + + def encode_str(str) + return Base64.encode64(str) + end + + def decode_str(str) + return Base64.decode64(str) + end + + # License File Creation + def create_license_file(response_data) + if File.exist?("config/license.yml") + delete_license_file end - # License File Creation - def create_license_file(response_data) - if File.exist?("config/license.yml") - delete_license_file - end + begin + # Licese File Creation + File.open("config/license.yml", "w") do |f| + f.puts("iv_key: #{response_data['iv_key']}") + f.puts("shop_name: #{response_data['shop_name']}") + f.puts("email: #{response_data['email']}") + f.puts("telephone: #{response_data['telephone']}") + f.puts("fax: #{response_data['fax']}") + f.puts("address: #{response_data['address']}") + f.puts("dbhost: #{response_data['dbhost']}") + f.puts("dbschema: #{response_data['dbschema']}") + f.puts("dbusername: #{response_data['dbusername']}") + f.puts("dbpassword: #{response_data['dbpassword']}") + f.puts("api_token: #{response_data['api_token']}") + f.puts("app_token: #{response_data['app_token']}") + f.puts("plan_sku: #{response_data['plan_sku']}") + f.puts("renewable_date: #{response_data['renewable_date']}") + f.puts("plan_name: #{response_data['plan_name']}") + end + rescue IOError + response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} + end + response = { "status": true, "message": "Success Activation. License also created."} + end + # Symmetric Configuration + def create_symmetric_config(sym_location, db_host, db_schema, db_user, db_password) + if File.directory? (sym_location) begin - # Licese File Creation - File.open("config/license.yml", "w") do |f| - f.puts("iv_key: #{response_data['iv_key']}") - f.puts("shop_name: #{response_data['shop_name']}") - f.puts("email: #{response_data['email']}") - f.puts("telephone: #{response_data['telephone']}") - f.puts("fax: #{response_data['fax']}") - f.puts("address: #{response_data['address']}") - f.puts("dbhost: #{response_data['dbhost']}") - f.puts("dbschema: #{response_data['dbschema']}") - f.puts("dbusername: #{response_data['dbusername']}") - f.puts("dbpassword: #{response_data['dbpassword']}") - f.puts("api_token: #{response_data['api_token']}") - f.puts("app_token: #{response_data['app_token']}") - end + # sx properties create + f = File.open(sym_location + "engines/sx.properties", "w") + f.write("engine.name=sx\n") + f.write("db.driver=com.mysql.jdbc.Driver\n") + f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n") + f.write("db.user=#{db_user}\n") + f.write("db.password=#{db_password}\n") + f.write("registration.url=\n") + f.write("sync.url=http://#{db_host}:31415/sync/sx\n") + f.write("group.id=sx\n") + f.write("external.id=000\n") + f.write("job.purge.period.time.ms=7200000\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("initial.load.create.first=true\n") + f.write("initial.load.use.extract.job.enabled=true\n") + f.close + + # read from license file + shop_name = read_license_no_decrypt("shop_name") + dbhost = read_license("dbhost") + dbschema = read_license("dbschema") + dbusername = read_license("dbusername") + dbpassword = read_license("dbpassword") + + # shop properties create + f = File.open(sym_location + "engines/#{shop_name}.properties", "w") + f.write("engine.name=#{shop_name}\n") + f.write("db.driver=com.mysql.jdbc.Driver\n") + f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n") + f.write("db.user=#{dbusername}\n") + f.write("db.password=#{dbpassword}\n") + f.write("registration.url=http://#{db_host}:31415/sync/sx\n") + f.write("group.id=store\n") + 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("initial.load.create.first=true\n") + # f.write("initial.load.use.extract.job.enabled=true\n") + f.close rescue IOError response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} end response = { "status": true, "message": "Success Activation. License also created."} end + end - # Symmetric Configuration - def create_symmetric_config(sym_location, db_host, db_schema, db_user, db_password) - if File.directory? (sym_location) - begin - # sx properties create - f = File.open(sym_location + "engines/sx.properties", "w") - f.write("engine.name=sx\n") - f.write("db.driver=com.mysql.jdbc.Driver\n") - f.write("db.url=jdbc:mysql://#{db_host}/#{db_schema}?tinyInt1isBit=false\n") - f.write("db.user=#{db_user}\n") - f.write("db.password=#{db_password}\n") - f.write("registration.url=\n") - f.write("sync.url=http://#{db_host}:31415/sync/sx\n") - f.write("group.id=sx\n") - f.write("external.id=000\n") - f.write("job.purge.period.time.ms=7200000\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("initial.load.create.first=true\n") - f.write("initial.load.use.extract.job.enabled=true\n") - f.close + # Run Symmetric + def run_symmetric(sym_path) + # check_sym_proc_str = `#{sym_path + "bin/sym_service status"}` + # check_sym_proc_str = check_sym_proc_str.split("\n") + # sym_install_status = check_sym_proc_str[0].split(": ") + + check_sym_proc_str = `#{"service SymmetricDS status"}` - # read from license file - shop_name = read_license("shop_name") - dbhost = read_license("dbhost") - dbschema = read_license("dbschema") - dbusername = read_license("dbusername") - dbpassword = read_license("dbpassword") + # Check Sym Installed + # if sym_install_status[1] == "false" + # response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} + # end - # shop properties create - f = File.open(sym_location + "engines/#{shop_name}.properties", "w") - f.write("engine.name=#{shop_name}\n") - f.write("db.driver=com.mysql.jdbc.Driver\n") - f.write("db.url=jdbc:mysql://#{dbhost}/#{dbschema}?tinyInt1isBit=false\n") - f.write("db.user=#{dbusername}\n") - f.write("db.password=#{dbpassword}\n") - f.write("registration.url=http://#{db_host}:31415/sync/sx\n") - f.write("group.id=store\n") - 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("initial.load.create.first=true\n") - # f.write("initial.load.use.extract.job.enabled=true\n") - f.close - rescue IOError - response = { "status": false, "message": "Activation is success but something is wrong. \n Please contact code2lab call center!"} - end - response = { "status": true, "message": "Success Activation. License also created."} - end - end - - # Run Symmetric - def run_symmetric(sym_path) - # check_sym_proc_str = `#{sym_path + "bin/sym_service status"}` - # check_sym_proc_str = check_sym_proc_str.split("\n") - # sym_install_status = check_sym_proc_str[0].split(": ") - - check_sym_proc_str = `#{"service SymmetricDS status"}` - - # Check Sym Installed - # if sym_install_status[1] == "false" - # response = { "status": false, "message": "Activation is success but Symmetric service not Installed. \n Please contact code2lab call center!"} - # end - - # Run Sym Service - sym_run_status = check_sym_running(check_sym_proc_str, sym_path) - if sym_run_status - # Create Sym Table - check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables") - if check_sym_table - sym_sql = Rails.root + "db/sym_master.sql" - - if File.exist? (sym_sql) - # Import Sym Sql to db and start sym - run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s) - stop_sym = system("service SymmetricDS stop") - run_sym = system("service SymmetricDS start") - if run_sym - response = { "status": true, "message": "Activation is success and Configuration done..."} - end - else - response = { "status": false, "message": "Activation is success but Symmetric Sql not found. \n Please contact code2lab call center!"} + # Run Sym Service + sym_run_status = check_sym_running(check_sym_proc_str, sym_path) + if sym_run_status + # Create Sym Table + check_sym_table = system(sym_path + "bin/symadmin --engine sx create-sym-tables") + if check_sym_table + sym_sql = Rails.root + "db/sym_master.sql" + + if File.exist? (sym_sql) + # Import Sym Sql to db and start sym + run_sym_sql = system(sym_path + "bin/dbimport --engine sx " + sym_sql.to_s) + stop_sym = system("service SymmetricDS stop") + run_sym = system("service SymmetricDS start") + if run_sym + response = { "status": true, "message": "Activation is success and Configuration done..."} end + else + response = { "status": false, "message": "Activation is success but Symmetric Sql not found. \n Please contact code2lab call center!"} end - else - response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"} end + else + response = { "status": false, "message": "Activation is success but Symmetric not running. \n Please contact code2lab call center!"} end + end - # Check Symmetric Running - def check_sym_running(status, sym_path) - # Run Sym Service - # if status.include? "Server is already running" - # return true - # elsif status.include? "false" - # sym_start_str = `#{sym_path + "bin/sym_service start"}` - # if sym_start_str.include? "Started" - # return true - # else - # check_sym_running(sym_start_status[0]) - # end - # else - # return true - # end + # Check Symmetric Running + def check_sym_running(status, sym_path) + # Run Sym Service + # if status.include? "Server is already running" + # return true + # elsif status.include? "false" + # sym_start_str = `#{sym_path + "bin/sym_service start"}` + # if sym_start_str.include? "Started" + # return true + # else + # check_sym_running(sym_start_status[0]) + # end + # else + # return true + # end - if status.include? "Active: active (running)" #"Server is already running" - return true - end - return false + if status.include? "Active: active (running)" || "Active: active (exited)" #"Server is already running" + return true end + return false + end - # Delete License File - def delete_license_file - File.delete("config/license.yml") if File.exist?("config/license.yml") - end + # Delete License File + def delete_license_file + File.delete("config/license.yml") if File.exist?("config/license.yml") + end # Assign db info for Cloud - def assign(aes_key, aes_iv) - # self.name = @license["name"] - # self.address_1 = @license["address_1"] - # self.address_2 = @license["address_2"] - # self.township = @license["township"] - # self.city = @license["city"] - # self.country = @license["country"] - # self.email = @license["email"] - # self.phone = @license["phone"] - # self.fax = @license["fax"] - # self.logo = @license["logo"] - # self.localhost_address = @license["localhost_address"] - # self.subdomain = @license["subdomain"] - # self.plan_activation_date = Date.parse(@license["plan_activation_date"]) - # self.plan_next_renewal_date = Date.parse(@license["plan_next_renewal_date"]) - - ## self.plan_activation_date = Date.strptime(@license["plan_activation_date"], "%Y-%m-%d") - ## self.plan_next_renewal_date = Date.strptime(@license["plan_next_renewal_date"], "%Y-%m-%d") - - # self.plan_max_products = @license["plan_max_products"].to_i - # self.plan_max_customers = @license["plan_max_customers"].to_i - # self.plan_active_connections = @license["plan_active_connections"].to_i - # salt = @license["secret_key"] - + def assign(aes_key, aes_iv) key = Base64.decode64(aes_key) iv = Base64.decode64(aes_iv) @@ -349,18 +424,6 @@ class License self.dbusername = AESCrypt.decrypt_data(dbusername, key, iv, ENV['CIPHER_TYPE']) self.dbpassword = AESCrypt.decrypt_data(dbpassword, key, iv, ENV['CIPHER_TYPE']) end - - # self.exchange_unqiue_id = @license["exchange_unqiue_id"] - - # self.localqueue_host= @license["localqueue_host"] - # self.localqueue_user= @license["localqueue_user"] - # self.localqueue_password= @license["localqueue_password"] - - # self.remotequeue_host = @license["remotequeue_host"] - # self.remotequeue_user = @license["remotequeue_user"] - # self.remotequeue_password = @license["remotequeue_password"] - - # self.api_token = @license["api_token"] - # self.app_token = @license["app_token"] + end end diff --git a/app/models/membership_setting.rb b/app/models/membership_setting.rb index 89f9eb14..3b60c781 100755 --- a/app/models/membership_setting.rb +++ b/app/models/membership_setting.rb @@ -1,2 +1,3 @@ class MembershipSetting < ApplicationRecord + MembershipSetting = MembershipSetting.find_by_id(1) end diff --git a/app/models/my_aes_crypt.rb b/app/models/my_aes_crypt.rb index 569a401d..680d0624 100644 --- a/app/models/my_aes_crypt.rb +++ b/app/models/my_aes_crypt.rb @@ -17,8 +17,7 @@ class MyAesCrypt passphrase = passphrase + ENV['SX_KEY'] passphrase = passphrase.gsub(".","_") digest = Digest::SHA256.new - key_digest = digest.update(passphrase) - # iv_digest = digest.update(iv_salt) + key_digest = digest.update(passphrase) key = key_digest.digest # iv = iv_digest.digest diff --git a/app/models/order.rb b/app/models/order.rb index ba8adc8f..318e8e91 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -10,7 +10,7 @@ class Order < ApplicationRecord has_many :assigned_order_items #internal references attributes for business logic control - attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id + attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } #Main Controller method to create new order - validate all inputs and generate new order # order_item : { @@ -25,14 +25,33 @@ class Order < ApplicationRecord booking = nil if self.new_booking - booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", + #add extra time + if self.is_extra_time && self.extra_time + booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", + :checkin_at => Time.now.utc,:checkout_at => Time.now.utc + self.extra_time.to_i, + :checkin_by => self.employee_name, + :booking_status => "assign" }) + else + booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, :booking_status => "assign" }) + end + #end extra time + + table = DiningFacility.find(self.table_id) table.status = "occupied" table.save else booking = Booking.find(self.booking_id) + #add extra time + if self.is_extra_time + if !booking.checkout_at.nil? + new_time = booking.checkout_at + self.extra_time.to_i + booking.update_attributes(checkout_at: new_time) + end + end + #end extra time end booking.save! diff --git a/app/models/print_setting.rb b/app/models/print_setting.rb index a13229dc..b4f17a62 100755 --- a/app/models/print_setting.rb +++ b/app/models/print_setting.rb @@ -1,4 +1,8 @@ class PrintSetting < ApplicationRecord # validations validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies + + def self.get_precision_delimiter + PrintSetting.find_by_unique_code("CloseCashierPdf") + end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 495bf85a..cc08f9ba 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -12,7 +12,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code) - filename = "tmp/order_item.pdf" + filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf" # check for item not to show # if order_item[0].price != 0 @@ -46,14 +46,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order=print_query('order_summary', order_id) # For Print Per Item if oqs.cut_per_item - order.each do|odi| - filename = "tmp/order_item.pdf" + + order_items.each do|odi| + odi_item=print_query('order_item', odi.order_items_id) + filename = "tmp/order_item_#{order_id}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options # check for item not to show #if odi.price != 0 - pdf = OrderItemPdf.new(print_settings,odi, print_status, options, oqs.use_alternate_name) + pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name) # pdf.render_file "tmp/order_item.pdf" pdf.render_file filename if oqs.print_copy @@ -68,7 +70,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/order_summary.pdf" + filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy @@ -96,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Per Item if oqs.cut_per_item order.each do|odi| - filename = "tmp/order_item.pdf" + filename = "tmp/order_item_#{booking_id}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options @@ -120,7 +122,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/booking_summary.pdf" + filename = "tmp/booking_summary_#{booking_id}" + ".pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 7a865bf4..aecd13da 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -117,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker pdf.render_file "tmp/print_crm_order.pdf" self.print("tmp/print_crm_order.pdf") end + + #Queue No Print + def print_call_waiter(printer_settings,table,time,shop_detail) + #Use CUPS service + #Generate PDF + #Print + pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail) + pdf.render_file "tmp/print_call_waiter.pdf" + self.print("tmp/print_call_waiter.pdf") + end + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 1598563f..69aa930a 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -114,7 +114,14 @@ class Sale < ApplicationRecord order.save booking.sale_id = self.id - booking.checkout_at = Time.now.utc.getlocal + if !booking.checkout_at.nil? + if booking.checkout_at < Time.now.utc.getlocal + booking.checkout_at = Time.now.utc.getlocal + end + else + booking.checkout_at = Time.now.utc.getlocal + end + booking.checkout_by = requested_by.name booking.save @@ -222,8 +229,6 @@ class Sale < ApplicationRecord sales_items.each do |item| #compute each item and added to total - puts "item.sales_item_id ddd" - puts item.sale_item_id subtotal_price = subtotal_price + item.price # only calc tax when true @@ -247,6 +252,7 @@ class Sale < ApplicationRecord #compute - invoice total def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil) + sale = Sale.find(sale_id) sales_items = sale_itemss @@ -659,7 +665,7 @@ def self.get_item_query() # "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ") query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id") # query = query.where("i.item_instance_code IS NOT NULL") - query = query.group("i.product_name").order("mi.account_id asc","mi.menu_category_id asc") + query = query.group("acc.title,mi.account_id,i.product_name").order("acc.title desc, mi.account_id desc") end def self.get_other_charges() @@ -1107,7 +1113,7 @@ end def self.top_items(today) query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price") .joins("JOIN sale_items as a ON a.sale_id = sales.sale_id") - .where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) + .where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today) .group("a.product_code") .order("SUM(a.qty) DESC") .first() diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 236606c6..8cb33c80 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -173,13 +173,20 @@ class SalePayment < ApplicationRecord private def cash_payment + status = false + sale_payments_data = SalePayment.find_by_sale_id(self.sale_id) + if sale_payments_data.nil? + status = true + end + payment_status = false self.payment_method = "cash" self.payment_amount = self.received_amount self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_method = self.save! - sale_update_payment_status(self.received_amount) + + sale_update_payment_status(self.received_amount,status) return payment_status end @@ -187,7 +194,7 @@ class SalePayment < ApplicationRecord payment_status = false # add to sale item with foc - sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'") + sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null") sale_items.each do|item| SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price) @@ -271,7 +278,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " - sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier") + sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1) if membership_data["status"]==true self.payment_method = "paypar" @@ -290,7 +297,7 @@ class SalePayment < ApplicationRecord end - def sale_update_payment_status(paid_amount) + def sale_update_payment_status(paid_amount,check_foc = false) #update amount_outstanding self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.save! @@ -328,7 +335,7 @@ class SalePayment < ApplicationRecord #record an payment in sale-audit remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " - sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier") + sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1) if !response.nil? if response["status"] == true @@ -349,8 +356,10 @@ class SalePayment < ApplicationRecord self.sale.save! table_update_status(sObj) - - if paid_amount != "0.0" + + if check_foc + update_shift + elsif paid_amount != "0.0" update_shift end end @@ -363,6 +372,11 @@ class SalePayment < ApplicationRecord shift.update(self.sale) self.sale.shift_sale_id = shift.id self.sale.save + else + shift = ShiftSale.current_shift + shift.update(self.sale) + self.sale.shift_sale_id = shift.id + self.sale.save end end @@ -436,7 +450,7 @@ class SalePayment < ApplicationRecord 'Accept' => 'application/json; version=2' }, :timeout => 10) rescue Net::OpenTimeout - response = { "status": false , "message": "Connect To" } + response = { "status": false , "message": " Connection timeout" } rescue OpenURI::HTTPError response = { "status": false, "message": "Can't connect server"} diff --git a/app/pdf/call_waiter_pdf.rb b/app/pdf/call_waiter_pdf.rb new file mode 100644 index 00000000..a1ea756b --- /dev/null +++ b/app/pdf/call_waiter_pdf.rb @@ -0,0 +1,71 @@ +class CallWaiterPdf < Prawn::Document + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(printer_settings, table,time,shop_detail) + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height + self.margin = 5 + self.price_width = 35 + self.qty_width = 20 + self.total_width = 35 + self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.item_height = 15 + self.item_description_width = (self.page_width-20) / 2 + self.label_width = 100 + + super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + # db font setup + if printer_settings.font != "" + font_families.update("#{printer_settings.font}" => { + :normal => "public/fonts/#{printer_settings.font}.ttf", + :italic => "public/fonts/#{printer_settings.font}.ttf", + :bold => "public/fonts/#{printer_settings.font}.ttf", + :bold_italic => "public/fonts/#{printer_settings.font}.ttf" + }) + + font "#{printer_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + end + + self.header_font_size = 10 + self.item_font_size = 8 + + header( shop_detail.name, printer_settings.name) + + call_waiter(table) + stroke_horizontal_rule + + # date_info(queue) + + end + + def header (shop_name, name) + text "#{shop_name}", :left_margin => -10, :size => self.header_font_size,:align => :center + text "#{name}", :size => self.header_font_size,:align => :center + # move_down self.item_height + move_down 5 + stroke_horizontal_rule + move_down 5 + end + + def call_waiter (table) + move_down 3 + text "Table Name : #{table.name}",:align => :center + end + + # def date_info(queue) + # move_down 5 + + # y_position = cursor + # bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do + # text "Date:", :size => self.item_font_size,:align => :left + # end + # bounding_box([self.label_width,y_position], :width => self.item_width) do + # text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left + # end + + # move_down 5 + + # end + +end diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 93cd7ab9..d84b0366 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -1,4 +1,5 @@ class CloseCashierPdf < Prawn::Document + include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount) @@ -38,11 +39,22 @@ class CloseCashierPdf < Prawn::Document self.header_font_size = 10 self.item_font_size = 8 + #precision checked + if printer_settings.precision.to_i > 2 + printer_settings.precision = 2 + end + #check delimiter + if printer_settings.delimiter + delimiter = "," + else + delimiter = "" + end + header( shop_details) stroke_horizontal_rule - shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount) + shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter) end def header (shop_details) @@ -58,7 +70,7 @@ class CloseCashierPdf < Prawn::Document stroke_horizontal_rule end - def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount) + def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter) move_down 7 y_position = cursor bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do @@ -97,7 +109,7 @@ class CloseCashierPdf < Prawn::Document text "Opening Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ shift_sale.opening_balance}" , :size => self.item_font_size,:align => :left + text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left end y_position = cursor @@ -105,7 +117,8 @@ class CloseCashierPdf < Prawn::Document text "Closing Float : ", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do - text "#{ shift_sale.closing_balance}" , :size => self.item_font_size,:align => :left + text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left + # text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}" end @@ -122,7 +135,8 @@ class CloseCashierPdf < Prawn::Document text "Received Amount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.closing_balance}", :size => self.item_font_size, :align => :right + text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end y_position = cursor @@ -130,7 +144,7 @@ class CloseCashierPdf < Prawn::Document text "Cash In:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.cash_in}", :size => self.item_font_size, :align => :right + text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -138,7 +152,7 @@ class CloseCashierPdf < Prawn::Document text "Cash Out:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.cash_out}", :size => self.item_font_size, :align => :right + text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end move_down -5 @@ -151,7 +165,7 @@ class CloseCashierPdf < Prawn::Document text "Cash Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.cash_sales}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -159,7 +173,7 @@ class CloseCashierPdf < Prawn::Document text "Credit Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.credit_sales}", :size => self.item_font_size, :align => :right + text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right end #start other payment details if shift_sale.other_sales > 0 @@ -170,7 +184,7 @@ class CloseCashierPdf < Prawn::Document text "MPU Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{other.mpu_amount.round(2)}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -178,7 +192,7 @@ class CloseCashierPdf < Prawn::Document text "VISA Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{other.visa_amount.round(2)}", :size => self.item_font_size, :align => :right + text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -186,7 +200,7 @@ class CloseCashierPdf < Prawn::Document text "Master Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{other.master_amount.round(2)}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -194,7 +208,7 @@ class CloseCashierPdf < Prawn::Document text "JCB Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{other.jcb_amount.round(2)}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -202,7 +216,7 @@ class CloseCashierPdf < Prawn::Document text "Reedem Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{other.paypar_amount.round(2)}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end else @@ -211,7 +225,7 @@ class CloseCashierPdf < Prawn::Document text "Other Payment :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.other_sales}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -220,7 +234,7 @@ class CloseCashierPdf < Prawn::Document text "Rounding Adjustments :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.total_rounding.round(2)}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -228,7 +242,7 @@ class CloseCashierPdf < Prawn::Document text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.grand_total.round(2)}", :style => :bold, :size => self.header_font_size - 1, :align => :right + text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right end # end other payment details @@ -243,7 +257,7 @@ class CloseCashierPdf < Prawn::Document text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{tax.st_amount.round(2)}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end end @@ -252,7 +266,7 @@ class CloseCashierPdf < Prawn::Document text "Total Taxes :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.total_taxes}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -260,7 +274,7 @@ class CloseCashierPdf < Prawn::Document text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{shift_sale.nett_sales}", :style => :bold , :size => self.header_font_size - 1, :align => :right + text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right end #end for service charges and commercial tax #COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES @@ -283,7 +297,7 @@ class CloseCashierPdf < Prawn::Document text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{amount.total_price.round(2)} ", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right end end #end total amount by Account @@ -297,7 +311,7 @@ class CloseCashierPdf < Prawn::Document text "Total Member Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{@member_discount}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end else @overall = shift_sale.total_discounts @@ -308,7 +322,7 @@ class CloseCashierPdf < Prawn::Document text "Total Discount :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "#{@overall}", :size => self.item_font_size, :align => :right + text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end y_position = cursor @@ -316,7 +330,7 @@ class CloseCashierPdf < Prawn::Document text "Total FOC :", :size => self.item_font_size, :align => :right end bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do - text "(#{@total_foc})", :size => self.item_font_size, :align => :right + text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right end y_position = cursor diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 4bc57878..9483b847 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -40,7 +40,7 @@ class OrderItemPdf < Prawn::Document text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 stroke_horizontal_rule - move_down 5 + move_down 3 #order_info order_info(order_item.order_id, order_item.order_by,order_item.order_at) @@ -56,13 +56,13 @@ class OrderItemPdf < Prawn::Document text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left end - move_down 5 + move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left end - move_down 5 + move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left @@ -92,7 +92,7 @@ class OrderItemPdf < Prawn::Document move_down 5 bounding_box([0,y_position], :width => self.item_width) do - text "#{order_item.item_name}", :size => self.item_font_size,:align => :left + text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left end bounding_box([self.item_width,y_position], :width => self.qty_width) do @@ -100,23 +100,27 @@ class OrderItemPdf < Prawn::Document end bounding_box([0,y_position], :width => self.item_width) do - text "#{order_item.item_name}", :size => self.item_font_size,:align => :left + text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left end if alt_name - move_down 4 - font("public/fonts/NotoSansCJKtc-Regular.ttf") do - text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + if !(order_item.alt_name).empty? + move_down 4 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end end end - move_down 5 + if !options.empty? + move_down 5 - # add option - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "#{options}", :size => self.item_font_size,:align => :left + # add option + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "#{options}", :size => self.item_font_size,:align => :left + end end move_down 5 diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb new file mode 100644 index 00000000..6887d201 --- /dev/null +++ b/app/pdf/order_item_slim_pdf.rb @@ -0,0 +1,129 @@ +class OrderItemSlimPdf < Prawn::Document + include ActionView::Helpers::NumberHelper + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order_item_slim, print_status, options, alt_name) + self.page_width = print_settings.page_width + self.page_height = print_settings.page_height + self.margin = 0 + self.price_width = 40 # No Need for item + self.qty_width = 40 + self.total_width = 40 # No Need for item + self.item_width = self.page_width - (self.qty_width - self.margin) + self.item_height = 15 + self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.label_width=90 + + super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) + + # db font setup + if print_settings.font != "" + font_families.update("#{print_settings.font}" => { + :normal => "public/fonts/#{print_settings.font}.ttf", + :italic => "public/fonts/#{print_settings.font}.ttf", + :bold => "public/fonts/#{print_settings.font}.ttf", + :bold_italic => "public/fonts/#{print_settings.font}.ttf" + }) + + font "#{print_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + + self.header_font_size = 11 + self.item_font_size = 9 + else + self.header_font_size = 12 + self.item_font_size = 10 + end + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + #font "public/fonts/Chinese.ttf" + + text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + stroke_horizontal_rule + move_down 1 + + #order_info + order_info(order_item_slim.order_id, order_item_slim.order_by,order_item_slim.order_at) + + # order items slim + order_items_slim(order_item_slim, options, alt_name, print_settings.precision) + end + + # Write Order Information to PDF + def order_info(order_no, order_by, order_at) + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + + move_down 3 + end + + # Write Order items to PDF + def order_items_slim(order_item_slim, options, alt_name, precision) + y_position = cursor + + #Add Order Item + add_order_items_slim(order_item_slim, options, alt_name, precision) + + dash(1, :space => 1, :phase => 1) + stroke_horizontal_line 0, (self.page_width - self.margin) + move_down 1 + end + + # Add order items slim under order info + def add_order_items_slim(order_item_slim, options, alt_name, precision) + y_position = cursor + + move_down 1 + + bounding_box([0,y_position], :width => self.item_width) do + text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left + end + + bounding_box([self.item_width,y_position], :width => self.qty_width) do + text "[#{number_with_precision(order_item_slim.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + end + + bounding_box([0,y_position], :width => self.item_width) do + text "#{order_item_slim.item_name}", :size => self.item_font_size,:align => :left + + end + + # if alt_name + # if !(order_item_slim.alt_name).empty? + # move_down 1 + # font("public/fonts/NotoSansCJKtc-Regular.ttf") do + # text "(#{order_item_slim.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + # end + # end + # end + + if !options.empty? + move_down 1 + + # add option + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "#{options}", :size => self.item_font_size,:align => :left + end + end + move_down 1 + + end + +end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index ea0d4502..9e9873d2 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -108,7 +108,7 @@ class OrderSummaryPdf < Prawn::Document y_position = cursor bounding_box([0,y_position], :width => self.item_width) do - text "#{odi.item_name}", :size => self.item_font_size,:align => :left + text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left end @@ -117,24 +117,26 @@ class OrderSummaryPdf < Prawn::Document end bounding_box([0,y_position], :width => self.item_width) do - text "#{odi.item_name}", :size => self.item_font_size,:align => :left + text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left end if alt_name - move_down 4 - font("public/fonts/NotoSansCJKtc-Regular.ttf") do - text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + if !(odi.alt_name).empty? + move_down 4 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end end end - move_down 5 - # add option options = odi.options == "[]"? "" : odi.options if options != "" + move_down 5 + y_position = cursor bounding_box([0,y_position], :width => self.item_width) do text "#{options}", :size => self.item_font_size,:align => :left diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb new file mode 100644 index 00000000..87aba403 --- /dev/null +++ b/app/pdf/order_summary_slim_pdf.rb @@ -0,0 +1,155 @@ +class OrderSummarySlimPdf < Prawn::Document + include ActionView::Helpers::NumberHelper + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order, print_status, order_items = nil,alt_name) + self.page_width = print_settings.page_width + self.page_height = print_settings.page_height + self.margin = 0 + self.price_width = 40 # No Need for item + self.qty_width = 40 + self.total_width = 40 # No Need for item + self.item_width = self.page_width - (self.qty_width - self.margin) + self.item_height = 15 + self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) + self.label_width=90 + + super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + # db font setup + if print_settings.font != "" + font_families.update("#{print_settings.font}" => { + :normal => "public/fonts/#{print_settings.font}.ttf", + :italic => "public/fonts/#{print_settings.font}.ttf", + :bold => "public/fonts/#{print_settings.font}.ttf", + :bold_italic => "public/fonts/#{print_settings.font}.ttf" + }) + + font "#{print_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + + self.header_font_size = 11 + self.item_font_size = 9 + else + self.header_font_size = 12 + self.item_font_size = 10 + end + + # font "public/fonts/Zawgyi-One.ttf" + # font "public/fonts/padauk.ttf" + + text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 + stroke_horizontal_rule + move_down 1 + + #order_info + order_info(order[0].order_id, order[0].order_by,order[0].order_at) + + # order items + if order_items == nil + order_items(order, alt_name, print_settings.precision) + else + order_items(order_items, alt_name, print_settings.precision) + end + end + + # Write Order Information to PDF + def order_info(order_no, order_by, order_at) + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left + end + + move_down 1 + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + + move_down 1 + end + + # Write Order items to PDF + def order_items(order_item, alt_name, precision) + y_position = cursor + + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Item", :size => self.item_font_size,:align => :left + end + + bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do + text "Qty", :size => self.item_font_size,:align => :left + end + + stroke_horizontal_rule + move_down 1 + + #Add Order Item + add_order_items(order_item, alt_name, precision) + + end + + # Add order items under order info + def add_order_items(order_item, alt_name, precision) + y_position = cursor + + move_down 1 + + order_item.each do|odi| + # check for item not to show + # if odi.price != 0 + y_position = cursor + + bounding_box([0,y_position], :width => self.item_width) do + text "#{odi.item_name}", :size => self.item_font_size,:align => :left + + end + + bounding_box([self.item_width,y_position], :width => self.qty_width) do + text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left + end + + bounding_box([0,y_position], :width => self.item_width) do + text "#{odi.item_name}", :size => self.item_font_size,:align => :left + + end + + if alt_name + if !(odi.alt_name).empty? + move_down 1 + font("public/fonts/NotoSansCJKtc-Regular.ttf") do + text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true + end + end + end + + # add option + options = odi.options == "[]"? "" : odi.options + + if options != "" + move_down 1 + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width) do + text "#{options}", :size => self.item_font_size,:align => :left + end + + move_down 1 + end + + move_down 1 + + dash(1, :space => 1, :phase => 1) + stroke_horizontal_line 0, (self.page_width - self.margin) + move_down 1 + # end + end + end +end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb new file mode 100644 index 00000000..0861c65a --- /dev/null +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -0,0 +1,507 @@ +class ReceiptBillA5Pdf < Prawn::Document + include ActionView::Helpers::NumberHelper + attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance) + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height + self.margin = 15 + self.price_width = 120 + self.qty_width = 50 + self.total_width = 120 + self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width)) + self.item_height = 25 + self.item_description_width = (self.page_width-40) / 2 + self.label_width = 150 + + self.description_width = 500 + self.price_num_width = 100 + # @item_width = self.page_width.to_i / 2 + # @qty_width = @item_width.to_i / 3 + # @double = @qty_width * 1.3 + # @half_qty = @qty_width / 2 + #setting page margin and width + super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + + #precision checked + if printer_settings.precision.to_i > 2 + printer_settings.precision = 2 + end + + # db font setup + if printer_settings.font != "" + font_families.update("#{printer_settings.font}" => { + :normal => "public/fonts/#{printer_settings.font}.ttf", + :italic => "public/fonts/#{printer_settings.font}.ttf", + :bold => "public/fonts/#{printer_settings.font}.ttf", + :bold_italic => "public/fonts/#{printer_settings.font}.ttf" + }) + + font "#{printer_settings.font}" + fallback_fonts ["Courier", "Helvetica", "Times-Roman"] + end + # 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 = "," + else + delimiter = "" + end + + header(shop_details) + + stroke_horizontal_rule + + cashier_info(sale_data, customer_name) + line_items(sale_items,printer_settings.precision,delimiter) + all_total(sale_data,printer_settings.precision,delimiter) + + + if member_info != nil + member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance) + end + + customer(customer_name) + + if discount_price_by_accounts.length > 0 && shop_details.show_account_info + discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) + end + + if shop_details.show_account_info + items_account(item_price_by_accounts,printer_settings.precision,delimiter) + end + + sign(sale_data) + + footer(printed_status) + end + + def header (shop_details) + move_down 10 + text "#{shop_details.name}", :size => self.header_font_size,:align => :center + move_down 10 + text "#{shop_details.address}", :size => self.item_font_size,:align => :center + # move_down self.item_height + move_down 10 + text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center + move_down 10 + + stroke_horizontal_rule + end + + def cashier_info(sale_data, customer_name) + move_down 12 + # move_down 2 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width, y_position], :width => self.item_description_width, :height => self.item_height) do + text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right + end + move_down 10 + + y_position = cursor + bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do + text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right + end + move_down 10 + + y_position = cursor + bounding_box([0,y_position], :width =>self.page_width - 20, :height => self.item_height) do + text "Date : #{ sale_data.receipt_date.strftime('%d-%m-%Y') } ( #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } - #{ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p') } )",:size => self.item_font_size,:align => :left + end + + + # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , + # :size => self.item_font_size,:align => :right + # end + + move_down 10 + stroke_horizontal_rule + end + + def line_items(sale_items,precision,delimiter) + if precision.to_i > 0 + item_label_qty_front_width = (self.item_width+self.price_width) + 5 + item_label_qty_end_width = self.qty_width + 4 + item_label_total_front_width = (self.item_width+self.price_width) + 10 + item_label_total_end_width = self.total_width + 9 + else + self.item_width = self.item_width.to_i + 8 + item_label_qty_front_width = (self.item_width+self.price_width) + 8 + item_label_qty_end_width = self.qty_width + 7 + item_label_total_front_width = (self.item_width+self.price_width) + 5 + item_label_total_end_width = self.total_width + 4 + end + move_down 10 + y_position = cursor + move_down 10 + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + move_down -5 + stroke_horizontal_rule + add_line_item_row(sale_items,precision,delimiter) + end + + def add_line_item_row(sale_items,precision,delimiter) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end + y_position = cursor + move_down 10 + sub_total = 0.0 + sale_items.each do |item| + # check for item not to show + if item.price != 0 + sub_total += item.price #(item.qty*item.unit_price) - comment for room charges + qty = item.qty + total_price = item.price #item.qty*item.unit_price - comment for room charges + price = item.unit_price + product_name = item.product_name + + + y_position = cursor + + pad_top(15) { + bounding_box([0,y_position], :width =>self.item_width) do + text "#{product_name}", :size => self.item_font_size,:align => :left + end + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + move_down 10 + end + end + + stroke_horizontal_rule + + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Sub Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}" ,:delimiter => ',', :size => self.item_font_size,:align => :right + end + move_down 10 + end + + def all_total(sale_data,precision,delimiter) + item_name_width = self.item_width + y_position = cursor + if sale_data.discount_type == 'member_discount' + dis_type = "Member Discount:" + else + dis_type = "Overall Discount:" + end + + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "#{ dis_type }", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right + end + + if sale_data.sale_taxes.length > 0 + sale_data.sale_taxes.each do |st| + move_down 10 + y_position = cursor + + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "#{ st.tax_name } ( #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + end + else + + end + + # move_down 10 + # y_position = cursor + + # bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + # text "Total Tax", :size => self.item_font_size,:align => :left + # end + # bounding_box([self.description_width,y_position], :width =>self.label_width) do + # text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right + # end + + if sale_data.rounding_adjustment != 0.0 + move_down 10 + y_position = cursor + + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Rounding Adjustment", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right + end + end + + move_down 10 + y_position = cursor + move_down 10 + bounding_box([0,y_position], :width =>self.description_width) do + text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right + end + move_down 10 + + sale_payment(sale_data,precision,delimiter) + + end + + def sale_payment(sale_data,precision,delimiter) + stroke_horizontal_rule + move_down 10 + sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method").where('sale_id = ?', sale_data.sale_id).group("payment_method") + sale_payments.each do |payment| + y_position = cursor + if payment.payment_method == "paypar" + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Redeem Payment", :size => self.item_font_size,:align => :left + end + else + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left + end + end + + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + move_down 10 + end + if sale_data.amount_received > 0 + y_position = cursor + move_down 10 + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Change Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + move_down 10 + end + end + + # show member information + def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) + if rebate_amount != nil + if rebate_amount["status"] == true + stroke_horizontal_rule + total = 0 + balance = 0 + rebate_balance =0 + redeem = 0 + redeem_count = 0 + rebate_amount["data"].each do |res| + total = total + res["balance"] + #total redeem amount + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" + redeem = redeem + res["withdraw"] + balance = balance + res["balance"] + end + #end Total redem + #total Rebate Earn + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate" + + rebate_balance = rebate_balance + res["deposit"] + + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Rebate Earn", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + + end + # Total Rebate Amount if birthday + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate" + rebate_balance = rebate_balance + res["deposit"] + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + end + #end Total rebate if birthday + end + + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Redeem Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end + + if current_balance != nil + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Old Balance", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end + end + + end + end + + if member_info["status"] == true && member_info["data"].present? + total_balance = 0 + member_info["data"].each do |res| + + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + total_balance = total_balance + res["balance"] + + end + end + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Total Balance", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + end + + end + + def customer(customer_name) + move_down 10 + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "Customer Name", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "#{ customer_name }" , :size => self.item_font_size,:align => :right + end + end + + + def discount_account(discount_price_by_accounts,precision,delimiter) + move_down 10 + stroke_horizontal_rule + move_down 10 + y_position = cursor + discount_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do + text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left + end + bounding_box([self.description_width,y_position], :width =>self.label_width) do + text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right + end + end + end + + def items_account(item_price_by_accounts,precision,delimiter) + move_down 10 + stroke_horizontal_rule + move_down 10 + y_position = cursor + item_price_by_accounts.each do |ipa| + y_position = cursor + bounding_box([0,y_position], :width =>self.label_width) do + text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left + end + bounding_box([self.label_width,y_position], :width =>self.description_width) do + text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + end + end + + def sign(sale_data) + SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment| + if payment.payment_method == "creditnote" + + y_position = cursor + stroke_horizontal_rule + + bounding_box([self.label_width,y_position], :width =>self.description_width) do + move_down 70 + stroke_horizontal_rule + end + + bounding_box([self.label_width,y_position], :width =>self.description_width) do + move_down 73 + text "Approved By" , :size => self.item_font_size,:align => :center + end + break; + end + end + if sale_data.payment_status == "foc" + + y_position = cursor + stroke_horizontal_rule + + bounding_box([self.label_width,y_position], :width =>self.description_width) do + move_down 70 + stroke_horizontal_rule + end + + bounding_box([self.label_width,y_position], :width =>self.description_width) do + move_down 73 + text "Acknowledged By" , :size => self.item_font_size,:align => :center + end + end + + + end + + def footer(printed_status) + move_down 10 + stroke_horizontal_rule + move_down 10 + + y_position = cursor + bounding_box([0, y_position], :width =>self.item_description_width) do + text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :right + end + + move_down 10 + end +end + diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index dfd67d89..ae02b22d 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,13 +4,13 @@ class ReceiptBillPdf < Prawn::Document def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height - self.margin = 5 - self.price_width = 40 - self.qty_width = 20 - self.total_width = 40 - self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width)) + self.margin = 0 + self.price_width = 60 + self.qty_width = 25 + self.total_width = 60 + self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width)) self.item_height = 15 - self.item_description_width = (self.page_width-20) / 2 + self.item_description_width = (self.page_width-5) / 2 self.label_width = 100 self.description_width = 150 @@ -22,6 +22,11 @@ class ReceiptBillPdf < Prawn::Document #setting page margin and width super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + #precision checked + if printer_settings.precision.to_i > 2 + printer_settings.precision = 2 + end + # db font setup if printer_settings.font != "" font_families.update("#{printer_settings.font}" => { @@ -74,7 +79,7 @@ class ReceiptBillPdf < Prawn::Document end def header (shop_details) - move_down 7 + move_down 5 text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center move_down 5 text "#{shop_details.address}", :size => self.item_font_size,:align => :center @@ -124,15 +129,27 @@ class ReceiptBillPdf < Prawn::Document end def line_items(sale_items,precision,delimiter) + if precision.to_i > 0 + item_label_qty_front_width = (self.item_width+self.price_width) + 5 + item_label_qty_end_width = self.qty_width + 4 + item_label_total_front_width = (self.item_width+self.price_width) + 10 + item_label_total_end_width = self.total_width + 9 + else + self.item_width = self.item_width.to_i + 8 + item_label_qty_front_width = (self.item_width+self.price_width) + 8 + item_label_qty_end_width = self.qty_width + 7 + item_label_total_front_width = (self.item_width+self.price_width) + 5 + item_label_total_end_width = self.total_width + 4 + end move_down 5 y_position = cursor move_down 5 pad_top(15) { # @item_width.to_i + @half_qty.to_i text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down -5 stroke_horizontal_rule @@ -140,7 +157,19 @@ class ReceiptBillPdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) - item_name_width = (self.item_width+self.price_width) + if precision.to_i > 0 + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = (self.item_width+self.price_width) + 5 + item_qty_end_width = self.qty_width + 4 + item_total_front_width = item_name_width + 10 + item_total_end_width = self.total_width + 9 + else + item_name_width = (self.item_width+self.price_width) + item_qty_front_width = item_name_width + 8 + item_qty_end_width = self.qty_width + 7 + item_total_front_width = item_name_width + 5 + item_total_end_width = self.total_width + 4 + end y_position = cursor move_down 5 sub_total = 0.0 @@ -162,8 +191,8 @@ class ReceiptBillPdf < Prawn::Document end # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_name_width,y_position], :width => self.qty_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[(item_name_width+4),y_position], :width =>self.total_width+3, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 5 end @@ -469,7 +498,7 @@ class ReceiptBillPdf < Prawn::Document text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left + text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left end move_down 5 diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder index 0ac1b92f..9f0b14b3 100755 --- a/app/views/api/orders/view_orders.json.jbuilder +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -60,16 +60,16 @@ if (@booking) end # For YGN BBQ - if adult_count > 0 - json.per_adult_spent (adult_spent/adult_count) * 0.05 - else + # if adult_count > 0 + # json.per_adult_spent (adult_spent/adult_count) * 0.05 + # else json.per_adult_spent 0 - end - if child_count > 0 - json.per_child_spent (child_spent/child_count) * 0.05 - else + # end + # if child_count > 0 + # json.per_child_spent (child_spent/child_count) * 0.05 + # else json.per_child_spent 0 - end + # end # End YGN BBQ json.sub_total @total_amount diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder index 9441daf9..8dcdf6fe 100755 --- a/app/views/api/restaurant/menu/_menu.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu.json.jbuilder @@ -7,8 +7,11 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) json.categories menu.menu_categories do |category| json.id category.id + json.code category.code + json.order_by category.order_by json.name category.name json.alt_name category.alt_name + json.order_by category.order_by json.parent_id category.menu_category_id json.is_available category.is_available diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 2682f203..d05af387 100755 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -52,6 +52,7 @@ <%= t("views.right_panel.detail.sr_no") %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.card_no") %> + <%= t("views.right_panel.detail.membership_type") %> <%= t("views.right_panel.detail.contact_no") %> <%= t("views.right_panel.detail.email") %> <%= t("views.right_panel.detail.action") %> @@ -75,6 +76,15 @@ <%= crm_customer.name %> <%= crm_customer.card_no rescue '-' %> + + <% if !@membership_types.nil? %> + <% @membership_types.each do |member_type| %> + <% if member_type[1] == crm_customer.membership_type %> + <%= member_type[0] %> + <% end %> + <% end %> + <% end %> + <%= crm_customer.contact_no %> <%= crm_customer.email %> <%= link_to t("views.btn.show"), crm_customer_path(crm_customer) %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 41fe9480..67746ba6 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -14,11 +14,16 @@
diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index ea118e9c..e5196917 100755 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -84,8 +84,8 @@ <%= qid.qty %> ]

- -

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

+ +

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

Order at - diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index d8909915..bebf18cc 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -7,17 +7,28 @@
@@ -54,6 +54,7 @@ <%= t("views.right_panel.detail.sr_no") %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.card_no") %> + <%= t("views.right_panel.detail.membership_type") %> <%= t("views.right_panel.detail.contact_no") %> <%= t("views.right_panel.detail.email") %> @@ -76,7 +77,16 @@ <% end %> <%= crm_customer.name %> - <%= crm_customer.company rescue '-' %> + <%= crm_customer.card_no rescue '-' %> + + <% if !@membership_types.nil? %> + <% @membership_types.each do |member_type| %> + <% if member_type[1] == crm_customer.membership_type %> + <%= member_type[0] %> + <% end %> + <% end %> + <% end %> + <%= crm_customer.contact_no %> <%= crm_customer.email %> @@ -423,13 +433,13 @@ success: function(data) { if(data.status == true) { - var id = $("#table_id").val() - var type = $("#type").val() + var id = $("#table_id").val(); + var type = $("#type").val(); if (type=="Table") { window.location.href = '/origami/table/'+id }else{ - window.location.href = '/origami/room/'+id - } + window.location.href = '/origami/room/'+id + } }else{ swal("Alert!", "Record not found!", "error"); location.reload(); diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 939b969a..46132fff 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -118,12 +118,13 @@ <%end%> + <%if current_login_employee.role != "waiter" %> - + <%end%>
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 9191bbae..a19f6b46 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -1,4 +1,7 @@
+
@@ -140,7 +143,11 @@
<% elsif @status_sale == 'sale' %>
INVOICE DETAILS | Table <%= @dining.name rescue "" %> - Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% if !@booking.reserved_by.nil? && %> + <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> + <% else %> + Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% end %>
<% else %> ORDER DETAILS | Table <%= @dining.name rescue "" %> @@ -153,8 +160,7 @@
  Receipt No: <% if @status_sale == 'sale' %> - <%= @sale_array[0].receipt_no rescue '' %> - + <%= @sale_array[0].receipt_no rescue '' %> <% end %>
@@ -264,7 +270,7 @@ - + <% if @obj_sale != nil && @obj_sale.discount_type == 'member_discount' %> @@ -291,7 +297,8 @@ + <%= @obj_sale.rounding_adjustment + %> @@ -366,6 +373,7 @@ <%= t("views.btn.back") %> + <% if current_login_employee.role != "waiter" %> <% if @dining.status != "available" %> <% if @status_order == 'order' && @status_sale != 'sale' %> @@ -389,6 +397,7 @@ + <% end %> @@ -398,11 +407,52 @@ <% else %> <% end %> + + + + <% end %> diff --git a/app/views/origami/others_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb index 2f847134..c0185182 100755 --- a/app/views/origami/others_payments/index.html.erb +++ b/app/views/origami/others_payments/index.html.erb @@ -14,8 +14,9 @@
+ <% @payment_method_setting.where("is_active = true").each do |payment_method|%> -
<%= payment_method.payment_method %>
+
<%= payment_method.payment_method %>
<% end %>
@@ -26,6 +27,19 @@
\ No newline at end of file diff --git a/app/views/reports/commission/index.html.erb b/app/views/reports/commission/index.html.erb index 2586018d..80cf5727 100755 --- a/app/views/reports/commission/index.html.erb +++ b/app/views/reports/commission/index.html.erb @@ -43,6 +43,18 @@ + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> <% total_qty = 0 %> <% total_price = 0 %> <% total_amount = 0 %> @@ -53,9 +65,9 @@ - - - + + + <% total_qty += result.qty.to_f %> @@ -65,9 +77,9 @@ - - - + + + diff --git a/app/views/reports/credit_payment/index.html.erb b/app/views/reports/credit_payment/index.html.erb index 9037f03b..0619d976 100755 --- a/app/views/reports/credit_payment/index.html.erb +++ b/app/views/reports/credit_payment/index.html.erb @@ -23,6 +23,18 @@
+ <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> <% unless @sale_data.blank? %>
Sub Total:<%= sub_total %><%= sub_total %>
Rounding Adj: - <%= @obj_sale.rounding_adjustment rescue 0 %>
Grand Total:
<%= result.sale_item_id rescue '-' %> <%= result.commissioner.name rescue '-' %> <%= result.commission.menu_item.name rescue '-' %><%= sprintf "%.2f", result.qty.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.price.to_f.to_d rescue '-' %><%= sprintf "%.2f", result.amount.to_f.to_d rescue '-' %><%= number_with_precision(result.qty.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(result.price.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(result.amount.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= result.updated_at.strftime("%e %b %Y %I:%M%p") rescue '-' %>
<%= sprintf("%.2f", total_qty) rescue '-' %><%= sprintf("%.2f", total_price) rescue '-' %><%= sprintf("%.2f", total_amount) rescue '-' %><%= number_with_precision(total_qty, precision: precision.to_i ,delimiter: delimiter) rescue '-'%><%= number_with_precision(total_price, precision: precision.to_i ,delimiter: delimiter) rescue '-'%><%= number_with_precision(total_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-'%>
@@ -52,7 +64,7 @@ - + <% end %> @@ -123,7 +135,10 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var str = ''; diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index b8eded4f..76438060 100755 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -44,6 +44,18 @@ + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> <% unless @sale_data.empty? %> @@ -79,37 +91,37 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + <% count = count + 1 %> <% end %> - - - - - - - - - - - - + + + + + + + + + + + + <% total_tax = 0 %> @@ -118,7 +130,7 @@ <% total_tax += tax.tax_amount.to_f %> - + @@ -126,7 +138,7 @@ <% net = total - total_tax %> - + <% end %> diff --git a/app/views/reports/payment_method/index.html.erb b/app/views/reports/payment_method/index.html.erb index 2407e50a..1fef1eab 100755 --- a/app/views/reports/payment_method/index.html.erb +++ b/app/views/reports/payment_method/index.html.erb @@ -50,18 +50,30 @@ + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> <% unless @sale_data.empty? %> <% @sale_data.each do |sale| %> - - - - - - - - + + + + + + + + <% end %> @@ -108,11 +120,11 @@ <% if payment.payment_method === 'cash' %> - + <%else%> - + <%end%> - + @@ -120,7 +132,7 @@ <%if total>0%> - + <%end%> @@ -189,7 +201,10 @@ var shift = $('#shift_name'); shift.empty(); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } var str = ''; var param_shift = ''; var param_shift = '<%= params[:shift_name] rescue '-'%>'; diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 00622069..9eee6ab9 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -58,6 +58,22 @@ + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + + puts precision + puts "predelidm" + puts delimiter %> + <% grand_total = 0 %> <% old_grand_total = 0 %> <% total_tax = 0 %> @@ -81,31 +97,31 @@ - - + + <%if result.customer.customer_type == "Takeaway"%> - + <%end%> <% result.sale_taxes.each do |tax| %> - + <%end%> - - - + + + <% end %> - - + + <% @sale_taxes.each do |tax| %> - + <% end %> - - - + + + @@ -196,7 +212,10 @@ var str = ''; var param_shift = ''; var param_shift = '<%= params[:shift_name] rescue '-'%>'; - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } url = '<%= reports_get_shift_by_date_path %>'; $.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){ diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index 7fa72521..4ad30d82 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -45,10 +45,23 @@ + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> <% unless @sale_data.blank? %> <% acc_arr = Array.new %> <% cate_arr = Array.new %> + <% sub_qty = 0 %> <% sub_total = 0 %> <% other_sub_total = 0 %> <% count = 0 %> @@ -70,12 +83,12 @@ end %> <% if sale.status_type == "foc" && sale.grand_total < 0 - total_item_foc += sale.grand_total*(-1) - end %> + total_item_foc += sale.grand_total*(-1) + end %> - <% if sale.status_type == "Discount" && sale.grand_total < 0 - total_item_dis += sale.grand_total*(-1) - end %> + <% if sale.status_type == "Discount" && sale.grand_total < 0 + total_item_dis += sale.grand_total*(-1) + end %> <% if !acc_arr.include?(sale.account_id) %> @@ -85,7 +98,7 @@ - - + + - <% @menu_cate_count.each do |key,value| %> - <% if sale.menu_category_id == key %> + <% @menu_cate_count.each do |key,value| %> + <% if sale.account_id == key %> <% count = count + 1 %> <% sub_total += sale.grand_total %> + <% #sub_qty += sale.total_item %> + <% if sale.status_type != "Discount" && sale.status_type != "foc" + sub_qty += sale.total_item + end %> <% if count == value %> - + + + - + <% sub_total = 0.0%> + <% sub_qty = 0 %> <% count = 0%> <% end %> - <% end %> <% end %> - <% end %> + + <% end %> - + <% if @other_charges.present? %> @@ -144,8 +164,8 @@ - - + + @@ -155,38 +175,38 @@ - + - + <%end%> - + <% end %> - + - + - + - + <% @sale_taxes.each do |tax| %> @@ -202,7 +222,7 @@ - + - - + + - + - + <% grand_total = result[:grand_total].to_f %> @@ -114,15 +126,15 @@ - - + + - - + + - +
<%= credit.receipt_no rescue '-' %> <%= credit.cashier_name rescue '-' %> <%= credit.sale.customer.name rescue '-' %><%= credit.payment_amount rescue '-' %><%= number_with_precision(credit.payment_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
<%= t("views.right_panel.detail.grand_total") %>
<%= count %> <%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%><%= number_with_precision(sale[:void_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:mpu_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:master_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:visa_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:jcb_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:paypar_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision:precision, delimiter: delimiter) rescue '-'%><%= number_with_precision(sale[:credit_amount], precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:foc_amount], precision:precision,delimiter:delimiter) rescue '-'%>(<%= number_with_precision(sale[:total_discount], precision:precision,delimiter:delimiter) rescue '-'%>)<%= number_with_precision(sale[:grand_total].to_f + sale[:rounding_adj].to_f , precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:rounding_adj].to_f, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale[:grand_total], precision:precision,delimiter:delimiter) rescue '-'%>
Total<%= number_with_delimiter(sprintf("%.2f",mpu), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",master), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",visa), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",jcb), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",paypar), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)<%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%><%= number_with_precision(mpu , precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(master, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(visa, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(jcb, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(paypar, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%>(<%= number_with_precision(discount, precision:precision,delimiter:delimiter) rescue '-'%>)<%= number_with_precision(total, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(rounding_adj, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(grand_total, precision:precision,delimiter:delimiter) rescue '-'%>
<%= tax.tax_name rescue '-'%><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%><%= number_with_precision(tax.tax_amount, precision:precision,delimiter:delimiter) rescue '-'%>  
<%= t("views.right_panel.detail.net_amount") %><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%><%= number_with_precision(net, precision:precision,delimiter:delimiter) rescue '-'%>  
<%= t("views.right_panel.detail.foc_sales") %>
<%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]-sale[:total_change_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%><%= number_with_precision(sale[:mpu_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:master_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:visa_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:cash_amount]-sale[:total_change_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:credit_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(sale[:foc_amount] , precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
<%= payment.payment_method rescue '-' %><%= payment.payment_amount - payment.change_amount%> <%= number_with_precision(payment.payment_amount - payment.change_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= payment.payment_amount%> <%= number_with_precision(payment.payment_amount , precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= payment.sale.grand_total rescue '-' %><%= number_with_precision(payment.sale.grand_total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
Total <%=total%><%=number_with_precision(total , precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
<%= result.receipt_no rescue '-' %> <%= result.cashier_name rescue '-' %><%= result.total_amount rescue '-' %><%= result.total_discount rescue '-' %><%= number_with_precision(result.total_amount, precision: precision.to_i ,delimiter: delimiter) %><%= number_with_precision(result.total_discount, precision: precision.to_i ,delimiter: delimiter) %>0.0<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %><%= tax.tax_payable_amount rescue '-' %><%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= result.grand_total %><%= result.rounding_adjustment.to_f rescue '-' %><%= result.grand_total_after_rounding() rescue '-'%><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
 <%= total_sum rescue '-'%><%= discount_amt rescue '-'%><%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= tax.st_amount.round(2) %><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= grand_total.to_f.round(2) rescue '-'%><%= rounding_adj rescue '-'%><%= grand_total.to_f.round + rounding_adj %><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(rounding_adj, precision: precision.to_i ,delimiter: delimiter) rescue '-' %><%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %>
 
<% @totalByAccount.each do |account, total| %> <% if sale.account_id == account %> - <%= total %> + <%= number_with_precision(total, precision:precision,delimiter:delimiter) %> <% grand_total += total %> <% end %> <% end %> @@ -104,30 +117,37 @@ <%= sale.item_code rescue '-' %> <%= sale.product_name rescue '-' %> <%= sale.total_item rescue '-' %><%= sale.unit_price rescue '-' %><%= sale.grand_total rescue '-' %><%= number_with_precision(sale.unit_price , precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(sale.grand_total , precision:precision,delimiter:delimiter) rescue '-'%>
  Total <%= sale.account_name %> Qty <%= sub_qty %> <%= t("views.right_panel.detail.sub_total") %><%= sub_total %><%= number_with_precision(sub_total , precision:precision,delimiter:delimiter)%>
Other Charges  <%= other.item_code rescue '-' %> <%= other.product_name rescue '-' %> <%= other.total_item rescue '-' %><%= other.unit_price rescue '-' %><%= other.grand_total rescue '-' %> <%= number_with_precision(other.unit_price , precision:precision,delimiter:delimiter) rescue '-'%> <%= number_with_precision(other.grand_total , precision:precision,delimiter:delimiter) rescue '-'%>
  <%= t("views.right_panel.detail.sub_total") %><%= other_sub_total %><%= number_with_precision(other_sub_total , precision:precision,delimiter:delimiter)%>
  <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %> <%= total_qty%> <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= grand_total%><%= number_with_precision(grand_total , precision:precision,delimiter:delimiter)%>
  <%= t("views.right_panel.detail.foc_item") %> <%= t("views.right_panel.detail.amount") %><%= total_item_foc %><%= number_with_precision(total_item_foc , precision:precision,delimiter:delimiter) %>
  <%= t("views.right_panel.detail.item_discount") %> <%= t("views.right_panel.detail.amount") %><%= total_item_dis %><%= number_with_precision(total_item_dis , precision:precision,delimiter:delimiter) %>
  <%= t("views.right_panel.detail.foc_sales") %><%= @foc_data %><%= number_with_precision(@foc_data , precision:precision,delimiter:delimiter) %>
  <%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %><%= @discount_data %><%= number_with_precision(@discount_data , precision:precision,delimiter:delimiter) %>
  Net Amount <%= grand_total.to_f - @discount_data.to_f%><%= number_with_precision(grand_total.to_f - @discount_data.to_f , precision:precision,delimiter:delimiter)%>
<%= sprintf "%.2f",result[:cash_sales].to_f.to_d rescue '-'%><%= sprintf "%.2f",result[:credit_sales].to_f.to_d rescue '-'%><%= number_with_precision(result[:cash_sales].to_f, precision:precision,delimiter:delimiter) %><%= number_with_precision(result[:credit_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%> <%= sprintf "%.2f",result[:other_sales].to_f.to_d rescue '-'%><%= number_with_precision(result[:other_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%> - <%= sprintf "%.2f",result[:foc_sales].to_f.to_d rescue '-'%> + <%= number_with_precision(result[:foc_sales].to_f, precision:precision,delimiter:delimiter) rescue '-'%> <%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%><%= number_with_precision(result[:grand_total].to_f, precision:precision,delimiter:delimiter) rescue '-'%>
<%= sprintf("%.2f",cash) rescue '-'%><%= sprintf("%.2f",credit) rescue '-'%><%= number_with_precision(cash, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(credit, precision:precision,delimiter:delimiter) rescue '-'%> <%= sprintf("%.2f",card) rescue '-'%><%= sprintf("%.2f",foc) rescue '-'%><%= number_with_precision(card, precision:precision,delimiter:delimiter) rescue '-'%><%= number_with_precision(foc, precision:precision,delimiter:delimiter) rescue '-'%> <%= sprintf("%.2f",g_total) rescue '-'%><%= number_with_precision(g_total, precision:precision,delimiter:delimiter) rescue '-'%>
@@ -191,7 +203,10 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var str = ''; diff --git a/app/views/reports/void_sale/index.html.erb b/app/views/reports/void_sale/index.html.erb index 3bc48410..d7b6ee10 100755 --- a/app/views/reports/void_sale/index.html.erb +++ b/app/views/reports/void_sale/index.html.erb @@ -52,6 +52,18 @@ + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> <% total_amount = 0.0 %> <% grand_total = 0.0 %> <% rounding_adjustment = 0.0 %> @@ -61,10 +73,10 @@ <%= item.receipt_no rescue '-' %> <%= item.receipt_date.utc.getlocal.strftime("%e %b %I:%M%p") rescue '-' %> - <%= item.total_amount.to_f rescue '-'%> - <%= item.grand_total.to_f rescue '-'%> - <%= item.rounding_adjustment.to_f rescue '-' %> - <%= item.grand_total.to_f + item.rounding_adjustment.to_f rescue '-'%> + <%= number_with_precision(item.total_amount.to_f, precision: precision.to_i ,delimiter: delimiter) %> + <%= number_with_precision(item.grand_total.to_f , precision: precision.to_i ,delimiter: delimiter) rescue '-'%> + <%= number_with_precision(item.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(item.grand_total.to_f + item.rounding_adjustment.to_f , precision: precision.to_i ,delimiter: delimiter) rescue '-'%> @@ -76,10 +88,10 @@ <% end %> Total Void Amount : - <%= total_amount rescue '-' %> - <%= grand_total rescue '-' %> - <%= rounding_adjustment rescue '-'%> - <%= grand_rounding_adjustment rescue '-'%> + <%= number_with_precision(total_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(rounding_adjustment, precision: precision.to_i ,delimiter: delimiter) rescue '-'%> + <%= number_with_precision(grand_rounding_adjustment, precision: precision.to_i ,delimiter: delimiter) rescue '-'%> @@ -144,7 +156,10 @@ function show_shift_name(period,period_type,from,to,shift_item){ var shift = $('#shift_name'); - + if (from == '' && to == '') { + from = $("#from").val(); + to = $("#to").val(); + } shift.empty(); var str = ''; diff --git a/app/views/settings/menu_categories/index.html.erb b/app/views/settings/menu_categories/index.html.erb index 870c19bc..8d8c044c 100755 --- a/app/views/settings/menu_categories/index.html.erb +++ b/app/views/settings/menu_categories/index.html.erb @@ -30,7 +30,7 @@ <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.alt_name") %> <%= t("views.right_panel.detail.is_available") %> - <%= t("views.right_panel.detail.order_by") %> + <%= t("views.right_panel.detail.parent") %> <%= t("views.right_panel.detail.actions") %> @@ -43,7 +43,7 @@ <%= link_to settings_menu_category.name, settings_menu_category_path(settings_menu_category) %> <%= settings_menu_category.alt_name rescue ''%> <%= settings_menu_category.is_available rescue false%> - <%= settings_menu_category.order_by rescue ''%> + <%= settings_menu_category.parent.name rescue ''%> <%= link_to t("views.btn.edit"), edit_settings_menu_category_path(settings_menu_category),:class => 'btn btn-info btn-sm waves-effect' %> @@ -51,8 +51,8 @@ <% end %> + <%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
- <%= paginate @settings_menu_categories, param_name: :page, :outer_window => 3 %>
diff --git a/app/views/sym_control/run.html.erb b/app/views/sym_control/run.html.erb new file mode 100755 index 00000000..8b137891 --- /dev/null +++ b/app/views/sym_control/run.html.erb @@ -0,0 +1 @@ + diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 00000000..3020554f --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,20 @@ +lock "3.10.1" + +set :application, "zsai" +set :repo_url, 'git@bitbucket.org:code2lab/sxrestaurant.git' + +set :deploy_user, 'deploy' + +set :rbenv_type, :global +set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" + +set :rbenv_map_bins, %w{rake gem bundle ruby rails} + +set :keep_releases, 5 + +set :linked_files, %w{config/database.yml config/secrets.yml config/puma.rb config/sidekiq.yml config/shops.json} + +set :linked_dirs, %w{bin log tmp/puma tmp/pids tmp/cache tmp/sockets vendor/bundle public/system pids sockets} + +set :tests, [] +set :pty, true diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 00000000..7fed1a97 --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,9 @@ +set :stage, :production +set :server_name, "svr.sxrestaurant.host" + +set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}" +server '192.168.1.27', user: 'deploy', roles: %w{web app db}, primary: true + +set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}" +set :rbenv_ruby, '2.4.1' +set :rails_env, :production diff --git a/config/license.yml b/config/license.yml index 4a5c6b90..cc470a1d 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,16 +1,15 @@ -iv_key: A30HZdW+iDZA0vM5PAqwgg== -shop_name: 7DdPBxVo8m1xpa5T2kIcWQ== -email: yanaung.nyein@code2lab.com -telephone: 111111 -fax: 111111 -address: bitp -dbhost: 9+83FZetcbLZi6COG5PbSw== -dbschema: shztSYIsNmM9nlHkR/4exQ== -dbusername: LapN+Geriht8yk866FxNiQ== -dbpassword: QtboWZ4ATE05vvYw6J+Uqw== -api_token: nGyMizHtoVEFYCjSVEFJuzkxuBJwSsH -app_token: QUdPwSakcsnuVLdfkXgGHhPMiIOcSSfaVwQyA - -plan_sku: 001 -renewable_date: 2018-12-14 -plan_name: Community +iv_key: TP8dIx4nBGzr+tYyKn5+Xw== +shop_name: Osaka +email: wathonaun9@gmail.com +telephone: 09979204288 +fax: 09979204288 +address: Yangon +dbhost: nk57NaR38B2eSYyron3Nbw== +dbschema: 3orxFaTi0uQhatBqZGiitQ== +dbusername: EtMle9Gr0/PE3NFHHfwo5A== +dbpassword: 86h61/O38GGo64nekz6oeA== +api_token: FVAGMnjVdaScfydXMbMvPPRWnkEwCSuxs +app_token: IoXPdqzbnQWbHsnxLAjMjimnjEJNySOeIo +plan_sku: PyQJ2sk5NZTudqQ2YIU16A== +renewable_date: d/Fk1deU/iPbZFDOdyKsjA== +plan_name: weWOqr1tZ61Av6YKth1lDw== diff --git a/config/routes.rb b/config/routes.rb index 4c302b94..9ffeb352 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,6 +12,7 @@ scope "(:locale)", locale: /en|mm/ do #--------- SmartSales Activation ------------# get 'activate' => 'install#index' post 'activate' => 'install#activate' + get 'run_sym' => 'sym_control#run' #--------- Login/Authentication ------------# get 'auth/:emp_id' => 'home#show', as: :emp_login @@ -244,7 +245,7 @@ scope "(:locale)", locale: /en|mm/ do post "/:id", to: "edit#update" # Pass assigned_order_item_id - get 'print/print/:id', to: "print#print" + post 'print/print/:id', to: "print#print" get 'print/print_order_summary/:id', to: "print#print_order_summary" get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs" diff --git a/config/secrets.yml b/config/secrets.yml index a53c9f76..48ad8e2c 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,12 +12,10 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: connect.smartsales.asia/api #provision.zsai.ws/api - server_mode: cloud + sx_provision_url: 192.168.1.49:3002/api #connect.smartsales.asia/api #provision.zsai.ws/api + server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L - aes_key: <%= ENV['AES_KEY'] %> - aes_iv: <%= ENV['AES_IV'] %> test: secret_key_base: 5c92143fd4a844fdaf8b22aba0cda22ef1fc68f1b26dd3d40656866893718ae5e58625b4c3a5dc86b04c8be0a505ec0ebc0be3bf52249a3d1e0c1334ee591cf0 @@ -30,6 +28,4 @@ production: server_mode: cloud cipher_type: AES-256-CBC sx_key: Wh@t1$C2L - aes_key: <%= ENV['AES_KEY'] %> - aes_iv: <%= ENV['AES_IV'] %> diff --git a/db/seeds.rb b/db/seeds.rb index 79aab88f..78321b72 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -140,10 +140,11 @@ menu_options = MenuItemOption.create([{option_type: "Oil", name: "Less Oil", val menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle", value: "Bottle"},{option_type: "Package", name: "Can", value: "can"}]) # #Default Menu Category - # menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"}) +# menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Person", alt_name: "Person", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"}) # menu_category2 = MenuCategory.create({menu: menu, code:"C005", name: "Beef & Mutton", alt_name: "Beef_and_mutton", order_by: 2,created_by: "SYSTEM DEFAULT"}) # menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Pork", alt_name: "Pork", order_by: 3,created_by: "SYSTEM DEFAULT"}) # menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Chicken", alt_name: "Chicken", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) +# menu_category5 = MenuCategory.create({menu: menu, code:"C001", name: "Extra Time", alt_name: "Extra Time", order_by: 1, is_available: 1, created_by: "SYSTEM DEFAULT"}) # # #Default Menu items # menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) @@ -162,11 +163,21 @@ menu_pkg_options = MenuItemOption.create([{option_type: "Package", name: "Bottle # menu_item_attribute_adult = MenuItemAttribute.create({attribute_type:"person", name: "Adult", value: "adult"}) # menu_item_attribute_child = MenuItemAttribute.create({attribute_type:"person", name: "Child", value: "child"}) - # menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" }) - # menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" }) +# menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"P00001", name: "Adult", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['1']", created_by: "System" }) +# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0001", menu_item: menu_category1_menu_item0, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" }) + +# menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" }) +# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" }) + +# menu_item_attribute_30_min = MenuItemAttribute.create({attribute_type:"Extra Time", name: "30 min", value: "30_min"}) +# menu_item_attribute_60_min = MenuItemAttribute.create({attribute_type:"Extra Time", name: "1 hrs", value: "60_min"}) + +# menu_category1_menu_item2 = SimpleMenuItem.create({item_code:"Ext30", name: "30 minutes", alt_name: "",menu_category: menu_category5 , min_qty: 1, account: extra_time, :item_attributes => "['1']", created_by: "System" }) +# menu_item0_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"Exti30", menu_item: menu_category1_menu_item2, price:15000.00, is_on_promotion:false, is_default:true, :item_attributes => "['1']" }) + +# menu_category1_menu_item3 = SimpleMenuItem.create({item_code:"Ext60", name: "1 hour", alt_name: "",menu_category: menu_category5 , min_qty: 1, account: extra_time, :item_attributes => "['2']", created_by: "System" }) +# menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"Exti60", menu_item: menu_category1_menu_item3, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" }) - # menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"P00002", name: "Child", alt_name: "",menu_category: menu_category1 , min_qty: 1, account: person, :item_attributes => "['2']", created_by: "System" }) - # menu_item1_instance = MenuItemInstance.create({item_instance_name:"",item_instance_code:"PI0002", menu_item: menu_category1_menu_item1, price:10000.00, is_on_promotion:false, is_default:true, :item_attributes => "['2']" }) # END menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"})