update conflix split pull

This commit is contained in:
Aung Myo
2018-02-28 17:04:35 +06:30
52 changed files with 2027 additions and 437 deletions

View File

@@ -1,60 +1,25 @@
class ApplicationController < ActionController::Base
include LicenseVerification
include LoginVerification
#before_action :check_installation
protect_from_forgery with: :exception
# lookup domain for db from provision
before_action :set_locale
helper_method :current_company,:current_login_employee,:current_user,:shop_detail
# before_action :set_locale
# helper_method :current_company,:current_login_employee,:current_user
# alias_method :current_user, :current_login_employee,:current_user
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
#change locallization
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
# RESTful url for localize
def default_url_options
{ locale: I18n.locale }
end
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
redirect_to root_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
# Get current Cashier
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end
def current_company
begin
return Company.first
rescue
return nil
end
end
def shop_detail
@shop = Shop.first
end
def current_login_employee
if (!session[:session_token].nil?)
@employee = Employee.find_by_token_session(session[:session_token])
end
end
end

View File

@@ -1,4 +1,5 @@
class BaseCrmController < ApplicationController
class BaseCrmController < ActionController::Base
include LoginVerification
layout "CRM"
#before_action :check_installation
@@ -8,19 +9,4 @@ class BaseCrmController < ApplicationController
flash[:warning] = exception.message
redirect_to root_path
end
#change locallization
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
# RESTful url for localize
def default_url_options
{ locale: I18n.locale }
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
end

View File

@@ -1,4 +1,5 @@
class BaseInventoryController < ApplicationController
class BaseInventoryController < ActionController::Base
include LoginVerification
layout "inventory"
#before_action :check_installation
@@ -8,9 +9,4 @@ class BaseInventoryController < ApplicationController
flash[:warning] = exception.message
redirect_to root_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
end

View File

@@ -1,4 +1,5 @@
class BaseOqsController < ApplicationController
class BaseOqsController < ActionController::Base
include LoginVerification
layout "OQS"
#before_action :check_installation
@@ -8,19 +9,4 @@ class BaseOqsController < ApplicationController
flash[:warning] = exception.message
redirect_to root_path
end
#change locallization
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
# RESTful url for localize
def default_url_options
{ locale: I18n.locale }
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
end

View File

@@ -1,10 +1,12 @@
class BaseOrigamiController < ApplicationController
class BaseOrigamiController < ActionController::Base
include LoginVerification
layout "origami"
# before_action :checkin_process
#before_action :check_installation
protect_from_forgery with: :exception
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
# redirect_to origami_root_path

View File

