change split bill equal person flow
This commit is contained in:
@@ -8,7 +8,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
sale_items = SaleItem.where("sale_id=?",sale_id)
|
||||
member_info = nil
|
||||
survey = Survey.find_by_receipt_no(sale_data.receipt_no)
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
@@ -67,7 +66,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil,survey)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +78,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop::ShopDetail
|
||||
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = saleObj.grand_total % 25 # Modulus
|
||||
@@ -153,7 +151,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data,survey)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
|
||||
|
||||
if params[:type] == "quick_service"
|
||||
booking = Booking.find_by_sale_id(sale_id)
|
||||
@@ -197,14 +195,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
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
|
||||
if !saleObj.equal_persons.nil?
|
||||
per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
|
||||
@individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
|
||||
end
|
||||
|
||||
# rounding adjustment
|
||||
@@ -295,7 +289,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
member_info = nil
|
||||
|
||||
saleObj = Sale.find(sale_id)
|
||||
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
|
||||
|
||||
# For Cashier by Zone
|
||||
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||
@@ -349,7 +342,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data,survey)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -363,7 +356,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
|
||||
|
||||
if saleObj.discount_type == "member_discount"
|
||||
saleObj.update_attributes(rounding_adjustment: 0)
|
||||
@@ -408,7 +400,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil,survey)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -146,15 +146,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|
|
||||
@@ -164,8 +164,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|
|
||||
@@ -194,7 +194,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
|
||||
@@ -222,7 +222,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)
|
||||
@@ -235,7 +235,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
|
||||
@@ -356,6 +356,14 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
orderItem.save!
|
||||
end
|
||||
|
||||
def update_sale
|
||||
sale = Sale.find(params[:sale_id])
|
||||
sale.equal_persons = params[:total_customer].to_i
|
||||
sale.save!
|
||||
|
||||
render :json => { status: true }
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -6,7 +6,6 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
survey = Survey.find_by_receipt_no(sale.receipt_no)
|
||||
|
||||
if sale.discount_type == "member_discount"
|
||||
sale.update_attributes(total_discount: 0)
|
||||
@@ -125,7 +124,7 @@ class Origami::VoidController < BaseOrigamiController
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,survey)
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
|
||||
end
|
||||
|
||||
#end print
|
||||
|
||||
Reference in New Issue
Block a user