Merge branch 'split_bill' of bitbucket.org:code2lab/sxrestaurant into quick_service

This commit is contained in:
Aung Myo
2018-02-22 09:39:54 +06:30
13 changed files with 92 additions and 166 deletions

View File

@@ -8,7 +8,6 @@ class Origami::PaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(sale_id) sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.where("sale_id=?",sale_id) sale_items = SaleItem.where("sale_id=?",sale_id)
member_info = nil member_info = nil
survey = Survey.find_by_receipt_no(sale_data.receipt_no)
# For Cashier by Zone # For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'") bookings = Booking.where("sale_id='#{sale_id}'")
@@ -67,7 +66,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) 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
end end
@@ -79,7 +78,6 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail shop_details = Shop::ShopDetail
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
# rounding adjustment # rounding adjustment
if shop_details.is_rounding_adj if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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" if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id) booking = Booking.find_by_sale_id(sale_id)
@@ -197,14 +195,10 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
#total customer with individual total amount #total customer with individual total amount
survey = nil
@individual_total = Array.new @individual_total = Array.new
if !@sale_data.nil? if !saleObj.equal_persons.nil?
survey = Survey.find_by_receipt_no(@sale_data.receipt_no) per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i
if !survey.nil? @individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f })
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 end
# rounding adjustment # rounding adjustment
@@ -295,7 +289,6 @@ class Origami::PaymentsController < BaseOrigamiController
member_info = nil member_info = nil
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
# For Cashier by Zone # For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'") 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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
end end
@@ -363,7 +356,6 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id)) if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id) saleObj = Sale.find(sale_id)
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
if saleObj.discount_type == "member_discount" if saleObj.discount_type == "member_discount"
saleObj.update_attributes(rounding_adjustment: 0) 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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 end
end end

View File

@@ -146,15 +146,15 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
puts order_id # puts order_id
puts order_ids.count # puts order_ids.count
puts order_id_count # puts order_id_count
puts order_items.count # puts order_items.count
puts order_item_count # puts order_item_count
if !order_id.nil? if !order_id.nil?
if order_id_count > 1 if order_id_count > 1
puts "order_id_count > 1" # puts "order_id_count > 1"
updated_order_id = Array.new updated_order_id = Array.new
order_ids.each do |odr_id| order_ids.each do |odr_id|
@@ -164,8 +164,8 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
puts "updated_order_id" # puts "updated_order_id"
puts updated_order_id # puts updated_order_id
if !updated_order_id.empty? if !updated_order_id.empty?
order_ids.each do |odr_id| order_ids.each do |odr_id|
@@ -194,7 +194,7 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
puts new_order_status # puts new_order_status
if new_order_status if new_order_status
BookingOrder.find_by_order_id(odr_id).delete BookingOrder.find_by_order_id(odr_id).delete
@@ -222,7 +222,7 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
else else
puts "order_id_count < 1" # puts "order_id_count < 1"
new_order_status = true new_order_status = true
order_items.each do |order_item| order_items.each do |order_item|
orderItem = OrderItem.find_by_order_id(order_id) orderItem = OrderItem.find_by_order_id(order_id)
@@ -235,7 +235,7 @@ class Origami::SplitBillController < BaseOrigamiController
end end
end end
puts new_order_status # puts new_order_status
if new_order_status if new_order_status
BookingOrder.find_by_order_id(order_id).delete BookingOrder.find_by_order_id(order_id).delete
@@ -356,6 +356,14 @@ class Origami::SplitBillController < BaseOrigamiController
orderItem.save! orderItem.save!
end 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 #Shop Name in Navbor
helper_method :shop_detail helper_method :shop_detail
def shop_detail def shop_detail

View File

