Merge branch 'r-1902001-01-dev' of gitlab.com:code2lab/SXRestaurant into r-1902001-01-dev
This commit is contained in:
9
Capfile
9
Capfile
@@ -22,10 +22,15 @@ require "capistrano/bundler"
|
||||
require "capistrano/rails"
|
||||
require "capistrano/rails/assets"
|
||||
require "capistrano/rails/migrations"
|
||||
# require "capistrano/passenger"
|
||||
require "capistrano/scm/git"
|
||||
install_plugin Capistrano::SCM::Git
|
||||
|
||||
require 'capistrano/puma'
|
||||
install_plugin Capistrano::Puma, load_hooks: false # Default puma tasks
|
||||
install_plugin Capistrano::Puma::Monit # if you need the monit tasks
|
||||
install_plugin Capistrano::Puma::Jungle # if you need the jungle tasks
|
||||
|
||||
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
|
||||
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
|
||||
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
|
||||
Dir.glob('lib/capistrano/**/*.rb').each { |r| import r }
|
||||
|
||||
|
||||
4
Gemfile
4
Gemfile
@@ -44,7 +44,8 @@ gem 'mini_magick'
|
||||
gem 'jquery-fileupload-rails', '~> 0.4.7'
|
||||
|
||||
#Report and Printing gems
|
||||
gem 'cups'
|
||||
#gem 'cups' #remove for cloud installation
|
||||
gem 'cups', '~>0.0.7'
|
||||
gem 'prawn'
|
||||
gem 'prawn-table'
|
||||
gem 'prawn-qrcode'
|
||||
@@ -114,6 +115,7 @@ group :development do
|
||||
gem 'capistrano-bundler'
|
||||
gem 'capistrano-rails'
|
||||
gem 'capistrano-rbenv', github: "capistrano/rbenv"
|
||||
gem 'capistrano3-puma'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
||||
17
Gemfile.lock
17
Gemfile.lock
@@ -72,11 +72,15 @@ GEM
|
||||
capistrano-rails (1.4.0)
|
||||
capistrano (~> 3.1)
|
||||
capistrano-bundler (~> 1.1)
|
||||
capistrano3-puma (3.1.1)
|
||||
capistrano (~> 3.7)
|
||||
capistrano-bundler
|
||||
puma (~> 3.4)
|
||||
carrierwave (1.3.1)
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
mime-types (>= 1.16)
|
||||
chartkick (3.2.1)
|
||||
chartkick (3.2.2)
|
||||
chronic (0.10.2)
|
||||
chunky_png (1.3.11)
|
||||
coffee-rails (4.2.2)
|
||||
@@ -89,7 +93,7 @@ GEM
|
||||
concurrent-ruby (1.1.5)
|
||||
connection_pool (2.2.2)
|
||||
crass (1.0.5)
|
||||
cups (0.1.10)
|
||||
cups (0.0.7)
|
||||
database_cleaner (1.7.0)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.9.0)
|
||||
@@ -140,7 +144,7 @@ GEM
|
||||
listen (3.0.8)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
loofah (2.3.0)
|
||||
loofah (2.3.1)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
@@ -265,7 +269,7 @@ GEM
|
||||
simple_form (5.0.1)
|
||||
actionpack (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
spreadsheet (1.2.4)
|
||||
spreadsheet (1.2.5)
|
||||
ruby-ole (>= 1.0)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
@@ -322,10 +326,11 @@ DEPENDENCIES
|
||||
capistrano-bundler
|
||||
capistrano-rails
|
||||
capistrano-rbenv!
|
||||
capistrano3-puma
|
||||
carrierwave (~> 1.0)
|
||||
chartkick
|
||||
coffee-rails (~> 4.2)
|
||||
cups
|
||||
cups (~> 0.0.7)
|
||||
database_cleaner
|
||||
factory_girl_rails (~> 4.0)
|
||||
faker
|
||||
@@ -370,8 +375,8 @@ DEPENDENCIES
|
||||
web-console (>= 3.3.0)
|
||||
whenever
|
||||
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
include ActionController::MimeResponds
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
@@ -23,25 +24,25 @@ class Api::ApiController < ActionController::API
|
||||
@employee = Employee.find_by_token_session(current_token)
|
||||
end
|
||||
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
# if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def website_connection(license)
|
||||
# def website_connection(license)
|
||||
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
# :username => license.dbusername, :password => license.dbpassword)
|
||||
# end
|
||||
@@ -55,8 +56,8 @@ class Api::ApiController < ActionController::API
|
||||
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||
# end
|
||||
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
|
||||
# if (@license.detail_with_local_cache(lookup) == true)
|
||||
# return @license
|
||||
|
||||
@@ -40,7 +40,7 @@ class Api::AuthenticateController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "This employee is not active!"
|
||||
# render json: JSON.generate({:status => false, :error_message => "This employee is not active!"})
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "Bad Emp_ID or Password!"
|
||||
|
||||
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
@@ -0,0 +1,90 @@
|
||||
require "net/http"
|
||||
class Api::LoaderService::LoadDataController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def get_sale_data_rage
|
||||
load_time_start = params[:load_time]
|
||||
load_time_end = params[:load_time_end]
|
||||
unless load_time_start.nil? || load_time_end.nil?
|
||||
@sale_data = Sale.get_load_sale_range(load_time_start.to_datetime,load_time_end.to_datetime)
|
||||
if !@sale_data.empty?
|
||||
@out = {general_status: true, data: @sale_data}
|
||||
else
|
||||
@out = {general_status: false, data: "Data is empty."}
|
||||
end
|
||||
else
|
||||
@out = {general_status: false, data: "load_time is missing."}
|
||||
end
|
||||
render :json => @out
|
||||
end
|
||||
|
||||
# SFTP for BreadTalk Start
|
||||
|
||||
# Detail Sale
|
||||
def get_detail_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data[:transaction_date].to_s
|
||||
detail_sale_data = SaleItem.get_detail_sale_data(transaction_date)
|
||||
json = detail_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless detail_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => detail_sale_data }
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty" }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json {render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Tender sale
|
||||
def get_tender_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
tender_sale_data = Sale.get_tender_sale_data(transaction_date)
|
||||
json = tender_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless tender_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => tender_sale_data }
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty" }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Daily_Sale summary
|
||||
def get_daily_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
daily_sale_data = Sale.get_daily_sale_data(transaction_date)
|
||||
unless daily_sale_data.empty?
|
||||
out = { :status => "success", :data => daily_sale_data}
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty"}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Check Sale Data
|
||||
def get_check_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
check_sale_data = Sale.get_check_sale_data(transaction_date)
|
||||
json = check_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless check_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => check_sale_data}
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty"}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# SFTP for BreadTalk End
|
||||
end
|
||||
@@ -305,7 +305,7 @@ class Origami::AddordersController < BaseOrigamiController
|
||||
def getCloudDomain
|
||||
from = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
from = request.subdomain.to_s + "." + request.domain.to_s
|
||||
end
|
||||
|
||||
return from
|
||||
|
||||
@@ -827,7 +827,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
def getCloudDomain
|
||||
from = ""
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
from = request.subdomain.to_s + "." + request.domain.to_s
|
||||
end
|
||||
|
||||
return from
|
||||
|
||||
@@ -22,7 +22,7 @@ class Origami::PendingOrderController < BaseOrigamiController
|
||||
else
|
||||
redirect_to "/origami/#{params[:type]}" and return
|
||||
end
|
||||
elsif id.start_with?("BKI")
|
||||
elsif (id.start_with?("BKI") || id.start_with?("CBKI"))
|
||||
@bookings = Booking.find(id)
|
||||
@order = @bookings.orders.where(status: "new").first
|
||||
@order_items = @bookings.order_items
|
||||
|
||||
@@ -333,7 +333,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
Promotion.promo_activate(sale)
|
||||
Promotion.promo_activate(sale_data)
|
||||
if ENV["SERVER_MODE"] == 'cloud'
|
||||
from = request.subdomain + "." + request.domain
|
||||
else
|
||||
|
||||
@@ -75,7 +75,7 @@ class OrderReservation < ApplicationRecord
|
||||
order_reservation.discount_amount = order_reserve[:payment_info][:discount_amount]
|
||||
order_reservation.convenience_charge = order_reserve[:payment_info][:convenience_charge]
|
||||
order_reservation.grand_total = order_reserve[:payment_info][:grand_total]
|
||||
order_reservation.transaction_fee = order_reserve[:payment_info][:transaction_fee]
|
||||
# order_reservation.transaction_fee = order_reserve[:payment_info][:transaction_fee]
|
||||
order_reservation.order_remark = order_reserve[:order_info][:order_remark]
|
||||
end
|
||||
if order_reserve[:reservation_info]
|
||||
|
||||
@@ -2717,6 +2717,139 @@ def grand_total_round
|
||||
self.grand_total =self.grand_total.round(print_settings.precision.to_i)
|
||||
end
|
||||
end
|
||||
|
||||
# Loader Service SFTP Start
|
||||
def self.get_load_sale_range(load_time_start,load_time_end)
|
||||
query = Sale.select("sales.sale_id,
|
||||
CONVERT(receipt_date, TIME) as transaction_time,
|
||||
CONVERT(receipt_date, DATE) as transaction_date,
|
||||
receipt_no as transaction_no,
|
||||
SUM(i.qty) as item_no,
|
||||
'MMK' as currency_salesamount,
|
||||
IFNULL((total_amount-total_discount)-((total_amount-total_discount)/21),0) as total_salesamount,
|
||||
IFNULL(amount_changed,0) as change_amt,
|
||||
IFNULL(total_amount-total_discount,0) as grand_salesamount,
|
||||
'5' as tax_percent,
|
||||
'MMK' as currency_payment,
|
||||
IFNULL(amount_received,0) as paymentamount,
|
||||
sp.payment_amount as payment_method,
|
||||
CASE
|
||||
WHEN sales.sale_status='completed' THEN 'Sales'
|
||||
WHEN sales.sale_status='void' THEN 'Void'
|
||||
END as sale_type,
|
||||
sales.updated_at as load_time")
|
||||
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" +
|
||||
" JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
|
||||
.where("(sale_status=? OR sale_status=?) AND sp.payment_method !=? AND sales.updated_at between ? AND ?", 'completed', 'void', 'foc', load_time_start, load_time_end)
|
||||
.group("receipt_no")
|
||||
.order("receipt_date")
|
||||
end
|
||||
|
||||
def self.get_tender_sale_data(transaction_date)
|
||||
query = Sale.select("sales.receipt_no as check_num,
|
||||
DATE_FORMAT(sales.receipt_date, '%d %b %Y') as business_date,
|
||||
sales.receipt_date as transaction_date,
|
||||
'36017' as item_id,
|
||||
'Cash Received' as item_name,
|
||||
'1' as qty,
|
||||
'Tender' as transaction_type,
|
||||
'0' as sales,
|
||||
CASE WHEN sales.sale_status = 'void' THEN '1' ELSE '0' END as is_void
|
||||
")
|
||||
.where("DATE(sales.receipt_date)=? AND sales.sale_status != ?", transaction_date, :void)
|
||||
.order("sales.receipt_no")
|
||||
end
|
||||
|
||||
def self.get_daily_sale_data(transaction_date)
|
||||
query = Sale.connection.select_all("SELECT s.receipt_date as business_date,
|
||||
(SUM(s.grand_total)+SUM(s.total_discount)) as gross_sales,
|
||||
SUM(s.total_discount) as discount,
|
||||
SUM(s.grand_total) as sales,
|
||||
SUM(s.grand_total)/21 as tax,
|
||||
0 as service_charge,
|
||||
SUM(s.grand_total) - (SUM(s.grand_total)/21) as net_sales,
|
||||
SUM(s.credit_amount) as credit_amount,
|
||||
SUM(s.voucher_sales) as voucher_sales,
|
||||
0 as staff_meal_amt,
|
||||
0 as round_amt,
|
||||
0 as raw_wastage_amt,
|
||||
0 as semi_wastage_amt,
|
||||
CASE WHEN s.sale_status='waste' THEN SUM(s.total_amount) ELSE 0 END as wastage_amt,
|
||||
CASE WHEN s.sale_status='spoile' THEN SUM(s.total_amount) ELSE 0 END as spoilage_amt,
|
||||
0 as sampling_amt,
|
||||
0 as other_amt,
|
||||
SUM(s.qty) as total_qty,
|
||||
(SELECT COUNT(sales.sale_id) FROM sales WHERE DATE(sales.receipt_date)='#{transaction_date}') as total_transaction,
|
||||
(SELECT COUNT(sales.sale_id) FROM sales WHERE (sales.sale_status='completed' OR sales.sale_status='void') AND DATE(sales.receipt_date)='#{transaction_date}') as valid_transaction_count,
|
||||
(SELECT COUNT(sales.sale_id) FROM sales WHERE (sales.sale_status IN('new','pending',null)) AND DATE(sales.receipt_date)='#{transaction_date}') as invalid_transaction_count,
|
||||
0 as overing_transaction_count,
|
||||
0 as cancle_transaction_count,
|
||||
0 as no_of_pax,
|
||||
0 as no_of_adult,
|
||||
0 as no_of_child
|
||||
FROM (
|
||||
SELECT s.*, SUM(qty) as qty
|
||||
FROM (
|
||||
SELECT sales.*,
|
||||
SUM(CASE WHEN sp.payment_method IN('mpu','master','visa','jcb','unionpay','alipay') THEN sp.payment_amount ELSE 0 END) as credit_amount,
|
||||
SUM(case when (sp.payment_method='giftvoucher') then sp.payment_amount else 0 end) as voucher_sales
|
||||
FROM sales
|
||||
LEFT JOIN sale_payments sp ON sp.sale_id = sales.sale_id
|
||||
WHERE DATE(sales.receipt_date) = '#{transaction_date}'
|
||||
AND sales.sale_status!='void'
|
||||
AND sales.sale_status='completed'
|
||||
GROUP BY sales.sale_id) AS s
|
||||
LEFT JOIN sale_items si ON si.sale_id = s.sale_id
|
||||
GROUP BY s.sale_id) as s
|
||||
GROUP BY DATE(s.receipt_date)").to_hash
|
||||
end
|
||||
|
||||
def self.get_check_sale_data(transaction_date)
|
||||
sale_receivables_subquery = "SELECT sale_payments.sale_id,
|
||||
CASE WHEN sale_payments.payment_method = 'mpu' OR sale_payments.payment_method = 'visa' OR sale_payments.payment_method = 'master' OR sale_payments.payment_method = 'jcb' OR sale_payments.payment_method = 'paypar' OR sale_payments.payment_method = 'unionpay' OR sale_payments.payment_method = 'alipay' OR sale_payments.payment_method = 'paymal' OR sale_payments.payment_method = 'dinga' OR sale_payments.payment_method = 'JunctionPay' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as credit_card_sales,
|
||||
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
|
||||
FROM sale_payments
|
||||
GROUP BY sale_payments.sale_id, sale_payments.payment_method"
|
||||
|
||||
query = Sale.select("
|
||||
sales.receipt_no as check_num,
|
||||
sales.receipt_date as business_date,
|
||||
sales.requested_at as check_open_time,
|
||||
sales.updated_at as check_close_time,
|
||||
(sales.grand_total + sales.total_discount) as gross_sales,
|
||||
sales.total_discount as discount_amt,
|
||||
sales.grand_total as sales,
|
||||
(sales.grand_total/21) as tax_amt,
|
||||
0 as service_charges,
|
||||
(sales.grand_total - (sales.grand_total/21)) as net_sales,
|
||||
receivables.credit_card_sales as credit_card_sales,
|
||||
receivables.voucher_sales as voucher_sales,
|
||||
0 as staff_meal_amt,
|
||||
sales.rounding_adjustment as rounding_amt,
|
||||
CASE WHEN sales.sale_status='waste' THEN sales.total_amount ELSE 0 END as wastage_amt,
|
||||
CASE WHEN sales.sale_status='spoile' THEN sales.total_amount ELSE 0 END as spoilage_amt,
|
||||
0 as sampling_amt,
|
||||
SUM(i.qty) as qty,
|
||||
0 as no_of_pax,
|
||||
0 as no_of_adult,
|
||||
0 as no_of_child,
|
||||
shift_sales.cashier_terminal_id as pos_id,
|
||||
sales.cashier_id as employee_code,
|
||||
employees.name as employee_name,
|
||||
CASE WHEN sales.sale_status='completed' THEN 1 ELSE 0 END is_valid,
|
||||
0 as overing,
|
||||
0 as cancle,
|
||||
CONCAT( employees.name, ' Cash&Go receipt generated and completed.') as remarks")
|
||||
.joins("LEFT JOIN shift_sales ON shift_sales.id = sales.shift_sale_id")
|
||||
.joins("LEFT JOIN sale_items i ON i.sale_id = sales.sale_id")
|
||||
.joins("LEFT JOIN (" + sale_receivables_subquery + ") as receivables ON receivables.sale_id = sales.sale_id")
|
||||
.joins("LEFT JOIN employees ON employees.id = sales.cashier_id")
|
||||
.where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void)
|
||||
.group("sales.receipt_no,sales.sale_status")
|
||||
end
|
||||
|
||||
# Loader Service SFTP End
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
@@ -294,4 +294,57 @@ class SaleItem < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
# Loader Service SFTP Start
|
||||
# Detail Sale Data
|
||||
def self.get_detail_sale_data(transaction_date)
|
||||
query = SaleItem.select("
|
||||
sale_items.sale_item_id as id,
|
||||
sale_items.sale_id as parent_id,
|
||||
s.receipt_no as check_num,
|
||||
s.receipt_date as business_date,
|
||||
s.receipt_date as transaction_date,
|
||||
'' as item_seq,
|
||||
sale_items.menu_category_code as category_code,
|
||||
sale_items.menu_category_name as category_name,
|
||||
'' as sub_category_code,
|
||||
'' as sub_category_name,
|
||||
'' as report_group_code,
|
||||
'' as report_group_name,
|
||||
sale_items.product_code as item_id,
|
||||
sale_items.product_name as item_name,
|
||||
sale_items.qty as qty,
|
||||
CASE
|
||||
WHEN s.sale_status = 'completed' OR s.sale_status = 'void' THEN 'Sales'
|
||||
WHEN s.sale_status = 'waste' THEN 'Waste'
|
||||
WHEN s.sale_status = 'spoile' THEN 'Spoil'
|
||||
END as transaction_type,
|
||||
sale_items.price as gross_sales,
|
||||
'' as discount_code,
|
||||
CASE
|
||||
WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0
|
||||
END as discount_amt,
|
||||
(sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) as sales,
|
||||
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21) as tax_amt,
|
||||
'' as service_charges,
|
||||
((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END)) - ((sale_items.price - (CASE WHEN i.unit_price IS NOT NULL THEN i.unit_price ELSE 0 END))/21)) as net_sales,
|
||||
'0' as is_set_item,
|
||||
'0' as is_staff_meal,
|
||||
'0' as is_raw_wastage,
|
||||
'0' as is_semi_wastage,
|
||||
CASE WHEN s.sale_status = 'waste' THEN 1 ELSE 0 END as is_wastage,
|
||||
CASE WHEN s.sale_status = 'spoile' THEN 1 ELSE 0 END as is_spoilage,
|
||||
'0' as is_sampling,
|
||||
'1' as tax_able,
|
||||
CASE
|
||||
WHEN s.sale_status = 'void' THEN 1 ELSE 0
|
||||
END as is_void
|
||||
")
|
||||
.joins("LEFT JOIN sales s ON s.sale_id = sale_items.sale_id")
|
||||
.joins("LEFT JOIN sale_items i ON sale_items.sale_id = i.sale_id AND sale_items.item_instance_code = i.item_instance_code AND i.status = 'Discount' AND sale_items.qty = abs(i.qty)")
|
||||
.where("DATE(s.receipt_date) = ? AND s.sale_status != 'void' AND (sale_items.status NOT IN('Discount', 'void','foc') OR sale_items.status IS NULL)", transaction_date)
|
||||
.order("s.receipt_no")
|
||||
end
|
||||
|
||||
# Loader Service SFTP End
|
||||
|
||||
end
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
<div class="form-inputs p-l-25">
|
||||
<%= f.input :name,:input_html=>{:class=>"col-md-9"} %>
|
||||
<%= f.input :is_active,:input_html=>{:class=>"col-md-9"} %>
|
||||
<%= f.input :is_ordering,:input_html=>{:class=>"col-md-9"} %>
|
||||
<%= f.input :is_active,:input_html=>{:class=>"col-md-9"}, as: :boolean %>
|
||||
<%= f.input :is_ordering,:input_html=>{:class=>"col-md-9"}, as: :boolean %>
|
||||
<div class="row checkboxes ">
|
||||
<div class="col-md-2">
|
||||
<label class="control-label"><abbr title="required">*</abbr> Valid Day</label>
|
||||
@@ -50,7 +50,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-actions p-l-20">
|
||||
@@ -58,7 +58,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
|
||||
<div class="card">
|
||||
@@ -81,7 +81,7 @@
|
||||
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.menu_txt") %> <br>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
@@ -114,4 +114,3 @@
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
100
config/deploy.rb
100
config/deploy.rb
@@ -1,20 +1,106 @@
|
||||
lock "3.10.1"
|
||||
# config valid only for current version of Capistrano
|
||||
lock '3.11.2'
|
||||
|
||||
set :application, "zsai"
|
||||
set :repo_url, 'git@bitbucket.org:code2lab/sxrestaurant.git'
|
||||
set :application, 'SmartsalesSX'
|
||||
|
||||
set :deploy_user, 'deploy'
|
||||
set :deploy_to, '/home/deploy/apps/SmartsalesSX'
|
||||
|
||||
set :rbenv_type, :global
|
||||
# setup repo details
|
||||
#set :scm, :git
|
||||
set :repo_url, 'git@gitlab.com:code2lab/SXRestaurant.git'
|
||||
|
||||
# setup rbenv.
|
||||
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
|
||||
|
||||
set :rbenv_map_bins, %w{rake gem bundle ruby rails}
|
||||
|
||||
# how many old releases do we want to keep, not much
|
||||
set :keep_releases, 5
|
||||
|
||||
set :linked_files, %w{config/database.yml config/secrets.yml config/puma.rb config/sidekiq.yml config/shops.json config/cable.yml}
|
||||
# files we want symlinking to specific entries in shared
|
||||
set :linked_files, %w{config/database.yml config/secrets.yml}
|
||||
|
||||
set :linked_dirs, %w{bin log tmp/puma tmp/pids tmp/cache tmp/sockets vendor/bundle public/system pids sockets}
|
||||
# dirs we want symlinking to shared
|
||||
set :linked_dirs, %w{log tmp/pids tmp/puma tmp/cache tmp/sockets vendor/bundle public/system}
|
||||
|
||||
# what specs should be run before deployment is allowed to
|
||||
# continue, see lib/capistrano/tasks/run_tests.cap
|
||||
set :tests, []
|
||||
set :pty, true
|
||||
|
||||
set :puma_jungle_conf, '/etc/puma.conf'
|
||||
set :puma_run_path, '/usr/local/bin/run-puma'
|
||||
set :puma_bind, %w(tcp://0.0.0.0:9393)
|
||||
|
||||
#set :enable_ssl, true
|
||||
|
||||
# which config files should be copied by deploy:setup_config
|
||||
# see documentation in lib/capistrano/tasks/setup_config.cap
|
||||
# for details of operations
|
||||
set(:config_files, %w(
|
||||
database.yml
|
||||
log_rotation
|
||||
monit.conf
|
||||
sidekiq_init.sh
|
||||
sidekiq.yml
|
||||
))
|
||||
|
||||
# which config files should be made executable after copying
|
||||
# by deploy:setup_config
|
||||
set(:executable_config_files, %w(
|
||||
sidekiq_init.sh
|
||||
))
|
||||
|
||||
# files which need to be symlinked to other parts of the
|
||||
# filesystem. For example nginx virtualhosts, log rotation
|
||||
# init scripts etc. The full_app_name variable isn't
|
||||
# available at this point so we use a custom template {{}}
|
||||
# tag and then add it at run time.
|
||||
set(:symlinks, [
|
||||
{
|
||||
source: "sidekiq_init.sh",
|
||||
link: "/etc/init.d/sidekiq_{{full_app_name}}"
|
||||
},
|
||||
{
|
||||
source: "log_rotation",
|
||||
link: "/etc/logrotate.d/{{full_app_name}}"
|
||||
},
|
||||
{
|
||||
source: "monit",
|
||||
link: "/etc/monit/conf.d/{{full_app_name}}.conf"
|
||||
}
|
||||
])
|
||||
|
||||
# this:
|
||||
# http://www.capistranorb.com/documentation/getting-started/flow/
|
||||
# is worth reading for a quick overview of what tasks are called
|
||||
# and when for `cap stage deploy`
|
||||
|
||||
namespace :deploy do
|
||||
# make sure we're deploying what we think we're deploying
|
||||
before :deploy, "deploy:check_revision"
|
||||
# only allow a deploy with passing tests to deployed
|
||||
before :deploy, "deploy:run_tests"
|
||||
# compile assets locally then rsync
|
||||
after 'deploy:symlink:shared', 'deploy:compile_assets_locally'
|
||||
Rake::Task["deploy:assets:precompile"].clear_actions
|
||||
|
||||
after :finishing, 'deploy:cleanup'
|
||||
|
||||
#nginx will be install in the Load Balancer - No need to deploy there
|
||||
# remove the default nginx configuration as it will tend
|
||||
# to conflict with our configs.
|
||||
#before 'deploy:setup_config', 'nginx:remove_default_vhost'
|
||||
|
||||
# reload nginx to it will pick up any modified vhosts from
|
||||
# setup_config
|
||||
#after 'deploy:setup_config', 'nginx:reload'
|
||||
|
||||
# Restart monit so it will pick up any monit configurations
|
||||
# we've added
|
||||
#after 'deploy:setup_config', 'monit:restart'
|
||||
|
||||
# As of Capistrano 3.1, the `deploy:restart` task is not called
|
||||
# automatically.
|
||||
after 'finishing', 'puma:jungle:restart'
|
||||
end
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
# set :stage, :production
|
||||
# set :server_name, "svr.sxrestaurant.host"
|
||||
|
||||
# set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
||||
# server '192.168.1.27', user: 'deploy', roles: %w{web app db}, primary: true
|
||||
|
||||
# set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
|
||||
# set :rbenv_ruby, '2.4.1'
|
||||
# set :rails_env, :production
|
||||
|
||||
set :stage, :production
|
||||
set :server_name, "svr.sxrestaurant.host"
|
||||
set :server_name, "a.c2l.shop"
|
||||
set :branch, "r-1902001-01"
|
||||
|
||||
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
|
||||
server '192.168.1.27', user: 'deploy', roles: %w{web app db}, primary: true
|
||||
server '167.71.194.57', user: 'deploy', roles: %w{web app db}, primary: true
|
||||
|
||||
set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:full_app_name)}"
|
||||
set :rbenv_ruby, '2.4.1'
|
||||
set :rbenv_ruby, '2.6.5'
|
||||
set :rails_env, :production
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
if File.exist?("config/license.yml")
|
||||
if File.exist?("config/license.yml")
|
||||
config = YAML.load_file(Rails.root.join("config/license.yml"))
|
||||
config.fetch(Rails.env, {}).each do |key, value|
|
||||
ENV[key.upcase] = value.to_s
|
||||
end
|
||||
end
|
||||
else
|
||||
ENV["SERVER_MODE"] = "cloud"
|
||||
end
|
||||
|
||||
@@ -117,6 +117,14 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
|
||||
#API for sync cloud
|
||||
post 'sync_data' => 'sync#sync_data'
|
||||
|
||||
namespace :loader_service do
|
||||
post "get_sale_data" => "load_data#get_sale_data_rage"
|
||||
post "get_detail_sale_data" => "load_data#get_detail_sale_data"
|
||||
post "get_tender_sale_data" => "load_data#get_tender_sale_data"
|
||||
post "get_daily_sale_data" => "load_data#get_daily_sale_data"
|
||||
post "get_check_sale_data" => "load_data#get_check_sale_data"
|
||||
end
|
||||
end
|
||||
|
||||
#--------- Cashier ------------#
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
version: '3'
|
||||
services:
|
||||
code2lab:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
links:
|
||||
- redis
|
||||
volumes:
|
||||
- .:/sxrestaurant
|
||||
env_file:
|
||||
- .code2lab.env
|
||||
ports:
|
||||
- '8082: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:
|
||||
- '6380:6379'
|
||||
volumes:
|
||||
- ../data/redis:/data
|
||||
code2lab:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
links:
|
||||
- redis
|
||||
volumes:
|
||||
- .:/sxrestaurant
|
||||
- "/etc/timezone:/etc/timezone:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
env_file:
|
||||
- .code2lab.env
|
||||
ports:
|
||||
- '62160:62158'
|
||||
environment:
|
||||
- REDIS_URL=redis://172.17.0.1:6380/0
|
||||
sidekiq:
|
||||
build: .
|
||||
command: bundle exec sidekiq -C config/sidekiq.yml
|
||||
links:
|
||||
- redis
|
||||
volumes:
|
||||
- .:/sxrestaurant
|
||||
environment:
|
||||
- REDIS_URL=redis://172.17.0.1:6380/0
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- '6380:6379'
|
||||
volumes:
|
||||
- ../data/redis:/data
|
||||
|
||||
12
lib/capistrano/substitute_strings.rb
Normal file
12
lib/capistrano/substitute_strings.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# we often want to refer to variables which
|
||||
# are defined in subsequent stage files. This
|
||||
# let's us use the {{var}} to represent fetch(:var)
|
||||
# in strings which are only evaluated at runtime.
|
||||
|
||||
def sub_strings(input_string)
|
||||
output_string = input_string
|
||||
input_string.scan(/{{(\w*)}}/).each do |var|
|
||||
output_string.gsub!("{{#{var[0]}}}", fetch(var[0].to_sym))
|
||||
end
|
||||
output_string
|
||||
end
|
||||
14
lib/capistrano/tasks/check_revision.cap
Normal file
14
lib/capistrano/tasks/check_revision.cap
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace :deploy do
|
||||
desc "checks whether the currently checkout out revision matches the
|
||||
remote one we're trying to deploy from"
|
||||
task :check_revision do
|
||||
branch = fetch(:branch)
|
||||
unless `git rev-parse HEAD` == `git rev-parse #{branch}`
|
||||
puts "WARNING: HEAD is not the same as #{branch}"
|
||||
puts "Run `git push` to sync changes or make sure you've"
|
||||
puts "checked out the branch: #{branch} as you can only deploy"
|
||||
puts "if you've got the target branch checked out"
|
||||
exit
|
||||
end
|
||||
end
|
||||
end
|
||||
17
lib/capistrano/tasks/compile_assets_locally.cap
Normal file
17
lib/capistrano/tasks/compile_assets_locally.cap
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace :deploy do
|
||||
desc "compiles assets locally then rsyncs"
|
||||
task :compile_assets_locally do
|
||||
run_locally do
|
||||
execute "RAILS_ENV=#{fetch(:rails_env)} bundle exec rake assets:precompile"
|
||||
end
|
||||
on roles(:app) do |role|
|
||||
run_locally do
|
||||
execute"rsync -av ./public/assets/ #{role.user}@#{role.hostname}:#{release_path}/public/assets/;"
|
||||
end
|
||||
sudo "chmod -R 755 #{release_path}/public/assets/"
|
||||
end
|
||||
run_locally do
|
||||
execute "rm -rf ./public/assets"
|
||||
end
|
||||
end
|
||||
end
|
||||
14
lib/capistrano/tasks/logs.cap
Normal file
14
lib/capistrano/tasks/logs.cap
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace :logs do
|
||||
task :tail, :file do |t, args|
|
||||
if args[:file]
|
||||
on roles(:app) do
|
||||
execute "tail -f #{shared_path}/log/#{args[:file]}.log"
|
||||
end
|
||||
else
|
||||
puts "please specify a logfile e.g: 'rake logs:tail[logfile]"
|
||||
puts "will tail 'shared_path/log/logfile.log'"
|
||||
puts "remember if you use zsh you'll need to format it as:"
|
||||
puts "rake 'logs:tail[logfile]' (single quotes)"
|
||||
end
|
||||
end
|
||||
end
|
||||
10
lib/capistrano/tasks/monit.cap
Normal file
10
lib/capistrano/tasks/monit.cap
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace :monit do
|
||||
%w(start stop restart).each do |task_name|
|
||||
desc "#{task_name} Monit"
|
||||
task task_name do
|
||||
on roles(:app), in: :sequence, wait: 5 do
|
||||
sudo "service monit #{task_name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
22
lib/capistrano/tasks/nginx.cap
Normal file
22
lib/capistrano/tasks/nginx.cap
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace :nginx do
|
||||
%w(start stop restart reload).each do |task_name|
|
||||
desc "#{task } Nginx"
|
||||
task task_name do
|
||||
on roles(:app), in: :sequence, wait: 5 do
|
||||
sudo "/etc/init.d/nginx #{task_name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Remove default Nginx Virtual Host"
|
||||
task "remove_default_vhost" do
|
||||
on roles(:app) do
|
||||
if test("[ -f /etc/nginx/sites-enabled/default ]")
|
||||
sudo "rm /etc/nginx/sites-enabled/default"
|
||||
puts "removed default Nginx Virtualhost"
|
||||
else
|
||||
puts "No default Nginx Virtualhost to remove"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
10
lib/capistrano/tasks/restart.cap
Normal file
10
lib/capistrano/tasks/restart.cap
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace :deploy do
|
||||
desc 'Commands for unicorn application'
|
||||
%w(start stop force-stop restart upgrade reopen-logs).each do |command|
|
||||
task command.to_sym do
|
||||
on roles(:app), in: :sequence, wait: 5 do
|
||||
sudo "/etc/init.d/unicorn_#{fetch(:full_app_name)} #{command}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
18
lib/capistrano/tasks/run_tests.cap
Normal file
18
lib/capistrano/tasks/run_tests.cap
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace :deploy do
|
||||
desc "Runs test before deploying, can't deploy unless they pass"
|
||||
task :run_tests do
|
||||
test_log = "log/capistrano.test.log"
|
||||
tests = fetch(:tests)
|
||||
tests.each do |test|
|
||||
puts "--> Running tests: '#{test}', please wait ..."
|
||||
unless system "bundle exec rspec #{test} > #{test_log} 2>&1"
|
||||
puts "--> Tests: '#{test}' failed. Results in: #{test_log} and below:"
|
||||
system "cat #{test_log}"
|
||||
exit;
|
||||
end
|
||||
puts "--> '#{test}' passed"
|
||||
end
|
||||
puts "--> All tests passed"
|
||||
system "rm #{test_log}"
|
||||
end
|
||||
end
|
||||
33
lib/capistrano/tasks/setup_config.cap
Normal file
33
lib/capistrano/tasks/setup_config.cap
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace :deploy do
|
||||
task :setup_config do
|
||||
on roles(:app) do
|
||||
# make the config dir
|
||||
execute :mkdir, "-p #{shared_path}/config"
|
||||
full_app_name = fetch(:full_app_name)
|
||||
|
||||
# config files to be uploaded to shared/config, see the
|
||||
# definition of smart_template for details of operation.
|
||||
# Essentially looks for #{filename}.erb in deploy/#{full_app_name}/
|
||||
# and if it isn't there, falls back to deploy/#{shared}. Generally
|
||||
# everything should be in deploy/shared with params which differ
|
||||
# set in the stage files
|
||||
config_files = fetch(:config_files)
|
||||
config_files.each do |file|
|
||||
smart_template file
|
||||
end
|
||||
|
||||
# which of the above files should be marked as executable
|
||||
executable_files = fetch(:executable_config_files)
|
||||
executable_files.each do |file|
|
||||
execute :chmod, "+x #{shared_path}/config/#{file}"
|
||||
end
|
||||
|
||||
# symlink stuff which should be... symlinked
|
||||
symlinks = fetch(:symlinks)
|
||||
|
||||
symlinks.each do |symlink|
|
||||
sudo "ln -nfs #{shared_path}/config/#{symlink[:source]} #{sub_strings(symlink[:link])}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
32
lib/capistrano/template.rb
Normal file
32
lib/capistrano/template.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
# will first try and copy the file:
|
||||
# config/deploy/#{full_app_name}/#{from}.erb
|
||||
# to:
|
||||
# shared/config/to
|
||||
# if the original source path doesn exist then it will
|
||||
# search in:
|
||||
# config/deploy/shared/#{from}.erb
|
||||
# this allows files which are common to all enviros to
|
||||
# come from a single source while allowing specific
|
||||
# ones to be over-ridden
|
||||
# if the target file name is the same as the source then
|
||||
# the second parameter can be left out
|
||||
def smart_template(from, to=nil)
|
||||
to ||= from
|
||||
full_to_path = "#{shared_path}/config/#{to}"
|
||||
if from_erb_path = template_file(from)
|
||||
from_erb = StringIO.new(ERB.new(File.read(from_erb_path)).result(binding))
|
||||
upload! from_erb, full_to_path
|
||||
info "copying: #{from_erb} to: #{full_to_path}"
|
||||
else
|
||||
error "error #{from} not found"
|
||||
end
|
||||
end
|
||||
|
||||
def template_file(name)
|
||||
if File.exist?((file = "config/deploy/#{fetch(:full_app_name)}/#{name}.erb"))
|
||||
return file
|
||||
elsif File.exist?((file = "config/deploy/shared/#{name}.erb"))
|
||||
return file
|
||||
end
|
||||
return nil
|
||||
end
|
||||
Reference in New Issue
Block a user