Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2018-04-11 13:15:09 +06:30
14 changed files with 92 additions and 13 deletions

1
.code2lab.env Normal file
View File

@@ -0,0 +1 @@
RAILS_ENV=production

2
.dockerignore Normal file
View File

@@ -0,0 +1,2 @@
.git
.dockerignore

12
Dockerfile Normal file
View File

@@ -0,0 +1,12 @@
FROM ruby:2.4.1
RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs
RUN mkdir /sxrestaurant
RUN mkdir -p /sxrestaurant/tmp/puma
ENV RAILS_ENV production
WORKDIR /sxrestaurant
COPY Gemfile /sxrestaurant/Gemfile
COPY Gemfile.lock /sxrestaurant/Gemfile.lock
RUN bundle install --without development test
RUN bundle exec rails assets:precompile
COPY . /sxrestaurant

View File

@@ -2,7 +2,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
# skip_before_action :authenticate
ORDER = "order"
RESERVATION = "reservation"
ORDER_RESERVATION = "order and reservation"
ORDER_RESERVATION = "order_and_reservation"
def check_customer
customer_id = 0
@@ -42,6 +42,8 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
else
status = true
end
elsif !params[:callback_url]
render :json => { :status => false, :message => "callback_url is required!" }
end
if status == true

View File

@@ -71,8 +71,10 @@ class Origami::MovetableController < BaseOrigamiController
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
order.order_items.each do |order_item|
order_items.push(order_item)
if order.status == 'new'
order.order_items.each do |order_item|
order_items.push(order_item)
end
end
end
end

View File

@@ -360,7 +360,7 @@ class Customer < ApplicationRecord
customer.contact_no = params[:contact_no]
customer.gender = params[:gender]
customer.address = params[:address]
customer.date_of_birth = Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d")
customer.date_of_birth = params[:date_of_birth] ? Time.parse(params[:date_of_birth]).strftime("%Y-%m-%d") : ''
customer.membership_id = params[:membership_id]
customer.customer_type = "Takeaway"
customer.tax_profiles = ["2"]

View File

@@ -13,6 +13,7 @@ class OrderReservation < ApplicationRecord
order_reservation.customer_id = params[:cus_info]
order_reservation.requested_time = Time.parse(params[:requested_time]).utc.strftime("%Y-%m-%d %H:%M:%S")
if params[:order_info]
order_reservation.callback_url = params[:order_info][:callback_url]
order_reservation.item_count = params[:order_info][:items].count
order_reservation.payment_type = params[:payment_info][:payment_type]
order_reservation.payment_status = params[:payment_info][:payment_status]
@@ -21,7 +22,7 @@ class OrderReservation < ApplicationRecord
order_reservation.total_tax = params[:payment_info][:total_tax]
order_reservation.discount_amount = params[:payment_info][:discount_amount]
order_reservation.grand_total = params[:payment_info][:grand_total]
order_reservation.order_remark = params[:payment_info][:order_remark]
order_reservation.order_remark = params[:order_info][:order_remark]
end
if params[:reservation_info]
order_reservation.total_customer = params[:reservation_info][:total_user]

View File

@@ -1132,16 +1132,40 @@ var customer_name = "<%= @customer.name %>";
// QR Code Reader
$(".btn_qr_code").on('click', function(e){
$("#is_memberModal").hide();
var code = "";
var code = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
setTimeout(function(){
code=getQRCode();
$("#qr_code").val(code);
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);
}
}
});
}
},100);
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
$("#qr_code").val(code);
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {

View File

@@ -107,7 +107,7 @@
<%end%>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<td><%= number_with_precision(result.rounding_adjustment.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
</tr>
@@ -120,7 +120,7 @@
<td><b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<% end %>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(rounding_adj, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f.round + rounding_adj, precision: precision.to_i ,delimiter: delimiter) %></b></td>
</tr>
<tr>

View File

@@ -3,6 +3,8 @@ require_relative 'boot'
require 'csv'
require 'rails/all'
# require 'iconv'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.

View File

@@ -1,6 +1,7 @@
application_path = '/home/superuser/Application/sxrestaurant'
application_path="#{File.expand_path("../..", __FILE__)}"
directory application_path
environment ENV.fetch("RAILS_ENV") { "production" }
#environment ENV.fetch("RAILS_ENV") { "production" }
environment "production"
pidfile "#{application_path}/tmp/puma/pid"
state_path "#{application_path}/tmp/puma/state"
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"

View File

@@ -21,7 +21,7 @@ class CreateShiftSales < ActiveRecord::Migration[5.1]
t.integer :dining_count, :default => 0
t.integer :takeaway_count, :default => 0
t.integer :member_count, :default => 0
t.integer :total_rounding, :default => 0
t.decimal :total_rounding,, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.integer :total_receipt, :default => 0
t.decimal :total_void, :default => 0
t.timestamps

View File

@@ -5,6 +5,7 @@ class CreateOrderReservations < ActiveRecord::Migration[5.1]
t.string :order_reservation_type, :null => false
t.string :customer_id, :null => false
t.datetime :requested_time, :null => false
t.string :callback_url, :null => false
t.integer :item_count, :null => false, :default => 0
t.integer :total_customer
t.string :payment_type

31
docker-compose.yml Normal file
View File

@@ -0,0 +1,31 @@
version: '3'
services:
code2lab:
build: .
links:
- redis
command: bundle exec puma -C config/puma.rb
volumes:
- .:/sxrestaurant
env_file:
- .code2lab.env
ports:
- '8081:62158'
environment:
- REDIS_URL=redis://redis:6379/0
sidekiq:
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
links:
- redis
volumes:
- .:/sxrestaurant
environment:
- REDIS_URL=redis://redis:6379/0
redis:
image: redis
ports:
- '6379:6379'
volumes:
- ../data/redis:/data