before sync
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,11 +119,12 @@ authorize_resource :class => false
|
|||||||
|
|
||||||
puts url
|
puts url
|
||||||
puts response
|
puts response
|
||||||
end
|
@message = @result.parsed_response['message']
|
||||||
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -9,20 +9,22 @@ 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
|
||||||
order_item.assigned_order_item_id = item['assigned_order_item_id']
|
|
||||||
order_item.item_code = item['item_code']
|
|
||||||
order_item.instance_code = item['instance_code']
|
|
||||||
order_item.order_queue_station_id = item['order_queue_station_id']
|
|
||||||
order_item.order_id = item['order_id']
|
|
||||||
order_item.print_status = item['print_status']
|
|
||||||
order_item.delivery_status = item['delivery_status']
|
|
||||||
order_item.save
|
|
||||||
puts '....... Assigned Order Item has been created .......'
|
|
||||||
end
|
end
|
||||||
|
order_item.assigned_order_item_id = item['assigned_order_item_id']
|
||||||
|
order_item.item_code = item['item_code']
|
||||||
|
order_item.instance_code = item['instance_code']
|
||||||
|
order_item.order_queue_station_id = item['order_queue_station_id']
|
||||||
|
order_item.order_id = item['order_id']
|
||||||
|
order_item.print_status = item['print_status']
|
||||||
|
order_item.delivery_status = item['delivery_status']
|
||||||
|
order_item.save
|
||||||
end
|
end
|
||||||
|
puts '....... Assigned Order Item sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,24 +14,26 @@ 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
|
||||||
booking.booking_id = b['booking_id']
|
|
||||||
booking.dining_facility_id = b['dining_facility_id']
|
|
||||||
# booking.type = b['type']
|
|
||||||
booking.checkin_at = b['checkin_at']
|
|
||||||
booking.checkin_by = b['checkin_by']
|
|
||||||
booking.checkout_at = b['checkout_at']
|
|
||||||
booking.checkout_by = b['checkout_by']
|
|
||||||
booking.reserved_at = b['reserved_at']
|
|
||||||
booking.reserved_by = b['reserved_by']
|
|
||||||
booking.booking_status = b['booking_status']
|
|
||||||
booking.sale_id = b['sale_id']
|
|
||||||
booking.customer_id = b['customer_id']
|
|
||||||
booking.save
|
|
||||||
puts '....... Booking has been created ......'
|
|
||||||
end
|
end
|
||||||
|
booking.booking_id = b['booking_id']
|
||||||
|
booking.dining_facility_id = b['dining_facility_id']
|
||||||
|
# booking.type = b['type']
|
||||||
|
booking.checkin_at = b['checkin_at']
|
||||||
|
booking.checkin_by = b['checkin_by']
|
||||||
|
booking.checkout_at = b['checkout_at']
|
||||||
|
booking.checkout_by = b['checkout_by']
|
||||||
|
booking.reserved_at = b['reserved_at']
|
||||||
|
booking.reserved_by = b['reserved_by']
|
||||||
|
booking.booking_status = b['booking_status']
|
||||||
|
booking.sale_id = b['sale_id']
|
||||||
|
booking.customer_id = b['customer_id']
|
||||||
|
booking.save
|
||||||
end
|
end
|
||||||
|
puts '....... Booking sync completed ......'
|
||||||
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)
|
||||||
|
|||||||
@@ -573,22 +573,24 @@ 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
|
||||||
order.order_id = o['order_id']
|
|
||||||
order.date = o['date']
|
|
||||||
order.source = o['source']
|
|
||||||
order.order_type = o['order_type']
|
|
||||||
order.customer_id = o['customer_id']
|
|
||||||
order.item_count = o['item_count']
|
|
||||||
order.quantity_count = o['quantity_count']
|
|
||||||
order.status = o['status']
|
|
||||||
order.waiters = o['waiters']
|
|
||||||
order.guest_info = o['guest_info']
|
|
||||||
order.save
|
|
||||||
puts '...... order has been created .....'
|
|
||||||
end
|
end
|
||||||
|
order.order_id = o['order_id']
|
||||||
|
order.date = o['date']
|
||||||
|
order.source = o['source']
|
||||||
|
order.order_type = o['order_type']
|
||||||
|
order.customer_id = o['customer_id']
|
||||||
|
order.item_count = o['item_count']
|
||||||
|
order.quantity_count = o['quantity_count']
|
||||||
|
order.status = o['status']
|
||||||
|
order.waiters = o['waiters']
|
||||||
|
order.guest_info = o['guest_info']
|
||||||
|
order.save
|
||||||
end
|
end
|
||||||
|
puts '...... order sync completed .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -68,28 +68,30 @@ 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
|
||||||
order_item.order_items_id = item['order_items_id']
|
|
||||||
order_item.order_id = item['order_id']
|
|
||||||
order_item.order_item_status = item['order_item_status']
|
|
||||||
order_item.item_order_by = item['item_order_by']
|
|
||||||
order_item.item_code = item['item_code']
|
|
||||||
order_item.item_instance_code = item['item_instance_code']
|
|
||||||
order_item.item_name = item['item_name']
|
|
||||||
order_item.alt_name = item['alt_name']
|
|
||||||
order_item.account_id = item['account_id']
|
|
||||||
order_item.qty = item['qty']
|
|
||||||
order_item.price = item['price']
|
|
||||||
order_item.remark = item['remark']
|
|
||||||
order_item.options = item['options']
|
|
||||||
order_item.set_menu_items = item['set_menu_items']
|
|
||||||
order_item.taxable = item['taxable']
|
|
||||||
order_item.completed_by = item['completed_by']
|
|
||||||
order_item.save
|
|
||||||
puts '...... order item has been created. .....'
|
|
||||||
end
|
end
|
||||||
|
order_item.order_items_id = item['order_items_id']
|
||||||
|
order_item.order_id = item['order_id']
|
||||||
|
order_item.order_item_status = item['order_item_status']
|
||||||
|
order_item.item_order_by = item['item_order_by']
|
||||||
|
order_item.item_code = item['item_code']
|
||||||
|
order_item.item_instance_code = item['item_instance_code']
|
||||||
|
order_item.item_name = item['item_name']
|
||||||
|
order_item.alt_name = item['alt_name']
|
||||||
|
order_item.account_id = item['account_id']
|
||||||
|
order_item.qty = item['qty']
|
||||||
|
order_item.price = item['price']
|
||||||
|
order_item.remark = item['remark']
|
||||||
|
order_item.options = item['options']
|
||||||
|
order_item.set_menu_items = item['set_menu_items']
|
||||||
|
order_item.taxable = item['taxable']
|
||||||
|
order_item.completed_by = item['completed_by']
|
||||||
|
order_item.save
|
||||||
end
|
end
|
||||||
|
puts '...... order item sync completed. .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -30,35 +30,37 @@ 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
|
||||||
sale.sale_id = s['sale_id']
|
|
||||||
sale.cashier_id = s['cashier_id']
|
|
||||||
sale.cashier_name = s['cashier_name']
|
|
||||||
sale.requested_by = s['requested_by']
|
|
||||||
sale.requested_at = s['requested_at']
|
|
||||||
sale.receipt_no = s['receipt_no']
|
|
||||||
sale.receipt_date = s['receipt_date']
|
|
||||||
sale.customer_id = s['customer_id']
|
|
||||||
sale.payment_status = s['payment_status']
|
|
||||||
sale.sale_status = s['sale_status']
|
|
||||||
sale.total_amount = s['total_amount']
|
|
||||||
sale.discount_type = s['discount_type']
|
|
||||||
sale.total_tax = s['total_tax']
|
|
||||||
sale.total_discount = s['total_discount']
|
|
||||||
sale.tax_type = s['tax_type']
|
|
||||||
sale.grand_total = s['grand_total']
|
|
||||||
sale.rounding_adjustment = s['rounding_adjustment']
|
|
||||||
sale.amount_received = s['amount_received']
|
|
||||||
sale.amount_changed = s['amount_changed']
|
|
||||||
sale.shift_sale_id = s['shift_sale_id']
|
|
||||||
sale.old_grand_total = s['old_grand_total']
|
|
||||||
sale.rebate_status = s['rebate_status']
|
|
||||||
sale.equal_persons = s['equal_persons']
|
|
||||||
sale.save
|
|
||||||
puts '........ Sale data has been created .......'
|
|
||||||
end
|
end
|
||||||
|
sale.sale_id = s['sale_id']
|
||||||
|
sale.cashier_id = s['cashier_id']
|
||||||
|
sale.cashier_name = s['cashier_name']
|
||||||
|
sale.requested_by = s['requested_by']
|
||||||
|
sale.requested_at = s['requested_at']
|
||||||
|
sale.receipt_no = s['receipt_no']
|
||||||
|
sale.receipt_date = s['receipt_date']
|
||||||
|
sale.customer_id = s['customer_id']
|
||||||
|
sale.payment_status = s['payment_status']
|
||||||
|
sale.sale_status = s['sale_status']
|
||||||
|
sale.total_amount = s['total_amount']
|
||||||
|
sale.discount_type = s['discount_type']
|
||||||
|
sale.total_tax = s['total_tax']
|
||||||
|
sale.total_discount = s['total_discount']
|
||||||
|
sale.tax_type = s['tax_type']
|
||||||
|
sale.grand_total = s['grand_total']
|
||||||
|
sale.rounding_adjustment = s['rounding_adjustment']
|
||||||
|
sale.amount_received = s['amount_received']
|
||||||
|
sale.amount_changed = s['amount_changed']
|
||||||
|
sale.shift_sale_id = s['shift_sale_id']
|
||||||
|
sale.old_grand_total = s['old_grand_total']
|
||||||
|
sale.rebate_status = s['rebate_status']
|
||||||
|
sale.equal_persons = s['equal_persons']
|
||||||
|
sale.save
|
||||||
end
|
end
|
||||||
|
puts '........ Sale data sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,20 +9,22 @@ 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
|
||||||
sale_audit.sale_audit_id = sa['sale_audit_id']
|
|
||||||
sale_audit.sale_id = sa['sale_id']
|
|
||||||
sale_audit.action = sa['action']
|
|
||||||
sale_audit.action_at = sa['action_at']
|
|
||||||
sale_audit.action_by = sa['action_by']
|
|
||||||
sale_audit.approved_by = sa['approved_by']
|
|
||||||
sale_audit.approved_at = sa['approved_at']
|
|
||||||
sale_audit.remark = sa['remark']
|
|
||||||
sale_audit.save
|
|
||||||
puts '....... Sale Audit has been created .......'
|
|
||||||
end
|
end
|
||||||
|
sale_audit.sale_audit_id = sa['sale_audit_id']
|
||||||
|
sale_audit.sale_id = sa['sale_id']
|
||||||
|
sale_audit.action = sa['action']
|
||||||
|
sale_audit.action_at = sa['action_at']
|
||||||
|
sale_audit.action_by = sa['action_by']
|
||||||
|
sale_audit.approved_by = sa['approved_by']
|
||||||
|
sale_audit.approved_at = sa['approved_at']
|
||||||
|
sale_audit.remark = sa['remark']
|
||||||
|
sale_audit.save
|
||||||
end
|
end
|
||||||
|
puts '....... Sale Audit sync completed .......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -29,28 +29,30 @@ 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
|
||||||
sale_item.sale_item_id = si['sale_item_id']
|
|
||||||
sale_item.sale_id = si['sale_id']
|
|
||||||
sale_item.menu_category_code = si['menu_category_code']
|
|
||||||
sale_item.menu_category_name = si['menu_category_name']
|
|
||||||
sale_item.product_code = si['product_code']
|
|
||||||
sale_item.product_name = si['product_name']
|
|
||||||
sale_item.product_alt_name = si['product_alt_name']
|
|
||||||
sale_item.item_instance_code = si['item_instance_code']
|
|
||||||
sale_item.account_id = si['account_id']
|
|
||||||
sale_item.status = si['status']
|
|
||||||
sale_item['remark'] = si['remark']
|
|
||||||
sale_item['qty'] = si['qty']
|
|
||||||
sale_item['unit_price'] = si['unit_price']
|
|
||||||
sale_item['taxable_price'] = si['taxable_price']
|
|
||||||
sale_item['price'] = si['price']
|
|
||||||
sale_item['is_taxable'] = si['is_taxable']
|
|
||||||
sale_item.save
|
|
||||||
puts '....... Sale Item has been created ......'
|
|
||||||
end
|
end
|
||||||
end
|
sale_item.sale_item_id = si['sale_item_id']
|
||||||
|
sale_item.sale_id = si['sale_id']
|
||||||
|
sale_item.menu_category_code = si['menu_category_code']
|
||||||
|
sale_item.menu_category_name = si['menu_category_name']
|
||||||
|
sale_item.product_code = si['product_code']
|
||||||
|
sale_item.product_name = si['product_name']
|
||||||
|
sale_item.product_alt_name = si['product_alt_name']
|
||||||
|
sale_item.item_instance_code = si['item_instance_code']
|
||||||
|
sale_item.account_id = si['account_id']
|
||||||
|
sale_item.status = si['status']
|
||||||
|
sale_item['remark'] = si['remark']
|
||||||
|
sale_item['qty'] = si['qty']
|
||||||
|
sale_item['unit_price'] = si['unit_price']
|
||||||
|
sale_item['taxable_price'] = si['taxable_price']
|
||||||
|
sale_item['price'] = si['price']
|
||||||
|
sale_item['is_taxable'] = si['is_taxable']
|
||||||
|
sale_item.save
|
||||||
|
end
|
||||||
|
puts '....... Sale Item sync completed ......'
|
||||||
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
|
||||||
sale_order.sale_order_id = so['sale_order_id']
|
|
||||||
sale_order.sale_id = so['sale_id']
|
|
||||||
sale_order.order_id = so['order_id']
|
|
||||||
sale_order.save
|
|
||||||
puts '......... Sale Order has been created ........'
|
|
||||||
end
|
end
|
||||||
|
sale_order.sale_order_id = so['sale_order_id']
|
||||||
|
sale_order.sale_id = so['sale_id']
|
||||||
|
sale_order.order_id = so['order_id']
|
||||||
|
sale_order.save
|
||||||
end
|
end
|
||||||
|
puts '......... Sale Order sync completed ........'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,19 +11,21 @@ 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
|
||||||
payment.sale_payment_id = sp['sale_payment_id']
|
|
||||||
payment.sale_id = sp['sale_id']
|
|
||||||
payment.payment_method = sp['payment_method']
|
|
||||||
payment.payment_amount = sp['payment_amount']
|
|
||||||
payment.outstanding_amount = sp['outstanding_amount']
|
|
||||||
payment.payment_reference = sp['payment_reference']
|
|
||||||
payment.payment_status = sp['payment_status']
|
|
||||||
payment.save
|
|
||||||
puts '....... Sale Payment has been created ......'
|
|
||||||
end
|
end
|
||||||
|
payment.sale_payment_id = sp['sale_payment_id']
|
||||||
|
payment.sale_id = sp['sale_id']
|
||||||
|
payment.payment_method = sp['payment_method']
|
||||||
|
payment.payment_amount = sp['payment_amount']
|
||||||
|
payment.outstanding_amount = sp['outstanding_amount']
|
||||||
|
payment.payment_reference = sp['payment_reference']
|
||||||
|
payment.payment_status = sp['payment_status']
|
||||||
|
payment.save
|
||||||
end
|
end
|
||||||
|
puts '....... Sale Payment sync completed ......'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,18 +8,20 @@ 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
|
||||||
tax.sale_tax_id = t['sale_tax_id']
|
|
||||||
tax.sale_id = t['sale_id']
|
|
||||||
tax.tax_name = t['tax_name']
|
|
||||||
tax.tax_rate = t['tax_rate']
|
|
||||||
tax.tax_payable_amount = t['tax_payable_amount']
|
|
||||||
tax.inclusive = t['inclusive']
|
|
||||||
tax.save
|
|
||||||
puts '...... Sale Tax has been created .....'
|
|
||||||
end
|
end
|
||||||
|
tax.sale_tax_id = t['sale_tax_id']
|
||||||
|
tax.sale_id = t['sale_id']
|
||||||
|
tax.tax_name = t['tax_name']
|
||||||
|
tax.tax_rate = t['tax_rate']
|
||||||
|
tax.tax_payable_amount = t['tax_payable_amount']
|
||||||
|
tax.inclusive = t['inclusive']
|
||||||
|
tax.save
|
||||||
end
|
end
|
||||||
|
puts '...... Sale Tax sync completed .....'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,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."
|
||||||
Reference in New Issue
Block a user