Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Nweni
2017-06-30 13:44:45 +06:30
27 changed files with 928 additions and 119 deletions

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

@@ -13,7 +13,7 @@
.selected-item { .selected-item {
color: #fff !important; color: #fff !important;
background-color: #54A5AF !important; background-color: #7a62d3 !important;
} }
.assign { .assign {
@@ -23,6 +23,14 @@
.assign .text-muted{ .assign .text-muted{
color: #fff !important; color: #fff !important;
} }
.normal{
color: #fff !important;
background-color: #54A5AF;
}
.cancel {
color: #fff !important;
background-color: #FF0000;
}
.red{ .red{
color: #fff !important; color: #fff !important;
background-color: red; background-color: red;
@@ -39,9 +47,9 @@
} }
.card-columns { .card-columns {
@include media-breakpoint-only(lg) { @include media-breakpoint-only(lg) {
column-count: 6; column-count: 5;
} }
@include media-breakpoint-only(xl) { @include media-breakpoint-only(xl) {
column-count: 6; column-count: 5;
} }
} }

View File

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

View File

@@ -68,8 +68,10 @@ class Api::OrdersController < Api::ApiController
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved' if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
if !booking.sale_id.nil? if !booking.sale_id.nil?
sale_status = check_order_with_booking(booking) sale_status = check_order_with_booking(booking)
# puts "WWwwWWWWWWww"
# puts sale_status
if sale_status if sale_status
return false , @message = "bill requested" return return_json_status_with_code(400, "bill requested")
end end
else else
@order.new_booking = false @order.new_booking = false
@@ -77,23 +79,28 @@ class Api::OrdersController < Api::ApiController
end end
else else
sale_status = check_order_with_table(params[:table_id]) sale_status = check_order_with_table(params[:table_id])
# puts "OOOOOOOOO"
# puts sale_status
if sale_status if sale_status
return false , @message = "bill requested" return return_json_status_with_code(400, "bill requested")
end end
end end
end #booking exists end #booking exists
else else
sale_status = check_order_with_table(params[:table_id]) sale_status = check_order_with_table(params[:table_id])
# puts "MMMMMMMM"
# puts sale_status
if sale_status if sale_status
return false , @message = "bill requested" # return false , @message = "bill requested"
return return_json_status_with_code(400, "bill requested")
end end
end end
@status, @booking = @order.generate @status, @booking = @order.generate
end end
# render json for http status code 202 # render json for http status code
def return_json_status_with_code(code, msg, booking_id) def return_json_status_with_code(code, msg)
render status: code, json: { render status: code, json: {
message: msg, message: msg,
booking_id: booking_id booking_id: booking_id
@@ -104,12 +111,14 @@ class Api::OrdersController < Api::ApiController
table = DiningFacility.find(table_id) table = DiningFacility.find(table_id)
if table if table
booking = table.get_current_booking booking = table.get_current_booking
puts booking # puts booking
if booking if booking
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true @order.new_booking = true
return true return false
else end
else
@order.new_booking = false @order.new_booking = false
@order.booking_id = booking.booking_id @order.booking_id = booking.booking_id
return false return false
@@ -118,10 +127,11 @@ class Api::OrdersController < Api::ApiController
end end
end end
# this can always true
def check_order_with_booking(booking) def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed" if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new"
@order.new_booking = true @order.new_booking = true
return true return false
else else
@order.new_booking = false @order.new_booking = false
@order.booking_id = params[:booking_id] @order.booking_id = params[:booking_id]

View File

@@ -7,7 +7,7 @@ class BaseOrigamiController < ActionController::Base
rescue_from CanCan::AccessDenied do |exception| rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message flash[:warning] = exception.message
redirect_to root_path redirect_to origami_root_path
end end
def current_user def current_user

View File

@@ -96,6 +96,17 @@ class Crm::DiningQueuesController < BaseCrmController
end end
end end
def cancel_queue
queue = DiningQueue.find(params[:id])
status = queue.update_attributes(id: params[:id],status:"Cancel")
if status == true
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully canceled .'})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.

View File

@@ -0,0 +1,48 @@
class Origami::OtherChargesController < BaseOrigamiController
authorize_resource :class => false
def index
sale_id = params[:sale_id]
if Sale.exists?(sale_id)
@sale_data = Sale.find(sale_id)
end
end
def create
sale_id = params[:sale_id]
other_charges_items = JSON.parse(params[:other_charges_items])
sub_total = params[:sub_total]
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_amount = sub_total.to_f
sale.grand_total = sub_total.to_f + sale.total_tax;
sale.save
if other_charges_items.length > 0
#save sale item for discount
other_charges_items.each do |di|
# origin_sale_item = SaleItem.find(di["id"])
sale_item = SaleItem.new
sale_item.sale_id = sale_id
sale_item.product_code = "Other Charges"
sale_item.product_name = di["name"]
sale_item.remark = "Other Charges"
sale_item.qty = 1
sale_item.unit_price = di["price"]
sale_item.taxable_price = di["price"]
sale_item.is_taxable = 0
sale_item.price = di["price"]
sale_item.save
end
end
end
dining = {:table_id => table_id, :table_type => table_type }
render :json => dining.to_json
end
end

View File

@@ -9,7 +9,12 @@ class Origami::PaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(sale_id) sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.where("sale_id=?",sale_id) sale_items = SaleItem.where("sale_id=?",sale_id)
new_total = Sale.get_rounding_adjustment(sale_data.grand_total)
rounding_adj = sale_data.grand_total - new_total
sale_data.update_attributes(grand_total: new_total,rounding_adjustment:rounding_adj)
# Print for First Bill to Customer # Print for First Bill to Customer
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
#shop detail #shop detail
shop_details = Shop.find(1) shop_details = Shop.find(1)

View File

@@ -1,5 +1,5 @@
class Origami::SaleEditController < BaseOrigamiController class Origami::SaleEditController < BaseOrigamiController
authorize_resource :class => false
# Index for sale item void OR edit # Index for sale item void OR edit
def edit def edit
sale_id = params[:sale_id] sale_id = params[:sale_id]

View File

@@ -1,5 +1,5 @@
class Origami::VoidController < BaseOrigamiController class Origami::VoidController < BaseOrigamiController
authorize_resource :class => false
def overall_void def overall_void
sale_id = params[:sale_id] sale_id = params[:sale_id]

View File

@@ -0,0 +1,18 @@
class Reports::ShiftsaleController < ApplicationController
# authorize_resource :class => false
def index
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_shiftsales(from,to)
respond_to do |format|
format.html
format.xls
end
end
def show
end
end

View File

@@ -0,0 +1,2 @@
module Reports::ShiftsaleHelper
end

View File

@@ -40,11 +40,14 @@ class Ability
can :add_customer, Customer can :add_customer, Customer
can :update_sale_by_customer, Customer can :update_sale_by_customer, Customer
can :index, :other_charges
can :create, :other_charges
can :index, :discount can :index, :discount
can :create, :discount can :create, :discount
can :remove_discount_items, :discount can :remove_discount_items, :discount
can :remove_all_discount, :discount can :remove_all_discount, :discount
can :first_bill, :payment
can :show, :payment can :show, :payment
can :create, :payment can :create, :payment
can :reprint, :payment can :reprint, :payment
@@ -54,6 +57,14 @@ class Ability
can :move_dining, :moveroom can :move_dining, :moveroom
can :edit, :sale_edit
can :item_void, :sale_edit
can :item_void_cancel, :sale_edit
can :cancel_all_void, :sale_edit
can :apply_void, :sale_edit
can :overall_void, :void
elsif user.role == "cashier" elsif user.role == "cashier"
can :read, Order can :read, Order

View File

@@ -39,6 +39,16 @@ class DiningFacility < ApplicationRecord
end end
end end
def get_moved_booking
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='moved' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
if booking.count > 0 then
return booking[0]
else
return nil
end
end
def get_new_booking def get_new_booking
# query for new # query for new
# if status # if status

View File

@@ -55,7 +55,7 @@ class Order < ApplicationRecord
end end
return false, @message = "booking fail" return false
end end

View File

@@ -320,6 +320,41 @@ class Sale < ApplicationRecord
end end
end end
def self.get_rounding_adjustment(num)
## 0 -- 25 -- 50 -- 75 -- 100
# if get_rounded_amt == true
value = 0
num = num.to_f.round
get_last_no = num.to_s.last(2).to_f
if get_last_no.between?(0,25)
## down to 0
num -= get_last_no
else
if get_last_no.between?(26,50)
## up to 50
value = 50 - get_last_no.to_f
num += value
puts 'up to 50'
else
if get_last_no.between?(51, 75)
## down to 50
value = get_last_no.to_f - 50
num -= value
puts 'down to 50'
else
## up to 100
value = 100 - get_last_no.to_f
num += value
puts 'up to 100'
end
end
end
# end
return num
end
def self.daily_sales_list(from,to) def self.daily_sales_list(from,to)
payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date,
SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
@@ -385,13 +420,13 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
.group('mi.id') .group('mi.id')
.order("mi.menu_category_id") .order("mi.menu_category_id")
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
JOIN menu_items mi ON i.product_code = mi.item_code" + JOIN menu_items mi ON i.product_code = mi.item_code" +
" JOIN menu_categories mc ON mc.id = mi.menu_category_id " JOIN menu_categories mc ON mc.id = mi.menu_category_id
JOIN employees ea ON ea.id = sales.cashier_id") JOIN employees ea ON ea.id = sales.cashier_id")
query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status) query = query.where("receipt_date between ? and ? and sale_status=?",from,to,status)
@@ -407,6 +442,11 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
end end
def self.get_by_shiftsales(from,to)
return ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to)
end
def get_cash_amount def get_cash_amount
cash = 0.0 cash = 0.0
self.sale_payments.each do |pay| self.sale_payments.each do |pay|
@@ -446,6 +486,7 @@ end
end end
end end
private private
def generate_custom_id def generate_custom_id

View File

@@ -18,19 +18,25 @@
<div class="active" role="tabpanel"> <div class="active" role="tabpanel">
<div class="tab-pane" role="tabpanel"> <div class="tab-pane" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @i =0 %>
<% @dining_queues.each do |queue| %> <% @dining_queues.each do |queue| %>
<div class="card select-queue <%= !queue.status.nil? ? "assign" : ""%>" data-id="<%= queue.id %>" style="width: 17.5rem;"> <% if queue.status == "Assign"
@bg_color = "assign"
elsif queue.status == "Cancel"
@bg_color = "cancel"
else
@bg_color = "normal"
end
%>
<div class="card select-queue <%= @bg_color %>" data-id="<%= queue.id %>" style="width: 21.5rem;">
<div class="card-block"> <div class="card-block">
<p class="hidden queue-id"><%= queue.id %></p> <p class="hidden queue-id"><%= queue.id %></p>
<p class="hidden queue-status"><%= queue.status %></p> <p class="hidden queue-status"><%= queue.status %></p>
<span class="card-title"> <span class="card-title"><strong> Queue No : <%= queue.queue_no %></strong></span>
<%= @i += 1 %> . Queue No </span> <span class="card-title pull-right"><strong> Seater : <%= queue.seater %></strong></span><br>
<span class="card-title pull-right">Seater : <%= queue.seater %> </span> <span class="card-title"> Name : <%= queue.name %></span><br>
<p style="font-size: 30px ;text-align: center;"> <span class="card-title"> Contact No : <%= queue.contact_no %></span>
<strong><%= queue.queue_no %></strong> <span class="card-title"> Remark : <%= queue.remark %></span>
</p>
</div> </div>
</div> </div>
@@ -43,7 +49,7 @@
</div> </div>
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button> <button type="button" id="assign" class="btn btn-primary btn-lg btn-block" disabled>Assign</button>
<button type="button" id="cancel" class="btn btn-warning btn-lg btn-block" disabled>Cancel</button>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@@ -53,20 +59,61 @@ $(function(){
$('.select-queue').removeClass('selected-item'); $('.select-queue').removeClass('selected-item');
$(this).addClass('selected-item'); $(this).addClass('selected-item');
var status = $(this).find(".queue-status").text(); var status = $(this).find(".queue-status").text();
if(status != "Assign"){ if(status != "Assign" && status != "Cancel"){
$("#assign").removeAttr("disabled"); $("#assign").removeAttr("disabled");
$("#cancel").removeAttr("disabled");
}else{ }else{
$("#assign").attr("disabled","disabled"); $("#assign").attr("disabled","disabled");
$("#cancel").attr("disabled","disabled");
} }
$("#assign").val($(this).find(".queue-id").text()); $("#assign").val($(this).find(".queue-id").text());
$("#cancel").val($(this).find(".queue-id").text());
}); //End Click }); //End Click
}); });
$('#assign').click(function() { $('#assign').click(function() {
var id = $(this).val(); var id = $(this).val();
window.location.href = "dining_queues/"+id + "/assign" window.location.href = "dining_queues/"+id + "/assign"
});
}); $('#cancel').click(function() {
var id = $(this).val();
url = '<%= crm_cancel_queue_path %>';
cancel_queue(id,url);
});
function cancel_queue(id,url) {
$.confirm({
title: 'Confirm!',
content: 'Are You Sure to cancel this Queue!',
buttons: {
cancel: function () {
},
confirm: {
text: 'Confirm',
btnClass: 'btn-green',
keys: ['enter', 'shift'],
action: function(){
$.ajax({
type: "POST",
url: url ,
data: {id:id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
location.reload();
}
}
});
}
}
}
});
}
</script> </script>

