fix bugs and improvement

This commit is contained in:
Thein Lin Kyaw
2020-07-13 12:27:38 +06:30
parent 8f0950f5a1
commit 40ae0cf388
4 changed files with 9 additions and 16 deletions

View File

@@ -36,7 +36,6 @@ class Employee < ApplicationRecord
end
end
return nil
end
def self.authenticate_by_token(session_token)
@@ -44,7 +43,7 @@ class Employee < ApplicationRecord
user = Employee.find_by_token_session(session_token)
expiry_time = login_expiry_time
if user && user.session_expiry.utc > DateTime.now.utc
if user && user.session_expiry && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
user.session_expiry = user.session_expiry.utc + expiry_time.minutes
user.save

View File

@@ -684,8 +684,11 @@ class SalePayment < ApplicationRecord
end
end
sale.save!
table_update_status(sale)
update_shift
if sale.sale_status == 'completed'
table_update_status(sale)
update_shift
end
end
# update for cashier shift

View File

@@ -28,7 +28,7 @@ class ShiftSale < ApplicationRecord
#find open shift where is open today and is not closed and login by current cashier
#DATE(shift_started_at)=? and
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = ?", current_user).take
return shift
#end
end
@@ -132,7 +132,7 @@ class ShiftSale < ApplicationRecord
self.commercial_taxes = self.commercial_taxes.to_f - tax.to_f
self.total_rounding = self.total_rounding - saleobj.rounding_adjustment
self.total_void = self.total_void + saleobj.grand_total
if saleobj.customer.customer_type == "Dinein"
self.dining_count = self.dining_count - 1
else