fix conflict

This commit is contained in:
Myat Zin Wai Maw
2019-06-20 15:22:06 +06:30
32 changed files with 585 additions and 80 deletions

View File

@@ -43,7 +43,7 @@ class Api::BillController < Api::ApiController
if booking
if booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source)
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
@sale_data = Sale.find_by_sale_id(@sale_id)
else
@status = true
@@ -177,7 +177,7 @@ class Api::BillController < Api::ApiController
if @booking.sale_id.nil?
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_booking(@booking.booking_id, current_login_employee, cashier, order.source)
@status, @sale_id = @sale.generate_invoice_from_booking(@booking.booking_id, current_login_employee, cashier, order.source,params[:current_checkin_induties_count])
@sale_data = Sale.find_by_sale_id(@sale_id)
else
@status = true

View File

@@ -0,0 +1,17 @@
class Api::SyncController < Api::ApiController
def sync_data
# Here comes to save the sync records.
Order.sync_order_records(params[:orders])
OrderItem.sync_order_item_records(params[:order_items])
SaleOrder.sync_sale_order_records(params[:sale_orders])
Sale.sync_sale_records(params[:sales])
SaleItem.sync_sale_item_records(params[:sale_items])
SaleAudit.sync_sale_audit_records(params[:sale_audits])
SalePayment.sync_sale_payment_records(params[:sale_payments])
SaleTax.sync_sale_tax_records(params[:sale_taxes])
ShiftSale.sync_shift_sale_records(params[:shift_sales])
Booking.sync_booking_records(params[:bookings])
AssignedOrderItem.sync_assigned_order_item_records(params[:assigned_order_items])
end
end

View File

@@ -120,7 +120,7 @@ class Origami::SplitBillController < BaseOrigamiController
if booking
if booking.sale_id.nil?
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type)
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, current_user, cashier_type,params[:current_checkin_induties_count])
sale_data = Sale.find_by_sale_id(sale_id)
else
status = true
@@ -333,7 +333,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type)
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user, cashier_type ,params[:current_checkin_induties_count])
end
Promotion.promo_activate(sale)

View File

@@ -69,5 +69,60 @@ authorize_resource :class => false
format.json { render json: out }
end
end
def sync_data
@orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales = Booking.get_sync_data(params[:sale_id])
# Here comes to call the sync api
# url = "http://192.168.1.176:3000/en/api/sync_data"
url = Lookup.sync_url
token = Lookup.get_sync_token
# token = Lookup.token
unless url.nil? and token.nil?
begin
@result = HTTParty.post(url.to_str,
:body => { :orders => @orders,
:order_items => @order_items,
:sale_orders => @sale_orders,
:sale => @sales,
:sale_items => @sale_items,
:sale_audits => @sale_audits,
:sale_payments => @sale_payments,
:sale_taxes => @sale_taxes,
:bookings => @bookings,
:assigned_order_items => @assigned_order_items,
:shift_sales => @shift_sales
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Authorization' => "Bearer #{token}"
}, :timeout => 10,
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
:verify => false )
rescue HTTParty::Error
response = { status: false, message: "Can't open membership server "}
rescue Net::OpenTimeout
response = { status: false, message: "Can't open membership server "}
rescue OpenURI::HTTPError
puts "Fire in here"
response = { status: false, message: "Can't open membership server "}
rescue SocketError
response = { status: false, message: "Can't open server "}
rescue Errno::EHOSTDOWN
response = { status: false, message: "Can't open server "}
rescue Errno::ECONNREFUSED, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
response = { status: false, message: "Can't open membership server"}
end
puts url
puts response
end
respond_to do |format|
format.html { redirect_to '/en/reports/receipt_no/', notice: 'Sync Record Completed.'}
end
end
end

View File