View File

@@ -42,6 +42,7 @@
<li><%= link_to "Daily Sale Report", reports_dailysale_index_path, :tabindex =>"-1" %></li> <li><%= link_to "Daily Sale Report", reports_dailysale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Sales Item Report", reports_saleitem_index_path, :tabindex =>"-1" %></li> <li><%= link_to "Sales Item Report", reports_saleitem_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %></li> <li><%= link_to "Receipt Report", reports_receipt_no_index_path, :tabindex =>"-1" %></li>
<!-- <li><%= link_to "Shift Sale Report", reports_shiftsale_index_path, :tabindex =>"-1" %></li> -->
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@@ -19,14 +19,14 @@
<%= render 'layouts/header_orgiami' %> <%= render 'layouts/header_orgiami' %>
<div class="container-fluid"> <div class="container-fluid">
<% flash.each do |type, message| %> <% flash.each do |type, message| %>
<% if !flash["errors"]%> <% if !flash["errors"]%>
<div class="alert fade in"> <div class="alert fade in">
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button> <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
<%=message%> <%=message%>
</div> </div>
<% end %> <% end %>
<% end %> <% end %>
<%= yield %> <%= yield %>
</div> </div>

View File

@@ -303,7 +303,8 @@
<% if @status_order == 'order' && @status_sale != 'sale' %> <% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" class="btn btn-primary btn-block" >Add Order</button> <button type="button" class="btn btn-primary btn-block" >Add Order</button>
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button> <button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button> <button type="button" id="discount" class="btn btn-primary btn-block" disabled>Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" disabled>Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button> <button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button> <button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button> <button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
@@ -313,6 +314,7 @@
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button> <button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button> <button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button> <button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block" >Charges</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button> <button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button> <button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button> <button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
@@ -390,6 +392,25 @@ $(document).ready(function(){
return false; return false;
}); });
// Add Other Charges
$('#other-charges').click(function() {
var sale = $('#sale_id').val();
if (sale!="") {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
}
if(sale_id!=""){
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
}
return false;
});
// Discount for Payment // Discount for Payment
$('#discount').click(function() { $('#discount').click(function() {
var sale = $('#sale_id').val(); var sale = $('#sale_id').val();
@@ -408,7 +429,6 @@ $(document).ready(function(){
return false; return false;
}); });
}); });
// Print for first bill // Print for first bill

