dashboard hourly sale and license code clean

This commit is contained in:
Yan
2017-12-12 17:41:35 +06:30
parent e55948a7b2
commit bbf30ed26f
3 changed files with 10 additions and 27 deletions

View File

@@ -18,39 +18,21 @@ class License
if (server != "")
self.class.base_uri server
end
# @secret = ENV["aes_key"]
# @params = { query: { device: "SX", token: SECRETS_CONFIG['provision_key'] } }
end
# For Cloud
def detail_with_local_cache(lookup)
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_to_file(lookup)
# flag = ENV["AES_IV"]
# # Check Exists IV
# if flag == "<%= ENV['AES_IV'] %>"
# # Export for Key
# aes = MyAesCrypt.new
# aes_key, aes_iv = aes.export_key(lookup)
# else
# aes_key = ENV["AES_KEY"]
# aes_iv = ENV["AES_IV"]
# end
##Check from local redis - if available load local otherwise get from remote
cache_key = "#{lookup}:license:#{aes_key}:hostname"
# No Needs for current
# @secret = key
##Check from local redis - if available load local otherwise get from remote
cache_key = "#{lookup}:license:#{aes_key}:hostname"
cache_license = nil
##Get redis connection from connection pool
redis = Redis.new
cache_license = redis.get(cache_key)
# Redis.current do |conn|
# cache_license = conn.get(cache_key)
# end
cache_license = redis.get(cache_key)
Rails.logger.info "Cache key - " + cache_key.to_s
if cache_license.nil?
@@ -85,7 +67,7 @@ class License
end
end
# For Local System
def detail_with_local_file()
has_license = true # verify_license()
@@ -117,8 +99,7 @@ class License
end
def verify_license
api_token = read_license_no_decrypt("api_token")
puts api_token
api_token = read_license_no_decrypt("api_token")
@params = { query: {lookup_type: "application", api_token: api_token} }
response = self.class.get("/verify", @params)
@varified = response.parsed_response

View File

@@ -979,7 +979,8 @@ end
def self.hourly_sales(today)
query= Sale.select("grand_total")
.where('payment_status="paid" and sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.group("date_format(receipt_date, '%I %p')")
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
.order('receipt_date')
end
def self.employee_sales(today)

View File

@@ -390,10 +390,11 @@
$(this).off("click");
var sale_id = $('#sale_id').text();
var item_row = $('.is_card');
if (item_row.length < 1) {
calculate_member_discount(sale_id);
}
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();