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

This commit is contained in:
phyusin
2018-03-30 15:25:15 +06:30
17 changed files with 325 additions and 40 deletions

View File

@@ -95,7 +95,7 @@ class Origami::HomeController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -113,8 +113,6 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
#end rounding adjustment
puts "sale"
puts saleObj.to_json
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, current_user.name, cash, "cash")

View File

@@ -79,8 +79,7 @@ class Origami::RoomsController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void'
puts "enter"
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'

View File

@@ -48,7 +48,7 @@ class Origami::VoidController < BaseOrigamiController
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else

View File

@@ -1,29 +1,28 @@
class Origami::WasteSpoileController < BaseOrigamiController
def index
end
def waste_and_spoile
def waste_and_spoilage
sale_id = params[:sale_id]
remark = params[:remark]
order_source = params[:type] #tax profile source
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
existing_tax.delete
end
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
sale.payment_status = remark
sale.sale_status = remark
sale.save
# sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source)
# add to sale item with foc
sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")
sale_items.each do|item|
SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
sale.sale_items.each do|item|
# SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price)
item.status = remark
item.remark = remark
item.save
end
if sale.bookings[0].dining_facility_id.to_i > 0
@@ -33,7 +32,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
table.bookings.each do |booking|
if booking.booking_status != 'moved'
if booking.sale_id
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste'
table_avaliable = false
table_count += 1
else
@@ -45,7 +44,6 @@ class Origami::WasteSpoileController < BaseOrigamiController
end
end
end
if table_avaliable && table_count == 0
table.status = 'available'
table.save
@@ -104,7 +102,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,

View File

@@ -0,0 +1,19 @@
class Reports::WasteAndSpoilageController < BaseReportController
authorize_resource :class => false
def index
from, to = get_date_range_from_params
@sale_type = params[:sale_type]
@sale_data = Sale.get_wastes_and_spoilages(from,to,@sale_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
respond_to do |format|
format.html
format.xls
end
end
end

View File

@@ -1109,6 +1109,16 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
return all_total,sale_type
end
def self.get_wastes_and_spoilages(from,to,status)
if status == "spoile"
type = "and sales.sale_status = 'spoile'"
else
type = "and sales.sale_status = 'waste'"
end
query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to)
.group("sales.receipt_no")
end
# def self.get_separate_tax(from,to,payment_method=nil)
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")

View File

@@ -420,7 +420,7 @@ class SalePayment < ApplicationRecord
bookings.each do |tablebooking|
if tablebooking.booking_status != 'moved'
if tablebooking.sale_id
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste'
status = false
sale_count += 1
else

View File

@@ -144,6 +144,9 @@
<li>
<a href="<%= reports_void_sale_index_path %>">Void Sales</a>
</li>
<li>
<a href="<%= reports_waste_and_spoilage_index_path %>">Wastes & Spoilages</a>
</li>
<li>
<a href="<%= reports_payment_method_index_path %>">Payment Method</a>
</li>

View File

@@ -26,7 +26,7 @@
</div>
<% end %>
<button id="member_acc_no" class="btn btn-success btn-sm"><span class="fa fa-credit-card"></span> Member Card</button> -->
<% path ="/origami/#{@sale_id}/customers" %>
<% path ="/origami/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %>
<%= form_tag path, :id => "filter_form", :method => :get do %>
<div class="row clearfix">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">

View File

@@ -598,8 +598,6 @@
</div>
</div>
<div class="modal-footer ">
</div>
</div>
</div>
@@ -1059,8 +1057,6 @@
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var url = "/origami/sale/" + sale_id + '/cashier/waste_and_spoilage';
console.log(url)
$.ajax({
type: 'POST',
url: url,
@@ -1068,10 +1064,10 @@ console.log(url)
success: function (result) {
console.log(result)
// For Server Print - from jade
// if ($("#server_mode").val() == "cloud") {
// code2lab.printFile(result.filepath.substr(6), result.printer_url);
// }
// window.location.href = '/origami/';
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/origami/';
}
});
}

