Merge branch 'split_bill' of bitbucket.org:code2lab/sxrestaurant into quick_service
This commit is contained in:
@@ -192,9 +192,21 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
@table_no = ''
|
@table_no = ''
|
||||||
@dining = ''
|
@dining = ''
|
||||||
|
|
||||||
@shop = Shop::ShopDetail
|
@shop = Shop::ShopDetail #show shop info
|
||||||
|
|
||||||
saleObj = Sale.find(sale_id)
|
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
|
# rounding adjustment
|
||||||
if @shop.is_rounding_adj
|
if @shop.is_rounding_adj
|
||||||
a = saleObj.grand_total % 25 # Modulus
|
a = saleObj.grand_total % 25 # Modulus
|
||||||
@@ -212,6 +224,8 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
#end rounding adjustment
|
#end rounding adjustment
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
@print_settings = PrintSetting.get_precision_delimiter()
|
||||||
|
|
||||||
#get customer amount
|
#get customer amount
|
||||||
@customer = Customer.find(@sale_data.customer_id)
|
@customer = Customer.find(@sale_data.customer_id)
|
||||||
|
|||||||
@@ -97,11 +97,11 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
else
|
else
|
||||||
table = nil
|
table = nil
|
||||||
|
cashier_zone = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
|
||||||
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
# get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
|
||||||
get_cashier_by_terminal = current_user
|
|
||||||
|
|
||||||
if booking
|
if booking
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
@@ -208,17 +208,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
order = Order.new
|
order = create_order(params,order_type,order_items.count,current_user)
|
||||||
order.source = "cashier"
|
|
||||||
order.order_type = order_type
|
|
||||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
|
||||||
order.item_count = order_items.count
|
|
||||||
order.status = "new"
|
|
||||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
|
||||||
order.waiters = current_user.name
|
|
||||||
order.employee_name = current_user.name
|
|
||||||
order.guest_info = nil
|
|
||||||
order.save!
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||||
|
|
||||||
@@ -260,17 +250,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
order = Order.new
|
order = create_order(params,order_type,order_items.count,current_user)
|
||||||
order.source = "cashier"
|
|
||||||
order.order_type = order_type
|
|
||||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
|
||||||
order.item_count = order_items.count
|
|
||||||
order.status = "new"
|
|
||||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
|
||||||
order.waiters = current_user.name
|
|
||||||
order.employee_name = current_user.name
|
|
||||||
order.guest_info = nil
|
|
||||||
order.save!
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||||
|
|
||||||
@@ -297,17 +277,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
order = Order.new
|
order = create_order(params,order_type,order_items.count,current_user)
|
||||||
order.source = "cashier"
|
|
||||||
order.order_type = order_type
|
|
||||||
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
|
||||||
order.item_count = order_items.count
|
|
||||||
order.status = "new"
|
|
||||||
order.table_id = params[:dining_id] # this is dining facilities's id
|
|
||||||
order.waiters = current_user.name
|
|
||||||
order.employee_name = current_user.name
|
|
||||||
order.guest_info = nil
|
|
||||||
order.save!
|
|
||||||
|
|
||||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||||
|
|
||||||
@@ -319,17 +289,12 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
sale = Sale.new
|
sale = Sale.new
|
||||||
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, get_cashier_by_terminal)
|
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, current_user)
|
||||||
sale_data = Sale.find_by_sale_id(sale_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bind shift sale id to sale
|
|
||||||
# sale_data.shift_sale_id = shift_by_terminal.id
|
|
||||||
# sale_data.save
|
|
||||||
|
|
||||||
Promotion.promo_activate(sale)
|
Promotion.promo_activate(sale)
|
||||||
|
|
||||||
BillBroadcastJob.perform_later(table)
|
ActionCable.server.broadcast "bill_channel",table: table
|
||||||
|
|
||||||
render :json => { status: status }
|
render :json => { status: status }
|
||||||
else
|
else
|
||||||
@@ -337,9 +302,36 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_order(params,order_type,items_count,current_user)
|
||||||
|
order = Order.new
|
||||||
|
order.source = "cashier"
|
||||||
|
order.order_type = order_type
|
||||||
|
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
|
||||||
|
order.item_count = items_count
|
||||||
|
order.status = "new"
|
||||||
|
order.table_id = params[:dining_id] # this is dining facilities's id
|
||||||
|
order.waiters = current_user.name
|
||||||
|
order.employee_name = current_user.name
|
||||||
|
order.guest_info = nil
|
||||||
|
order.save!
|
||||||
|
|
||||||
|
return order
|
||||||
|
end
|
||||||
|
|
||||||
def update_order_item(order_id, order_item)
|
def update_order_item(order_id, order_item)
|
||||||
orderItem = OrderItem.find(order_item["id"])
|
orderItem = OrderItem.find(order_item["id"])
|
||||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||||
|
set_menu_items_obj = Array.new
|
||||||
|
if !orderItem.set_menu_items.nil?
|
||||||
|
instance_item_sets = JSON.parse(orderItem.set_menu_items)
|
||||||
|
instance_item_sets.each_with_index do |instance_item, instance_index|
|
||||||
|
instance_item_sets[instance_index]["quantity"] = (instance_item["quantity"].to_i - order_item['qty'].to_i).to_s
|
||||||
|
"[{\"item_instance_code\":\"psi002in001\",\"quantity\":\"2\",\"price\":\"5500.0\"}]"
|
||||||
|
set_menu_items_obj.push({'item_instance_code' => instance_item["item_instance_code"], 'quantity' => order_item['qty'].to_i, 'price' => instance_item["price"]})
|
||||||
|
end
|
||||||
|
orderItem.set_menu_items = instance_item_sets.to_json
|
||||||
|
end
|
||||||
|
|
||||||
OrderItem.processs_item(orderItem.item_code,
|
OrderItem.processs_item(orderItem.item_code,
|
||||||
orderItem.item_instance_code,
|
orderItem.item_instance_code,
|
||||||
orderItem.item_name,
|
orderItem.item_name,
|
||||||
@@ -348,7 +340,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
|||||||
order_item['qty'],
|
order_item['qty'],
|
||||||
orderItem.price,
|
orderItem.price,
|
||||||
orderItem.options,
|
orderItem.options,
|
||||||
orderItem.set_menu_items,
|
set_menu_items_obj.to_json,
|
||||||
order_id,
|
order_id,
|
||||||
orderItem.item_order_by,
|
orderItem.item_order_by,
|
||||||
orderItem.taxable)
|
orderItem.taxable)
|
||||||
|
|||||||
@@ -86,9 +86,10 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
|
|
||||||
def create_survey
|
def create_survey
|
||||||
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
|
||||||
@type = params[:cashier_type]
|
@type = params[:cashier_type]
|
||||||
@sale_id = params[:sale_id]
|
@sale_id = params[:sale_id]
|
||||||
sale = Sale.find(@sale_id)
|
sale = Sale.find(@sale_id)
|
||||||
|
receipt_no = params[:receipt_no]
|
||||||
|
|
||||||
if @type != "quick_service"
|
if @type != "quick_service"
|
||||||
dining_facility = DiningFacility.find(params[:dining_id])
|
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)
|
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_terminal_id,nil)
|
||||||
|
|
||||||
if @type != "quick_service"
|
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
|
else
|
||||||
survey = nil
|
survey = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if survey.nil?
|
if survey.nil?
|
||||||
survey = Survey.new
|
|
||||||
if @type != "quick_service"
|
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
|
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
|
else
|
||||||
survey.receipt_no = params[:receipt_no]
|
survey.receipt_no = params[:receipt_no]
|
||||||
survey.total_customer = params[:total_customer]
|
survey.total_customer = params[:total_customer]
|
||||||
|
survey.total_amount = params[:total_amount]
|
||||||
survey.save!
|
survey.save!
|
||||||
end
|
end
|
||||||
render :json => {status: true}
|
render :json => {status: true}
|
||||||
@@ -131,6 +148,22 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
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.
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ class ReceiptBillA5Pdf < Prawn::Document
|
|||||||
|
|
||||||
bounding_box([0,y_position], :width =>self.label_width) do
|
bounding_box([0,y_position], :width =>self.label_width) do
|
||||||
move_down 15
|
move_down 15
|
||||||
text "Total", :size => self.item_font_size,:align => :left
|
text "Total Amount", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
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
|
bounding_box([0,y_position], :width =>self.label_width) do
|
||||||
move_down 15
|
move_down 15
|
||||||
text "Total", :size => self.item_font_size,:align => :left
|
text "Total Amount", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
|
|
||||||
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
|
||||||
|
|||||||
@@ -2,6 +2,21 @@
|
|||||||
<div id="loading_wrapper" style="display:none;">
|
<div id="loading_wrapper" style="display:none;">
|
||||||
<div id="loading"></div>
|
<div id="loading"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if !@print_settings.nil? %>
|
||||||
|
<% if @print_settings.precision.to_i > 0
|
||||||
|
precision = @print_settings.precision
|
||||||
|
else
|
||||||
|
precision = 0
|
||||||
|
end
|
||||||
|
#check delimiter
|
||||||
|
if @print_settings.delimiter
|
||||||
|
delimiter = ","
|
||||||
|
else
|
||||||
|
delimiter = ""
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="row clearfix">
|
<div class="row clearfix">
|
||||||
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -56,9 +71,9 @@
|
|||||||
<% sub_total += sale_item.price%>
|
<% sub_total += sale_item.price%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
<td class="item-name"><%=sale_item.product_name%>@<%=sale_item.unit_price%></td>
|
<td class="item-name"><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%></td>
|
||||||
<td class="item-attr"><%=sale_item.qty%></td>
|
<td class="item-attr"><%=sale_item.qty%></td>
|
||||||
<td class="item-attr"><%=(sale_item.price)%></td>
|
<td class="item-attr"><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%></td>
|
||||||
</tr>
|
</tr>
|
||||||
<%end %>
|
<%end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -71,7 +86,7 @@
|
|||||||
<tfooter>
|
<tfooter>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="charges-name"><strong>Sub Total</strong></td>
|
<td class="charges-name"><strong>Sub Total</strong></td>
|
||||||
<td class="item-attr"><strong><span id="sub-total"><%=sub_total%></span></strong></td>
|
<td class="item-attr"><strong><span id="sub-total"><%=number_with_precision(sub_total, precision: precision.to_i)%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<%if @sale_data.discount_type == 'member_discount'%>
|
<%if @sale_data.discount_type == 'member_discount'%>
|
||||||
@@ -79,7 +94,7 @@
|
|||||||
<%else%>
|
<%else%>
|
||||||
<td class="charges-name"><strong>(Discount)</strong></td>
|
<td class="charges-name"><strong>(Discount)</strong></td>
|
||||||
<%end%>
|
<%end%>
|
||||||
<td class="item-attr"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
|
<td class="item-attr"><strong><span>(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="charges-name"><strong>Tax
|
<td class="charges-name"><strong>Tax
|
||||||
@@ -91,22 +106,30 @@
|
|||||||
<%end%>
|
<%end%>
|
||||||
<%end %>)
|
<%end %>)
|
||||||
</strong></td>
|
</strong></td>
|
||||||
<td class="item-attr"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
|
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||||
<td class="item-attr"><strong><%= @sale_data.rounding_adjustment rescue 0%></strong></td>
|
<td class="item-attr"><strong><%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="charges-name"><strong>Grand Total</strong></td>
|
<td class="charges-name"><strong>Grand Total</strong></td>
|
||||||
<td class="item-attr"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
|
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<%if @balance > 0%>
|
<%if @balance > 0%>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="charges-name"><strong><%= @accountable_type %></strong></td>
|
<td class="charges-name"><strong><%= @accountable_type %></strong></td>
|
||||||
<td class="item-attr"><strong><span><%=@balance%></span></strong></td>
|
<td class="item-attr"><strong><span><%=number_with_precision(@balance, precision: precision.to_i )%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if !@individual_total[0].nil? %>
|
||||||
|
<tr>
|
||||||
|
<td class="charges-name">
|
||||||
|
<strong>Individual amount for <%= @individual_total[0]['total_customer'] %> persons</strong>
|
||||||
|
</td>
|
||||||
|
<td class="item-attr"><strong><span><%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%></span></strong></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
</tfooter>
|
</tfooter>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,24 +147,24 @@
|
|||||||
<div class="col-md-8"><strong>Amount Due</strong></div>
|
<div class="col-md-8"><strong>Amount Due</strong></div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<strong>
|
<strong>
|
||||||
<span id="grand_total" class="hidden"><%= @sale_data.grand_total rescue 0%></span>
|
<span id="grand_total" class="hidden"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%></span>
|
||||||
<span id="amount_due"><%= @sale_data.grand_total rescue 0%></span></strong>
|
<span id="amount_due"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row payment cash-color p-l-5 p-r-5">
|
<div class="row payment cash-color p-l-5 p-r-5">
|
||||||
<div class="col-md-8">Cash</div>
|
<div class="col-md-8">Cash</div>
|
||||||
<div class="col-md-4" id="cash" ><%= @cash %></div>
|
<div class="col-md-4" id="cash" ><%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
|
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
|
||||||
<div class="col-md-8">Credit</div>
|
<div class="col-md-8">Credit</div>
|
||||||
<div class="col-md-4" id="credit"><%= @credit %></div>
|
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
|
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
|
||||||
<div class="row payment other-payment-color" id="card_payment" >
|
<div class="row payment other-payment-color" id="card_payment" >
|
||||||
<div class="col-md-8">Other Payments</div>
|
<div class="col-md-8">Other Payments</div>
|
||||||
<div class="col-md-4" id="others"><%= @other %></div>
|
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row payment other-payment-color" id="card_payment" >
|
<div class="row payment other-payment-color" id="card_payment" >
|
||||||
@@ -156,13 +179,13 @@
|
|||||||
<div class="row payment others-color">
|
<div class="row payment others-color">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">MPU</div>
|
<div class="col-md-3">MPU</div>
|
||||||
<div class="col-md-4 mpu is_card" id="others"><%= @other %></div>
|
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row hidden">
|
<div class="row hidden">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">MPU</div>
|
<div class="col-md-3">MPU</div>
|
||||||
<div class="col-md-4" id="others">0.0</div>
|
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- paypar -->
|
<!-- paypar -->
|
||||||
@@ -170,13 +193,13 @@
|
|||||||
<div class="row payment others-color">
|
<div class="row payment others-color">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">Redeem</div>
|
<div class="col-md-3">Redeem</div>
|
||||||
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
|
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row hidden">
|
<div class="row hidden">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">Redeem</div>
|
<div class="col-md-3">Redeem</div>
|
||||||
<div class="col-md-4" id="ppamount">0.0</div>
|
<div class="col-md-4" id="ppamount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- Visa -->
|
<!-- Visa -->
|
||||||
@@ -184,13 +207,13 @@
|
|||||||
<div class="row payment others-color">
|
<div class="row payment others-color">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">VISA</div>
|
<div class="col-md-3">VISA</div>
|
||||||
<div class="col-md-4 visa is_card" id="visacount"><%= @visacount %></div>
|
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row hidden">
|
<div class="row hidden">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">VISA</div>
|
<div class="col-md-3">VISA</div>
|
||||||
<div class="col-md-4" id="visacount">0.0</div>
|
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- JCB -->
|
<!-- JCB -->
|
||||||
@@ -198,13 +221,13 @@
|
|||||||
<div class="row payment others-color">
|
<div class="row payment others-color">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">JCB</div>
|
<div class="col-md-3">JCB</div>
|
||||||
<div class="col-md-4 jcb is_card" id="jcbcount"><%= @jcbcount %></div>
|
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row hidden">
|
<div class="row hidden">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">JCB</div>
|
<div class="col-md-3">JCB</div>
|
||||||
<div class="col-md-4" id="jcbcount">0.0</div>
|
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- Master -->
|
<!-- Master -->
|
||||||
@@ -212,13 +235,13 @@
|
|||||||
<div class="row payment others-color">
|
<div class="row payment others-color">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">MASTER</div>
|
<div class="col-md-3">MASTER</div>
|
||||||
<div class="col-md-4 master is_card" id="mastercount"><%= @mastercount %></div>
|
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row hidden">
|
<div class="row hidden">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">MASTER</div>
|
<div class="col-md-3">MASTER</div>
|
||||||
<div class="col-md-4" id="mastercount">0.0</div>
|
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- <br> -->
|
<!-- <br> -->
|
||||||
@@ -227,18 +250,18 @@
|
|||||||
<div class="row payment others-color">
|
<div class="row payment others-color">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">UNIONPAY</div>
|
<div class="col-md-3">UNIONPAY</div>
|
||||||
<div class="col-md-4 master is_card" id="unionpaycount"><%= @unionpaycount %></div>
|
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="row hidden">
|
<div class="row hidden">
|
||||||
<div class="col-md-5"></div>
|
<div class="col-md-5"></div>
|
||||||
<div class="col-md-3">UNIONPAY</div>
|
<div class="col-md-3">UNIONPAY</div>
|
||||||
<div class="col-md-4" id="unionpaycount">0.0</div>
|
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="row m-l-5 m-r-5">
|
<div class="row m-l-5 m-r-5">
|
||||||
<div class="col-md-8"><strong>Balance</strong></div>
|
<div class="col-md-8"><strong>Balance</strong></div>
|
||||||
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total rescue 0 %></span></strong></div>
|
<div class="col-md-4"><strong><span id='balance'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <br> -->
|
<!-- <br> -->
|
||||||
</div>
|
</div>
|
||||||
@@ -488,8 +511,13 @@ console.log("fffffffffffff")
|
|||||||
var unionpay1 = $('#unionpaycount').text();
|
var unionpay1 = $('#unionpaycount').text();
|
||||||
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
|
||||||
var total = $('#amount_due').text();
|
var total = $('#amount_due').text();
|
||||||
var amt = parseFloat(total) - parseFloat(othertotal);
|
var amt = 0;
|
||||||
$('#cash').text(parseFloat(amt).toFixed(1));
|
<% if precision.to_i > 0 %>;
|
||||||
|
amt = parseFloat(parseFloat(total) - parseFloat(othertotal)).toFixed(<%= precision %>);
|
||||||
|
<% else %>
|
||||||
|
amt = parseFloat(parseFloat(total) - parseFloat(othertotal));
|
||||||
|
<% end %>
|
||||||
|
$('#cash').text(amt);
|
||||||
update_balance();
|
update_balance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -654,7 +682,11 @@ console.log("fffffffffffff")
|
|||||||
var amount_due = $('#amount_due').text();
|
var amount_due = $('#amount_due').text();
|
||||||
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
|
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
|
||||||
var result = parseFloat(amount_due) - parseFloat(total);
|
var result = parseFloat(amount_due) - parseFloat(total);
|
||||||
$('#balance').text(result.toFixed(2));
|
<% if precision.to_i > 0 %>
|
||||||
|
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
|
||||||
|
<% else %>
|
||||||
|
$('#balance').text(parseFloat(result));
|
||||||
|
<% end %>
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#foc').click(function() {
|
$('#foc').click(function() {
|
||||||
|
|||||||
@@ -318,7 +318,6 @@
|
|||||||
var split_receipt_no = "";
|
var split_receipt_no = "";
|
||||||
var split_total_amount = 0;
|
var split_total_amount = 0;
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
$('#back').on('click',function(){
|
$('#back').on('click',function(){
|
||||||
backToOrigami();
|
backToOrigami();
|
||||||
})
|
})
|
||||||
@@ -472,9 +471,26 @@
|
|||||||
|
|
||||||
//equal split process
|
//equal split process
|
||||||
$('#equal_split').on('click', function(){
|
$('#equal_split').on('click', function(){
|
||||||
|
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');
|
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});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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', to: 'split_bill#create', as:"order_item_split_bills"
|
||||||
|
|
||||||
post '/split_bills/surveys', to: 'surveys#create_survey'
|
post '/split_bills/surveys', to: 'surveys#create_survey'
|
||||||
|
post '/split_bills/get_survey', to: 'surveys#get_survey'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user