View File

@@ -0,0 +1,331 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Order Details -->
<div class="card" >
<!-- <div class="card-header">
<div><strong id="order-title">ORDER DETAILS</strong></div>
</div> -->
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
<p>Receipt No: <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></p>
<!-- <p>Cashier: <span id="cashier"><%=@sale_data.cashier_name rescue ' '%></span></p> -->
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"> <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-text">
<table class="table table-default" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
</tr>
</thead>
<tbody>
<% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %>
<%
sub_total += sale_item.qty*sale_item.unit_price
unless sale_item.price == 0
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left">
<span id="item-account-type" class="hidden"><%=sale_item.account_id%></span>
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.qty*sale_item.unit_price)%></span>
</td>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%=sub_total%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr">(<strong id="order-discount"><%=@sale_data.total_discount rescue 0%></strong>)</td>
</tr>
<tr class="hidden">
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%=@sale_data.total_tax rescue 0%></strong></td>
</tr>
<tr class="hidden">
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%=@sale_data.grand_total rescue 0%></strong></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<!-- Discount Amount -->
<div class="card">
<div class="card-header">
<div><strong id="order-title">Other Charges Control</strong></div>
</div>
<div class="card-block">
<div class="card-title">
<div class="form-horizontal">
<div class="col-md-12">
<div class="form-group">
<input type="text" id="other-charges-amount" name="other-charges-amount" class="form-control" placeholder="Amount" />
</div>
<div class="form-group">
<textarea id="reasons" name="reasons" rows="2" class="form-control" placeholder="Reasons"></textarea>
</div>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-9">
<div class="row bottom">
<div class="col-md-3">
<div class="fluid cashier_number" data-value="3000" data-type="add">3000</div>
</div>
<div class="col-md-9">
<div class="col-md-4 cashier_number" data-value="1" data-type="num">1</div>
<div class="col-md-4 left cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-4 left cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-3">
<div class="fluid cashier_number" data-value="5000" data-type="add">5000</div>
</div>
<div class="col-md-9">
<div class="col-md-4 cashier_number" data-value="4" data-type="num">4</div>
<div class="col-md-4 left cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-4 left cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-3">
<div class="fluid cashier_number" data-value="10000" data-type="add">10000</div>
</div>
<div class="col-md-9">
<div class="col-md-4 cashier_number" data-value="7" data-type="num">7</div>
<div class="col-md-4 left cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-4 left cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-3">
<div class="fluid cashier_number" data-value="15000" data-type="add">15000</div>
</div>
<div class="col-md-9">
<div class="col-md-4 cashier_number" data-value="0" data-type="num">0</div>
<div class="col-md-4 left cashier_number" data-value="." data-type="num">.</div>
<div class="col-md-4 left cashier_number" data-value="00" data-type="num">00</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="fluid cashier_number" data-value="20000" data-type="add">20000</div>
</div>
<div class="col-md-9">
<div class="col-md-4 cashier_number"></div>
<div class="col-md-4 left cashier_number red" data-type="del">DEL</div>
<div class="col-md-4 left cashier_number green" data-type="clr">CLR</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<button id="add_charges" class="btn btn-info fluid action-btn">Add</button>
<button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Action Panel -->
<div>
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami';"><i class="fa fa-arrow-left"></i> Back </button>
<button id="charge_other" class="btn btn-danger btn-block action-btn">Enter</button>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(".cashier_number").on('click', function(event){
if(event.handled !== true) {
var original_value=0;
original_value = $('#other-charges-amount').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#other-charges-amount').val(input_value);
}
else{
$('#other-charges-amount').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#other-charges-amount').val(amount);
break;
case 'del' :
var discount_text=$('#other-charges-amount').val();
$('#other-charges-amount').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#other-charges-amount').val("0.0");
break;
}
event.handled = true;
} else {
return false;
}
});
// Select discount-item
$('#order-items-table tbody').on('click', '.other-item-row',function(){
if($(this).hasClass('selected-item') == true){
$(this).removeClass('selected-item');
}
else {
$(this).addClass('selected-item');
}
});
// Remove selected discount items
$("#remove-item").on('click', function(e){
e.preventDefault();
$('.other-item-row.selected-item').each(function(i){
var sub_total = $('#order-sub-total').text();
var charge_amount = $(this).children('td').find("#item-total-price").text();
// Update sub total
$('#order-sub-total').text(parseFloat(sub_total) - parseFloat(charge_amount));
$(this).remove();
});
});
// Calculate Net Discount for Payment
$("#add_charges").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sub_total = $('#order-sub-total').text();
var charge_amount = $("#other-charges-amount").val();
var reasons = $("#reasons").val();
// Update sub total
$('#order-sub-total').text(parseFloat(sub_total) + parseFloat(charge_amount));
var item_row = item_row_template(sale_id, charge_amount, reasons);
$("#order-items-table tbody").append(item_row);
});
// Calculate Other Charges for Payment
$("#charge_other").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var sub_total = $('#order-sub-total').text();
var other_charges_items = JSON.stringify(get_other_item_rows());
var ajax_url = "/origami/" + sale_id + "/other_charges";
var params = { 'sale_id': sale_id, 'sub_total': sub_total, 'other_charges_items': other_charges_items };
$.ajax({
type: "POST",
url: ajax_url,
data: params,
success:function(result){
alert("Success!");
if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
}
});
});
});
/* Remove Selection */
function selection_remove(){
$(".item-row").removeClass("selected-item");
$(".discount_item_row").removeClass("selected-item");
$(".accounts-type").removeClass("selected-account");
}
/* Get discount Item rows */
function get_other_item_rows(){
var sale_items = [];
$('.other-item-row').each(function(i){
var sale_item = {};
sale_item.id = $(this).attr('id');
sale_item.name = $(this).find('#item-name-price').text();
sale_item.price = $(this).find('#item-total-price').text();
sale_items.push(sale_item);
});
return sale_items;
}
function item_row_template(sale_id, charge_amount, reasons){
var item_row = "<tr class='other-item-row' id='SLI-000000000000'>" +
"<td style='width: 60%; text-align: left;'>" +
"<span id='item_account_type' class='hidden'>" +
0 +
"</span>" +
"<span id='item-name-price'>" +
reasons +
"</span>" +
"</td>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-qty'>1</span>" +
"</td>" +
"<td style='width: 20%; text-align: right;'>" +
"<span id='item-total-price'>" +
charge_amount +
"</span>" +
"</td>" +
"</tr>";
return item_row;
}
</script>

