From 25a212bb702c199b9dcb4bf6061df0d3852b74c6 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 23 Feb 2018 14:45:53 +0630 Subject: [PATCH 1/3] update base controllers --- app/controllers/base_crm_controller.rb | 1 + app/controllers/base_inventory_controller.rb | 1 + app/controllers/base_oqs_controller.rb | 1 + app/controllers/base_origami_controller.rb | 1 + app/controllers/base_report_controller.rb | 1 + app/controllers/base_waiter_controller.rb | 1 + app/controllers/concerns/license_verification.rb | 3 ++- app/controllers/concerns/login_verification.rb | 3 ++- app/controllers/home_controller.rb | 5 +++-- app/controllers/print_settings_controller.rb | 1 + 10 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 5c412fcf..970ffe17 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,4 +1,5 @@ class BaseCrmController < ApplicationController + include LoginVerification layout "CRM" #before_action :check_installation diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index f44747d3..1d99c766 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,4 +1,5 @@ class BaseInventoryController < ApplicationController + include LoginVerification layout "inventory" #before_action :check_installation diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index f1f2831a..b50684de 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,4 +1,5 @@ class BaseOqsController < ApplicationController + include LoginVerification layout "OQS" #before_action :check_installation diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 58d9b801..8a79c009 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,4 +1,5 @@ class BaseOrigamiController < ApplicationController + include LoginVerification layout "origami" # before_action :checkin_process diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index f7551f22..a9fe207b 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,4 +1,5 @@ class BaseReportController < ApplicationController + include LoginVerification layout "application" #before_action :check_installation diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index 248e32a6..ca793e17 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,4 +1,5 @@ class BaseWaiterController < ApplicationController + include LoginVerification layout "waiter" #before_action :check_installation diff --git a/app/controllers/concerns/license_verification.rb b/app/controllers/concerns/license_verification.rb index bfa40f03..b838a48f 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 @@ -40,6 +40,7 @@ module LicenseVerification @user = Employee.authenticate_by_token(token) if !@user flash[:notice] = 'Invalid Access!' + redirect_to root_path end end end diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 7ddf3cec..bb98cf2e 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -2,7 +2,7 @@ module LoginVerification extend ActiveSupport::Concern included do - before_action :authenticate + before_action :authenticate_session_token helper_method :current_company,:current_login_employee end @@ -25,6 +25,7 @@ module LoginVerification #Maybe log - login? else flash[:notice] = 'Invalid Access!' + # return false end end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index ea411fa0..5c0d4117 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,11 +1,12 @@ class HomeController < ApplicationController + include LoginVerification # layout "application", except: [:index, :show] # skip_before_action only: [:index, :show, :create, :update, :destroy] 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 +57,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/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index a72319b3..329b0fa2 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -1,4 +1,5 @@ class PrintSettingsController < ApplicationController + include LoginVerification load_and_authorize_resource except: [:create] before_action :set_print_setting, only: [:show, :edit, :update, :destroy] From 77a66d726bc48a7c5d8be7c12728c1d0a9a5621e Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 23 Feb 2018 14:53:08 +0630 Subject: [PATCH 2/3] update foc and void overall add remark --- .../origami/payments_controller.rb | 5 +- app/controllers/origami/void_controller.rb | 6 +- app/models/sale_audit.rb | 12 +- app/models/sale_payment.rb | 6 +- app/views/origami/home/show.html.erb | 30 +++- app/views/origami/payments/show.html.erb | 156 +++++++++++++----- 6 files changed, 162 insertions(+), 53 deletions(-) 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 6e1f7128..d5f63d3c 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -428,7 +428,8 @@ <% if @status_sale == 'sale' %> - - - +
+ +