shift open/close

This commit is contained in:
Nweni
2017-06-29 13:35:09 +06:30
parent 45961880c8
commit 618a89472a
20 changed files with 320 additions and 18 deletions

View File

@@ -14,13 +14,14 @@
class ShiftSale < ApplicationRecord
belongs_to :cashier_terminal
belongs_to :employee
belongs_to :employee, :foreign_key => 'employee_id'
def self.current_open_shift(current_user)
#if current_user
#find open shift where is open today and is not closed and login by current cashier
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}",today_date).take
puts today_date
shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
return shift
#end
@@ -35,6 +36,7 @@ class ShiftSale < ApplicationRecord
end
def update(sale)
puts ">>>>>> shift sale update"
saleobj = Sale.find(sale)
self.total_revenue = self.total_revenue + saleobj.total_amount
self.total_discounts = self.total_discounts + saleobj.total_discount