View File

@@ -0,0 +1,127 @@
<div class="row">
<div class="col-md-12">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="form-group col-md-2">
<label>Select Period</label>
<select name="period" id="sel_period" class="form-control">
<option value="0">Today</option>
<option value="1">Yesterday</option>
<option value="2">This week</option>
<option value="3">Last week</option>
<option value="4">Last 7 days</option>
<option value="5">This month</option>
<option value="6">Last month</option>
<option value="7">Last 30 days</option>
<option value="8">This year</option>
<option value="9">Last year</option>
</select>
</div>
<!-- <input type="hidden" name="report_type" value="daily_sale" id="sel_sale_type"> -->
<!-- <div class="form-group col-md-2">
<label>Select Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<option value="0">All Sale Type</option>
<option value="1">Revenue Only</option>
<option value="2">Discount Only</option>
<option value="3">Void Only</option>
<option value="4">Taxes Only</option>
<option value="5">Other Amount Only</option>
</select>
</div> -->
<div class="form-group col-md-3">
<!-- <label class="">Select Shift Period</label> -->
<label class="">From</label>
<input data-behaviour='datepicker' class="form-control" name="from" id="from" type="text" placeholder="From date">
</div>
<div class="form-group col-md-3">
<label class="">To</label>
<input data-behaviour='datepicker' class="form-control" name="to" id="to" type="text" placeholder="To date">
</div>
<div class="form-group col-md-2 margin-top-20">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<script type="text/javascript">
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
else if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
}
else{
$('#waiter').hide();
$('#cashier').show();
$("#item").val('sale');
}
});
//Reset the form to pervious values
$("#branch").val(<%=params[:branch]%>);
$("#waiter").val("<%=params[:waiter]%>");
$("#cashier").val(<%=params[:cashier]%>);
$("#product").val(<%=params[:product]%>);
$("#singer").val(<%=params[:singer]%>);
$("#item").val('<%=params[:item]%>');
$("#guest_role").val('<%=params[:guest_role]%>');
$("#from").val("<%=params[:from]%>");
$("#to").val("<%=params[:to]%>");
$("#sel_period").val(<%=params[:period]%>);
$("#sel_sale_type").val(<%=params[:sale_type]%>);
<% if params[:period_type] == 1 || params[:period_type] == "1" %>
$("#rd_period_type_1").attr("checked","checked");
<% else %>
$("#rd_period_type_0").attr("checked","checked");
<% end %>
$(".btn-group button").removeClass("active");
<% report_type = params[:report_type].blank? ? "0" : params[:report_type] %>
$("#btn_report_type_<%= report_type %>").addClass("active");
$('#item').change(function(){
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}
}
else{
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
});
</script>

