fix timezone
This commit is contained in:
@@ -23,7 +23,7 @@ class CardSaleTran < ApplicationRecord
|
||||
|
||||
if from.present? && to.present?
|
||||
|
||||
# cardSale = CardSaleTran.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status IS NULL ", from,to)
|
||||
# cardSale = CardSaleTran.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ?" + " AND DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ? and status IS NULL ", from,to)
|
||||
from_date = from.strftime("%Y-%m-%d")
|
||||
to_date = to.strftime("%Y-%m-%d")
|
||||
query = CardSaleTran.joins("Join sales s ON s.sale_id = card_sale_trans.sale_id"+
|
||||
@@ -48,7 +48,7 @@ class CardSaleTran < ApplicationRecord
|
||||
|
||||
query = CardSaleTran.joins("Join sales s ON s.sale_id = card_sale_trans.sale_id"+
|
||||
" JOIN customers c ON c.customer_id = s.customer_id")
|
||||
cardSale = query.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ? and DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status = 'Approved'",from,to)
|
||||
cardSale = query.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ? and DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ? and status = 'Approved'",from,to)
|
||||
|
||||
if shift.present?
|
||||
query1 = cardSale.where("s.shift_sale_id in (?)", shift.to_a)
|
||||
@@ -63,8 +63,8 @@ class CardSaleTran < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale_by_card(from,to,status)
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,
|
||||
shift_closed_at As closing_date,")
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at,
|
||||
shift_closed_at,")
|
||||
.order("shift_sales.id DESC")
|
||||
return query = query.where("shift_sales.shift_started_at >= ?" , from)
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class CardSettleTran < ApplicationRecord
|
||||
|
||||
query = CardSettleTran.joins("Join shift_sales ss ON ss.id = card_settle_trans.shift_sale_id"+
|
||||
" JOIN employees e ON e.id = ss.employee_id")
|
||||
cardSettle = query.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ? and DATE_FORMAT(req_date,'%Y-%m-%d') <= ?",from,to)
|
||||
cardSettle = query.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ? and DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ?",from,to)
|
||||
query1 = cardSettle.where(keyword)
|
||||
query2 = query1.where(payment)
|
||||
query3 = query2.where(status)
|
||||
@@ -45,14 +45,14 @@ class CardSettleTran < ApplicationRecord
|
||||
|
||||
query = CardSettleTran.joins("Join shift_sales ss ON ss.id = card_settle_trans.shift_sale_id"+
|
||||
" JOIN employees e ON e.id = ss.employee_id")
|
||||
cardSettle = query.where("DATE_FORMAT(req_date,'%Y-%m-%d') >= ? and DATE_FORMAT(req_date,'%Y-%m-%d') <= ? and status = 'Approved'",from,to)
|
||||
cardSettle = query.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') >= ? and DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') <= ? and status = 'Approved'",from,to)
|
||||
|
||||
if shift.present?
|
||||
query1 = cardSettle.where("ss.id in (?)", shift.to_a)
|
||||
elsif shift_sale_range.present?
|
||||
query1 = cardSettle.where("ss.id in (?)",shift_sale_range.to_a)
|
||||
else
|
||||
query1 = cardSettle.where("DATE_FORMAT(req_date,'%Y-%m-%d') between ? and ?",from,to)
|
||||
query1 = cardSettle.where("DATE_FORMAT(CONVERT_TZ(req_date,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') between ? and ?",from,to)
|
||||
end
|
||||
query2 = query1.where(payment)
|
||||
|
||||
@@ -60,8 +60,8 @@ class CardSettleTran < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale_by_card(from,to,status)
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,
|
||||
shift_closed_at As closing_date,")
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at,
|
||||
shift_closed_at,")
|
||||
.order("shift_sales.id DESC")
|
||||
return query = query.where("shift_sales.shift_started_at >= ?" , from)
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ class Customer < ApplicationRecord
|
||||
self.contact_no = params[:phone_number]
|
||||
self.email = pin.to_s + "@gmail.com"
|
||||
self.pin_code = pin.to_s
|
||||
self.pin_sent_at = Time.now
|
||||
self.pin_sent_at = Time.current
|
||||
tax_profiles=TaxProfile.where(group_type: "online_order")
|
||||
tax_ids =[]
|
||||
tax_profiles.each {|tax| tax_ids << "#{tax.id}"}
|
||||
@@ -33,7 +33,7 @@ class Customer < ApplicationRecord
|
||||
return self
|
||||
else
|
||||
cus.pin_code = pin
|
||||
cus.pin_sent_at = Time.now
|
||||
cus.pin_sent_at = Time.current
|
||||
cus.save
|
||||
return cus
|
||||
end
|
||||
@@ -389,7 +389,7 @@ class Customer < ApplicationRecord
|
||||
def self.search(search)
|
||||
if search
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
where("name LIKE ? OR customer_type LIKE ? OR contact_no LIKE ? OR card_no LIKE ? OR DATE_FORMAT(date_of_birth,'%Y-%m-%d') LIKE ? OR nrc_no LIKE ? OR gender LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%")
|
||||
where("name LIKE ? OR customer_type LIKE ? OR contact_no LIKE ? OR card_no LIKE ? OR DATE_FORMAT(CONVERT_TZ(date_of_birth,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') LIKE ? OR nrc_no LIKE ? OR gender LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%")
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class DiningQueue < ApplicationRecord
|
||||
belongs_to :dining_facility, :optional => true
|
||||
def self.generate_queue_no
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no desc")
|
||||
today = Time.current.strftime('%Y-%m-%d')
|
||||
dining_queues = DiningQueue.where("DATE_FORMAT(CONVERT_TZ(created_at,'+00:00', Time.zone.formatted_offset),'%Y-%m-%d') = ? ", today).order("queue_no desc")
|
||||
queue_no = dining_queues.count + 1
|
||||
return queue_no
|
||||
end
|
||||
|
||||
@@ -36,8 +36,8 @@ class Employee < ApplicationRecord
|
||||
#user.authenticate(password)
|
||||
if (user.authenticate(password))
|
||||
user.generate_token
|
||||
user.session_expiry = DateTime.now.utc + expiry_time.minutes
|
||||
user.session_last_login = DateTime.now.utc
|
||||
user.session_expiry = Time.now + expiry_time.minutes
|
||||
user.session_last_login = Time.now
|
||||
user.save
|
||||
return user
|
||||
end
|
||||
@@ -50,7 +50,7 @@ class Employee < ApplicationRecord
|
||||
user = Employee.find_by_token_session(session_token)
|
||||
expiry_time = login_expiry_time
|
||||
|
||||
if user && user.session_expiry && user.session_expiry.utc > DateTime.now.utc
|
||||
if user && user.session_expiry && user.session_expiry.utc > Time.current.utc
|
||||
#Extend the login time each time authenticatation take place
|
||||
user.session_expiry = user.session_expiry.utc + expiry_time.minutes
|
||||
user.save
|
||||
|
||||
@@ -7,7 +7,7 @@ class KbzPay
|
||||
prefix = shop.shop_code
|
||||
receipt_no = "#{prefix}#{receipt_no}"
|
||||
|
||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||
datetime = Time.current.strftime("%d%m%Y%H%M")
|
||||
kbz_app_id = app_id
|
||||
kbz_merch_code = code
|
||||
kbz_api_key = key
|
||||
@@ -66,7 +66,7 @@ class KbzPay
|
||||
prefix = shop.shop_code
|
||||
receipt_no = "#{prefix}#{receipt_no}"
|
||||
amount = 0
|
||||
datetime = DateTime.now.strftime("%d%m%Y%H%M")
|
||||
datetime = Time.current.strftime("%d%m%Y%H%M")
|
||||
kbz_app_id = app_id
|
||||
kbz_merch_code = code
|
||||
kbz_api_key = key
|
||||
|
||||
@@ -10,7 +10,7 @@ class Menu < ApplicationRecord
|
||||
scope :active, -> {where("is_active = true")}
|
||||
|
||||
def self.current_menu
|
||||
today = DateTime.now
|
||||
today = Time.current
|
||||
day_of_week = today.wday
|
||||
menus = Menu.where("is_active = true and '#{today.strftime("%H:%M")}' between TIME(valid_time_from) and TIME(valid_time_to)")
|
||||
current_menu = nil
|
||||
|
||||
@@ -13,7 +13,7 @@ class Order < ApplicationRecord
|
||||
|
||||
#internal references attributes for business logic control
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id, :extra_time, :is_extra_time
|
||||
scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
scope :active, -> { where("date BETWEEN '#{Time.current.utc.end_of_day}' AND '#{Time.current.utc.beginning_of_day}'") }
|
||||
#Main Controller method to create new order - validate all inputs and generate new order
|
||||
# order_item : {
|
||||
# order_item_code : "",
|
||||
|
||||
@@ -20,7 +20,8 @@ class OrderItem < ApplicationRecord
|
||||
# after_save :add_to_journal, if: Proc.new { !self.id_changed? }
|
||||
# after_save :update_stock_journal, if: Proc.new { self.id_changed? }
|
||||
|
||||
|
||||
alias_attribute :order_at, :created_at
|
||||
alias_attribute :order_by, :item_order_by
|
||||
|
||||
#This Method - handle how items is added into order
|
||||
# order_item : {
|
||||
|
||||
@@ -182,7 +182,7 @@ class OrderQueueStation < ApplicationRecord
|
||||
@to = (DiningFacility.find(change_to)).name
|
||||
@type = (DiningFacility.find(change_to)).type
|
||||
@moved_by = current_user
|
||||
@date = DateTime.now
|
||||
@date = Time.current
|
||||
|
||||
@shop = Shop.current_shop
|
||||
unique_code = "MoveTablePdf"
|
||||
|
||||
@@ -7,7 +7,7 @@ class OrderReservation < ApplicationRecord
|
||||
has_many :order_reservation_items
|
||||
has_one :delivery
|
||||
|
||||
scope :active, -> { where("created_at BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
scope :active, -> { where("created_at BETWEEN '#{Time.current.beginning_of_day.utc}' AND '#{Time.current.end_of_day.utc}'") }
|
||||
scope :latest_order, -> { order("order_reservation_id desc, created_at desc") }
|
||||
|
||||
SEND_TO_KITCHEN = "send_to_kitchen"
|
||||
@@ -158,7 +158,7 @@ class OrderReservation < ApplicationRecord
|
||||
if(Sale.exists?(order.sale_id))
|
||||
saleObj = Sale.find(order.sale_id)
|
||||
|
||||
shop_details = Shop.current_shop
|
||||
shop_details = Shop.current_shop
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -311,18 +311,18 @@ class OrderReservation < ApplicationRecord
|
||||
end
|
||||
|
||||
if status == "accepted"
|
||||
action_times = {"accepted_time" => DateTime.now.utc, "kitchen_time" => "", "ready_time" => ""}
|
||||
action_times = {"accepted_time" => Time.now.utc, "kitchen_time" => "", "ready_time" => ""}
|
||||
order_reservation.action_times = action_times.to_json
|
||||
elsif status == SEND_TO_KITCHEN
|
||||
if !order_reservation.action_times.nil?
|
||||
action_data = JSON.parse(order_reservation.action_times)
|
||||
action_data["kitchen_time"] = DateTime.now.utc
|
||||
action_data["kitchen_time"] = Time.now.utc
|
||||
order_reservation.action_times = action_data.to_json
|
||||
end
|
||||
elsif status == READY_TO_DELIVERY
|
||||
if !order_reservation.action_times.nil?
|
||||
action_data = JSON.parse(order_reservation.action_times)
|
||||
action_data["ready_time"] = DateTime.now.utc
|
||||
action_data["ready_time"] = Time.now.utc
|
||||
order_reservation.action_times = action_data.to_json
|
||||
end
|
||||
end
|
||||
@@ -391,7 +391,7 @@ class OrderReservation < ApplicationRecord
|
||||
|
||||
def self.get_count_on_completed
|
||||
order_reservation = OrderReservation.select("COUNT(order_reservation_id) as count")
|
||||
.where("created_at BETWEEN '#{DateTime.now.beginning_of_day}' AND '#{DateTime.now.end_of_day}' AND status = 'delivered'").first()
|
||||
.where("created_at BETWEEN '#{Time.current.beginning_of_day.utc}' AND '#{Time.current.end_of_day.utc}' AND status = 'delivered'").first()
|
||||
end
|
||||
|
||||
def self.get_pending_orders
|
||||
@@ -426,7 +426,7 @@ class OrderReservation < ApplicationRecord
|
||||
else
|
||||
shop_code = ''
|
||||
end
|
||||
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.current.utc}'")
|
||||
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.now.utc}'")
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
@@ -444,7 +444,7 @@ class OrderReservation < ApplicationRecord
|
||||
else
|
||||
shop_code = ''
|
||||
end
|
||||
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.current.utc}'")
|
||||
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.now.utc}'")
|
||||
if order_reservation.length > 0
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
|
||||
@@ -22,7 +22,7 @@ class PaymentJournal < ApplicationRecord
|
||||
|
||||
# def self.today_cash_in(current_user)
|
||||
# credit = 0.0
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
# today_date = Time.current.strftime("%Y-%m-%d")
|
||||
# pj_credit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user)
|
||||
# pj_credit.each do |obj|
|
||||
# credit += obj.credit_amount
|
||||
@@ -32,7 +32,7 @@ class PaymentJournal < ApplicationRecord
|
||||
#
|
||||
# def self.today_cash_out(current_user)
|
||||
# debit = 0.0
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
# today_date = Time.current.strftime("%Y-%m-%d")
|
||||
# pj_debit = PaymentJournal.where("TO_CHAR(created_at, 'YYYY-MM-DD')=? and created_by=?",today_date, current_user)
|
||||
# pj_debit.each do |obj|
|
||||
# debit += obj.debit_amount
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
|
||||
def print_open_cashier(receipt_no)
|
||||
time = DateTime.now
|
||||
time = Time.current
|
||||
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
@@ -17,7 +17,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
# def print_close_cashier(receipt_no)
|
||||
# #Use CUPS service
|
||||
# #Generate PDF
|
||||
# time = DateTime.now
|
||||
# time = Time.current
|
||||
# #Print
|
||||
# pdf = CashierStationClosing.new
|
||||
# pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
|
||||
|
||||
@@ -150,7 +150,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# Query for OQS with status
|
||||
def print_query(type, id)
|
||||
if type == "order_item"
|
||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
|
||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by, order_items.created_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
|
||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
@@ -160,7 +160,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
.where("order_items.order_items_id = '#{ id }'")
|
||||
.group("order_items.item_code")
|
||||
elsif type == "order_summary"
|
||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
|
||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by, order_items.created_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
|
||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
@@ -171,7 +171,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
.group("order_items.order_items_id")
|
||||
else
|
||||
# order summary for booking
|
||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
|
||||
OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by, order_items.created_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name")
|
||||
.joins("left join orders ON orders.order_id = order_items.order_id
|
||||
left join booking_orders AS bo ON bo.order_id=order_items.order_id
|
||||
left join bookings AS b ON b.booking_id = bo.booking_id
|
||||
|
||||
@@ -31,7 +31,7 @@ class Promotion < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
|
||||
promoList = Promotion.where("(Date_Format(promo_start_date, '%Y-%m-%d') <=? AND Date_Format(promo_end_date, '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
promoList = Promotion.where("(Date_Format(CONVERT_TZ(promo_start_date, '+00:00', Time.zone.formatted_offset), '%Y-%m-%d') <=? AND Date_Format(CONVERT_TZ(promo_start_date, '+00:00', Time.zone.formatted_offset), '%Y-%m-%d') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
|
||||
return promoList
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class Reservation < ApplicationRecord
|
||||
|
||||
has_many :reservation_items
|
||||
|
||||
scope :active, -> { where("created_at BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
scope :active, -> { where("created_at BETWEEN '#{Time.current.utc.beginning_of_day}' AND '#{Time.current.utc.end_of_day}'") }
|
||||
|
||||
private
|
||||
def generate_custom_id
|
||||
|
||||
@@ -29,8 +29,8 @@ class Sale < ApplicationRecord
|
||||
before_save :round_to_precision
|
||||
after_update :update_stock_journal
|
||||
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{Time.current.utc.end_of_day}' AND '#{Time.current.utc.beginning_of_day}'") }
|
||||
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{Time.current.utc.beginning_of_day}' AND '#{Time.current.utc.end_of_day}'") }
|
||||
scope :paid, -> { where(payment_status: 'paid')}
|
||||
scope :completed, -> { where(sale_status: 'completed') }
|
||||
|
||||
@@ -202,7 +202,7 @@ class Sale < ApplicationRecord
|
||||
def generate_invoice_by_items (items, requested_by)
|
||||
taxable = true
|
||||
self.requested_by = requested_by
|
||||
self.requested_at = DateTime.now
|
||||
self.requested_at = Time.current
|
||||
|
||||
items.each do |item|
|
||||
add_item(item)
|
||||
@@ -658,7 +658,7 @@ class Sale < ApplicationRecord
|
||||
# SaleOrder.create(:sale_id => self.id, :order_id => order_id)
|
||||
# end
|
||||
#dosomrting here
|
||||
#puts Time.now.format(":short")
|
||||
#puts Time.current.format(":short")
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
@@ -707,7 +707,7 @@ class Sale < ApplicationRecord
|
||||
shop_details = Shop.current_shop
|
||||
#Date-Shift-
|
||||
if self.receipt_no.nil?
|
||||
prefix = DateTime.now().utc
|
||||
prefix = Time.current().utc
|
||||
#self.receipt_no = prefix.to_s + "/" + self.shit_id.to_s + "/" + SeedGenerator.new_receipt_no().to_s
|
||||
new_receipt_no = SeedGenerator.new_receipt_no().to_s
|
||||
|
||||
@@ -897,8 +897,8 @@ def self.get_by_shiftsales(from,to,shift)
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale(from,to,status)
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,
|
||||
shift_closed_at As closing_date," +
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at,
|
||||
shift_closed_at," +
|
||||
" grand_total AS grand_total, cash_sales AS cash," +
|
||||
"total_taxes AS total_tax,total_discounts As total_discount")
|
||||
.order("shift_sales.id DESC")
|
||||
@@ -906,8 +906,8 @@ def self.get_by_shift_sale(from,to,status)
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale_by_item(from,to,status)
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at AS opening_date,
|
||||
shift_closed_at As closing_date," +
|
||||
query = ShiftSale.select("shift_sales.id ,shift_started_at,
|
||||
shift_closed_at," +
|
||||
" grand_total AS grand_total, cash_sales AS cash," +
|
||||
"total_taxes AS total_tax,total_discounts As total_discount")
|
||||
.order("shift_sales.id DESC")
|
||||
|
||||
@@ -35,7 +35,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = "SALEVOID"
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = void_by
|
||||
sale_audit.approved_by = approved_by
|
||||
sale_audit.remark = reason
|
||||
@@ -47,7 +47,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = "SALECOMPLETE"
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = Sale.find(sale_id).cashier_id
|
||||
sale_audit.remark = remark
|
||||
sale_audit.approved_by = action_by
|
||||
@@ -59,7 +59,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = type
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = discount_by
|
||||
sale_audit.approved_by = approved_by
|
||||
sale_audit.remark = reason
|
||||
@@ -72,7 +72,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = "SALEFOC"
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = cashier_id
|
||||
sale_audit.approved_by = approved_by
|
||||
sale_audit.remark = reason
|
||||
@@ -84,7 +84,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = type
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = cashier_id
|
||||
sale_audit.approved_by = approved_by
|
||||
sale_audit.remark = reason
|
||||
@@ -95,7 +95,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = "SALEPAYMENT"
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = action_by
|
||||
sale_audit.remark = remark
|
||||
sale_audit.approved_by = action_by
|
||||
@@ -106,7 +106,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = "PAYMAL"
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = Sale.find(sale_id).cashier_id
|
||||
sale_audit.remark = remark
|
||||
sale_audit.approved_by = action_by
|
||||
@@ -117,7 +117,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = type
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = action_by
|
||||
sale_audit.remark = remark
|
||||
sale_audit.approved_by = action_by
|
||||
@@ -128,7 +128,7 @@ class SaleAudit < ApplicationRecord
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
sale_audit.action = "CHANGE_TAX"
|
||||
sale_audit.action_at = DateTime.now.utc
|
||||
sale_audit.action_at = Time.current.utc
|
||||
sale_audit.action_by = action_by
|
||||
sale_audit.remark = remark
|
||||
sale_audit.approved_by = action_by
|
||||
|
||||
@@ -17,8 +17,11 @@ class ShiftSale < ApplicationRecord
|
||||
belongs_to :employee, :foreign_key => 'employee_id'
|
||||
has_many :sales
|
||||
|
||||
alias_attribute :opening_date, :shift_started_at
|
||||
alias_attribute :closing_date, :shift_closed_at
|
||||
|
||||
def self.current_shift
|
||||
# today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||
# today_date = Time.current.strftime("%Y-%m-%d")
|
||||
shift = ShiftSale.where.not(shift_started_at: nil).where(shift_closed_at: nil).first
|
||||
return shift
|
||||
end
|
||||
@@ -27,7 +30,7 @@ class ShiftSale < ApplicationRecord
|
||||
#if current_user
|
||||
#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")
|
||||
today_date = Time.current.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
|
||||
return shift
|
||||
#end
|
||||
@@ -80,7 +83,7 @@ class ShiftSale < ApplicationRecord
|
||||
|
||||
def create(opening_balance,cashier_terminal, current_user)
|
||||
self.cashier_terminal_id = cashier_terminal
|
||||
self.shift_started_at = DateTime.now
|
||||
self.shift_started_at = Time.current
|
||||
self.employee_id = current_user.id
|
||||
self.opening_balance = opening_balance
|
||||
self.other_sales = 0
|
||||
|
||||
Reference in New Issue
Block a user