Pull from master
This commit is contained in:
47
app/controllers/api/survey_controller.rb
Normal file
47
app/controllers/api/survey_controller.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
class Api::SurveyController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def index
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
survey_data = Survey.find_by_dining_name(dining_facility.name)
|
||||
countries = Lookup.collection_of("country")
|
||||
if !countries.nil? || !survey_data.nil?
|
||||
render :json => { :status => true, :data => { :countries => countries, :survey_data => survey_data} }
|
||||
else
|
||||
render :json => { :status => true, :error_message => "There is no data" }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
dining_facility = DiningFacility.find(params[:id])
|
||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
|
||||
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||
|
||||
if params[:survey_id]
|
||||
survey = Survey.find(params[:survey_id])
|
||||
else
|
||||
survey = Survey.new
|
||||
end
|
||||
survey.dining_name = dining_facility.name
|
||||
survey.shift_id = shift_by_terminal.id
|
||||
survey.child = params[:child]
|
||||
survey.adult = params[:adult]
|
||||
survey.male = params[:male]
|
||||
survey.female = params[:female]
|
||||
survey.local = params[:local]
|
||||
survey.created_by = current_login_employee.name
|
||||
survey.total_customer = params[:total_customer]
|
||||
survey.total_amount = params[:total_amount]
|
||||
survey.foreigner = params[:foreigner].to_json
|
||||
survey.save!
|
||||
|
||||
render :json => { :status => true }
|
||||
end
|
||||
|
||||
# private
|
||||
# def survey_params
|
||||
# params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner,
|
||||
# :dining_name,:created_by,:total_customer,:total_amount)
|
||||
# end
|
||||
|
||||
end
|
||||
@@ -16,7 +16,7 @@ class Origami::RequestBillsController < ApplicationController
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
order = Order.find(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
table = DiningFacility.find(check_booking.dining_facility_id)
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source)
|
||||
@@ -33,6 +33,8 @@ class Origami::RequestBillsController < ApplicationController
|
||||
|
||||
# Promotion Activation
|
||||
Promotion.promo_activate(@sale)
|
||||
#bill channel
|
||||
ActionCable.server.broadcast "bill_channel",table: table
|
||||
if order.source == "quick_service"
|
||||
result = {:status=> @status, :data => @sale.sale_id }
|
||||
render :json => result.to_json
|
||||
|
||||
@@ -3,18 +3,26 @@ class Reports::SaleitemController < BaseReportController
|
||||
def index
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
shift_sale_range = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale_range = ''
|
||||
|
||||
shift = ''
|
||||
if params[:shift_name].to_i != 0
|
||||
|
||||
shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
shift_sale = ShiftSale.find(params[:shift_name])
|
||||
if to.blank?
|
||||
if to.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
|
||||
else
|
||||
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
if shift_sale.shift_closed_at.blank?
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',shift_sale.shift_started_at)
|
||||
else
|
||||
shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@type = params[:sale_type]
|
||||
@sale_data, @other_charges,@discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type)
|
||||
|
||||
@@ -54,8 +62,8 @@ class Reports::SaleitemController < BaseReportController
|
||||
|
||||
def show
|
||||
from, to, report_type = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
puts "aaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
@@ -68,8 +76,8 @@ class Reports::SaleitemController < BaseReportController
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
@sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
# @totalByAccount = Hash.new {|hash, key| hash[key] = 0}
|
||||
# @sale_data.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user