View File

@@ -0,0 +1,160 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Shift Sale Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_shiftsale_index_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_shiftsale_index_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<!-- <div class="span11">
<div id="report_container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</div> -->
<div class="card row">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<% if params[:from]%>
<tr>
<th colspan="7">From Date : <%= params[:from] rescue '-'%> ,To Date : <%= params[:to] rescue '-'%></th>
</tr>
<% end %>
<tr>
<th>Cashier Station</th>
<th>Shift Name</th>
<th>Void Amount</th>
<th>Cash Payment</th>
<th>Credit Charges</th>
<th>Credit Payment</th>
<th>FOC Payment</th>
<th>Card Payment</th>
<th>Grand Total +
<br/>Rounding Adj</th>
<th>Rounding Adj</th>
<th>Grand Total</th>
</tr>
</thead>
<tbody>
<% void = 0%>
<% cash = 0%>
<% credit = 0%>
<% accept_credit = 0%>
<% foc = 0%>
<% card = 0%>
<% total = 0%>
<% rounding_adj = 0%>
<% g_total = 0 %>
<% @sale_data.each do |result| %>
<tr>
<td>
<%= result[:cashier_station_name] rescue '-'%>
</td>
<td><%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> -
<%= result[:shift_closed_at].strftime("%e %b %I:%M%p") rescue '-' %>
</td>
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result[:void_amount].to_f.to_d rescue '-'%>)</td> -->
<td><%= sprintf "%.2f",result[:cash_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:credit_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:accept_credit_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:foc_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:card_amount].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:grand_total].to_f.to_d rescue '-'%></td>
<td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td>
<% grand_total = result[:grand_total].to_f - result[:rounding_adj].to_f %>
<td><%= sprintf "%.2f",grand_total.to_f.to_d rescue '-'%></td>
</tr>
<% void += result[:void_amount].to_f %>
<% cash += result[:cash_amount].to_f %>
<% credit += result[:credit_amount].to_f %>
<% accept_credit += result[:accept_credit_amount].to_f %>
<% foc += result[:foc_amount].to_f %>
<% card += result[:card_amount].to_f %>
<% total += result[:grand_total].to_f %>
<% rounding_adj += result[:rounding_adj].to_f %>
<% g_total += grand_total.to_f %>
<% end %>
<tr style="border-top: 3px solid grey;">
<td colspan="2"></td>
<td style='color:red;'><b>(<%= sprintf("%.2f",void) rescue '-'%>)</b></td>
<td><b><%= sprintf("%.2f",cash) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",credit) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",accept_credit) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",foc) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",card) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",total) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td>
<td><b><%= sprintf("%.2f",g_total) rescue '-'%></b></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var to = $('#to').val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
// console.log(check_arr.length)
if(check_arr.length == 1){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
</script>

View File

@@ -1,26 +1,4 @@
<div class="page-header"> <div class="card row">
<ul class="breadcrumb">
<li><a href="<%= dashboard_path %>">Home</a></li>
<li>Daily Sale Report</li>
</ul>
</div>
<div class="container">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => false, :report_path =>reports_daily_sales_path} %>
<hr />
</div>
<div class="container">
<div class="row">
<div class="col-md-12 text-right">
<a href="javascript:export_to('<%=reports_daily_sales_path%>.xls')" class = "btn btn-default">Export to Excel</a>
</div>
</div>
</div>
<div class="container margin-top-20">
<div class="card row">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
@@ -136,55 +114,3 @@
</table> </table>
</div> </div>
</div> </div>
</div>
<script>
$(function(){
var check_arr = [];
var search = '<%= params[:period_type] %>';
if(search){
if(parseInt(search) == 0){
search_by_period();
}
else{
search_by_date();
}
}else{
search_by_period();
}
$('#sel_period').change(function(){
search_by_period();
});
function search_by_period(){
var period = $('#sel_period').val();
var period_type = 0;
var from = "";
var to = "";
}
$('#from').change(function(){
search_by_date();
});
$('#to').change(function(){
search_by_date();
});
function search_by_date(){
var from = $('#from').val();
var to = $('#to').val();
var period = 0;
var period_type = 1;
if(to != '' && from != ''){
shift_name = from + ',' + to;
check_arr.push(to);
// console.log(check_arr.length)
if(check_arr.length == 1){
}
if(check_arr.length == 3){
check_arr = [];
}
}
}
});
</script>