@@ -84,86 +84,6 @@ class Origami::SurveysController < BaseOrigamiController
end end
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 private
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -6,7 +6,6 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id) if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(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" if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0) 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) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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
#end print #end print

View File

@@ -136,6 +136,7 @@ class Ability
#ability for split_bill #ability for split_bill
can :index, :split_bill can :index, :split_bill
can :create, :split_bill can :create, :split_bill
can :update_sale, :split_bill
elsif user.role == "account" elsif user.role == "account"

View File

@@ -173,19 +173,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
#Bill Receipt Print #Bill Receipt Print
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,survey) def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey) pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty? if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5| receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1' if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey) pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
else else
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey) pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
end end
end end
end end

View File

@@ -1,7 +1,7 @@
class ReceiptBillA5Pdf < Prawn::Document class ReceiptBillA5Pdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,survey) def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.margin = 15 self.margin = 15
@@ -80,8 +80,8 @@ class ReceiptBillA5Pdf < Prawn::Document
end end
#start for individual payment #start for individual payment
if !survey.nil? if !sale_data.equal_persons.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter) individual_payment(sale_data, printer_settings.precision, delimiter)
end end
#end for individual payment #end for individual payment
@@ -480,14 +480,14 @@ class ReceiptBillA5Pdf < Prawn::Document
end end
#individual payment per person #individual payment per person
def individual_payment(sale_data, survey, precision, delimiter) def individual_payment(sale_data, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i per_person = sale_data.grand_total.to_f / sale_data.equal_persons.to_i
move_down 5 move_down 5
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do bounding_box([0,y_position], :width =>self.label_width+50) do
text "Individual amount for #{survey.total_customer} persons", :size => self.item_font_size+1,:align => :left text "Individual amount for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
end end
bounding_box([0,y_position], :width =>self.label_width) do bounding_box([0,y_position], :width =>self.label_width) do

View File

@@ -1,7 +1,7 @@
class ReceiptBillPdf < Prawn::Document class ReceiptBillPdf < Prawn::Document
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,survey) def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data)
self.page_width = printer_settings.page_width self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height self.page_height = printer_settings.page_height
self.margin = 0 self.margin = 0
@@ -80,8 +80,8 @@ class ReceiptBillPdf < Prawn::Document
end end
#start for individual payment #start for individual payment
if !survey.nil? if !sale_data.equal_persons.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter) individual_payment(sale_data, printer_settings.precision, delimiter)
end end
#end for individual payment #end for individual payment
@@ -481,14 +481,14 @@ class ReceiptBillPdf < Prawn::Document
end end
#individual payment per person #individual payment per person
def individual_payment(sale_data, survey, precision, delimiter) def individual_payment(sale_data, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i per_person = sale_data.grand_total.to_f / sale_data.equal_persons.to_i
move_down 5 move_down 5
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do bounding_box([0,y_position], :width =>self.label_width+50) do
text "Individual amount for #{survey.total_customer} persons", :size => self.item_font_size+1,:align => :left text "Individual amount for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
end end
bounding_box([0,y_position], :width =>self.label_width) do bounding_box([0,y_position], :width =>self.label_width) do

View File

@@ -464,12 +464,12 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button> <button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%> <%end%>
<% end %> <% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% if !@split_bill.nil? %> <% if !@split_bill.nil? %>
<% if @split_bill == '1' %> <% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button> <button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %> <% end %>
<% end %> <% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% end %> <% end %>
<!-- Cashier Buttons --> <!-- Cashier Buttons -->

View File

@@ -59,7 +59,8 @@
</td> </td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %> <% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<td class="p-1" width="5%"> <td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/> <input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
</td> </td>
<td class="p-1" width="10%"> <td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/> <input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
@@ -166,21 +167,27 @@ var cashier_type = "<%= @cashier_type %>";
var sale_item_id = $(this).attr('data-id'); var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val(); var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val(); var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price) console.log(qty + "|" + price);
var ajax_url = "/origami/item_edit"; if(qty > 0){
$.ajax({ $('#' + sale_item_id + "_qtyErr").html("");
type: "POST", var ajax_url = "/origami/item_edit";
url: ajax_url, $.ajax({
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price, type: "POST",
success: function (result) { url: ajax_url,
swal({ data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
title: "Information!", success: function (result) {
text: "Qty and Price was successfully Updated", swal({
}, function () { title: "Information!",
location.reload(); text: "Qty and Price was successfully Updated",
}); }, function () {
} location.reload();
}); });
}
});
}else{
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
}
}); });
$('.void').on('click', function () { $('.void').on('click', function () {
@@ -311,4 +318,20 @@ var cashier_type = "<%= @cashier_type %>";
return false; return false;
} }
}); });
//check for isNumber
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
function checkQuantity(obj_value,sale_item_id) {
if(obj_value == '0'){
$("#"+sale_item_id+"_qty").val('1');
}
}
</script> </script>

