split bill process
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -484,7 +484,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
||||
|
||||
bounding_box([0,y_position], :width =>self.label_width) do
|
||||
move_down 15
|
||||
text "Total", :size => self.item_font_size,:align => :left
|
||||
text "Total Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
|
||||
@@ -493,7 +493,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
bounding_box([0,y_position], :width =>self.label_width) do
|
||||
move_down 15
|
||||
text "Total", :size => self.item_font_size,:align => :left
|
||||
text "Total Amount", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||
|
||||
@@ -107,6 +107,14 @@
|
||||
<td class="item-attr"><strong><span><%=@balance%></span></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if !@individual_total.nil? %>
|
||||
<tr>
|
||||
<td class="charges-name">
|
||||
<strong>Individual amount for <%= @individual_total[0]['total_customer'] %> persons</strong>
|
||||
</td>
|
||||
<td class="item-attr"><strong><span><%=@individual_total[0]['per_person_amount']%></span></strong></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tfooter>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -318,7 +318,6 @@
|
||||
var split_receipt_no = "";
|
||||
var split_total_amount = 0;
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#back').on('click',function(){
|
||||
backToOrigami();
|
||||
})
|
||||
@@ -472,9 +471,26 @@
|
||||
|
||||
//equal split process
|
||||
$('#equal_split').on('click', function(){
|
||||
var dining_id = $("#table_id").text();
|
||||
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val();
|
||||
split_receipt_no = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('id');
|
||||
split_total_amount = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('data');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/split_bills/get_survey",
|
||||
dataType: 'JSON',
|
||||
data: {'dining_id':dining_id, 'receipt_no':split_receipt_no },
|
||||
success: function (result) {
|
||||
if(result.status){
|
||||
if(parseInt(result.survey.total_customer) > 0){
|
||||
$("#per_person").val(parseInt(result.survey.total_customer));
|
||||
}else{
|
||||
$("#per_person").val("");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if(split_sale_id != undefined && split_sale_id != ""){
|
||||
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
|
||||
}
|
||||
|
||||
@@ -239,6 +239,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills"
|
||||
|
||||
post '/split_bills/surveys', to: 'surveys#create_survey'
|
||||
post '/split_bills/get_survey', to: 'surveys#get_survey'
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user