@@ -7,6 +7,25 @@ class AssignedOrderItem < ApplicationRecord
belongs_to :order
belongs_to :order_queue_station
def self.sync_assigned_order_item_records(assigned_order_items)
if !assigned_order_items.nil?
assigned_order_items.each do |items|
unless AssignedOrderItem.exists?(items['assigned_order_item_id'])
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
end
end
def self.assigned_order_item (order, item_code, instance_code, order_queue_station )
assigned_order_item = AssignedOrderItem.new()
assigned_order_item.order = order
@@ -43,6 +62,11 @@ class AssignedOrderItem < ApplicationRecord
private
def generate_custom_id
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
prefix = "AOI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CAOI"
end
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -11,6 +11,30 @@ class Booking < ApplicationRecord
scope :active, -> {where("booking_status != 'moved'")}
scope :today, -> {where("created_at >= #{Time.now.utc}")}
def self.sync_booking_records(bookings)
if !bookings.nil?
bookings.each do |b|
unless TableBooking.exists?(b['booking_id'])
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
end
end
def self.update_dining_facility(booking_arr, newd, old)
table = DiningFacility.find(newd)
exist = table.get_booking
@@ -60,8 +84,47 @@ class Booking < ApplicationRecord
.order("sale_id DESC")
end
def self.get_sync_data(sale_id)
@orders = Order.select('orders.*')
.joins('left join sale_orders on sale_orders.order_id = orders.order_id')
.where('sale_orders.sale_id=?', sale_id)
@order_items = OrderItem.select('order_items.*')
.joins('left join sale_orders on sale_orders.order_id = order_items.order_id')
.where('sale_orders.sale_id=?', sale_id)
@assigned_order_items = AssignedOrderItem.select('assigned_order_items.*')
.joins('left join sale_orders on sale_orders.order_id=assigned_order_items.order_id')
.where('sale_orders.sale_id=?', sale_id)
@bookings = TableBooking.where('sale_id=?', sale_id)
@sales = Sale.where("sale_id=?", sale_id)
@sale_items = SaleItem.where("sale_id=?", sale_id)
@sale_taxes = SaleTax.where("sale_id=?", sale_id)
@sale_orders = SaleOrder.where("sale_id=?", sale_id)
@sale_audits = SaleAudit.where("sale_id=?", sale_id)
@sale_payments = SalePayment.where("sale_id=?", sale_id)
@shift_sales = ShiftSale.select('shift_sales.*')
.joins('left join sales on sales.shift_sale_id = shift_sales.id')
.where('sales.sale_id=?', sale_id)
return @orders, @order_items, @sales, @sale_items, @sale_taxes, @sale_payments, @sale_orders, @sale_audits, @bookings, @assigned_order_items, @shift_sales
end
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
prefix = "BKI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CBKI"
end
self.booking_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -6,6 +6,11 @@ class CashierLoginLog < ApplicationRecord
private
def generate_custom_id
self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO")
prefix = "CLO"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CCLO"
end
self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end
end

View File

@@ -13,6 +13,11 @@ class Commission < ApplicationRecord
scope :active, -> {where(is_active: true)}
private
def generate_custom_id
self.commission_id = SeedGenerator.generate_id(self.class.name, 'COM')
prefix = "COM"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CCOM"
end
self.commission_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -365,6 +365,11 @@ class Customer < ApplicationRecord
private
def generate_custom_id
self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS")
prefix = "CUS"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CCUS"
end
self.customer_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -21,6 +21,16 @@ class Lookup < ApplicationRecord
# Lookup.select("value, name").where("lookup_type = ?", lookup_type ).order("name asc").map { |r| [r.name, r.value] }
# end
def self.sync_url
lookup = Lookup.find_by_lookup_type('sync_data')
return lookup.value
end
def self.get_sync_token
lookup = Lookup.find_by_lookup_type('sync_token')
return lookup.value
end
def self.collection_of(type)
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }

View File

@@ -550,14 +550,46 @@ class Order < ApplicationRecord
return false
end
def self.env
return ENV["SERVER_MODE"]
end
private
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
def set_order_date
self.date = Time.now.utc
end
def self.sync_order_records(orders)
if !orders.nil?
orders.each do |o|
unless Order.exists?(o['order_id'])
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
end
end
end

View File