View File

@@ -450,10 +450,11 @@
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<% if current_login_employee.role != "waiter" %>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn bg-blue btn-block" >Charges</button>
@@ -512,6 +513,32 @@
</div>
</div>
</div>
<div class="modal fade" id="waste_spoileModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="waste_spoileModalLabel">Are you sure Waste or Spoile ?</h4>
</div>
<div class="modal-body">
<div class="row p-r-20">
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')"><strong>Waste</strong></button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-red waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')"><strong>Spoile</strong></button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-lg bg-blue waves-effect" data-dismiss="modal"><strong>CLOSE</strong></button>
</div>
</div>
</div>
<div class="modal-footer ">
</div>
</div>
</div>
</div>
<script>
var cashier_type = "cashier";
$(document).ready(function(){
@@ -979,4 +1006,34 @@ $('#add_invoice').on('click',function(){
});
return attribute_arr;
}
function waste_and_spoilage(remark) {
swal({
title: "Alert",
text: "Are you sure want to " + remark +" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, " +remark+ " it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var url = "/origami/sale/" + sale_id + '/cashier/waste_and_spoilage';
$.ajax({
type: 'POST',
url: url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function (result) {
console.log(result)
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
window.location.href = '/origami/';
}
});
}
});
}
</script>

View File

@@ -0,0 +1,73 @@
<div class="p-l-15">
<%= form_tag report_path, :method => :get, :id=>"frm_report", :class => "form" do %>
<% if period_type != false %>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14">Type</label>
<select name="sale_type" id="sel_sale_type" class="form-control">
<%if @sale_type=="waste" %>
<option value="waste" selected>Waste</option>
<% else %>
<option value="waste">Waste</option>
<% end %>
<%if @sale_type=="spoile" %>
<option value="spoile" selected>Spoilage</option>
<% else %>
<option value="spoile">Spoilage</option>
<% end %>
</select>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_period") %></label>
<select name="period" id="sel_period" class="form-control">
<option value=""><%= t("views.right_panel.detail.select_period") %></option>
<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>
<div class="col-lg-3 col-md-3 col-sm-3">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="to" id="to" type="text" placeholder="To date" style="height: 32px;">
</div>
<div class="col-lg-1 col-md-1 col-sm-1 margin-top-20">
<br>
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">
<% if params[:shift_name].to_i > 0%>
shift_id = '<%= params[:shift_name] %>'
local_date = '<%= @shift_from %> - <%= @shift_to %> '
var shift = $('#shift_name');
str = '<option value="'+ shift_id +'" '+ 'selected = "selected"' +'>' + local_date + '</option>';
shift.append(str);
<% end %>
$("#from").val("<%=params[:from] rescue '-'%>");
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
</script>

View File

