Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
130
app/controllers/origami/waste_spoile_controller .rb
Executable file
130
app/controllers/origami/waste_spoile_controller .rb
Executable file
@@ -0,0 +1,130 @@
|
|||||||
|
class Origami::WasteSpoileController < BaseOrigamiController
|
||||||
|
def index
|
||||||
|
|
||||||
|
end
|
||||||
|
def waste_and_spoile
|
||||||
|
|
||||||
|
sale_id = params[:sale_id]
|
||||||
|
remark = params[:remark]
|
||||||
|
order_source = params[:type] #tax profile source
|
||||||
|
if Sale.exists?(sale_id)
|
||||||
|
sale = Sale.find_by_sale_id(sale_id)
|
||||||
|
|
||||||
|
if sale.discount_type == "member_discount"
|
||||||
|
sale.update_attributes(total_discount: 0)
|
||||||
|
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
|
||||||
|
end
|
||||||
|
|
||||||
|
sale.payment_status = remark
|
||||||
|
sale.sale_status = remark
|
||||||
|
sale.save
|
||||||
|
|
||||||
|
# add to sale item with foc
|
||||||
|
sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
|
||||||
|
|
||||||
|
sale_items.each do|item|
|
||||||
|
SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
|
||||||
|
end
|
||||||
|
|
||||||
|
if sale.bookings[0].dining_facility_id.to_i > 0
|
||||||
|
table_avaliable = true
|
||||||
|
table_count = 0
|
||||||
|
table = sale.bookings[0].dining_facility
|
||||||
|
table.bookings.each do |booking|
|
||||||
|
if booking.booking_status != 'moved'
|
||||||
|
if booking.sale_id
|
||||||
|
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
|
||||||
|
table_avaliable = false
|
||||||
|
table_count += 1
|
||||||
|
else
|
||||||
|
table_avaliable = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table_avaliable = false
|
||||||
|
table_count += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if table_avaliable && table_count == 0
|
||||||
|
table.status = 'available'
|
||||||
|
table.save
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
# FOr Sale Audit
|
||||||
|
action_by = current_user.name
|
||||||
|
# remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
|
||||||
|
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,remark )
|
||||||
|
|
||||||
|
# For Print
|
||||||
|
|
||||||
|
member_info = nil
|
||||||
|
rebate_amount = nil
|
||||||
|
current_balance = nil
|
||||||
|
|
||||||
|
# For Cashier by Zone
|
||||||
|
bookings = Booking.where("sale_id='#{sale_id}'")
|
||||||
|
if bookings.count > 1
|
||||||
|
# for Multiple Booking
|
||||||
|
if bookings[0].dining_facility_id.to_i>0
|
||||||
|
table = DiningFacility.find(bookings[0].dining_facility_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if bookings[0].dining_facility_id.to_i > 0
|
||||||
|
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
|
||||||
|
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
|
||||||
|
else
|
||||||
|
shift = ShiftSale.find(sale.shift_sale_id)
|
||||||
|
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
customer= Customer.find(sale.customer_id)
|
||||||
|
|
||||||
|
#shop detail
|
||||||
|
shop_details = Shop.find(1)
|
||||||
|
# get member information
|
||||||
|
rebate = MembershipSetting.find_by_rebate(1)
|
||||||
|
if customer.membership_id != nil && rebate
|
||||||
|
member_info = Customer.get_member_account(customer)
|
||||||
|
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
|
||||||
|
current_balance = SaleAudit.paymal_search(sale_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
# get printer info
|
||||||
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
# Calculate Food and Beverage Total
|
||||||
|
item_price_by_accounts = SaleItem.calculate_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)
|
||||||
|
filename, sale_receipt_no, printer_name = 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)
|
||||||
|
result = {
|
||||||
|
:filepath => filename,
|
||||||
|
:printer_model => print_settings.brand_name,
|
||||||
|
:printer_url => print_settings.api_settings
|
||||||
|
}
|
||||||
|
|
||||||
|
# Mobile Print
|
||||||
|
render :json => result.to_json
|
||||||
|
# end
|
||||||
|
|
||||||
|
#end print
|
||||||
|
|
||||||
|
# update complete order items in oqs
|
||||||
|
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
|
||||||
|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|
|
||||||
|
aoi.delivery_status = 1
|
||||||
|
aoi.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -38,7 +38,8 @@ class SaleItem < ApplicationRecord
|
|||||||
sale_item.product_alt_name = item.product_alt_name
|
sale_item.product_alt_name = item.product_alt_name
|
||||||
sale_item.account_id = item.account_id
|
sale_item.account_id = item.account_id
|
||||||
sale_item.status = type
|
sale_item.status = type
|
||||||
if type == "foc" || type == "promotion" || type == "void"
|
sale_item.remark = type
|
||||||
|
if type == "foc" || type == "promotion" || type == "void" || type == "waste" || type == "spoile"
|
||||||
sale_item.qty = qty * (-1)
|
sale_item.qty = qty * (-1)
|
||||||
else
|
else
|
||||||
sale_item.qty = qty
|
sale_item.qty = qty
|
||||||
|
|||||||
@@ -488,6 +488,11 @@
|
|||||||
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
|
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
|
||||||
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
|
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if current_login_employee.role != "waiter" %>
|
||||||
|
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
|
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
|
||||||
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
|
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
|
||||||
|
|
||||||
@@ -569,6 +574,32 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal fade" id="waste_spoileModal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title" id="waste_spoileModalLabel">Are you sure Waste or Spoile ?</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="row p-r-20">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')"><strong>Waste</strong></button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')"><strong>Spoile</strong></button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<button type="button" class="btn btn-lg bg-blue waves-effect" data-dismiss="modal"><strong>CLOSE</strong></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer ">
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -737,19 +768,19 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// click select option icon for add
|
// click select option icon for add
|
||||||
$(document).on('click', '.payment_btn', function(event){
|
$(document).on('click', '.payment_btn', function(event){
|
||||||
active = $(this).hasClass('selected-payment');
|
active = $(this).hasClass('selected-payment');
|
||||||
value = $(this).data('value');
|
value = $(this).data('value');
|
||||||
type = $(this).data('type');
|
type = $(this).data('type');
|
||||||
group = $(this).data('group');
|
group = $(this).data('group');
|
||||||
payments = $(".payment_btn");
|
payments = $(".payment_btn");
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
$(this).removeClass('selected-payment');
|
$(this).removeClass('selected-payment');
|
||||||
}else{
|
}else{
|
||||||
$(this).addClass('selected-payment');
|
$(this).addClass('selected-payment');
|
||||||
}
|
}
|
||||||
}); //End selecct attribute buttom
|
}); //End selecct attribute buttom
|
||||||
|
|
||||||
$(".choose_payment").on('click', function () {
|
$(".choose_payment").on('click', function () {
|
||||||
$( "#loading_wrapper").show();
|
$( "#loading_wrapper").show();
|
||||||
@@ -1014,4 +1045,36 @@
|
|||||||
});
|
});
|
||||||
return attribute_arr;
|
return attribute_arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function waste_and_spoilage(remark) {
|
||||||
|
swal({
|
||||||
|
title: "Alert",
|
||||||
|
text: "Are you sure want to " + remark +" ?",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#DD6B55",
|
||||||
|
confirmButtonText: "Yes, " +remark+ " it!",
|
||||||
|
closeOnConfirm: false
|
||||||
|
}, function (isConfirm) {
|
||||||
|
if (isConfirm) {
|
||||||
|
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||||
|
var url = "/origami/sale/" + sale_id + '/cashier/waste_and_spoilage';
|
||||||
|
|
||||||
|
console.log(url)
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: url,
|
||||||
|
data: "remark="+ remark + "&sale_id=" + sale_id,
|
||||||
|
success: function (result) {
|
||||||
|
console.log(result)
|
||||||
|
// For Server Print - from jade
|
||||||
|
// if ($("#server_mode").val() == "cloud") {
|
||||||
|
// code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||||
|
// }
|
||||||
|
// window.location.href = '/origami/';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
post "check_in" => "check_in_process#check_in_process"
|
post "check_in" => "check_in_process#check_in_process"
|
||||||
post "request_time" => "check_in_process#request_time"
|
post "request_time" => "check_in_process#request_time"
|
||||||
post "call_waiter" => "call_waiters#index"
|
post "call_waiter" => "call_waiters#index"
|
||||||
|
#---------Waste and Spoile --------------#
|
||||||
|
post 'sale/:sale_id/:type/waste_and_spoilage' => 'waste_spoile#waste_and_spoilage'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -85,6 +87,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
|
|
||||||
#--------- Cashier ------------#
|
#--------- Cashier ------------#
|
||||||
namespace :origami do
|
namespace :origami do
|
||||||
|
|
||||||
get "dashboard" => "dashboard#index"
|
get "dashboard" => "dashboard#index"
|
||||||
|
|
||||||
get "quick_service" => "quick_service#index"
|
get "quick_service" => "quick_service#index"
|
||||||
@@ -192,6 +195,8 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
#---------Void --------------#
|
#---------Void --------------#
|
||||||
post 'sale/:sale_id/:type/void' => 'void#overall_void'
|
post 'sale/:sale_id/:type/void' => 'void#overall_void'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---------Multiple Invoices --------------#
|
#---------Multiple Invoices --------------#
|
||||||
get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index"
|
get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index"
|
||||||
get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show", :as => "table_invoice_show"
|
get 'table/:table_id/table_invoice/:invoice_id' => "table_invoices#show", :as => "table_invoice_show"
|
||||||
@@ -245,6 +250,7 @@ scope "(:locale)", locale: /en|mm/ do
|
|||||||
resources :second_display #second display routes
|
resources :second_display #second display routes
|
||||||
|
|
||||||
post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' }
|
post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#--------- Waiter/Ordering Station ------------#
|
#--------- Waiter/Ordering Station ------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user