add shift id in authenticate and remove session token for close shift

This commit is contained in:
phyusin
2018-10-18 10:21:35 +06:30
parent 2859dcda34
commit 72cc466165
4 changed files with 15 additions and 12 deletions

View File

@@ -28,6 +28,7 @@ class Api::AuthenticateController < Api::ApiController
shift = ShiftSale.current_open_shift(@employee.id)
if !shift.nil?
@status = true
@shift_id = shift.id
# render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
else
@status = true

View File

@@ -44,7 +44,7 @@ class Api::ShiftsController < Api::ApiController
cashier_terminal.is_currently_login = 0
cashier_terminal.save
logout_status = Employee.logout(params[:session_token])
logout_status = Employee.logout(current_token)
if logout_status
render json: JSON.generate({:status => true, :message => "Shift successfully close."})
else

View File

@@ -8,19 +8,20 @@ class SeedGenerator < ApplicationRecord
end
padding_len = 15 - prefix.length
generate_id = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
return generate_id
last_val = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
return last_val
end
# Generate Receipt No for number order (1,2,3) Don't touch
def self.new_receipt_no
seed = SeedGenerator.find_by_model("sale")
seed = SeedGenerator.find_by_model("Sale")
new_receipt_no = 0
if (seed.nil?)
seed = SeedGenerator.new()
seed.model = "sale"
seed.model = "Sale"
new_receipt_no = seed.next
seed.save
else
current_no = seed.next
seed.next = seed.next
@@ -66,14 +67,12 @@ class SeedGenerator < ApplicationRecord
sql = "INSERT INTO seed_generators (model, created_at, updated_at)
VALUES('#{ model }', NOW(), NOW())
ON DUPLICATE KEY UPDATE current = next, next = next + 1;"
ON DUPLICATE KEY UPDATE current = current + 1, next = next + 1;"
select_sql = "select * from seed_generators where model='#{model}';"
ActiveRecord::Base.connection.execute(sql);
select_result = ActiveRecord::Base.connection.execute(select_sql);
select_result.each do |row|
current = row [3]
nex = row[4]
@@ -88,8 +87,8 @@ class SeedGenerator < ApplicationRecord
update_sql = "UPDATE seed_generators set current = next, next = next + 1 WHERE model='#{model}';"
select_sql = "select * from seed_generators where model='#{model}';"
update_result = ActiveRecord::Base.connection.execute(update_sql);
select_result = ActiveRecord::Base.connection.execute(select_sql);
select_result.each do |row|

View File

@@ -3,6 +3,9 @@ if @status == true
json.session_token @employee.token_session
json.name @employee.name
json.role @employee.role
if @shift_id
json.shift_id @shift_id
end
if @error_message
json.error_message @error_message
json.terminals do