@@ -0,0 +1,75 @@
<div class="container-fluid">
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.waste_spoilage_report") %></li>
<span class="float-right">
<%= link_to 'Back', dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-md-12">
<%= render :partial=>'shift_sale_report_filter',
:locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %>
<hr />
<div class="text-right">
<a href="javascript:export_to('<%=reports_waste_and_spoilage_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<h5 class="p-l-10 p-t-10">Report For <%= @sale_type? @sale_type : 'Waste' %></h5>
<% @sale_data.each do |sale| %>
<% waste_and_spoil_item_count = 0%>
<thead>
<tr>
<td >
<strong>Receipt No :<%= sale.receipt_no %></strong>
</td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %></strong></td>
</tr>
</thead>
<tbody>
<tr>
<td ><strong>Item Name</strong></td>
<td ><strong>Item Code</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
<% sale.sale_items.each do |item| %>
<% if !item.item_instance_code.nil?%>
<% waste_and_spoil_item_count += item.qty.to_i%>
<tr>
<td><%= item.product_name %></td>
<td><%= item.product_code %></td>
<td><%= item.qty %></td>
<td><%= item.price %></td>
<td><%= item.price %></td>
</tr>
<% end %>
<% end %>
<tr>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td><span class="underline" style="text-align:right">
<strong><%= waste_and_spoil_item_count %></strong>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= sale.grand_total %></strong>
</span>
</td>
</tr>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,58 @@
<div class="row">
<div class="col-md-12">
<div class="margin-top-20">
<div class="card">
<table class="table table-striped" border="0">
<h5 class="p-l-10 p-t-10">Report For <%= @sale_type? @sale_type : 'Waste' %></h5>
<% @sale_data.each do |sale| %>
<% waste_and_spoil_item_count = 0%>
<thead>
<tr>
<td >
<strong>Receipt No :<%= sale.receipt_no %></strong>
</td>
<td></td>
<td colspan="3" style="text-align:right"><strong>Date : <%= sale.created_at.utc.getlocal.strftime("%e,%b %Y %I:%M %p") %></strong></td>
</tr>
</thead>
<tbody>
<tr>
<td ><strong>Item Name</strong></td>
<td ><strong>Item Code</strong></td>
<td><strong>Qty</strong></td>
<td><strong>Price</strong></td>
<td><strong>Total Price</strong></td>
</tr>
<% sale.sale_items.each do |item| %>
<% if !item.item_instance_code.nil?%>
<% waste_and_spoil_item_count += item.qty.to_i%>
<tr>
<td><%= item.product_name %></td>
<td><%= item.product_code %></td>
<td><%= item.qty %></td>
<td><%= item.price %></td>
<td><%= item.price %></td>
</tr>
<% end %>
<% end %>
<tr>
<td colspan="2" style="text-align:right"> <strong>Total Qty: </strong></td>
<td><span class="underline" style="text-align:right">
<strong><%= waste_and_spoil_item_count %></strong>
</span></td>
<td style="text-align:right"> <strong>Grand Total: </strong></td>
<td >
<span class="underline" style="text-align:right">
<strong><%= sale.grand_total %></strong>
</span>
</td>
</tr>
</tbody>
<% end %>
</table>
</div>
</div>
</div>
</div>

View File

@@ -78,15 +78,13 @@ scope "(:locale)", locale: /en|mm/ do
post "check_in" => "check_in_process#check_in_process"
post "request_time" => "check_in_process#request_time"
post "call_waiter" => "call_waiters#index"
#---------Waste and Spoile --------------#
post 'sale/:sale_id/:type/waste_and_spoilage' => 'waste_spoile#waste_and_spoilage'
end
end
#--------- Cashier ------------#
namespace :origami do
namespace :origami do
get "dashboard" => "dashboard#index"
@@ -199,7 +197,7 @@ scope "(:locale)", locale: /en|mm/ do
#---------Void --------------#
post 'sale/:sale_id/:type/void' => 'void#overall_void'
post 'sale/:sale_id/:type/waste_and_spoilage' => "waste_spoile#waste_and_spoilage"
#---------Multiple Invoices --------------#
get 'table/:table_id/table_invoices' => "table_invoices#index", :as => "table_invoice_index"
@@ -408,6 +406,7 @@ scope "(:locale)", locale: /en|mm/ do
resources :shiftsale, :only => [:index, :show]
resources :credit_payment, :only => [:index, :show]
resources :void_sale, :only => [:index, :show]
resources :waste_and_spoilage, :only => [:index, :show]
resources :commission, :only => [:index, :show]
resources :stock_check, :only => [:index, :show]
resources :payment_method

View File

@@ -2,7 +2,7 @@ class CreateTaxProfiles < ActiveRecord::Migration[5.1]
def change
create_table :tax_profiles do |t|
t.string :name, :null => false
t.string :group_type, :null => false
t.string :group_type
t.decimal :rate, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.boolean :inclusive, :null => false, :default => false
t.integer :order_by, :null => false, :default => 1