@@ -65,8 +65,41 @@ class OrderItem < ApplicationRecord
return order_details
end
def self.sync_order_item_records(order_items)
if !order_items.nil?
order_items.each do |item|
unless OrderItem.exists?(item['order_items_id'])
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
end
end
private
def generate_custom_id
self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI")
prefix = "ODI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CODI"
end
self.order_items_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -519,6 +519,10 @@ class OrderReservation < ApplicationRecord
private
def generate_custom_id
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "ODRS")
prefix = "ODRS"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CODRS"
end
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -27,6 +27,11 @@ class OrderReservationItem < ApplicationRecord
private
def generate_custom_id
self.order_reservation_items_id = SeedGenerator.generate_id(self.class.name, "ODRSI")
prefix = "ODRSI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CODRSI"
end
self.order_reservation_items_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -85,11 +85,11 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
filename = "tmp/reports_sale_items.pdf"
if print_settings.unique_code == "SaleItemsPdf"
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges, nil, nil, nil)
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
puts 'Printing!!!!'
end
if print_settings.unique_code == "SaleItemsStarPdf"
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges, nil, nil, nil)
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
puts 'PrintingStar!!!!'
end

View File

@@ -10,6 +10,11 @@ class Reservation < ApplicationRecord
private
def generate_custom_id
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "RS")
prefix = "RS"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CRS"
end
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -7,7 +7,12 @@ class ReservationItem < ApplicationRecord
belongs_to :reservation, autosave: true
private
def generate_custom_id
self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI")
end
def generate_custom_id
prefix = "RSI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CRSI"
end
self.reservation_items_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -26,7 +26,40 @@ class Sale < ApplicationRecord
}
SALE_STATUS_OUTSTANDING = "outstanding"
SALE_STATUS_COMPLETED = "completed"
def self.sync_sale_records(sales)
if !sales.nil?
sales.each do |s|
unless Sale.exists?(s['sale_id'])
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
end
end
def generate_invoice_from_booking(booking_id, requested_by, cashier, order_source = nil, current_checkin_induties_count)
booking = Booking.find(booking_id)
status = false
@@ -2755,6 +2788,11 @@ end
private
def generate_custom_id
self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL")
prefix = "SAL"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CSAL"
end
self.sale_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -6,6 +6,26 @@ class SaleAudit < ApplicationRecord
belongs_to :sale
def self.sync_sale_audit_records(sale_audits)
if !sale_audits.nil?
sale_audits.each do |sa|
unless SaleAudit.exists?(sa['sale_audit_id'])
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
end
end
def self.record_audit_void(sale_id, void_by, approved_by, reason)
#sale_audit
sale_audit = SaleAudit.new()
@@ -154,6 +174,11 @@ class SaleAudit < ApplicationRecord
private
def generate_custom_id
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI")
prefix = "SAI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CSAI"
end
self.sale_audit_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -26,6 +26,34 @@ class SaleItem < ApplicationRecord
end
end
def self.sync_sale_item_records(sale_items)
if !sale_items.nil?
sale_items.each do |si|
unless SaleItem.exists?(si['sale_item_id'])
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
end
def self.update_existing_item(qty, item, sale_id, type, item_price, price)
# Original Item to add remark
item.status = type
@@ -193,6 +221,11 @@ class SaleItem < ApplicationRecord
private
def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
prefix = "SLI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CSLI"
end
self.sale_item_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -14,10 +14,30 @@ class SaleOrder < ApplicationRecord
sale_order.save!
end
def self.sync_sale_order_records(sale_orders)
if !sale_orders.nil?
sale_orders.each do |so|
unless SaleOrder.exists?(so['sale_order_id'])
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
end
end
private
def generate_sale_order_id
prefix = "SOI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CSOI"
end
self.class.name
saleOrderId = SeedGenerator.generate_id(self.class.name, "SOI")
saleOrderId = SeedGenerator.generate_id(self.class.name, prefix)
self.sale_order_id = saleOrderId
end
end

View File

