split bill process

This commit is contained in:
phyusin
2018-02-20 13:33:59 +06:30
parent 8ccf45d06f
commit 4bfb5842bf
7 changed files with 88 additions and 18 deletions

View File

@@ -186,9 +186,21 @@ class Origami::PaymentsController < BaseOrigamiController
@table_no = ''
@dining = ''
@shop = Shop::ShopDetail
@shop = Shop::ShopDetail #show shop info
saleObj = Sale.find(sale_id)
#total customer with individual total amount
survey = nil
@individual_total = Array.new
if !@sale_data.nil?
survey = Survey.find_by_receipt_no(@sale_data.receipt_no)
if !survey.nil?
per_person_amount = saleObj.grand_total.to_f / survey.total_customer.to_i
@individual_total.push({'total_customer' => survey.total_customer, 'per_person_amount' => per_person_amount.to_f })
end
end
# rounding adjustment
if @shop.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus

View File

@@ -86,9 +86,10 @@ class Origami::SurveysController < BaseOrigamiController
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)
@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])
@@ -102,27 +103,43 @@ class Origami::SurveysController < BaseOrigamiController
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(dining_facility.name)
survey = Survey.find_by_dining_name_and_receipt_no(dining_facility.name,receipt_no)
else
survey = nil
end
if survey.nil?
survey = Survey.new
if @type != "quick_service"
survey.dining_name = dining_facility.name
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
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
render :json => {status: true}
@@ -131,6 +148,22 @@ class Origami::SurveysController < BaseOrigamiController
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.