Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -5,26 +5,29 @@ class Api::BillController < Api::ApiController
|
|||||||
def create
|
def create
|
||||||
@status = false
|
@status = false
|
||||||
@error_message = "Order ID or Booking ID is require to request for a bill."
|
@error_message = "Order ID or Booking ID is require to request for a bill."
|
||||||
|
if ShiftSale.current_shift
|
||||||
#create Bill by Booking ID
|
#create Bill by Booking ID
|
||||||
if (params[:booking_id])
|
if (params[:booking_id])
|
||||||
booking = Booking.find(params[:booking_id])
|
booking = Booking.find(params[:booking_id])
|
||||||
|
|
||||||
if booking
|
if booking
|
||||||
if booking.sale_id.nil?
|
if booking.sale_id.nil?
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier)
|
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier)
|
||||||
else
|
else
|
||||||
@status = true
|
@status = true
|
||||||
@sale_id = booking.sale_id
|
@sale_id = booking.sale_id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
elsif (params[:order_id])
|
elsif (params[:order_id])
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@status = false
|
||||||
|
@error_message = "No Current Open Shift"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Not Use for these printed bill cannot give customer
|
# Not Use for these printed bill cannot give customer
|
||||||
# @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)
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
puts ">>>>>"
|
||||||
|
puts current_user.id
|
||||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class SalePayment < ApplicationRecord
|
|||||||
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by)
|
||||||
|
|
||||||
# update complete order items in oqs
|
# update complete order items in oqs
|
||||||
SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr|
|
SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr|
|
||||||
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||||
aoi.delivery_status = 1
|
aoi.delivery_status = 1
|
||||||
aoi.save
|
aoi.save
|
||||||
@@ -287,7 +287,7 @@ class SalePayment < ApplicationRecord
|
|||||||
bookings = table.bookings
|
bookings = table.bookings
|
||||||
bookings.each do |tablebooking|
|
bookings.each do |tablebooking|
|
||||||
if tablebooking.booking_status != 'moved'
|
if tablebooking.booking_status != 'moved'
|
||||||
if tablebooking.sale.sale_status != 'completed'
|
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
|
||||||
status = false
|
status = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -314,7 +314,7 @@ class SalePayment < ApplicationRecord
|
|||||||
# overall_dis = SaleItem.get_overall_discount(sObj.id)
|
# overall_dis = SaleItem.get_overall_discount(sObj.id)
|
||||||
overall_dis = sObj.total_discount
|
overall_dis = sObj.total_discount
|
||||||
|
|
||||||
total_amount = rebate_prices - payparcost + overall_dis
|
total_amount = rebate_prices - payparcost - overall_dis
|
||||||
if total_amount > 0
|
if total_amount > 0
|
||||||
receipt_no = sObj.receipt_no
|
receipt_no = sObj.receipt_no
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
|
|||||||
@@ -16,11 +16,17 @@ class ShiftSale < ApplicationRecord
|
|||||||
belongs_to :cashier_terminal
|
belongs_to :cashier_terminal
|
||||||
belongs_to :employee, :foreign_key => 'employee_id'
|
belongs_to :employee, :foreign_key => 'employee_id'
|
||||||
|
|
||||||
|
def self.current_shift
|
||||||
|
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||||
|
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null",today_date).take
|
||||||
|
return shift
|
||||||
|
end
|
||||||
|
|
||||||
def self.current_open_shift(current_user)
|
def self.current_open_shift(current_user)
|
||||||
#if current_user
|
#if current_user
|
||||||
#find open shift where is open today and is not closed and login by current cashier
|
#find open shift where is open today and is not closed and login by current cashier
|
||||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||||
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take
|
||||||
return shift
|
return shift
|
||||||
#end
|
#end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -163,18 +163,18 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<%
|
<%
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
sub_total = 0
|
sub_total = 0
|
||||||
if @status_sale == "sale"
|
if @status_sale == "sale"
|
||||||
@sale_array[0].sale_items.each do |sale_item|
|
@sale_array[0].sale_items.each do |sale_item|
|
||||||
count += 1
|
|
||||||
sub_total = sub_total + sale_item.price
|
sub_total = sub_total + sale_item.price
|
||||||
%>
|
%>
|
||||||
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
|
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
|
||||||
<%
|
<%
|
||||||
# Can't check for discount
|
# Can't check for discount
|
||||||
unless sale_item.price == 0
|
unless sale_item.price == 0
|
||||||
|
count += 1
|
||||||
%>
|
%>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= count %></td>
|
<td><%= count %></td>
|
||||||
@@ -439,7 +439,7 @@ $("#first_bill").on('click', function(){
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -452,11 +452,11 @@ $('#pay').on('click',function() {
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: '/origami/sale/'+ sale_id + "/rounding_adj",
|
url: '/origami/sale/'+ sale_id + "/rounding_adj",
|
||||||
success:function(result){
|
success:function(result){
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
window.location.href = '/origami/sale/'+ sale_id + "/payment";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bill Request
|
// Bill Request
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ $( document ).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#pay').click(function() {
|
$('#pay').click(function() {
|
||||||
|
$('#pay').text("Processing, Please wait!")
|
||||||
if($('#balance').text() > 0){
|
if($('#balance').text() > 0){
|
||||||
alert(" Insufficient Amount!")
|
alert(" Insufficient Amount!")
|
||||||
}else{
|
}else{
|
||||||
@@ -351,6 +352,7 @@ $( document ).ready(function() {
|
|||||||
if($('#balance').text() < 0){
|
if($('#balance').text() < 0){
|
||||||
alert("Changed amount " + $('#balance').text() * (-1) )
|
alert("Changed amount " + $('#balance').text() * (-1) )
|
||||||
}else{
|
}else{
|
||||||
|
$('#pay').text("Pay")
|
||||||
alert("Thank you")
|
alert("Thank you")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user