@@ -8,6 +8,25 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
def self.sync_sale_payment_records(sale_payments)
if !sale_payments.nil?
sale_payments.each do |sp|
unless SalePayment.exists?(sp['sale_payment_id'])
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
end
end
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
self.sale = invoice
self.received_amount = cash_amount
@@ -983,6 +1002,11 @@ class SalePayment < ApplicationRecord
private
def generate_custom_id
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI")
prefix = "SPI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CSPI"
end
self.sale_payment_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -5,6 +5,24 @@ class SaleTax < ApplicationRecord
before_create :generate_custom_id
belongs_to :sale
def self.sync_sale_tax_records(sale_taxes)
if !sale_taxes.nil?
sale_taxes.each do |t|
unless SaleTax.exists?(t['sale_tax_id'])
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
end
end
def self.get_tax(from,to)
query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount")
.joins("join sales on sales.sale_id = sale_taxes.sale_id")
@@ -14,6 +32,11 @@ class SaleTax < ApplicationRecord
private
def generate_custom_id
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI")
prefix = "STI"
if ENV["SERVER_MODE"] == 'cloud'
prefix = "CSTI"
end
self.sale_tax_id = SeedGenerator.generate_id(self.class.name, prefix)
end
end

View File

@@ -1,15 +1,17 @@
class SeedGenerator < ApplicationRecord
# Generate ID for Tables
def self.generate_id(model, prefix)
cur_val, next_val = self.update_seed(model)
model_name = self.get_model_name(model)
cur_val, next_val = self.update_seed(model_name)
if (cur_val == 0)
cur_val, next_val = self.execute_query(model)
end
cur_val, next_val = self.execute_query(model_name)
end
padding_len = 15 - prefix.length
saleOrderId = prefix +"-"+ cur_val.to_s.to_s.rjust((14-prefix.length)+1,'0')
return saleOrderId
return saleOrderId
end
# Generate Receipt No for number order (1,2,3) Don't touch
@@ -66,6 +68,17 @@ class SeedGenerator < ApplicationRecord
# return next_code
# end
def self.get_model_name(model)
model_name = ""
if ENV["SERVER_MODE"] == 'cloud'
model_name = "Cloud#{model}"
else
model_name = model
end
return model_name
end
def self.execute_query(model)
current = 0
nex = 0

View File

@@ -32,6 +32,52 @@ class ShiftSale < ApplicationRecord
#end
end
def self.sync_shift_sale_records(shift_sales)
if !shift_sales.nil?
shift_sales.each do |ss|
status = nil
shift_sale = nil
if ShiftSale.exists?(ss['id'])
shift_sale = ShiftSale.find(ss['id'])
status = 'updated'
else
shift_sale = ShiftSale.new
shift_sale.id = ss['id']
status = 'created'
end
shift_sale.cashier_terminal_id = ss['cashier_terminal_id']
shift_sale.shift_started_at = ss['shift_started_at']
shift_sale.shift_closed_at = ss['shift_closed_at']
shift_sale.employee_id = ss['employee_id']
shift_sale.opening_balance = ss['opening_balance']
shift_sale.closing_balance = ss['closing_balance']
shift_sale.total_revenue = ss['total_revenue']
shift_sale.total_discounts = ss['total_discounts']
shift_sale.total_taxes = ss['total_taxes']
shift_sale.grand_total = ss['grand_total']
shift_sale.nett_sales = ss['nett_sales']
shift_sale.cash_sales = ss['cash_sales']
shift_sale.credit_sales = ss['credit_sales']
shift_sale.other_sales = ss['other_sales']
shift_sale.commercial_taxes = ss['commercial_taxes']
shift_sale.cash_in = ss['cash_in']
shift_sale.cash_out = ss['cash_out']
shift_sale.dining_count = ss['dining_count']
shift_sale.takeaway_count = ss['takeaway_count']
shift_sale.member_count = ss['member_count']
shift_sale.total_rounding = ss['total_rounding']
shift_sale.total_receipt = ss['total_receipt']
shift_sale.total_void = ss['total_void']
shift_sale.save
puts "....... Shift Sale has been #{status} ......"
end
end
end
def create(opening_balance,cashier_terminal, current_user)
self.cashier_terminal_id = cashier_terminal
self.shift_started_at = DateTime.now

