Merge branch 'master' into menu_sync

This commit is contained in:
Yan
2017-08-14 15:34:19 +06:30
50 changed files with 1481 additions and 172 deletions

View File

@@ -23,8 +23,90 @@ $(document).ready(function(){
// setTimeout(function(){
// window.location.reload(1);
// }, 10000);
$(".nav-completed").on("click", function(){
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
});
$('.queue_station').on('click',function(){
$(".oqs_click").on("click", function(){
$("#completed").addClass('hide')
$(".oqs_append").removeClass('hide')
var oqs_id = $(this).find(".oqs-id").text();
var url = 'oqs/get_items/'+oqs_id;
show_details(url);
}); //End Click
function show_details(url){
var oqs_append = $('.oqs_append');
oqs_append.empty();
var filter = $('.filter').text();
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {'filter':filter},
dataType: "json",
success: function(data) {
for(var field in data) {
var price = parseFloat(data[field].price).toFixed(2);
if (data[field]["options"] == "[]") {
var options = "";
}else{
var options = data.options;
}
var date = new Date(data[field]["created_at"]);
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
row ='<div class="card queue_station">'
+'<div class="card-block">'
+'<h4 class="card-title">'
+'<span class="order-zone-type">'+data[field]["table_type"]+'- </span>'
+'<span class="order-zone">'+ data[field]["zone"] +'</span>'
+'<small class="pull-right">'+ data[field]["order_id"] +'- </small>'
+'</h4>'
+'<h4>'
+'<span class="order-item">'+ data[field]["item_name"] +'- </span>'
+'<span class="order-qty">'+ data[field]["qty"] +'- </span>'
+'</h4>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<p class="card-text">'
+'<small class="text-muted">Order at'
+'<span class="order-at">'+ show_date +'</span> - '
+'<span class="order-by">'+ data[field]["item_order_by"] +'</span> '
+'</small> '
+'</p>'
+'<p class="hidden order-customer">'+ data[field]["customer_name"] +'</p> '
+'<p class="hidden assigned-order-item">'+ data[field]["assigned_order_item_id"] +'</p> '
+'</div>'
+'<div class="card-footer">'
+'<button id="edit_'+ data[field]["assigned_order_item_id"]+'" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + data[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'</div>'
+'</div>';
$('.oqs_append').append(row);
}
}
});
//end Ajax
}
$(document).on('click', '.queue_station', function(event){
var orderZone=$(this).children().children().children('.order-zone').text().trim();
// var orderItem=$(this).children().children().children('.order-item').text();
var assigned_item_id = $(this).children().find(".assigned-order-item").text();
@@ -41,7 +123,6 @@ $(document).ready(function(){
$('#order-from').text(orderZone);
// clear order items
$("#oqs-order-details-table").children("tbody").empty();
// Call get_order_items() for Order Items by dining
$.ajax({
type: 'GET',
@@ -68,19 +149,20 @@ $(document).ready(function(){
$(this).addClass('selected-item');
});
$(".order-item-edit").on('click', function(){
$(document).on('click', '.order-item-edit', function(event){
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(5);
window.location.href = '/oqs/'+ assigned_item_id + "/edit"
});
// complete for queue item
$('.order-complete').on('click',function(e){
$(document).on('click', '.order-complete', function(event){
//e.preventDefault();
var _self = $(this); // To know in ajax return
var assigned_item_id=$(this).attr('id').substr(15);
var params = { 'id':assigned_item_id };
// Call update_delivery_status() for changed delivery and move to delivery
$.ajax({
type: 'POST',
@@ -117,10 +199,11 @@ $(document).ready(function(){
});
// Print Order Item
$('#print_order_item').on('click',function(){
$(document).on('click', '#print_order_item', function(event){
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
var options = $('.selected-item').children('.card-block').find('.item-options').text();
var params = { 'options':options };
$.ajax({
type: 'GET',
url: '/oqs/print/print/'+assigned_item_id,
@@ -129,7 +212,8 @@ $(document).ready(function(){
});
// Print Order Summary
$('#print_order_summary').on('click',function(){
// $('#print_order_summary').on('click',function(){
$(document).on('click', '#print_order_summary', function(event){
var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'table_name':table_name };

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the dining_charges controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -26,7 +26,22 @@ ul.dropdown-menu li a{
background-color: transparent !important;
margin-bottom: 0px !important;
}
.page-header{
border-bottom :0px solid #000 !important;
margin :0px !important;
}
}
.card-block {
text-align:center;
background-color:#ddd;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
height: auto;
background-color: #ef404a;
width: 100%;
}

View File

@@ -0,0 +1,126 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
# Query for OQS with delivery status false
@queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
@queue_completed_item = completed_order
@queue_stations_items=Array.new
# Calculate Count for each station tab
queue_stations.each do |que|
i = 0
zone_id = 0
@queue_items_details.each do |qid|
dining = DiningFacility.find_by_name(qid.zone)
que.order_queue_process_by_zones.each do |qz|
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
zone_id = qid.zone_id
i=i+1
end
end
end
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
@queue_stations_items
end
# Get Order items
def get_order_items
items = []
table_name = params[:table_id]
status = params[:status]
dining = DiningFacility.find_by_name(table_name);
# oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
# if status == ""
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
# oi = OrderItem.find_by_item_code(aoi.item_code)
# items.push(oi)
# end
# else
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
# oi = OrderItem.find_by_item_code(aoi.item_code)
# items.push(oi)
# end
# end
booking = Booking.find_by_dining_facility_id(dining.id)
BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
order=Order.find(bo.order_id)
order.order_items.each do |oi|
items.push(oi)
end
end
# booking_id = dining.get_new_booking
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
# order=Order.find(bo.order_id);
# order.order_items.each do |oi|
# items.push(oi)
# end
# end
render :json => items.to_json
end
def show
end
# update delivery status when complete click
def update_delivery_status
removed_item = []
assigned_item_id = params[:id]
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# update delivery status for completed same order items
assigned_items.each do |ai|
ai.delivery_status=true
ai.save
removed_item.push(ai.assigned_order_item_id)
end
render :json => removed_item.to_json
end
# Query for OQS with delivery status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
.group("assigned_order_items.assigned_order_item_id")
.order("assigned_order_items.created_at")
end
# Completed Order
def completed_order
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
end

View File

@@ -1,33 +1,44 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
@queue_stations = OrderQueueStation.all
# Query for OQS with delivery status false
@queue_items_details = queue_items_query(false)
# @queue_items_details = queue_items_query(false)
# Query for OQS with delivery status true
@queue_completed_item = completed_order
@queue_stations_items=Array.new
@filter = params[:filter]
@queue_completed_item = completed_order(@filter)
if !@filter.nil?
@count = queue_items_count_query(false,@filter)
@count.each do |count|
# Calculate Count for each station tab
queue_stations.each do |que|
i = 0
zone_id = 0
@queue_items_details.each do |qid|
dining = DiningFacility.find_by_name(qid.zone)
que.order_queue_process_by_zones.each do |qz|
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
zone_id = qid.zone_id
i=i+1
end
end
end
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
end
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
@queue_stations_items
# @queue_stations_items=Array.new
# Calculate Count for each station tab
# @queue_stations.each do |que|
# i = 0
# zone_id = 0
# @queue_items_details.each do |qid|
# dining = DiningFacility.find_by_name(qid.zone)
# que.order_queue_process_by_zones.each do |qz|
# if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
# zone_id = qid.zone_id
# i=i+1
# end
# end
# end
# @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
# end
# # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
# @queue_stations_items
end
# Get Order items
@@ -68,6 +79,13 @@ class Oqs::HomeController < BaseOqsController
render :json => items.to_json
end
def get_items_by_oqs
oqs_id = params[:id]
filter = params[:filter]
items = queue_items_query(false,oqs_id,filter)
render :json => items.to_json
end
def show
end
@@ -87,9 +105,22 @@ class Oqs::HomeController < BaseOqsController
render :json => removed_item.to_json
end
# Query for OQS with delivery status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
def queue_items_query(status,oqs_id=nil,filter)
if oqs_id == nil
oqs = ''
else
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
end
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
oqs.id as station_id, oqs.station_name,
oqs.is_active, oqpz.zone_id,
df.name as zone, df.type as table_type,
odt.order_id, odt.item_code, odt.item_name,
odt.price, odt.qty, odt.item_order_by, odt.options,
cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -98,14 +129,15 @@ class Oqs::HomeController < BaseOqsController
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.assigned_order_item_id")
.order("assigned_order_items.created_at")
end
# Completed Order
def completed_order
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
def completed_order(filter)
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
@@ -115,12 +147,28 @@ class Oqs::HomeController < BaseOqsController
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("assigned_order_items.order_id")
.limit(20)
.order("assigned_order_items.created_at")
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
def queue_items_count_query(status,filter)
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("oqs.id")
end
end

View File

@@ -89,6 +89,8 @@ class Origami::CustomersController < BaseOrigamiController
if status == true
render json: JSON.generate({:status => true})
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end

View File

@@ -7,6 +7,7 @@ class Origami::HomeController < BaseOrigamiController
@complete = Sale.where("sale_status != 'new'")
@orders = Order.all.order('date desc')
@shop = Shop.find_by_id(1)
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -39,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -39,13 +39,13 @@ class Origami::ShiftsController < BaseOrigamiController
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account)
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end
@@ -72,6 +72,8 @@ class Origami::ShiftsController < BaseOrigamiController
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
end
end

View File

@@ -0,0 +1,72 @@
class Origami::VoucherController < BaseOrigamiController
def index
@sale_id = params[:sale_id]
# limit voucher_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
@vouchercount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "voucher"
@vouchercount = @vouchercount + sale_payment.payment_amount
else
others = others + sale_payment.payment_amount
end
end
@can_voucher = total - @vouchercount - others
end
def create
cash = params[:amount]
sale_id = params[:sale_id]
sale_id = params[:refnumber]
if(Sale.exists?(sale_id))
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
if customer_data
membership_id = customer_data.membership_id
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
if membership_setting.gateway_url
member_actions =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here
if member_actions.gateway_url
campaign_type_id = member_actions.additional_parameter["campaign_type_id"]
url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s
merchant_uid= member_actions.merchant_account_id
auth_token = member_actions.auth_token.to_s
# membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
# if membership_data["status"]==true
begin
response = HTTParty.get(url,
:body => { app_token: token,membership_id:membership_id,
campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
auth_token:auth_token
}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
rescue OpenURI::HTTPError
response = { status: false}
rescue SocketError
response = { status: false}
end
# end
end
end
end
if( response["status"]==true )
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "voucher")
end
end
end
end

View File

@@ -0,0 +1,91 @@
class Settings::DiningChargesController < ApplicationController
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
before_action :set_settings_facility
before_action :set_settings_zone
# GET /dining_charges
# GET /dining_charges.json
def index
@dining_charges = DiningCharge.all
end
# GET /dining_charges/1
# GET /dining_charges/1.json
def show
end
# GET /dining_charges/new
def new
@dining_charge = DiningCharge.new
end
# GET /dining_charges/1/edit
def edit
end
# POST /dining_charges
# POST /dining_charges.json
def create
@dining_charge = DiningCharge.new(dining_charge_params)
@dining_charge.dining_facility_id = @settings_dining_facility.id
respond_to do |format|
if @dining_charge.save
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully created.' }
format.json { render :show, status: :created, location: @dining_charge }
else
format.html { render :new }
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /dining_charges/1
# PATCH/PUT /dining_charges/1.json
def update
respond_to do |format|
@dining_charge.dining_facility_id = @settings_dining_facility.id
if @dining_charge.update(dining_charge_params)
format.html { redirect_to edit_settings_zone_table_path(@zone,@settings_dining_facility), notice: 'Dining charge was successfully updated.' }
format.json { render :show, status: :ok, location: @dining_charge }
else
format.html { render :edit }
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
end
end
end
# DELETE /dining_charges/1
# DELETE /dining_charges/1.json
def destroy
@dining_charge.destroy
respond_to do |format|
format.html { redirect_to dining_charges_url, notice: 'Dining charge was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_dining_charge
@dining_charge = DiningCharge.find(params[:id])
end
def set_settings_facility
if params[:table_id]
@table = true
@settings_dining_facility = Table.find(params[:table_id])
elsif params[:room_id]
@room = true
@settings_dining_facility = Room.find(params[:room_id])
end
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def dining_charge_params
# params.fetch(:dining_charge, {})
params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id)
end
end

View File

@@ -0,0 +1,2 @@
module DiningChargesHelper
end

View File

@@ -0,0 +1,41 @@
class DiningCharge < ApplicationRecord
belongs_to :table
belongs_to :room
def amount_calculate(dining_charges_obj, checkin , checkout)
if !checkin.nil? && !checkout.nil? && !dining_charges_obj.nil?
minutes = ((checkin - checkout) * 24 * 60).to_i # stay minutes
dining_minutes = minutes - dining_charges_obj.minimum_free_time # stayminutes - free minutes
charge_type = dining_charges_obj.charge_type
if charge_type == 'hr'
elsif charge_type == 'day'
price = charge_by_day
end
end
end
def charge_by_hour
end
def charge_by_day(chargesObj, dining_minutes)
minues_per_day = 12 * 60
result = dining_minutes / minues_per_day
if result < 1
return chargesObj.unit_price
elsif result > 1
solid_price = result * chargesObj.unit_price
remain_value = dining_minutes % minues_per_day
roundingblock = remain_value / chargesObj.time_rounding_block
if roundingblock > 1
end
end
end
end

View File

@@ -1,5 +1,6 @@
class DiningFacility < ApplicationRecord
belongs_to :zone
has_many :dining_charges
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"

View File

@@ -22,14 +22,14 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# end
#Bill Receipt Print
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
def print_close_cashier(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
#Use CUPS service
#Generate PDF
#Print
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf.render_file filename
self.print(filename)

View File

@@ -274,10 +274,9 @@ class Sale < ApplicationRecord
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(sale.customer_id)
# #Creat new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => sale)
sale_tax.tax_name = tax.name
@@ -319,11 +318,10 @@ class Sale < ApplicationRecord
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
# #Create new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
customer.tax_profiles.each do |cus_tax|
if cus_tax.to_i == tax.id
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate

View File

@@ -125,6 +125,12 @@ class ShiftSale < ApplicationRecord
query = query.where("sales.shift_sale_id =? and sale_status = 'completed'", shift.id)
.group("acc.title").order("acc.id")
end
end
def self.get_total_member_discount(shift)
query = Sale.select("SUM(sales.total_discount) as member_discount")
.where("shift_sale_id =? and sale_status = 'completed' and discount_type = 'member_discount'", shift.id)
end
end

View File

@@ -1,6 +1,6 @@
class CloseCashierPdf < Prawn::Document
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,:text_width
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
self.page_width = 210
self.page_height = 7000
self.margin = 5
@@ -32,7 +32,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
@@ -51,7 +51,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account)
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -277,9 +277,32 @@ class CloseCashierPdf < Prawn::Document
end
#end total amount by Account
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@member_discount}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Overall Discount Amount :", :size => self.item_font_size, :align => :right
text "Total Overall Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{@overall}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_discounts}", :size => self.item_font_size, :align => :right

View File

@@ -124,18 +124,20 @@ $(document).on('click',".customer_tr",function(){
var url = "customers/" + customer_id + "/edit";
}
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});;
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
success: function(data) {
// Selected for Taxes
var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes);
console.log(parse_taxes);
$.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
});
$('#customer_id').val(data.id);

View File

@@ -1,12 +1,12 @@
<div class="row">
<div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<% if current_login_employee.role = "admin" %>
<% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %>
<% elsif current_login_employee = "waiter" %>
<% elsif current_login_employee = "account" %>
<%= link_to "Cashier Station", oishi_path %>
<% else %>
@@ -14,22 +14,29 @@
<% end %>
<% shop = Shop.first %>
<!-- -->
<div class="card">
<div class="page-header" style="width:100%;text-align:center;background-color:#ddd;">
<h4 style="color : #ef404a;font-weight:bold;font-style:italic;"><%= shop.name %></h4>
</div>
<div class="card-block">
<%= shop.address %>
</div>
<div class="card-block">
<%= shop.phone_no %>
</div>
</div>
</div>
</div>
<div class="footer">
<div class="card">
<div class="page-header" style="width:100%;text-align:center;background-color:#ddd;">
<h4 style="color : #ef404a;font-weight:bold;font-style:italic;margin-bottom:0px;"><%= shop.name %></h4>
</div>
<div class="card-block" style="text-align:center;background-color:#ddd;padding:0rem;">
<%= shop.address %>
</div>
<div class="card-block" style="text-align:center;background-color:#ddd;padding:0rem;">
<%= shop.phone_no %>
</div>
</div>
</div>
<style type="text/css">
.footer {
position: fixed;
bottom: 0;
left: 0;
height: auto;
background-color: #ef404a;
width: 100%;
}
</style>

View File

@@ -0,0 +1,197 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-8 col-md-8 col-sm-8">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<% # For Tab Disable for Station is inactive
status=""
@queue_stations_items.each do |qsi|
if qsi[:is_active] == false
status="disabled"
end
%>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi[:station_name].gsub(' ', '_') %> role="tab" <%= status %>>
<%= qsi[:station_name] %>
<span class="badge badge-pill badge-default" id=<%= qsi[:station_name].gsub(' ', '_') + '_count' %>>
<%= qsi[:item_count] %>
</span>
<% if qsi[:is_ap] %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% end %>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_completed_item.each do |qid|
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item">
<%= qid.item_name %>
</span> [x
<span class="order-qty">
<%= qid.qty %>
</span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<p class="hidden order-status">completed</p>
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
</div>
<%
end
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!-- Order Item for Queue Station -->
<%
@queue_stations_items.each do |qsi|
%>
<!-- Generated Pane -->
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
<!--- Order Items -->
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_items_details.each do |qid|
if qid.price != 0
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item"><%= qid.item_name %></span> [x
<span class="order-qty"><%= qid.qty %></span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<!-- Hidden Fields for Items -->
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
<div class="card-footer">
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
<%
end
end
end
%>
<!--- end of Items-->
</div>
</div>
<!-- end of Pane -->
<% end %>
<!-- End Order Item for Queue Station -->
</div>
</div>
<!-- Column Two -->
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">ORDER DETAILS - Table</strong></div>
</div>
<div class="card-block">
<div class="card-title">
<table class="table">
<thead>
<tr>
<th style="width:33%; text-align:left">Order By</th>
<th style="width:33%; text-align:right">Order At</td>
<th style="width:33%; text-align:right">Customer</td>
</tr>
</thead>
<tbody>
<tr>
<td id="order-by" style="width:33%; text-align:left"></td>
<td id="order-at" style="width:33%; text-align:right"></td>
<td id="order-customer" style="width:33%; text-align:right"></td>
</tr>
<tr>
<td><strong>Table/Room</strong></td>
<td id="order-from" colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<div class="card-text" style="min-height:360px; max-height:360px; overflow:auto">
<table class="table" id="oqs-order-details-table">
<thead>
<tr>
<th style="width:80%; text-align:left">Items</th>
<th style="width:20%; text-align:right">QTY</th>
</tr>
</thead>
<tbody>
<!-- Bind With JS -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three--->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons -->
<button type="button" title="Print Order Item" id="print_order_item" class="btn btn-primary btn-lg btn-block">Print</a>
<button type="button" class="btn btn-primary btn-lg btn-block" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<a href="<%= dashboard_path %>" class="btn btn-primary btn-lg btn-block" role="button" aria-haspopup="true"> Back </a>
<!-- <button type="button" class="" id="print_order_summary">Print <br/>Order<br/>Summary</button> -->
</div>
</div>

View File

@@ -1,39 +1,63 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="col-md-6">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="form-group col-md-4">
<input type="text" name="filter" class="form-control input-sm" placeholder="" style="margin-right: 10px">
</div>
<div class="form-group col-md-1">
<input type="submit" value="Search" class='btn btn-primary btn-sm'>
</div>
<% end %>
</div>
</div>
<!-- Column One -->
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
<!-- <li class="nav-item nav-search <%= @filter.to_s.length > 0? " " : "hide"%>">
<a class="nav-link <%= @filter.to_s.length > 0? "active" : " "%>" data-toggle="tab" href="#search" role="tab">Searching .. <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li> -->
<li class="nav-item nav-completed">
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<%
# For Tab Disable for Station is inactive
<% # For Tab Disable for Station is inactive
status=""
@queue_stations_items.each do |qsi|
if qsi[:is_active] == false
@queue_stations.each do |qsi|
if qsi.is_active == false
status="disabled"
end
%>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href=<%= '#' + qsi[:station_name].gsub(' ', '_') %> role="tab" <%= status %>>
<%= qsi[:station_name] %>
<span class="badge badge-pill badge-default" id=<%= qsi[:station_name].gsub(' ', '_') + '_count' %>>
<%= qsi[:item_count] %>
end %>
<li class="nav-item oqs_click" >
<p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab" <%= status %>>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge badge-pill badge-default" id=""> <%= qsi.assigned_order_items.where("delivery_status=0").count %>
</span>
<% if qsi[:is_ap] %>
<span>(ap)</span>
<% end %>
</a>
<%else%>
<span class="badge badge-pill badge-default" id="">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% end %>
</ul>
<!-- Nav tabs - End -->
<p class="hidden filter"><%= @filter %></p>
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@@ -77,66 +101,14 @@
%>
</div>
</div>
<!-- End Panel 0 - Completed -->
<!-- Order Item for Queue Station -->
<%
@queue_stations_items.each do |qsi|
%>
<!-- Generated Pane -->
<div class="tab-pane" id=<%= qsi[:station_name].gsub(' ', '_') %> role="tabpanel">
<!--- Order Items -->
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<%
@queue_items_details.each do |qid|
if qid.price != 0
if qid.zone_id == qsi[:zone_id] && qid.station_name == qsi[:station_name]
%>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item"><%= qid.item_name %></span> [x
<span class="order-qty"><%= qid.qty %></span> ]
</h4>
<p class="card-text item-options"><%= qid.options == "[]"? "" : qid.options %></p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<!-- Hidden Fields for Items -->
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
</div>
<div class="card-footer">
<button id=<%= 'edit_' + qid.assigned_order_item_id.to_s %> class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id=<%= 'assigned_queue_' + qid.assigned_order_item_id.to_s %> class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
<%
end
end
end
%>
<!--- end of Items-->
</div>
</div>
<!-- end of Pane -->
<% end %>
<!-- End Order Item for Queue Station -->
<!--- Order Items -->
<div class="card-columns oqs_append" style="padding-top:10px; column-gap: 1.2rem;">
</div>
<!--- end of Items-->
</div>
</div>
@@ -197,4 +169,6 @@
</div>
</div>
<script type="text/javascript">
</script>

View File

@@ -108,7 +108,7 @@
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- Temporary Disabled -->
<%if current_login_employee.role == "cashier" %>
<%if current_login_employee.role == "cashier" && @shop.quick_sale_summary == true%>
<button id="sale_summary" type="button" class="btn btn-block btn-primary">Sale Sammary</button>
<%end%>
<button id="close_cashier" type="button" class="btn btn-block btn-primary"> Close Cashier </button>

View File

@@ -55,11 +55,29 @@
<td><%= amount.total_price.round(2) %></td>
</tr>
<%end%>
<% if !@total_member_discount[0].member_discount.nil?
@member_discount = @total_member_discount[0].member_discount rescue 0.0
@overall = @shift.total_discounts - @member_discount
%>
<tr>
<th></th>
<th style="text-align: right;"> Overall Discount Amount</th>
<th><%= @shift.total_discounts %></th>
<th></th>
<th style="text-align: right;"> Total Member Discount</th>
<th><%= @member_discount %></th>
</tr>
<%else @overall = @shift.total_discounts %>
<%end%>
<tr>
<th></th>
<th style="text-align: right;"> Total Overall Discount</th>
<th><%= @overall %></th>
</tr>
<tr>
<th></th>
<th style="text-align: right;"> Total Discount</th>
<th><%= @shift.total_discounts %></th>
</tr>
<% @sale_taxes.each do |tax| %>
<tr>
@@ -98,6 +116,7 @@
<th><%=@shift.credit_sales %></th>
</tr>
<% @total_amount = 0
@other_payment.each do |other| %>
<tr>
<th></th>
@@ -107,32 +126,32 @@
<tr>
<th></th>
<td style="text-align: right;">MPU Payment </td>
<td><%=other.mpu_amount.round(2) %></td>
<% @total_amount = @total_amount+other.mpu_amount %>
<td><%=other.mpu_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">VISA Payment </td>
<td><%=other.visa_amount.round(2) %></td>
<% @total_amount = @total_amount+other.visa_amount %>
<td><%=other.visa_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.visa_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">JCB Payment </td>
<td><%=other.master_amount.round(2) %></td>
<% @total_amount = @total_amount+other.master_amount %>
<td><%=other.master_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.master_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Master Payment </td>
<td><%=other.jcb_amount.round(2) %></td>
<% @total_amount = @total_amount+other.jcb_amount %>
<td><%=other.jcb_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %>
</tr>
<tr>
<th></th>
<td style="text-align: right;">Reedem Payment </td>
<td><%=other.paypar_amount.round(2) %></td>
<% @total_amount = @total_amount+other.paypar_amount %>
<td><%=other.paypar_amount.round(2) rescue 0.0 %></td>
<% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %>
</tr>
<%end%>

View File

@@ -0,0 +1,5 @@
if(@status)
json.status @status
else
json.status false
end

View File

@@ -0,0 +1,179 @@
<div class="row">
<div class="col-lg-5 col-md-5 col-sm-3">
<div class="row">
<div class="col-md-6">
<h2>Voucher / Coupon</h2>
</div>
</div>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_voucher %>" data-member-value="">
</div>
<hr>
</div>
<% if @vouchercount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent Voucher paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@vouchercount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="<%=@sale_id %>" class="form-control col-lg-7 col-md-7 col-sm-7 float-value" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<!-- <div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div> -->
<input type="text" name="" id="amount" class="form-control col-lg-7 col-md-7 col-sm-7 float-value" value="" data-value="amount" data-member-value="">
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="voucher_pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
</div>
</div>
<script>
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_voucher %>") - parseFloat(localStorage.getItem("cash")));
}
});
// number key pad
var float_value = ""
var total = 0
$(document).on('focusout', '.float-value', function(event){
float_value = $(this).attr("data-value");
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#'+float_value).val();
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#'+float_value).val(input_value);
}else{
$('#'+float_value).val(original_value+input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#'+float_value).val(amount);
break;
case 'clr':
$('#'+float_value).val("0.0");
break;
case 'del' :
var cash=$('#'+float_value).val();
$('#'+float_value).val(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#'+float_value).val(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
})
$('#voucher_pay').on('click',function(){
var amount = $('#amount').val();
var refnumber = $("#<%=@sale_id %>").val();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
// alert(amount);
// alert(refnumber);
$.ajax({type: "POST",
url: "<%= origami_payment_voucher_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id+ "&refnumber="+ refnumber,
success:function(result){
if(result){
alert("Payment success")
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
});
}else{
alert("Paid Amount is over!");
}
})
</script>

View File

@@ -0,0 +1,2 @@
json.extract! dining_charge, :id, :created_at, :updated_at
json.url dining_charge_url(dining_charge, format: :json)

View File

@@ -0,0 +1,18 @@
<%= simple_form_for([:settings,@zone,@settings_dining_facility,@dining_charge]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<%= f.input :item_code %>
<%= f.input :unit_price %>
<%= f.input :taxable %>
<%= f.input :charge_type %>
<%= f.input :minimum_free_time %>
<%= f.input :charge_block %>
<%= f.input :time_rounding %>
<%= f.input :time_rounding_block %>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -0,0 +1,19 @@
<!-- <h1>Editing Dining Charge</h1>
<%= render 'form', dining_charge: @dining_charge %>-->
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_zone_path(@zone) %>">Zone</a></li>
<% if @table %>
<li><a href="<%= edit_settings_zone_table_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% elsif @room %>
<li><a href="<%= edit_settings_zone_room_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% end %>
<li>New</li>
</ul>
</div>
<%= render 'form', dining_charge: @dining_charge %>
</div>

View File

@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>
<h1>Dining Charges</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @dining_charges.each do |dining_charge| %>
<tr>
<td><%= link_to 'Show', dining_charge %></td>
<td><%= link_to 'Edit', edit_dining_charge_path(dining_charge) %></td>
<td><%= link_to 'Destroy', dining_charge, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Dining Charge', new_dining_charge_path %>

View File

@@ -0,0 +1 @@
json.array! @dining_charges, partial: 'dining_charges/dining_charge', as: :dining_charge

View File

@@ -0,0 +1,18 @@
<!-- <h1>New Dining Charge</h1>
<%= render 'form', dining_charge: @dining_charge %> -->
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_zone_path(@zone) %>">Zone</a></li>
<% if @table %>
<li><a href="<%= edit_settings_zone_table_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% elsif @room %>
<li><a href="<%= edit_settings_zone_room_path(@zone,@settings_dining_facility) %>">Table / Room</a></li>
<% end %>
<li>New</li>
</ul>
</div>
<%= render 'form', dining_charge: @dining_charge %>
</div>

View File

@@ -0,0 +1,4 @@
<p id="notice"><%= notice %></p>
<%= link_to 'Edit', edit_dining_charge_path(@dining_charge) %> |
<%= link_to 'Back', dining_charges_path %>

View File

@@ -0,0 +1 @@
json.partial! "dining_charges/dining_charge", dining_charge: @dining_charge

View File

@@ -16,6 +16,7 @@
<th style="width:20%">Name</th>
<th style="width:20%">Role</th>
<th style="width:20%">Created At</th>
<th style="width:20%">Updated At</th>
<th style="width:20%">Action</th>
</tr>
</thead>
@@ -26,6 +27,7 @@
<td><%= link_to employee.name,settings_employee_path(employee) %></td>
<td><%= employee.role %></td>
<td><%= employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td><%= employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td>
<%= link_to 'Edit', edit_settings_employee_path(employee) %>
<%if employee.role != "administrator"%>

View File

@@ -2,7 +2,7 @@
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= settings_employees_path %>">Employee</a></li>
<span style="float: right">
</span>
</ul>
@@ -15,7 +15,8 @@
<tr>
<th>Name</th>
<th>Role</th>
<th>Created At</th>
<th>Updated At</th>
<th>Action</th>
</tr>
</thead>
@@ -24,6 +25,8 @@
<tr>
<td><%= @employee.name %></td>
<td><%= @employee.role %></td>
<td><%= @employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td><%= @employee.updated_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
<td>
<%= link_to 'Edit', edit_settings_employee_path(@employee) %>
</td>
@@ -34,4 +37,3 @@
</div>
</div>

View File

@@ -7,6 +7,26 @@
<%= f.input :seater %>
<%= f.input :order_by %>
<%= f.input :is_active %>
<% if @settings_table.dining_charges.length == 0 %>
<div class="div-border">
<div class="col-md-10">
<%= link_to 'Add For Extra Charges', new_settings_zone_table_dining_charge_path(@zone,@settings_table),:class => 'btn btn-primary' %>
</div>
</div>
<% else %>
<% @settings_table.dining_charges.each do |dc| %>
<div class="div-border">
<div class="col-md-10"><b><u>Dining Charge</u></b></div>
<div class="col-md-10">item code : <%= dc.item_code %></div>
<div class="col-md-10">Unit price : <%= dc.unit_price %></div>
<div class="col-md-10">Charge type : <%= dc.charge_type %></div>
<div class="col-md-10">
<%= link_to 'Edit Charges', edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc),:class => 'btn btn-primary' %>
<!-- <button class="btn btn-primary" src="<%= edit_settings_zone_table_dining_charge_path(@zone,@settings_table,dc) %>">Edit Charge</button> -->
</div>
</div>
<% end %>
<% end %>
</div>
<div class="form-actions">

View File

@@ -140,6 +140,7 @@ Rails.application.routes.draw do
post 'payment/visa' => "visa#create"
post 'payment/paypar' => 'paypar_payments#create'
post 'payment/credit' => 'credit_payments#create'
post 'payment/voucher' => 'voucher_payments#create'
get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index"
get 'sale/:sale_id/payment/others_payment' => "others_payments#index"
@@ -148,6 +149,7 @@ Rails.application.routes.draw do
get 'sale/:sale_id/payment/others_payment/Master' => "master#index"
get 'sale/:sale_id/payment/others_payment/JCB' => "jcb#index"
get 'sale/:sale_id/payment/others_payment/Redeem' => "redeem_payments#index"
get 'sale/:sale_id/payment/others_payment/Voucher' => "voucher#index"
#---------Void --------------#
post 'sale/:sale_id/void' => 'void#overall_void'
@@ -201,6 +203,8 @@ Rails.application.routes.draw do
# Pass assigned_order_item_id
get 'print/print/:id', to: "print#print"
get 'print/print_order_summary/:id', to: "print#print_order_summary"
get "/get_items/:id" =>"home#get_items_by_oqs", :as => "get_order_items_by_oqs"
#dashboard
#
end
@@ -256,9 +260,13 @@ Rails.application.routes.draw do
#zones
resources :zones do
#tables
resources :tables
resources :tables do
resources :dining_charges
end
#rooms
resources :rooms
resources :rooms do
resources :dining_charges
end
end
end

View File

@@ -0,0 +1,16 @@
class CreateDiningCharges < ActiveRecord::Migration[5.1]
def change
create_table :dining_charges do |t|
t.references :dining_facility
t.string :item_code, :null => false
t.integer :unit_price, :default => 0
t.boolean :taxable, :default => true
t.string :charge_type, :default => "hr"
t.time :minimum_free_time
t.time :charge_block
t.string :time_rounding, :default => "down"
t.time :time_rounding_block
t.timestamps
end
end
end

View File

@@ -1224,6 +1224,7 @@ payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://staging.membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://staging.membership.paypar.ws"})
payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://staging.membership.paypar.ws",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv"})
payment_methods = PaymentMethodSetting.create({payment_method:"Voucher",gateway_url: "http://staging.membership.paypar.ws",merchant_account_id:"RxzaYyAGzm7VqAZ4hKnv"})
#Default Order Queue stations
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['I0001','I0002','I0003','I0004']), print_copy:false, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})

View File

@@ -0,0 +1,141 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
#
# Also compared to earlier versions of this generator, there are no longer any
# expectations of assigns and templates rendered. These features have been
# removed from Rails core in Rails 5, but can be added back in via the
# `rails-controller-testing` gem.
RSpec.describe DiningChargesController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# DiningCharge. As you add validations to DiningCharge, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# DiningChargesController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "returns a success response" do
dining_charge = DiningCharge.create! valid_attributes
get :index, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #show" do
it "returns a success response" do
dining_charge = DiningCharge.create! valid_attributes
get :show, params: {id: dining_charge.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "GET #new" do
it "returns a success response" do
get :new, params: {}, session: valid_session
expect(response).to be_success
end
end
describe "GET #edit" do
it "returns a success response" do
dining_charge = DiningCharge.create! valid_attributes
get :edit, params: {id: dining_charge.to_param}, session: valid_session
expect(response).to be_success
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new DiningCharge" do
expect {
post :create, params: {dining_charge: valid_attributes}, session: valid_session
}.to change(DiningCharge, :count).by(1)
end
it "redirects to the created dining_charge" do
post :create, params: {dining_charge: valid_attributes}, session: valid_session
expect(response).to redirect_to(DiningCharge.last)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
post :create, params: {dining_charge: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested dining_charge" do
dining_charge = DiningCharge.create! valid_attributes
put :update, params: {id: dining_charge.to_param, dining_charge: new_attributes}, session: valid_session
dining_charge.reload
skip("Add assertions for updated state")
end
it "redirects to the dining_charge" do
dining_charge = DiningCharge.create! valid_attributes
put :update, params: {id: dining_charge.to_param, dining_charge: valid_attributes}, session: valid_session
expect(response).to redirect_to(dining_charge)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'edit' template)" do
dining_charge = DiningCharge.create! valid_attributes
put :update, params: {id: dining_charge.to_param, dining_charge: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "DELETE #destroy" do
it "destroys the requested dining_charge" do
dining_charge = DiningCharge.create! valid_attributes
expect {
delete :destroy, params: {id: dining_charge.to_param}, session: valid_session
}.to change(DiningCharge, :count).by(-1)
end
it "redirects to the dining_charges list" do
dining_charge = DiningCharge.create! valid_attributes
delete :destroy, params: {id: dining_charge.to_param}, session: valid_session
expect(response).to redirect_to(dining_charges_url)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the DiningChargesHelper. For example:
#
# describe DiningChargesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe DiningChargesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe DiningCharge, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "DiningCharges", type: :request do
describe "GET /dining_charges" do
it "works! (now write some real specs)" do
get dining_charges_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe DiningChargesController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/dining_charges").to route_to("dining_charges#index")
end
it "routes to #new" do
expect(:get => "/dining_charges/new").to route_to("dining_charges#new")
end
it "routes to #show" do
expect(:get => "/dining_charges/1").to route_to("dining_charges#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/dining_charges/1/edit").to route_to("dining_charges#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/dining_charges").to route_to("dining_charges#create")
end
it "routes to #update via PUT" do
expect(:put => "/dining_charges/1").to route_to("dining_charges#update", :id => "1")
end
it "routes to #update via PATCH" do
expect(:patch => "/dining_charges/1").to route_to("dining_charges#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/dining_charges/1").to route_to("dining_charges#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "dining_charges/edit", type: :view do
before(:each) do
@dining_charge = assign(:dining_charge, DiningCharge.create!())
end
it "renders the edit dining_charge form" do
render
assert_select "form[action=?][method=?]", dining_charge_path(@dining_charge), "post" do
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "dining_charges/index", type: :view do
before(:each) do
assign(:dining_charges, [
DiningCharge.create!(),
DiningCharge.create!()
])
end
it "renders a list of dining_charges" do
render
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "dining_charges/new", type: :view do
before(:each) do
assign(:dining_charge, DiningCharge.new())
end
it "renders new dining_charge form" do
render
assert_select "form[action=?][method=?]", dining_charges_path, "post" do
end
end
end

View File

@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe "dining_charges/show", type: :view do
before(:each) do
@dining_charge = assign(:dining_charge, DiningCharge.create!())
end
it "renders attributes in <p>" do
render
end
end

View File

@@ -0,0 +1,9 @@
require "application_system_test_case"
class DiningChargesTest < ApplicationSystemTestCase
# test "visiting the index" do
# visit dining_charges_url
#
# assert_selector "h1", text: "DiningCharge"
# end
end