diff --git a/app/controllers/concerns/license_verification.rb b/app/controllers/concerns/license_verification.rb index bfa40f03..94e9ad91 100644 --- a/app/controllers/concerns/license_verification.rb +++ b/app/controllers/concerns/license_verification.rb @@ -13,7 +13,7 @@ module LicenseVerification if (!@license.nil?) # logger.info "Location - " + @license.name ActiveRecord::Base.establish_connection(website_connection(@license)) - authenticate_session_token + # authenticate_session_token # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema else # reconnect_default_db @@ -29,6 +29,7 @@ module LicenseVerification # redirect_to activate_path # end end + authenticate_session_token end def authenticate_session_token @@ -38,8 +39,12 @@ module LicenseVerification #Rails.logger.debug "token - " + token.to_s @user = Employee.authenticate_by_token(token) - if !@user + if @user + return true + #Maybe log - login? + else flash[:notice] = 'Invalid Access!' + # return false end end end diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 7ddf3cec..aa9d8319 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -2,10 +2,25 @@ module LoginVerification extend ActiveSupport::Concern included do - before_action :authenticate + before_action :authenticate_session_token helper_method :current_company,:current_login_employee end + #this is base api base controller to need to inherit. + #all token authentication must be done here + #response format must be set to JSON + def current_company + begin + return Company.first + rescue + return nil + end + + end + + def current_login_employee + @employee = Employee.find_by_token_session(session[:session_token]) + end protected # Authenticate the user with token based authentication @@ -25,6 +40,7 @@ module LoginVerification #Maybe log - login? else flash[:notice] = 'Invalid Access!' + # return false end end end @@ -33,23 +49,6 @@ module LoginVerification redirect_to root_path end - - #this is base api base controller to need to inherit. - #all token authentication must be done here - #response format must be set to JSON - def current_company - begin - return Company.first - rescue - return nil - end - - end - - def current_login_employee - @employee = Employee.find_by_token_session(session[:session_token]) - end - private def check_license License.check_license_file diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 3ca8ba81..a860e6ff 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,7 +5,7 @@ class HomeController < ApplicationController def index # @employees = Employee.all_emp_except_waiter.order("name asc") @employees = Employee.all.order("name asc") - @login_form = LoginForm.new() + @login_form = LoginForm.new() render "layouts/login_dashboard", layout: false end @@ -56,7 +56,7 @@ class HomeController < ApplicationController render :index end else - redirect_to origami_root_path, :notice => "Username and Password doesn't match!" + redirect_to root_path, :notice => "Username and Password doesn't match!" end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 199325e9..317743dd 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -87,7 +87,7 @@ class Origami::PaymentsController < BaseOrigamiController #end rounding adjustment sale_payment = SalePayment.new - sale_payment.process_payment(saleObj, @user, cash, "cash") + sale_payment.process_payment(saleObj, @usercurrent_user.name, cash, "cash") render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "}) rebate_amount = nil @@ -300,6 +300,7 @@ class Origami::PaymentsController < BaseOrigamiController cash = params[:cash] sale_id = params[:sale_id] sub_total = params[:sub_total] + remark = params[:remark] member_info = nil rebate_amount = nil current_balance = nil @@ -313,7 +314,7 @@ class Origami::PaymentsController < BaseOrigamiController end sale_payment = SalePayment.new - sale_payment.process_payment(saleObj, @user, cash, "foc") + sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark) # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index aa36067b..578054ee 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -3,7 +3,7 @@ class Origami::VoidController < BaseOrigamiController def overall_void sale_id = params[:sale_id] - + remark = params[:remark] if Sale.exists?(sale_id) sale = Sale.find_by_sale_id(sale_id) if sale.discount_type == "member_discount" @@ -64,8 +64,8 @@ class Origami::VoidController < BaseOrigamiController end # FOr Sale Audit - action_by = current_user.id - remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" + action_by = current_user.name + # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" ) # For Print diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 55541851..633db6fe 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -24,9 +24,9 @@ class SaleAudit < ApplicationRecord sale_audit.sale_id = sale_id sale_audit.action = "SALECOMPLETE" sale_audit.action_at = DateTime.now.utc - sale_audit.action_by = action_by + sale_audit.action_by = Sale.find(sale_id).cashier_id sale_audit.remark = remark - sale_audit.approved_by = Time.now + sale_audit.approved_by = action_by sale_audit.save! end @@ -72,9 +72,9 @@ class SaleAudit < ApplicationRecord sale_audit.sale_id = sale_id sale_audit.action = "SALEPAYMENT" sale_audit.action_at = DateTime.now.utc - sale_audit.action_by = action_by + sale_audit.action_by = Sale.find(sale_id).cashier_id sale_audit.remark = remark - sale_audit.approved_by = Time.now + sale_audit.approved_by = action_by sale_audit.save! end @@ -83,9 +83,9 @@ class SaleAudit < ApplicationRecord sale_audit.sale_id = sale_id sale_audit.action = "PAYMAL" sale_audit.action_at = DateTime.now.utc - sale_audit.action_by = action_by + sale_audit.action_by = Sale.find(sale_id).cashier_id sale_audit.remark = remark - sale_audit.approved_by = Time.now + sale_audit.approved_by = action_by sale_audit.save! end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 661eb57b..5b0da284 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -8,7 +8,7 @@ class SalePayment < ApplicationRecord attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status - def process_payment(invoice, action_by, cash_amount, payment_method) + def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil) self.sale = invoice self.received_amount = cash_amount amount_due = invoice.grand_total @@ -53,7 +53,7 @@ class SalePayment < ApplicationRecord end #record an payment in sale-audit - remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}" + # remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{cash_amount} | Payment Status ->#{payment_status}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) # update complete order items in oqs @@ -67,7 +67,7 @@ class SalePayment < ApplicationRecord return true, self.save else #record an payment in sale-audit - remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" + # remark = "No outstanding Amount - Grand Total [#{invoice.grand_total}] | Due [#{amount_due}] | Paid [#{invoice.amount_received}]" sale_audit = SaleAudit.record_payment(invoice.id, remark,action_by) return false, "No outstanding Amount" diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 386a142f..c1f20956 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -430,7 +430,8 @@ <% if @status_sale == 'sale' %> - + + @@ -490,6 +491,30 @@ + +