Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01
This commit is contained in:
@@ -13,5 +13,8 @@ class Api::SyncController < Api::ApiController
|
|||||||
ShiftSale.sync_shift_sale_records(params[:shift_sales])
|
ShiftSale.sync_shift_sale_records(params[:shift_sales])
|
||||||
Booking.sync_booking_records(params[:bookings])
|
Booking.sync_booking_records(params[:bookings])
|
||||||
AssignedOrderItem.sync_assigned_order_item_records(params[:assigned_order_items])
|
AssignedOrderItem.sync_assigned_order_item_records(params[:assigned_order_items])
|
||||||
|
SeedGenerator.sync_seed_generator_records(params[:seed_generators])
|
||||||
|
|
||||||
|
# render :json => { :status => true, :message => "Hello!" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -77,6 +77,7 @@ authorize_resource :class => false
|
|||||||
# url = "http://192.168.1.176:3000/en/api/sync_data"
|
# url = "http://192.168.1.176:3000/en/api/sync_data"
|
||||||
url = Lookup.sync_url
|
url = Lookup.sync_url
|
||||||
token = Lookup.get_sync_token
|
token = Lookup.get_sync_token
|
||||||
|
@message = ''
|
||||||
# token = Lookup.token
|
# token = Lookup.token
|
||||||
|
|
||||||
unless url.nil? and token.nil?
|
unless url.nil? and token.nil?
|
||||||
@@ -118,10 +119,11 @@ authorize_resource :class => false
|
|||||||
|
|
||||||
puts url
|
puts url
|
||||||
puts response
|
puts response
|
||||||
|
@message = @result.parsed_response['message']
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to '/en/reports/receipt_no/', notice: 'Sync Record Completed.'}
|
format.html { redirect_to '/en/reports/receipt_no/', notice: @message}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,12 @@ class AssignedOrderItem < ApplicationRecord
|
|||||||
|
|
||||||
def self.sync_assigned_order_item_records(assigned_order_items)
|
def self.sync_assigned_order_item_records(assigned_order_items)
|
||||||
if !assigned_order_items.nil?
|
if !assigned_order_items.nil?
|
||||||
assigned_order_items.each do |items|
|
assigned_order_items.each do |item|
|
||||||
unless AssignedOrderItem.exists?(items['assigned_order_item_id'])
|
order_item = AssignedOrderItem.find_by_assigned_order_item_id(item['assigned_order_item_id'])
|
||||||
|
# unless AssignedOrderItem.exists?(item['assigned_order_item_id'])
|
||||||
|
if order_item.nil?
|
||||||
order_item = AssignedOrderItem.new
|
order_item = AssignedOrderItem.new
|
||||||
|
end
|
||||||
order_item.assigned_order_item_id = item['assigned_order_item_id']
|
order_item.assigned_order_item_id = item['assigned_order_item_id']
|
||||||
order_item.item_code = item['item_code']
|
order_item.item_code = item['item_code']
|
||||||
order_item.instance_code = item['instance_code']
|
order_item.instance_code = item['instance_code']
|
||||||
@@ -20,9 +23,8 @@ class AssignedOrderItem < ApplicationRecord
|
|||||||
order_item.print_status = item['print_status']
|
order_item.print_status = item['print_status']
|
||||||
order_item.delivery_status = item['delivery_status']
|
order_item.delivery_status = item['delivery_status']
|
||||||
order_item.save
|
order_item.save
|
||||||
puts '....... Assigned Order Item has been created .......'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '....... Assigned Order Item sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,11 +64,6 @@ class AssignedOrderItem < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "AOI"
|
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CAOI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,8 +14,11 @@ class Booking < ApplicationRecord
|
|||||||
def self.sync_booking_records(bookings)
|
def self.sync_booking_records(bookings)
|
||||||
if !bookings.nil?
|
if !bookings.nil?
|
||||||
bookings.each do |b|
|
bookings.each do |b|
|
||||||
unless TableBooking.exists?(b['booking_id'])
|
booking = TableBooking.find_by_booking_id(b['booking_id'])
|
||||||
|
# unless TableBooking.exists?(b['booking_id'])
|
||||||
|
if booking.nil?
|
||||||
booking = TableBooking.new
|
booking = TableBooking.new
|
||||||
|
end
|
||||||
booking.booking_id = b['booking_id']
|
booking.booking_id = b['booking_id']
|
||||||
booking.dining_facility_id = b['dining_facility_id']
|
booking.dining_facility_id = b['dining_facility_id']
|
||||||
# booking.type = b['type']
|
# booking.type = b['type']
|
||||||
@@ -29,9 +32,8 @@ class Booking < ApplicationRecord
|
|||||||
booking.sale_id = b['sale_id']
|
booking.sale_id = b['sale_id']
|
||||||
booking.customer_id = b['customer_id']
|
booking.customer_id = b['customer_id']
|
||||||
booking.save
|
booking.save
|
||||||
puts '....... Booking has been created ......'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '....... Booking sync completed ......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -120,11 +122,6 @@ class Booking < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "BKI"
|
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CBKI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.booking_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,11 +6,6 @@ class CashierLoginLog < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "CLO"
|
self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CCLO"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -13,11 +13,6 @@ class Commission < ApplicationRecord
|
|||||||
scope :active, -> {where(is_active: true)}
|
scope :active, -> {where(is_active: true)}
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "COM"
|
self.commission_id = SeedGenerator.generate_id(self.class.name, "COM")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CCOM"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.commission_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -365,11 +365,6 @@ class Customer < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "CUS"
|
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CCUS"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.customer_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_current_booking
|
def get_current_booking
|
||||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||||
|
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and (CASE WHEN checkin_at > '#{DateTime.now.utc}' THEN checkin_at >= '#{DateTime.now.utc}' ELSE checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' END) and checkout_by is null").limit(1) #and checkout_at is null
|
||||||
# booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null
|
# booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_by is null").limit(1) #and checkout_at is null
|
||||||
if booking.count > 0 then
|
if booking.count > 0 then
|
||||||
return booking[0]
|
return booking[0]
|
||||||
@@ -42,7 +43,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_moved_booking
|
def get_moved_booking
|
||||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||||
|
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||||
|
|
||||||
if booking.count > 0 then
|
if booking.count > 0 then
|
||||||
return booking[0]
|
return booking[0]
|
||||||
@@ -68,7 +70,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_current_checkout_booking
|
def get_current_checkout_booking
|
||||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||||
|
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null").limit(1)
|
||||||
if booking.count > 0 then
|
if booking.count > 0 then
|
||||||
return booking[0]
|
return booking[0]
|
||||||
else
|
else
|
||||||
@@ -115,7 +118,8 @@ class DiningFacility < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.get_checkin_booking
|
def self.get_checkin_booking
|
||||||
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
checkin_time_lookup = Lookup.get_checkin_time_limit
|
||||||
|
bookings = Booking.where("booking_status ='assign' and checkin_at between '#{DateTime.now.utc - checkin_time_lookup.hours}' and '#{DateTime.now.utc}' and reserved_by is not null and checkout_by is null")
|
||||||
arr_booking = Array.new
|
arr_booking = Array.new
|
||||||
if bookings
|
if bookings
|
||||||
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
|
||||||
|
|||||||
@@ -21,14 +21,37 @@ class Lookup < ApplicationRecord
|
|||||||
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
|
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
def self.get_checkin_time_limit
|
||||||
|
time_limit = 5
|
||||||
|
|
||||||
|
lookup = Lookup.find_by_lookup_type('checkin_time_limit')
|
||||||
|
if !lookup.nil?
|
||||||
|
time_limit = lookup.value.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
return time_limit
|
||||||
|
end
|
||||||
|
|
||||||
def self.sync_url
|
def self.sync_url
|
||||||
|
url = ""
|
||||||
|
|
||||||
lookup = Lookup.find_by_lookup_type('sync_data')
|
lookup = Lookup.find_by_lookup_type('sync_data')
|
||||||
return lookup.value
|
if !lookup.nil?
|
||||||
|
url = lookup.value
|
||||||
|
end
|
||||||
|
|
||||||
|
return url
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_sync_token
|
def self.get_sync_token
|
||||||
|
token = ""
|
||||||
|
|
||||||
lookup = Lookup.find_by_lookup_type('sync_token')
|
lookup = Lookup.find_by_lookup_type('sync_token')
|
||||||
return lookup.value
|
if !lookup.nil?
|
||||||
|
token = lookup.value
|
||||||
|
end
|
||||||
|
|
||||||
|
return token
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.collection_of(type)
|
def self.collection_of(type)
|
||||||
|
|||||||
@@ -557,13 +557,7 @@ class Order < ApplicationRecord
|
|||||||
private
|
private
|
||||||
|
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
|
self.order_id = SeedGenerator.generate_id(self.class.name, "ODR")
|
||||||
prefix = "ODR"
|
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CODR"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.order_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_order_date
|
def set_order_date
|
||||||
@@ -573,8 +567,11 @@ class Order < ApplicationRecord
|
|||||||
def self.sync_order_records(orders)
|
def self.sync_order_records(orders)
|
||||||
if !orders.nil?
|
if !orders.nil?
|
||||||
orders.each do |o|
|
orders.each do |o|
|
||||||
unless Order.exists?(o['order_id'])
|
order = Order.find_by_order_id(o['order_id'])
|
||||||
|
# unless Order.exists?(o['order_id'])
|
||||||
|
if order.nil?
|
||||||
order = Order.new
|
order = Order.new
|
||||||
|
end
|
||||||
order.order_id = o['order_id']
|
order.order_id = o['order_id']
|
||||||
order.date = o['date']
|
order.date = o['date']
|
||||||
order.source = o['source']
|
order.source = o['source']
|
||||||
@@ -586,9 +583,8 @@ class Order < ApplicationRecord
|
|||||||
order.waiters = o['waiters']
|
order.waiters = o['waiters']
|
||||||
order.guest_info = o['guest_info']
|
order.guest_info = o['guest_info']
|
||||||
order.save
|
order.save
|
||||||
puts '...... order has been created .....'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '...... order sync completed .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,11 @@ class OrderItem < ApplicationRecord
|
|||||||
def self.sync_order_item_records(order_items)
|
def self.sync_order_item_records(order_items)
|
||||||
if !order_items.nil?
|
if !order_items.nil?
|
||||||
order_items.each do |item|
|
order_items.each do |item|
|
||||||
unless OrderItem.exists?(item['order_items_id'])
|
order_item = OrderItem.find_by_order_items_id(item['order_items_id'])
|
||||||
|
# unless OrderItem.exists?(item['order_items_id'])
|
||||||
|
if order_item.nil?
|
||||||
order_item = OrderItem.new
|
order_item = OrderItem.new
|
||||||
|
end
|
||||||
order_item.order_items_id = item['order_items_id']
|
order_item.order_items_id = item['order_items_id']
|
||||||
order_item.order_id = item['order_id']
|
order_item.order_id = item['order_id']
|
||||||
order_item.order_item_status = item['order_item_status']
|
order_item.order_item_status = item['order_item_status']
|
||||||
@@ -87,19 +90,13 @@ class OrderItem < ApplicationRecord
|
|||||||
order_item.taxable = item['taxable']
|
order_item.taxable = item['taxable']
|
||||||
order_item.completed_by = item['completed_by']
|
order_item.completed_by = item['completed_by']
|
||||||
order_item.save
|
order_item.save
|
||||||
puts '...... order item has been created. .....'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '...... order item sync completed. .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "ODI"
|
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CODI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.order_items_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -519,10 +519,6 @@ class OrderReservation < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "ODRS"
|
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "ODRS")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CODRS"
|
|
||||||
end
|
|
||||||
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,11 +27,6 @@ class OrderReservationItem < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "ODRSI"
|
self.order_reservation_items_id = SeedGenerator.generate_id(self.class.name, "ODRSI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CODRSI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.order_reservation_items_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ class Reservation < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "RS"
|
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "RS")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CRS"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,11 +8,6 @@ class ReservationItem < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "RSI"
|
self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CRSI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.reservation_items_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ class Sale < ApplicationRecord
|
|||||||
def self.sync_sale_records(sales)
|
def self.sync_sale_records(sales)
|
||||||
if !sales.nil?
|
if !sales.nil?
|
||||||
sales.each do |s|
|
sales.each do |s|
|
||||||
unless Sale.exists?(s['sale_id'])
|
sale = Sale.find_by_sale_id(s['sale_id'])
|
||||||
|
# unless Sale.exists?(s['sale_id'])
|
||||||
|
if sale.nil?
|
||||||
sale = Sale.new
|
sale = Sale.new
|
||||||
|
end
|
||||||
sale.sale_id = s['sale_id']
|
sale.sale_id = s['sale_id']
|
||||||
sale.cashier_id = s['cashier_id']
|
sale.cashier_id = s['cashier_id']
|
||||||
sale.cashier_name = s['cashier_name']
|
sale.cashier_name = s['cashier_name']
|
||||||
@@ -55,9 +58,8 @@ class Sale < ApplicationRecord
|
|||||||
sale.rebate_status = s['rebate_status']
|
sale.rebate_status = s['rebate_status']
|
||||||
sale.equal_persons = s['equal_persons']
|
sale.equal_persons = s['equal_persons']
|
||||||
sale.save
|
sale.save
|
||||||
puts '........ Sale data has been created .......'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '........ Sale data sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil, current_checkin_induties_count)
|
||||||
@@ -2788,11 +2790,6 @@ end
|
|||||||
private
|
private
|
||||||
|
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "SAL"
|
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CSAL"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sale_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ class SaleAudit < ApplicationRecord
|
|||||||
def self.sync_sale_audit_records(sale_audits)
|
def self.sync_sale_audit_records(sale_audits)
|
||||||
if !sale_audits.nil?
|
if !sale_audits.nil?
|
||||||
sale_audits.each do |sa|
|
sale_audits.each do |sa|
|
||||||
unless SaleAudit.exists?(sa['sale_audit_id'])
|
sale_audit = SaleAudit.find_by_sale_audit_id(sa['sale_audit_id'])
|
||||||
|
# unless SaleAudit.exists?(sa['sale_audit_id'])
|
||||||
|
if sale_audit.nil?
|
||||||
sale_audit = SaleAudit.new
|
sale_audit = SaleAudit.new
|
||||||
|
end
|
||||||
sale_audit.sale_audit_id = sa['sale_audit_id']
|
sale_audit.sale_audit_id = sa['sale_audit_id']
|
||||||
sale_audit.sale_id = sa['sale_id']
|
sale_audit.sale_id = sa['sale_id']
|
||||||
sale_audit.action = sa['action']
|
sale_audit.action = sa['action']
|
||||||
@@ -20,9 +23,8 @@ class SaleAudit < ApplicationRecord
|
|||||||
sale_audit.approved_at = sa['approved_at']
|
sale_audit.approved_at = sa['approved_at']
|
||||||
sale_audit.remark = sa['remark']
|
sale_audit.remark = sa['remark']
|
||||||
sale_audit.save
|
sale_audit.save
|
||||||
puts '....... Sale Audit has been created .......'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '....... Sale Audit sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,11 +176,6 @@ class SaleAudit < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "SAI"
|
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CSAI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ class SaleItem < ApplicationRecord
|
|||||||
def self.sync_sale_item_records(sale_items)
|
def self.sync_sale_item_records(sale_items)
|
||||||
if !sale_items.nil?
|
if !sale_items.nil?
|
||||||
sale_items.each do |si|
|
sale_items.each do |si|
|
||||||
unless SaleItem.exists?(si['sale_item_id'])
|
sale_item = SaleItem.find_by_sale_item_id(si['sale_item_id'])
|
||||||
|
# unless SaleItem.exists?(si['sale_item_id'])
|
||||||
|
if sale_item.nil?
|
||||||
sale_item = SaleItem.new
|
sale_item = SaleItem.new
|
||||||
|
end
|
||||||
sale_item.sale_item_id = si['sale_item_id']
|
sale_item.sale_item_id = si['sale_item_id']
|
||||||
sale_item.sale_id = si['sale_id']
|
sale_item.sale_id = si['sale_id']
|
||||||
sale_item.menu_category_code = si['menu_category_code']
|
sale_item.menu_category_code = si['menu_category_code']
|
||||||
@@ -48,9 +51,8 @@ class SaleItem < ApplicationRecord
|
|||||||
sale_item['price'] = si['price']
|
sale_item['price'] = si['price']
|
||||||
sale_item['is_taxable'] = si['is_taxable']
|
sale_item['is_taxable'] = si['is_taxable']
|
||||||
sale_item.save
|
sale_item.save
|
||||||
puts '....... Sale Item has been created ......'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '....... Sale Item sync completed ......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -221,11 +223,6 @@ class SaleItem < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "SLI"
|
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CSLI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sale_item_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,15 +17,17 @@ class SaleOrder < ApplicationRecord
|
|||||||
def self.sync_sale_order_records(sale_orders)
|
def self.sync_sale_order_records(sale_orders)
|
||||||
if !sale_orders.nil?
|
if !sale_orders.nil?
|
||||||
sale_orders.each do |so|
|
sale_orders.each do |so|
|
||||||
unless SaleOrder.exists?(so['sale_order_id'])
|
sale_order = SaleOrder.find_by_sale_order_id(so['sale_order_id'])
|
||||||
|
# unless SaleOrder.exists?(so['sale_order_id'])
|
||||||
|
if sale_order.nil?
|
||||||
sale_order = SaleOrder.new
|
sale_order = SaleOrder.new
|
||||||
|
end
|
||||||
sale_order.sale_order_id = so['sale_order_id']
|
sale_order.sale_order_id = so['sale_order_id']
|
||||||
sale_order.sale_id = so['sale_id']
|
sale_order.sale_id = so['sale_id']
|
||||||
sale_order.order_id = so['order_id']
|
sale_order.order_id = so['order_id']
|
||||||
sale_order.save
|
sale_order.save
|
||||||
puts '......... Sale Order has been created ........'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '......... Sale Order sync completed ........'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ class SalePayment < ApplicationRecord
|
|||||||
def self.sync_sale_payment_records(sale_payments)
|
def self.sync_sale_payment_records(sale_payments)
|
||||||
if !sale_payments.nil?
|
if !sale_payments.nil?
|
||||||
sale_payments.each do |sp|
|
sale_payments.each do |sp|
|
||||||
unless SalePayment.exists?(sp['sale_payment_id'])
|
payment = SalePayment.find_by_sale_payment_id(sp['sale_payment_id'])
|
||||||
|
# unless SalePayment.exists?(sp['sale_payment_id'])
|
||||||
|
if payment.nil?
|
||||||
payment = SalePayment.new
|
payment = SalePayment.new
|
||||||
|
end
|
||||||
payment.sale_payment_id = sp['sale_payment_id']
|
payment.sale_payment_id = sp['sale_payment_id']
|
||||||
payment.sale_id = sp['sale_id']
|
payment.sale_id = sp['sale_id']
|
||||||
payment.payment_method = sp['payment_method']
|
payment.payment_method = sp['payment_method']
|
||||||
@@ -21,9 +24,8 @@ class SalePayment < ApplicationRecord
|
|||||||
payment.payment_reference = sp['payment_reference']
|
payment.payment_reference = sp['payment_reference']
|
||||||
payment.payment_status = sp['payment_status']
|
payment.payment_status = sp['payment_status']
|
||||||
payment.save
|
payment.save
|
||||||
puts '....... Sale Payment has been created ......'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '....... Sale Payment sync completed ......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1002,11 +1004,6 @@ class SalePayment < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "SPI"
|
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CSPI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ class SaleTax < ApplicationRecord
|
|||||||
def self.sync_sale_tax_records(sale_taxes)
|
def self.sync_sale_tax_records(sale_taxes)
|
||||||
if !sale_taxes.nil?
|
if !sale_taxes.nil?
|
||||||
sale_taxes.each do |t|
|
sale_taxes.each do |t|
|
||||||
unless SaleTax.exists?(t['sale_tax_id'])
|
tax = SaleTax.find_by_sale_tax_id(t['sale_tax_id'])
|
||||||
|
# unless SaleTax.exists?(t['sale_tax_id'])
|
||||||
|
if tax.nil?
|
||||||
tax = SaleTax.new
|
tax = SaleTax.new
|
||||||
|
end
|
||||||
tax.sale_tax_id = t['sale_tax_id']
|
tax.sale_tax_id = t['sale_tax_id']
|
||||||
tax.sale_id = t['sale_id']
|
tax.sale_id = t['sale_id']
|
||||||
tax.tax_name = t['tax_name']
|
tax.tax_name = t['tax_name']
|
||||||
@@ -17,9 +20,8 @@ class SaleTax < ApplicationRecord
|
|||||||
tax.tax_payable_amount = t['tax_payable_amount']
|
tax.tax_payable_amount = t['tax_payable_amount']
|
||||||
tax.inclusive = t['inclusive']
|
tax.inclusive = t['inclusive']
|
||||||
tax.save
|
tax.save
|
||||||
puts '...... Sale Tax has been created .....'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
puts '...... Sale Tax sync completed .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -32,11 +34,6 @@ class SaleTax < ApplicationRecord
|
|||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
prefix = "STI"
|
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI")
|
||||||
if ENV["SERVER_MODE"] == 'cloud'
|
|
||||||
prefix = "CSTI"
|
|
||||||
end
|
|
||||||
|
|
||||||
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, prefix)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ class SeedGenerator < ApplicationRecord
|
|||||||
def self.generate_id(model, prefix)
|
def self.generate_id(model, prefix)
|
||||||
model_name = self.get_model_name(model)
|
model_name = self.get_model_name(model)
|
||||||
|
|
||||||
|
if ENV["SERVER_MODE"] == 'cloud'
|
||||||
|
prefix = "C#{prefix}"
|
||||||
|
end
|
||||||
|
|
||||||
cur_val, next_val = self.update_seed(model_name)
|
cur_val, next_val = self.update_seed(model_name)
|
||||||
|
|
||||||
if (cur_val == 0)
|
if (cur_val == 0)
|
||||||
@@ -14,6 +18,23 @@ class SeedGenerator < ApplicationRecord
|
|||||||
return saleOrderId
|
return saleOrderId
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.sync_seed_generator_records(seed_generators)
|
||||||
|
if !seed_generators.nil?
|
||||||
|
seed_generators.each do |sg|
|
||||||
|
seed = SeedGenerator.find_by_model(sg['model'])
|
||||||
|
if seed.nil?
|
||||||
|
seed = SeedGenerator.new
|
||||||
|
end
|
||||||
|
seed.model = sg['model']
|
||||||
|
seed.increase_by = sg['increase_by']
|
||||||
|
seed.current = sg['current']
|
||||||
|
seed.next = sg['next']
|
||||||
|
seed.save
|
||||||
|
end
|
||||||
|
puts '....... Seed Generator sync completed! .......'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Generate Receipt No for number order (1,2,3) Don't touch
|
# Generate Receipt No for number order (1,2,3) Don't touch
|
||||||
def self.new_receipt_no
|
def self.new_receipt_no
|
||||||
seed = SeedGenerator.find_by_model("Sale")
|
seed = SeedGenerator.find_by_model("Sale")
|
||||||
|
|||||||
@@ -35,19 +35,18 @@ class ShiftSale < ApplicationRecord
|
|||||||
def self.sync_shift_sale_records(shift_sales)
|
def self.sync_shift_sale_records(shift_sales)
|
||||||
if !shift_sales.nil?
|
if !shift_sales.nil?
|
||||||
shift_sales.each do |ss|
|
shift_sales.each do |ss|
|
||||||
status = nil
|
# status = nil
|
||||||
shift_sale = nil
|
shift_sale = nil
|
||||||
|
|
||||||
if ShiftSale.exists?(ss['id'])
|
# if ShiftSale.exists?(ss['id'])
|
||||||
shift_sale = ShiftSale.find(ss['id'])
|
shift_sale = ShiftSale.find(ss['id'])
|
||||||
status = 'updated'
|
# status = 'updated'
|
||||||
else
|
if shift_sale.nil?
|
||||||
shift_sale = ShiftSale.new
|
shift_sale = ShiftSale.new
|
||||||
shift_sale.id = ss['id']
|
# status = 'created'
|
||||||
|
|
||||||
status = 'created'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shift_sale.id = ss['id']
|
||||||
shift_sale.cashier_terminal_id = ss['cashier_terminal_id']
|
shift_sale.cashier_terminal_id = ss['cashier_terminal_id']
|
||||||
shift_sale.shift_started_at = ss['shift_started_at']
|
shift_sale.shift_started_at = ss['shift_started_at']
|
||||||
shift_sale.shift_closed_at = ss['shift_closed_at']
|
shift_sale.shift_closed_at = ss['shift_closed_at']
|
||||||
@@ -73,8 +72,8 @@ class ShiftSale < ApplicationRecord
|
|||||||
shift_sale.total_void = ss['total_void']
|
shift_sale.total_void = ss['total_void']
|
||||||
shift_sale.save
|
shift_sale.save
|
||||||
|
|
||||||
puts "....... Shift Sale has been #{status} ......"
|
|
||||||
end
|
end
|
||||||
|
puts "....... Shift Sale sync completed ......"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
json.status = true
|
json.status true
|
||||||
json.message = 'Data successfully Sync'
|
json.message "Sync Record Completed."
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
application_path="#{File.expand_path("../..", __FILE__)}"
|
application_path="#{File.expand_path("../..", __FILE__)}"
|
||||||
directory application_path
|
directory application_path
|
||||||
environment ENV.fetch("RAILS_ENV") { "production" }
|
#environment ENV.fetch("RAILS_ENV") { "production" }
|
||||||
environment "production"
|
environment "production"
|
||||||
pidfile "#{application_path}/tmp/puma/pid"
|
pidfile "#{application_path}/tmp/puma/pid"
|
||||||
state_path "#{application_path}/tmp/puma/state"
|
state_path "#{application_path}/tmp/puma/state"
|
||||||
|
|||||||
Reference in New Issue
Block a user