Merge branch 'quick_service' of bitbucket.org:code2lab/sxrestaurant into split_bill

This commit is contained in:
phyusin
2018-02-27 11:09:40 +06:30
13 changed files with 147 additions and 83 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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
@@ -59,7 +59,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

View File

@@ -52,7 +52,7 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.product_name = di["name"]
sale_item.item_instance_code = origin_sale_item.item_instance_code
sale_item.product_alt_name = ""
sale_item.remark = "Discount"
sale_item.status = "Discount"
sale_item.qty = -1
sale_item.unit_price = di["price"].to_f * (-1)
@@ -175,7 +175,7 @@ class Origami::DiscountsController < BaseOrigamiController
discount_items = []
#destroy all discount sale item
sale.sale_items.each do |si|
if si.remark == "Discount" && si.price < 0
if si.status == "Discount" && si.price < 0
sale.total_amount = (sale.total_amount + si.price.abs)
discount_items.push(si)
end
@@ -343,7 +343,7 @@ class Origami::DiscountsController < BaseOrigamiController
# sale_item.sale_id = sale_id
# sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
# sale_item.product_name = product_name
# sale_item.remark = remark
# sale_item.status = remark
# sale_item.qty = 1
# sale_item.unit_price = (0-discount_amount.to_f)

View File

@@ -44,7 +44,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.product_code = "Other Charges"
sale_item.product_name = "*" + di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Other Charges"
sale_item.status = "Other Charges"
sale_item.qty = 1
sale_item.unit_price = di["price"]

View File

@@ -357,12 +357,13 @@ 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
saleObj.update_attributes(rounding_adjustment: 0)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "foc" ,remark)

View File

@@ -16,8 +16,10 @@ class Origami::SaleEditController < BaseOrigamiController
# create item void. make duplicate old record and update qty and price
def item_void
saleitemId = params[:sale_item_id]
remark = params[:remark]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'void'
saleitemObj.status = 'void'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@@ -27,6 +29,7 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.is_taxable = 1
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (VOID)'
@newsaleitem.remark = remark
@newsaleitem.save
# re-calc tax
@@ -54,8 +57,10 @@ class Origami::SaleEditController < BaseOrigamiController
def item_foc
saleitemId = params[:sale_item_id]
remark = params[:remark]
saleitemObj = SaleItem.find(saleitemId)
saleitemObj.remark = 'foc'
saleitemObj.status = 'foc'
saleitemObj.remark = remark
saleitemObj.save
@newsaleitem = SaleItem.new
@newsaleitem = saleitemObj.dup
@@ -65,6 +70,7 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.taxable_price = saleitemObj.taxable_price * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.product_name = saleitemObj.product_name + ' (FOC)'
@newsaleitem.remark = remark
@newsaleitem.save
# re-calc tax
@@ -83,7 +89,7 @@ class Origami::SaleEditController < BaseOrigamiController
# update_qty = params[:update_qty]
# update_price = params[:update_price]
# saleitemObj = SaleItem.find(saleitemId)
# saleitemObj.remark = 'void'
# saleitemObj.status = 'void'
# saleitemObj.save
# @newsaleitem = SaleItem.new
# @newsaleitem = saleitemObj.dup
@@ -147,7 +153,7 @@ class Origami::SaleEditController < BaseOrigamiController
both = SaleItem.where('product_code=?', saleitemObj.product_code)
both.each do |item|
if item.qty.to_i > 0
item.remark = nil
item.status = nil
item.save
end
end
@@ -172,7 +178,7 @@ class Origami::SaleEditController < BaseOrigamiController
if item.qty.to_i < 0
item.destroy
else
item.remark = nil
item.status = nil
end
item.save
ProductCommission.remove_product_commission(item)