View File

@@ -318,7 +318,6 @@
<script type="text/javascript"> <script type="text/javascript">
var split_sale_id = ""; var split_sale_id = "";
var split_receipt_no = ""; var split_receipt_no = "";
var split_total_amount = 0;
$(document).ready(function(){ $(document).ready(function(){
$('#back').on('click',function(){ $('#back').on('click',function(){
backToOrigami(); backToOrigami();
@@ -396,7 +395,7 @@
// orderItemSplitBillProcess(cnt_items); // orderItemSplitBillProcess(cnt_items);
// } // }
}else{ }else{
swal("Opps","Please select at least one item!","warning"); swal("Oops","Please select at least one item!","warning");
} }
}); });
@@ -460,7 +459,7 @@
// orderSplitBillProcess(cnt_odrs); // orderSplitBillProcess(cnt_odrs);
// } // }
}else{ }else{
swal("Opps","Please select at least one order!","warning"); swal("Oops","Please select at least one order!","warning");
} }
}); });
@@ -476,28 +475,12 @@
var dining_id = $("#table_id").text(); var dining_id = $("#table_id").text();
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val(); 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_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 != ""){ if(split_sale_id != undefined && split_sale_id != ""){
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true}); $('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
} }
else{ else{
swal("Opps","Please select one receipt!","warning"); swal("Oops","Please select one receipt!","warning");
} }
}); });
@@ -508,15 +491,15 @@
$("#per_personErr").html(''); $("#per_personErr").html('');
$('#equal_split_modal').modal('hide'); $('#equal_split_modal').modal('hide');
if(person > 1){ if(person > 1){
var ajax_url = "/origami/split_bills/surveys"; var ajax_url = "/origami/split_bills/equal_person";
var dining_id = $("#table_id").text(); var dining_id = $("#table_id").text();
var type = $("#table_type").text(); var type = $("#table_type").text();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: ajax_url, url: ajax_url,
dataType: 'JSON', dataType: 'JSON',
data: {'dining_id':dining_id, 'sale_id':split_sale_id, 'receipt_no':split_receipt_no, 'total_customer': person, 'total_amount':split_total_amount }, data: { 'sale_id':split_sale_id, 'total_customer': person },
success: function (result) { success: function (result) {
console.log(result); console.log(result);
if(result.status){ if(result.status){

View File

@@ -238,8 +238,7 @@ scope "(:locale)", locale: /en|mm/ do
get '/room/:dining_id/split_bills' => 'split_bill#index' get '/room/:dining_id/split_bills' => 'split_bill#index'
post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills" post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills"
post '/split_bills/surveys', to: 'surveys#create_survey' post '/split_bills/equal_person', to: 'split_bill#update_sale'
post '/split_bills/get_survey', to: 'surveys#get_survey'
end end

View File

@@ -24,6 +24,7 @@ class CreateSales < ActiveRecord::Migration[5.1]
t.integer :shift_sale_id t.integer :shift_sale_id
t.decimal :old_grand_total t.decimal :old_grand_total
t.string :rebate_status t.string :rebate_status
t.integer :equal_persons
t.timestamps t.timestamps
end end
end end