@@ -1,18 +1,15 @@
class BaseReportController < ApplicationController
layout "application"
class BaseReportController < ActionController::Base
include LoginVerification
layout "application"
#before_action :check_installation
protect_from_forgery with: :exception
#before_action :check_installation
protect_from_forgery with: :exception
rescue_from CanCan::AccessDenied do |exception|
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
redirect_to root_path
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
PERIOD = {
"today" => 0,
"yesterday" => 1,
@@ -82,8 +79,5 @@ class BaseReportController < ApplicationController
end
return from, to
end
end

View File

@@ -1,4 +1,5 @@
class BaseWaiterController < ApplicationController
class BaseWaiterController < ActionController::Base
include LoginVerification
layout "waiter"
#before_action :check_installation

View File

@@ -3,7 +3,7 @@ module LoginVerification
included do
before_action :authenticate_session_token
helper_method :current_company,:current_login_employee
helper_method :current_company, :current_login_employee, :current_user, :get_cashier
end
#this is base api base controller to need to inherit.
@@ -15,16 +15,32 @@ module LoginVerification
rescue
return nil
end
end
def current_login_employee
@employee = Employee.find_by_token_session(session[:session_token])
if (!session[:session_token].nil?)
@employee = Employee.find_by_token_session(session[:session_token])
else
render_unauthorized
end
end
def current_user
if (!session[:session_token].nil?)
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
else
render_unauthorized
end
end
# Get current Cashiers
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end
protected
# Authenticate the user with token based authentication
def authenticate
def authenticate
authenticate_session_token || render_unauthorized
end
@@ -38,9 +54,9 @@ module LoginVerification
if @user
return true
#Maybe log - login?
else
flash[:notice] = 'Invalid Access!'
# return false
# else
# flash[:notice] = 'Invalid Access!'
# # return false
end
end
end

View File

@@ -65,57 +65,59 @@ class HomeController < ApplicationController
end
def dashboard
@from, @to = get_date_range_from_params
@shop = Shop.first
today = DateTime.now.strftime('%Y-%m-%d')
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
@top_products = Sale.top_products(today).sum('i.qty')
@bottom_products = Sale.bottom_products(today).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today).sum(:grand_total)
@top_products = Sale.top_products(today,@from,@to).sum('i.qty')
@bottom_products = Sale.bottom_products(today,@from,@to).sum('i.qty')
@hourly_sales = Sale.hourly_sales(today,@from,@to).sum(:grand_total)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
@employee_sales = Sale.employee_sales(today)
@employee_sales = Sale.employee_sales(today,@from,@to)
.sum('(CASE WHEN sp.payment_method="cash" THEN (sp.payment_amount - sales.amount_changed) ELSE sp.payment_amount END)')
@inventories = StockJournal.inventory_balances(today).sum(:balance)
@inventories = StockJournal.inventory_balances(today,@from,@to).sum(:balance)
@total_sale = Sale.total_sale(today)
@total_count = Sale.total_count(today)
@total_card = Sale.total_card_sale(today)
@total_credit = Sale.credit_payment(today)
@total_sale = Sale.total_sale(today,current_user,@from,@to)
@total_count = Sale.total_count(today,current_user,@from,@to)
@total_card = Sale.total_card_sale(today,current_user,@from,@to)
@total_credit = Sale.credit_payment(today,current_user,@from,@to)
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(today)
@total_payment_methods = Sale.total_payment_methods(today,current_user,@from,@to)
@total_payment_methods.each do |payment|
if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb"
pay = Sale.payment_sale('card', today)
pay = Sale.payment_sale('card', today, current_user,@from,@to)
@sale_data.push({'card' => pay.payment_amount})
else
pay = Sale.payment_sale(payment.payment_method, today)
pay = Sale.payment_sale(payment.payment_method, today, current_user,@from,@to)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
@summ_sale = Sale.summary_sale_receipt(today)
@total_customer = Sale.total_customer(today)
@total_dinein = Sale.total_dinein(today)
@total_takeaway = Sale.total_takeaway(today)
@total_other_customer = Sale.total_other_customer(today)
@total_membership = Sale.total_membership(today)
@summ_sale = Sale.summary_sale_receipt(today,current_user,@from,@to)
@total_customer = Sale.total_customer(today,current_user,@from,@to)
@total_dinein = Sale.total_dinein(today,current_user,@from,@to)
@total_takeaway = Sale.total_takeaway(today,current_user,@from,@to)
@total_other_customer = Sale.total_other_customer(today,current_user,@from,@to)
@total_membership = Sale.total_membership(today,current_user,@from,@to)
@total_order = Sale.total_order(today)
@total_accounts = Sale.total_account(today)
@total_order = Sale.total_order(today,current_user,@from,@to)
@total_accounts = Sale.total_account(today,current_user,@from,@to)
@account_data = Array.new
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id, today)
acc = Sale.account_data(account.account_id, today,current_user,@from,@to)
if !acc.nil?
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
@top_items = Sale.top_items(today)
@total_foc_items = Sale.total_foc_items(today)
@top_items = Sale.top_items(today,current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(today,current_user,@from,@to)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@@ -173,4 +175,19 @@ class HomeController < ApplicationController
end
end
def get_date_range_from_params
from = params[:from]
to = params[:to]
if from.present? && to.present?
f_date = DateTime.parse(from)
t_date = DateTime.parse(to)
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
end
return from, to
end
end

View File

@@ -14,19 +14,19 @@ class Oqs::HomeController < BaseOqsController
@queue_stations = OrderQueueStation.all
@queue_completed_item = completed_order(@filter)
# if !@queue_completed_item.empty?
# @queue_completed_item.each do |queue_item|
# if !queue_item.set_menu_items.nil?
# instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
# arr_instance_item_sets = Array.new
# instance_item_sets.each do |instance_item|
# item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
# arr_instance_item_sets.push(item_instance_name)
# end
# queue_item.set_menu_items = arr_instance_item_sets
# end
# end
# end
if !@queue_completed_item.empty?
@queue_completed_item.each do |queue_item|
if !queue_item.set_menu_items.nil?
instance_item_sets = JSON.parse(JSON.parse(queue_item.set_menu_items))
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
end
queue_item.set_menu_items = arr_instance_item_sets
end
end
end
if !@filter.nil?
@count = queue_items_count_query(false,@filter)

View File

@@ -90,14 +90,17 @@ class Origami::HomeController < BaseOrigamiController
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
# end
end
accounts = @customer.tax_profiles
puts accounts.to_json
puts "sssssssssss"
puts @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
@account_arr = Array.new
if @customer.tax_profiles
accounts = @customer.tax_profiles
puts accounts.to_json
puts "sssssssssss"
puts @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
end
end

View File

@@ -58,7 +58,7 @@ class Origami::RoomsController < BaseOrigamiController
@room.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
@assigned_order_items = Array.new
# @assigned_order_items = Array.new
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@customer = order.customer
@@ -79,10 +79,10 @@ class Origami::RoomsController < BaseOrigamiController
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
if !assigned_order_items.nil?
@assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
end
# assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id)
# if !assigned_order_items.nil?
# @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id})
# end
end
end
end

View File

@@ -61,7 +61,21 @@ class Origami::ShiftsController < BaseOrigamiController
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
close_cashier_pdf = Lookup.collection_of("print_settings")
unique_code = "CloseCashierPdf"
if !close_cashier_pdf.empty?
close_cashier_pdf.each do |close_cashier|
if close_cashier[0] == 'CloseCashierCustomisePdf'
if close_cashier[1] == '1'
unique_code="CloseCashierCustomisePdf"
else
unique_code="CloseCashierPdf"
end
end
end
end
shop_details = Shop.find(1)
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@@ -73,12 +87,16 @@ class Origami::ShiftsController < BaseOrigamiController
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
#byebug
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges)
end
end
Employee.logout(session[:session_token])
@@ -102,8 +120,7 @@ class Origami::ShiftsController < BaseOrigamiController
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
end
end

