Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into sqa-1804-001

This commit is contained in:
phyusin
2018-04-23 14:42:43 +06:30
41 changed files with 437 additions and 197 deletions

1
.gitignore vendored
View File

@@ -24,6 +24,7 @@ capybara-*.html
/public/image
/public/system/*
/public/assets/*
/public/menus/*
/public/uploads/*
/public/swf/*
/public/receipts/

View File

@@ -184,6 +184,9 @@ For MoveTablePdf in print settings
Add Kitchen Role of Employee
=> 1) settings/lookups => { type:employee_roles, name: Kitchen, value:kitchen }
Add Base URL for DOEMAL
1) settings/lookups => { type:order_reservation, name: BaseURL, value:'{doemal url}' }
* ToDo list
1. Migration

View File

@@ -268,21 +268,24 @@ $(function() {
value = item_sets[field]["instances"];
$(value).each(function(i){
if (type != -1 && modify_order != -1) {
url = '../../../../api/restaurant/menu_item_instances/'+value[i]["id"];
url = '../../../addorders/get_item_instance/'+value[i]["id"];
console.log("ssssssss")
}
if(modify_order == -1 && type != -1){
url = '../../api/restaurant/menu_item_instances/'+value[i]["id"] ;
url = 'addorders/get_item_instance/'+value[i]["id"] ;
console.log("aaaaaa")
}
if (type ==-1 && modify_order == -1){
url = '../../api/restaurant/menu_item_instances/'+value[i]["id"];
url = '../addorders/get_item_instance/'+value[i]["id"];
console.log("cccccccccc")
}
$.ajax({
type: "GET",
url: url,
data: {id:value[i]},
// data: {id:value[i]},
success:function(result){
row = '<div class="col-md-4 " >'

View File

@@ -0,0 +1,38 @@
App.checkin = App.cable.subscriptions.create('OrderReservationChannel', {
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
connected: function() {},
disconnected: function() {},
received: function(data) {
var order = data.data;
var rowCount = $('.order_reserve_cable tbody tr').length+1;
var date = new Date(order.requested_time);
var requested_time = date.getHours()+ ':' + date.getMinutes()+ '-' + date.getMinutes();
var isPM = date.getHours() >= 12;
var isMidday = date.getHours() == 12;
var result = document.querySelector('#result');
var time = [date.getHours() - (isPM && !isMidday ? 12 : 0),
date.getMinutes() || '00'].join(':') +
(isPM ? ' PM' : 'AM');
row = '<tr class="custom-tr first-'+rowCount+'" style="" data-id="'+order.order_reservation_id+'" data-sr-no="'+rowCount+'">'
+'<td width ="5%" class="align-left">'+rowCount
+'</td>'
+'<td width ="30%" class="align-center">'+time
+'</td>'
+'<td width ="30%" class="align-center">'+order.grand_total
+'</td>'
+'<td width ="30%" class="align-center">'
+'<span class="font-10 col-blue">'+ order.status +'</span>'
+'</td>'
+' </tr>'
$('.order_reserve_cable tbody').append(row);
}
});

View File

@@ -62,7 +62,6 @@ $(function() {
// console.log(data);
var delivery = data["delivery"];
var items = data["order_items"];
var item_list = $('.summary-items');
item_list.empty();
@@ -113,7 +112,12 @@ $(function() {
$("#order_remark").text(data.reservation_remark);
}
$("#sr_number").text("No."+sr_no);
$("#contact_info").text();
if (data["receipt_no"]) {
$("#contact_info").text(data["receipt_no"]);
}else{
$("#contact_info").text(data["order_reservation_id"]);
}
}
}
}
@@ -153,7 +157,6 @@ $(function() {
data: {'order_id': order_id, 'status': status},
dataType: "json",
success: function(data) {
console.log(data);
if (data.status) {
swal({
title: 'Information',

View File

@@ -0,0 +1,10 @@
class OrderReservationChannel < ApplicationCable::Channel
def subscribed
stream_from "order_reservation_channel"
end
def unsubscribed
stop_all_streams
# Any cleanup needed when channel is unsubscribed
end
end

View File

@@ -41,6 +41,21 @@ class Api::ApiController < ActionController::API
end
end
def website_connection(license)
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
:username => license.dbusername, :password => license.dbpassword)
end
def reconnect_default_db
ActiveRecord::Base.establish_connection(Rails.env)
end
# Regular database.yml configuration hash
def default_connection
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
end
def cache_license(url, lookup)
@license = License.new(url, lookup)

View File

@@ -57,6 +57,10 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
if status == true
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(params)
order_reservation = OrderReservation.find(order_reservation_id)
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation
if flag
render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
else

View File

@@ -53,16 +53,4 @@ module LoginVerification
def render_unauthorized
redirect_to root_path
end
private
def check_license
License.check_license_file
end
def check_installation
if current_company.nil?
redirect_to install_path
end
end
end

View File

@@ -13,8 +13,8 @@ module TokenVerification
authenticate_token || render_unauthorized
end
def authenticate_token
authenticate_with_http_token do |token, options|
def authenticate_token
authenticate_with_http_token do |token, options|
# Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL")
if(ENV["SERVER_MODE"] === "cloud")
@@ -24,7 +24,8 @@ module TokenVerification
end
end
@user = Employee.authenticate_by_token(token)
@user = Employee.
(token)
if @user
return true
#Maybe log - login?

View File

@@ -58,6 +58,10 @@ class Origami::AddordersController < BaseOrigamiController
end
end
def get_item_instance
@id = MenuItemInstance.find(params[:id])
end
def get_menu()
if (params[:id])
#Pull this menu
@@ -180,7 +184,11 @@ puts items_arr.to_json
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
# if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
# end
result = {:status=> @status, :data => @sale }
render :json => result.to_json
end

View File

@@ -285,10 +285,10 @@ class Origami::DiscountsController < BaseOrigamiController
'Accept' => 'application/json; version=3'
}, :timeout => 10)
rescue HTTParty::Error
response = {"status": false, "message": "Can't open membership server " }
response = {"status": false, "message": "Http party error" }
rescue Net::OpenTimeout
response = {"status": false, "message": "Can't open membership server " }
response = {"status": false, "message": "Connection TIme out " }
rescue OpenURI::HTTPError
response = {"status": false, "message": "Can't open membership server " }

View File

@@ -13,8 +13,9 @@ class Origami::SecondDisplayController < BaseOrigamiController
else
tax_profiles = nil
end
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
end
end
#Shop Name in Navbor
helper_method :shop_detail

View File

@@ -92,7 +92,8 @@ class Origami::WasteSpoileController < BaseOrigamiController
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
# get printer info

View File

@@ -99,11 +99,39 @@ class Settings::MenusController < ApplicationController
sheet.add_row ["Name",menu.name], :style=>title
sheet.add_row
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Instance Code", "Instance Name", "Price"], :style=>header_text
sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Price", "Is Default"], :style=>header_text
menu.menu_categories.each do |mc|
mc.menu_items.each do |mi|
attributes = ""
i=0
if mi.item_attributes.length > 0
mi.item_attributes.each do |mia|
attribute = MenuItemAttribute.find(mia)
if i == mi.item_attributes.length - 1
attributes = attributes + attribute.name
else
attributes = attributes + attribute.name + ","
end
i = i + 1
end
end
options = ""
i=0
if mi.item_options.length > 0
mi.item_options.each do |mia|
option = MenuItemOption.find(mia)
if i == mi.item_options.length - 1
options = options + option.name
else
options = options + option.name + ","
end
i = i + 1
end
end
mi.menu_item_instances.each do |mii|
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, mii.item_instance_code, mii.item_instance_name, mii.price], :style=>wrap_text
sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, mii.price, mii.is_default], :style=>wrap_text
end
end
end

View File

@@ -40,6 +40,8 @@ class Ability
can :index, :shiftsale
can :index, :credit_payment
can :index, :void_sale
can :index, :waste_and_spoilage
can :index, :product_sale
can :show, :dailysale
can :show, :saleitem
@@ -47,6 +49,8 @@ class Ability
can :show, :shiftsale
can :show, :credit_payment
can :show, :void_sale
can :show, :waste_and_spoilage
can :show, :product_sale
can :get_customer, Customer
can :add_customer, Customer
@@ -114,6 +118,9 @@ class Ability
can :print, :print
can :print_order_summary, :print
can :read, ShiftSale
can :update, ShiftSale
elsif user.role == "cashier"
# can :overall_void, :void
@@ -185,12 +192,16 @@ class Ability
can :index, :shiftsale
can :index, :credit_payment
can :index, :void_sale
can :index, :waste_and_spoilage
can :index, :product_sale
can :show, :dailysale
can :show, :saleitem
can :show, :receipt_no
can :show, :shiftsale
can :show, :credit_payment
can :show, :void_sale
can :show, :waste_and_spoilage
can :show, :product_sale
elsif user.role == "supervisor"

View File

@@ -153,6 +153,28 @@ class Menu < ApplicationRecord
# status = status + "Category Code already exists."
end
# Menu Item Attributes
item_attrs = []
attributes = row["Attributes"].split(',')
attributes.each do |attr|
attribute = MenuItemAttribute.find_by_name(attr)
if attribute.nil?
attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase })
end
item_attrs.push(attribute.id)
end
# Menu Item Options
item_opts = []
options = row["Options"].split(',')
options.each do |opt|
option = MenuItemOption.find_by_name(opt)
if option.nil?
option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase })
end
item_opts.push(option.id)
end
menu_itm = MenuItem.find_by_item_code(row["Item Code"])
if !menu_itm
account = Account.find_by_title(row["Account"])
@@ -160,14 +182,14 @@ class Menu < ApplicationRecord
account = Account.create({title: row["Account"], account_type: "0"})
end
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", is_sub_item: 0, is_available: 1, created_by: created_by)
menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
# else
# status = status + "Item Code already exists for " + row["Item Name"] + "."
end
menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"])
if !menu_inst
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: "[]", price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: false)
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"])
# else
# status = status + "Instance Code already exists for " + row["Instance Name"] + "."
end

View File

@@ -62,8 +62,9 @@ class MyAesCrypt
shop_json = JSON.parse(shop_data)
shop_json["data"].each do |j|
if j["lookup"] == from
if(j["value"]["key"] == token)
if j["lookup"] == from
# add [0...44] for production cloud for remove \n
if(j["value"]["key"][0...44] == token)
return true
end
end

View File

@@ -285,28 +285,13 @@ class Order < ApplicationRecord
#Process order items and send to order queue
def process_order_queue
#Send to background job for processing
order = Order.find(self.id)
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
cup_start = `#{"sudo service cups start"}`
if ENV["SERVER_MODE"] != 'cloud'
#Send to background job for processing
order = Order.find(self.id)
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
@@ -315,40 +300,61 @@ class Order < ApplicationRecord
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(id, table_id)
else
order = Order.find(id)
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
if ENV["SERVER_MODE"] != 'cloud'
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(id, table_id)
else
order = Order.find(id)
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end

View File

@@ -219,7 +219,19 @@ class OrderReservation < ApplicationRecord
end
def self.send_status_to_ordering(url,ref_no,status)
base_url = "http://192.168.1.186:3002"
base_url = 'https://api.doemal.com'
order_reservation = Lookup.collection_of("order_reservation")
if !order_reservation.empty?
order_reservation.each do |order_reserve|
if order_reserve[0] == 'BaseURL'
base_url = order_reserve[1]
end
end
else
Rails.logger.debug "Add order reservation BaseURL "
response = {status: false}
end
Rails.logger.debug "Doemal URL" + base_url
post_url = base_url + url
begin

View File

@@ -128,6 +128,9 @@ class Sale < ApplicationRecord
self.save!
#compute sales summary
if order_source.nil?
order_source = order.source
end
compute(order_source)
#Update the order items that is billed
@@ -2603,34 +2606,35 @@ end
end
def self.all_receipts
query = Sale.select("sales.*, sale_payments.created_at as receipt_close_time,
case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
SUM(sale_items.qty) as qty,
sales.cashier_name as cashier_name,
surveys.child as child,
surveys.adult as adult")
query = Sale.select("sale_payments.created_at as receipt_close_time,
case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
SUM(sale_items.qty) as qty,
sales.cashier_name as cashier_name,
surveys.child as child,
surveys.adult as adult")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join sale_taxes on sale_taxes.sale_id = sales.sale_id")
.joins("join sale_items on sale_items.sale_id = sales.sale_id")
.joins("join sale_audits on sale_audits.sale_id = sales.sale_id")
.joins("left join surveys on surveys.receipt_no = sales.receipt_no")
query = query.where("sale_status != 'new' && sale_payments.payment_amount > 0")
.group("sale_id")
query = query.where("sales.sale_status != 'new' && sale_payments.payment_amount > 0")
query = query.where("sales.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-02-05 13:59:59 +0630')
.group("sales.sale_id")
return query
end
@@ -2640,7 +2644,8 @@ def self.all_receipt_details
.joins("join sale_payments on sale_payments.sale_id = sale_items.sale_id")
.joins("join sales on sales.sale_id = sale_items.sale_id")
.group("sale_items.sale_item_id")
query = query.where("qty > 0 and sales.sale_status !='new'")
query = query.where("sale_itemsqty > 0 and sales.sale_status !='new'")
query = query.where("sale_items.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-02-05 13:59:59 +0630')
return query
end

View File

@@ -84,7 +84,7 @@ class ReceiptBillPdf < Prawn::Document
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data, printer_settings.precision, delimiter)
individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
end
#end for individual payment
@@ -487,7 +487,8 @@ class ReceiptBillPdf < Prawn::Document
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
# per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
per_person = sale_data.grand_total.to_f / survey.to_i
stroke_horizontal_rule
move_down line_move
y_position = cursor

View File

@@ -142,7 +142,7 @@ $(function() {
});
// QR Code Reader
$("#qr_code").on('sclick', function(e){
$("#qr_code").on('click', function(e){
var code = "";
setTimeout(function(){
code=getQRCode();

View File

@@ -0,0 +1,39 @@
if(@id)
menu_item = MenuItem.find(@id.menu_item_id)
# Format for option json
opt_format = []
# Format for attributes json
menu_item.item_options.each do|opt|
menu_opt = MenuItemOption.find(opt)
if opt_format.count == 0
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
next
end
opt_format.each do |of|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
if menu_opt.option_type == of[:type]
of[:values].push(menu_opt.name)
end
else
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
opt_format.push(new_opt)
break
end
end
end
json.success true
json.id @id.id
json.name @id.item_instance_name
json.code @id.item_instance_code
json.item_id @id.menu_item_id
json.attributes @id.item_attributes
json.price @id.price
json.is_default @id.is_default
json.options opt_format
else
json.success false
end

View File

@@ -358,7 +358,7 @@
}
// QR Code Reader
$("#qr_code").on('click', function(e){
$("#qr_code").on('click', function(e){
var code = "";
var customer_id = '';
var customer_name = '';
@@ -368,35 +368,34 @@
setTimeout(function(){
code=getQRCode();
setQRCode(code);
}, 100);
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
// $.alert({
// title: 'Alert!',
// content: data[0].message,
// type: 'red',
// typeAnimated: true,
// btnClass: 'btn-danger',
// });
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
}
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
// $.alert({
// title: 'Alert!',
// content: data[0].message,
// type: 'red',
// typeAnimated: true,
// btnClass: 'btn-danger',
// });
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id);
}
});
}
},100);
}
});
}
});
// Read qrcode from java

View File

@@ -106,6 +106,12 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn bg-default m-t-10 btn-lg btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
<div class="m-r-20" align="right">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
</div>
</div>
</div>
</div>
@@ -341,7 +347,7 @@
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
url: "<%=origami_payment_dinga_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
success: function(result){

View File

@@ -786,7 +786,6 @@
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
alert(parseInt(jQuery.inArray("PAYMAL", type)));
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();

View File

@@ -4,7 +4,7 @@ if @order
:requested_time,:callback_url,:transaction_ref,:item_count,:total_customer,:payment_type,
:payment_status,:payment_ref,:total_amount,:total_tax,
:discount_amount,:grand_total,:status,:order_remark,
:reservation_remark)
:reservation_remark,:sale_id)
@delivery = Delivery.find_by_order_reservation_id(@order.order_reservation_id)
if @delivery
json.delivery do |json|
@@ -22,4 +22,9 @@ if @order
json.customer_name @customer.name
json.phone @customer.contact_no
if @order.sale_id
@receipt_no = Sale.find(@order.sale_id).receipt_no
json.receipt_no @receipt_no
end
end

View File

@@ -22,7 +22,7 @@
<div class="tab-pane active" id="pending" role="tabpanel">
<div class="card-block font-13">
<div id="menu-slimscroll" data-height="50">
<table class="table table-stripe custom-table">
<table class="table table-stripe custom-table order_reserve_cable">
<tbody>
<% i=1
@order.each do |order| %>
@@ -152,11 +152,12 @@
<div class="card-header custom-card-header" style="color:">
<table class="table">
<tr>
<td width ="70%" class="header-td align-left">
<td width ="30%" class="header-td align-left">
<b class="col-pink font-16"><span id="sr_number"></span> </b>
<span class="font-13"><span id="delivery_info"></span></span>
</td>
<td width ="30%" class="header-td font-16 align-right"><b><span id="contact_info">0065 4321</span></b></td>
<td class="header-td align-left"></td>
<td width ="50%" class="header-td font- align-right"><b><span id="contact_info"></span></b></td>
</tr>
</table>
</div>

View File

@@ -432,20 +432,12 @@
<iframe id="receipt_pdf" src="" class="pdf-iframe" scrolling="no"></iframe>
</div>
</div>
<div class="modal-footer ">
<div class="row m-b-10 m-r-30">
<div class="col-md-5 m-r-20">
<% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" class="btn btn-link bg-red waves-effect print_receipt">Print</button>
<% end %>
</div>
<div class="col-md-5 m-r-20">
<button type="button" class="btn btn-link bg-blue waves-effect btn_pdf_close" data-dismiss="modal">CLOSE</button>
</div>
</div>
<div class="modal-footer">
<button type="button" class="mr-2 btn btn-link bg-red waves-effect print_receipt"> Print
</button>
<button type="button" class="btn btn-link bg-blue waves-effect btn_pdf_close" data-dismiss="modal">
CLOSE
</button>
</div>
</div>
</div>
@@ -531,14 +523,24 @@ var customer_name = "<%= @customer.name %>";
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
console.log(payment_type)
if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
} else{
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1, parseInt(jQuery.inArray("PAYMAL", payment_type)) !=-1 || parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Alipay", payment_type)) !=-1 || parseInt(jQuery.inArray("DINGA", payment_type)) !=-1){
console.log(jQuery.inArray("Master", payment_type))
if(parseInt(jQuery.inArray("MPU", payment_type)) != -1 ||
parseInt(jQuery.inArray("VISA", payment_type)) != -1 ||
parseInt(jQuery.inArray("JCB", payment_type)) != -1 ||
parseInt(jQuery.inArray("Master", payment_type)) != -1 ||
parseInt(jQuery.inArray("UNIONPAY", payment_type)) != -1 ||
parseInt(jQuery.inArray("Redeem", payment_type)) != -1 ||
parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 ||
parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 ||
parseInt(jQuery.inArray("Alipay", payment_type)) != -1 ||
parseInt(jQuery.inArray("DINGA", payment_type)) != -1){
$("#card_payment").show();
} else{
$("#card_payment").hide();
@@ -1049,7 +1051,6 @@ var customer_name = "<%= @customer.name %>";
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params,
success:function(result){
console.log(result);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
@@ -1143,33 +1144,34 @@ var customer_name = "<%= @customer.name %>";
var membership_type = '';
setTimeout(function(){
code=getQRCode();
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : code ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
$("#qr_code").val(code);
});
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : code ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
});
}
},100);
}
});
}
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
$("#qr_code").val(code);
return code2lab.readQRCode();
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {

View File

@@ -361,7 +361,7 @@ $('#pay').on('click',function() {
$('#back').on('click',function(){
var lookup_split_bill = '<%= @split_bill %>';
if(lookup_split_bill == '1'){
window.location.href = '/origami/table/<%= @table.id %>/split_bills';
window.location.href = '/origami/table/<%= @table.id %>/cashier/split_bills';
}else{
window.location.href = '/origami/table/<%= @table.id %>';
}

View File

@@ -16,7 +16,7 @@
<% if(@server_mode != 'cloud') %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
<% else %>
<%= f.input :printer_name %>
<%= f.input :printer_name, :as => :select, :collection => [] %>
<% end %>
<%= f.input :brand_name %>
<%= f.input :printer_type %>

View File

@@ -7,7 +7,11 @@
<div class="form-inputs p-l-15">
<%= f.input :name %>
<%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %>
<% if current_user.role == "administrator" %>
<%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %>
<% else %>
<%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] != "administrator"},:class=>'form-group' %>
<% end %>
<%= f.input :emp_id, :label => "Employee Numberic ID (*Unique)" %>
<%= f.input :password %>

View File

@@ -12,7 +12,7 @@ class ActionController::Base
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else8
else
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"
@@ -50,6 +50,16 @@ class ActionController::Base
end
end
def check_license
License.check_license_file
end
def check_installation
if current_company.nil?
redirect_to install_path
end
end
def website_connection(license)
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
:username => license.dbusername, :password => license.dbpassword)

View File

@@ -24,7 +24,7 @@ module ActiveRecord
end
client = Mysql2::Client.new(config.symbolize_keys)
options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], 0]
options = [config[:host], config[:username], config[:password], config[:database], config[:port], config[:socket], config[:wait_timeout], 0]
ConnectionAdapters::Mysql2Adapter.new(client, logger, options, config)
end
end

View File

@@ -237,6 +237,9 @@ scope "(:locale)", locale: /en|mm/ do
get '/:addorders/:id' => "addorders#detail"
post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' }
get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' }
resources :commissions
resources :commissioners

View File

@@ -13,7 +13,7 @@
development:
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
sx_provision_url: https://connect.pos-myanmar.com/bensai/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
server_mode: cloud
server_mode: application
cipher_type: AES-256-CBC
sx_key: Wh@t1$C2L

View File

@@ -5,10 +5,13 @@ class CreateReceipts < ActiveRecord::Migration[5.1]
t.string :client_name, :null => false
t.string :shop_code, :limit => 16, :null => false
t.string :shop_name, :null => false
t.integer :receipt_no, :limit => 8, :null => false
t.string :receipt_no, :null => false
t.datetime :transaction_time, :null => false
t.datetime :receipt_open_time, :null => false
t.datetime :receipt_close_time, :null => false
t.string :shift_id, :null => false
t.datetime :shift_open_time, :null => false
t.datetime :shift_close_time, :null => false
t.decimal :gross_sales, :null => false, :default => 0
t.decimal :discount_amount, :null => false, :default => 0
t.decimal :sales, :null => false, :default => 0

View File

@@ -18,6 +18,8 @@ namespace :clear do
DiningFacility.update_all(status:'available')
CashierTerminal.update_all(is_currently_login: 0)
SeedGenerator.where("id > 1").update(:current => 0, :next => 0)
Receipt.delete_all
ReceiptDetail.delete_all
puts "Clear Data Done."
end

View File

@@ -1,20 +1,25 @@
namespace :consolidate do
desc "Receipt"
task :receipt => :environment do
Receipt.delete_all
# Receipt.delete_all
sales = Sale.all_receipts
puts sales.to_json
shop = Shop.find(1)
sales.each do |sale|
puts sale.to_json
shift = ShiftSale.find(sale.shift_sale_id)
receipt = Receipt.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.client_code = shop.client_code
receipt.client_name = shop.client_name
receipt.shop_code = shop.shop_code
receipt.shop_name = shop.name
receipt.receipt_no = sale.receipt_no
receipt.transaction_time = sale.requested_at #requet-at
receipt.receipt_open_time = sale.requested_at #before disco/after tax /after/ser_char
receipt.receipt_close_time = sale.receipt_close_time
receipt.shift_id = sale.shift_sale_id
receipt.shift_open_time = shift.shift_started_at
receipt.shift_close_time = shift.shift_closed_at
receipt.gross_sales = sale.total_amount + sale.total_tax #before disco/after tax /after/ser_char
receipt.discount_amount = sale.total_discount + sale.item_discount
receipt.sales = sale.grand_total #after disco/after tax /after/ser_char /no roundingadn
@@ -96,10 +101,10 @@ namespace :consolidate do
if sale_id != sale.sale_id && count !=0
receipt = ReceiptDetail.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.client_code = shop.client_code
receipt.client_name = shop.client_name
receipt.shop_code = shop.shop_code
receipt.shop_name = shop.name
receipt.receipt_no = @receipt_no
receipt.receipt_date = @requested_at #requet-at
receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char
@@ -145,10 +150,10 @@ namespace :consolidate do
discount_amount = (sale.status=="Discount") ? sale.price : 0
receipt = ReceiptDetail.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.client_code = shop.client_code
receipt.client_name = shop.client_name
receipt.shop_code = shop.shop_code
receipt.shop_name = shop.name
receipt.receipt_no = sale.receipt_no
receipt.receipt_date = sale.requested_at #requet-at
receipt.transaction_date = sale.requested_at #before disco/after tax /after/ser_char
@@ -195,10 +200,10 @@ namespace :consolidate do
if count == sale_count
receipt = ReceiptDetail.new
receipt.client_code = shop.id
receipt.client_name = shop.id
receipt.shop_code = shop.id
receipt.shop_name = shop.id
receipt.client_code = shop.client_code
receipt.client_name = shop.client_name
receipt.shop_code = shop.shop_code
receipt.shop_name = shop.name
receipt.receipt_no = @receipt_no
receipt.receipt_date = @requested_at #requet-at
receipt.transaction_date = @requested_at #before disco/after tax /after/ser_char

Binary file not shown.