View File

@@ -2,7 +2,7 @@ class SaleItemsPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges, acc_cate_count, menu_cate_count, total_by_acc)
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -58,7 +58,7 @@ class SaleItemsPdf < Prawn::Document
sale_details(period, type, account, from_date, to_date, shift)
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
sale_items_detail(sale_items, total_other_charges)
move_down 10
end
@@ -128,7 +128,7 @@ class SaleItemsPdf < Prawn::Document
move_down 10
end
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
def sale_items_detail(sale_items, total_other_charges)
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "Sale Items Summary", :size => self.header_font_size, :align => :center

View File

@@ -2,7 +2,7 @@ class SaleItemsStarPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges, acc_cate_count, menu_cate_count, total_by_acc)
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, total_other_charges)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -58,7 +58,7 @@ class SaleItemsStarPdf < Prawn::Document
sale_details(period, type, account, from_date, to_date, shift)
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
sale_items_detail(sale_items, total_other_charges)
end
def header (shop_details)
@@ -127,7 +127,7 @@ class SaleItemsStarPdf < Prawn::Document
move_down 10
end
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges)
def sale_items_detail(sale_items, total_other_charges)
self.item_width = 73
self.price_width = 35
item_label_qty_front_width = (self.item_width+self.price_width) + 2

View File

@@ -0,0 +1,2 @@
json.status = true
json.message = 'Data successfully Sync'

View File

@@ -47,16 +47,16 @@
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<% if table.get_booking.nil? %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<% else %>
<div class="card tables orange text-white" data-id="<%= table.id %>">
<% end %>
<div class="card-block">
Table <%= table.name %> ( <%= table.seater %> Seat ) <br>
<%= table.zone.name %>
</div>
</div>
<% if table.get_checkout_booking.nil? %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<% else %>
<div class="card tables orange text-white" data-id="<%= table.id %>">
<% end %>
<div class="card-block">
Table <%= table.name %> ( <%= table.seater %> Seat ) <br>
<%= table.zone.name %>
</div>
</div>
<% else %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables blue text-white" data-id="<%= table.id %>">

View File

@@ -56,6 +56,7 @@
<th><%= t("views.right_panel.detail.grand_total") %> +<br/>
<%= t("views.right_panel.detail.rnd_adj_sh") %>
</th>
<th><%= "actions" %></th>
</tr>
</thead>
<tbody>
@@ -130,42 +131,48 @@
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
<td>
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
end %>
<% end %>
<% else %>
<% @tax_profiles.each do |tax| %>
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<td>
<!-- ############### Need to Check SyncStatus ############# -->
<%= link_to "Sync", reports_sync_data_path(:sale_id => result.sale_id), class:"btn btn-info wave-effects" %>
<!-- ###################################################### -->
</td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
@@ -218,6 +225,7 @@
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
@@ -232,6 +240,8 @@
<td><%= t("views.right_panel.detail.grand_total") %> +<br/>
<%= t("views.right_panel.detail.rnd_adj_sh") %>
</td>
<td>
</td>
</tr>
<%end%>
</tbody>

View File

@@ -114,6 +114,9 @@ scope "(:locale)", locale: /en|mm/ do
post "request_bill" => "bill#request_bill"
post "paymal_payment" => "payments#paymal_payment"
get ":sale_id/void" => "void#overall_void"
#API for sync cloud
post 'sync_data' => 'sync#sync_data'
end
#--------- Cashier ------------#
@@ -538,7 +541,7 @@ scope "(:locale)", locale: /en|mm/ do
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"
get "shiftsale_print/:id" , to: "shiftsale#print_close_receipt", as: "get_shift_id"
post "print_sale_items", to: "saleitem#print_sale_items", as: "print_sale_items"
get "sync_data", to:'receipt_no#sync_data', as:'sync_data'
end
# ----------- Inventory ---------------------------

BIN
dump.rdb

Binary file not shown.