change split bill equal person flow

This commit is contained in:
phyusin
2018-02-21 18:24:04 +06:30
parent d991a9f0ee
commit e2903075b2
11 changed files with 52 additions and 149 deletions

View File

@@ -84,86 +84,6 @@ class Origami::SurveysController < BaseOrigamiController
end
end
def create_survey
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
@type = params[:cashier_type]
@sale_id = params[:sale_id]
sale = Sale.find(@sale_id)
receipt_no = params[:receipt_no]
if @type != "quick_service"
dining_facility = DiningFacility.find(params[:dining_id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
cashier_terminal_id = cashier_zone.cashier_terminal_id
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_terminal_id = shift.cashier_terminal_id
end
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_terminal_id,nil)
if @type != "quick_service"
survey = Survey.find_by_dining_name_and_receipt_no(dining_facility.name,receipt_no)
else
survey = nil
end
if survey.nil?
if @type != "quick_service"
survey = Survey.find_by_dining_name_and_receipt_no(dining_facility.name,nil)
if survey.nil?
survey = Survey.new
survey.dining_name = dining_facility.name
survey.receipt_no = params[:receipt_no]
survey.shift_id = shift_by_terminal.id
survey.created_by = current_user.name
survey.total_customer = params[:total_customer]
survey.total_amount = params[:total_amount]
survey.save!
else
survey.receipt_no = params[:receipt_no]
survey.total_customer = params[:total_customer]
survey.total_amount = params[:total_amount]
survey.save!
end
else
survey = Survey.new
survey.receipt_no = params[:receipt_no]
survey.shift_id = shift_by_terminal.id
survey.created_by = current_user.name
survey.total_customer = params[:total_customer]
survey.total_amount = params[:total_amount]
survey.save!
end
else
survey.receipt_no = params[:receipt_no]
survey.total_customer = params[:total_customer]
survey.total_amount = params[:total_amount]
survey.save!
end
render :json => {status: true}
else
render :json => { status: false, error_message: 'No Current Open Shift!'}
end
end
def get_survey
dining_id = params[:dining_id]
receipt_no = params[:receipt_no]
table = DiningFacility.find_by_id(dining_id)
survey = Survey.find_by_dining_name_and_receipt_no(table.name,receipt_no)
if survey.nil?
survey = Survey.find_by_dining_name_and_receipt_no(table.name,nil)
end
if !survey.nil?
render :json => { status: true, survey: survey }
else
render :json => { status: false }
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.