View File

@@ -93,6 +93,11 @@ Rails.application.routes.draw do
# post '/:booking_id' => 'home#item_show' # post '/:booking_id' => 'home#item_show'
# Other Charges
get "/:sale_id/other_charges" => "other_charges#index"
post "/:sale_id/other_charges" => "other_charges#create"
# Discount
get "/:id/discount" => "discounts#index" get "/:id/discount" => "discounts#index"
post "/:id/discount" => "discounts#create" post "/:id/discount" => "discounts#create"
get "/:id/remove_all_discount" => "discounts#remove_all_discount" get "/:id/remove_all_discount" => "discounts#remove_all_discount"
@@ -168,6 +173,7 @@ Rails.application.routes.draw do
get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign" get "/dining_queues/:id/assign" =>"dining_queues#assign", :as => "assign"
post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table" post "/dining_queues/assign_table" =>"dining_queues#assign_table", :as => "assign_table"
post "/dining_queues/cancel_queue" =>"dining_queues#cancel_queue", :as => "cancel_queue"
end end
@@ -263,6 +269,7 @@ Rails.application.routes.draw do
resources :receipt_no, :only => [:index, :show] resources :receipt_no, :only => [:index, :show]
resources :dailysale, :only => [:index, :show] resources :dailysale, :only => [:index, :show]
resources :saleitem, :only => [:index, :show] resources :saleitem, :only => [:index, :show]
resources :shiftsale, :only => [:index, :show]
# resources :sales, :only => [:index, :show] # resources :sales, :only => [:index, :show]
# resources :orders, :only => [:index, :show] # resources :orders, :only => [:index, :show]
# resources :customers, :only => [:index, :show] # resources :customers, :only => [:index, :show]

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Reports::ShiftsaleController, type: :controller do
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Reports::ShiftsaleHelper. For example:
#
# describe Reports::ShiftsaleHelper 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 Reports::ShiftsaleHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end