View File

@@ -147,15 +147,15 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
# puts order_id
# puts order_ids.count
# puts order_id_count
# puts order_items.count
# puts order_item_count
puts order_id
puts order_ids.count
puts order_id_count
puts order_items.count
puts order_item_count
if !order_id.nil?
if order_id_count > 1
# puts "order_id_count > 1"
puts "order_id_count > 1"
updated_order_id = Array.new
order_ids.each do |odr_id|
@@ -165,8 +165,8 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
# puts "updated_order_id"
# puts updated_order_id
puts "updated_order_id"
puts updated_order_id
if !updated_order_id.empty?
order_ids.each do |odr_id|
@@ -195,7 +195,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
# puts new_order_status
puts new_order_status
if new_order_status
BookingOrder.find_by_order_id(odr_id).delete
@@ -223,7 +223,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
else
# puts "order_id_count < 1"
puts "order_id_count < 1"
new_order_status = true
order_items.each do |order_item|
orderItem = OrderItem.find_by_order_id(order_id)
@@ -236,7 +236,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
# puts new_order_status
puts new_order_status
if new_order_status
BookingOrder.find_by_order_id(order_id).delete
@@ -266,7 +266,9 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
else
if order_ids.count == 1 && order_id_count > 0 && order_item_count == 1
# puts order_ids
if order_ids.count == 1 && order_id_count == 0 && order_item_count == 1
BookingOrder.find_by_order_id(order_ids[0]).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
order_items.each do |order_item|
update_order_item(order_ids[0], order_item)

View File

@@ -0,0 +1,21 @@
class Reports::ProductSaleController < BaseReportController
authorize_resource :class => false
def index
@order_by = 'desc'
if !params[:order_by].nil?
@order_by = params[:order_by]
end
@sale_data = Sale.get_menu_item_query(@order_by)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.json
format.xls
end
end
end

View File

@@ -33,7 +33,7 @@ class Reports::SaleitemController < BaseReportController
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()

View File

@@ -17,7 +17,7 @@ class Reports::StockCheckController < BaseReportController
@from = from_date
@to = to_date
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls