Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -9,7 +9,6 @@
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
.DS_Store
|
||||
*.rdb
|
||||
*.rbc
|
||||
*.sassc
|
||||
.sass-cache
|
||||
@@ -46,3 +45,6 @@ config/deploy/config/*
|
||||
# Gem files
|
||||
#Gemfile
|
||||
#Gemfile.lock
|
||||
|
||||
# For Redis Server log file
|
||||
dump.rdb
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
$(document).ready(function(){
|
||||
// auto refresh every 10 seconds
|
||||
setTimeout(function(){
|
||||
window.location.reload(1);
|
||||
}, 10000);
|
||||
// setTimeout(function(){
|
||||
// window.location.reload(1);
|
||||
// }, 10000);
|
||||
|
||||
$('.queue_station').on('click',function(){
|
||||
var orderZone=$(this).children().children().children('.order-zone').text();
|
||||
|
||||
@@ -157,10 +157,11 @@ $(document).ready(function(){
|
||||
|
||||
if(sale_item_id != null){
|
||||
ajax_url = "/origami/" + sale_item_id + "/discount";
|
||||
sub_total = $("#"+sale_item_id).children().find("#item-total-price").text();
|
||||
}
|
||||
|
||||
// For Percentage Discount
|
||||
if(discount_type == 1){
|
||||
if(discount_type == 1){
|
||||
discount_amount=(sub_total*discount_value)/100;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
discount_value = params[:discount_value]
|
||||
discount_amount = params[:discount_amount]
|
||||
grand_total = params[:grand_total]
|
||||
product_name = "Overall Discount"
|
||||
|
||||
if discount_type == 0
|
||||
remark="Discount " + discount_amount + " as net"
|
||||
@@ -32,13 +33,14 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
#save sale item for discount
|
||||
if sale_item_id != nil
|
||||
origin_sale_item = SaleItem.find(sale_item_id)
|
||||
product_name = origin_sale_item.product_name + "-Disocunt"
|
||||
end
|
||||
sale_item = SaleItem.new
|
||||
|
||||
#pull
|
||||
sale_item.sale_id = sale_id
|
||||
sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id
|
||||
sale_item.product_name = "Overall Discount"
|
||||
sale_item.product_name = product_name
|
||||
sale_item.remark = remark
|
||||
|
||||
sale_item.qty = 1
|
||||
|
||||
@@ -4,7 +4,8 @@ class Settings::OrderQueueStationsController < ApplicationController
|
||||
# GET /settings/order_queue_stations
|
||||
# GET /settings/order_queue_stations.json
|
||||
def index
|
||||
@settings_order_queue_stations = OrderQueueStation.all.active
|
||||
@settings_order_queue_stations = OrderQueueStation.all
|
||||
@settings_order_queue_stations = Kaminari.paginate_array(@settings_order_queue_stations).page(params[:page]).per(50)
|
||||
end
|
||||
|
||||
# GET /settings/order_queue_stations/1
|
||||
|
||||
@@ -9,23 +9,30 @@ class Transactions::SalesController < ApplicationController
|
||||
receipt_no = params[:receipt_no]
|
||||
today = Date.today
|
||||
|
||||
if receipt_no.nil?
|
||||
sales = Sale.order("sale_id desc")
|
||||
if receipt_no.nil? && search_date.nil?
|
||||
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
else
|
||||
order = Sale.search(receipt_no)
|
||||
if order.count > 0
|
||||
sales = order
|
||||
if !search_date.blank? && receipt_no.blank?
|
||||
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||
elsif !search_date.blank? && !receipt_no.blank?
|
||||
sale = Sale.where("receipt_no LIKE ? or DATE_FORMAT(receipt_date,'%d-%m-%Y') = ? and NOT sale_status = 'void' ", "%#{receipt_no}%", search_date).order("sale_id desc").limit(500).page(params[:page])
|
||||
else
|
||||
sale = Sale.where("receipt_no LIKE ? and NOT sale_status = 'void' ", receipt_no).order("sale_id desc").limit(500).page(params[:page])
|
||||
end
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
else
|
||||
sales = Sale.order("sale_id desc")
|
||||
|
||||
end
|
||||
end
|
||||
@sales = Kaminari.paginate_array(sales).page(params[:page]).per(50)
|
||||
@sales = 0
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @sales }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# GET /transactions/sales/1
|
||||
@@ -108,11 +115,10 @@ class Transactions::SalesController < ApplicationController
|
||||
sale_id = params[:sale_id]
|
||||
reason = params[:reason]
|
||||
sale = Sale.find(sale_id)
|
||||
sale.sales_status = 'void'
|
||||
sale.remarks = reason
|
||||
sale.void_by = current_user.id
|
||||
sale.sale_status = 'void'
|
||||
sale.requested_by = current_login_employee.id
|
||||
if sale.save
|
||||
sale =SaleAudit.record_audit_void(sale_id, current_user.id, current_user.id, reason)
|
||||
@sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' }
|
||||
|
||||
@@ -35,23 +35,29 @@ class OrderItem < ApplicationRecord
|
||||
|
||||
#logger.debug orderitem.to_yml
|
||||
orderitem.save!
|
||||
|
||||
|
||||
end
|
||||
#Origami : Cashier : to show order items details
|
||||
|
||||
#Origami : Cashier : to show order items details
|
||||
def self.get_order_items_details(booking_id)
|
||||
booking_orders = BookingOrder.where("booking_id=?",booking_id)
|
||||
if booking_orders
|
||||
booking_orders.each do |book_order|
|
||||
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
# booking_orders = BookingOrder.where("booking_id=?",booking.booking_id)
|
||||
# if booking_orders
|
||||
# booking_orders.each do |book_order|
|
||||
# order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
# .joins("left join orders on orders.order_id = order_items.order_id")
|
||||
# .where("order_items.order_id=?",book_order.order)
|
||||
# return order_details
|
||||
# end
|
||||
# else
|
||||
# return false
|
||||
# end
|
||||
|
||||
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
.joins("left join orders on orders.order_id = order_items.order_id")
|
||||
.where("order_items.order_id=?",book_order.order)
|
||||
return order_details
|
||||
end
|
||||
else
|
||||
return false
|
||||
end
|
||||
.joins("left join booking_orders on booking_orders.order_id = order_items.order_id")
|
||||
.joins("left join bookings on bookings.booking_id = booking_orders.booking_id")
|
||||
.where("bookings.booking_id=?",booking_id)
|
||||
|
||||
return order_details
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -186,6 +186,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable)
|
||||
|
||||
#if tax is not apply create new record
|
||||
|
||||
@@ -6,7 +6,7 @@ class SaleAudit < ApplicationRecord
|
||||
|
||||
belongs_to :sale
|
||||
|
||||
def record_audit_void(sale_id, void_by, approved_by, reason)
|
||||
def self.record_audit_void(sale_id, void_by, approved_by, reason)
|
||||
#sale_audit
|
||||
sale_audit = SaleAudit.new()
|
||||
sale_audit.sale_id = sale_id
|
||||
|
||||
@@ -165,16 +165,32 @@ class ReceiptBillPdf < Prawn::Document
|
||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
if sale_data.sale_taxes.length > 1
|
||||
sale_data.sale_taxes.each do |st|
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "#{ st.tax_name }", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( " +"#{ st.tax_payable_amount }" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
end
|
||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
end
|
||||
|
||||
# move_down 5
|
||||
# y_position = cursor
|
||||
|
||||
# bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||
# text "Total Tax", :size => self.item_font_size,:align => :left
|
||||
# end
|
||||
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
|
||||
# end
|
||||
|
||||
move_down 5
|
||||
y_position = cursor
|
||||
move_down 5
|
||||
|
||||
@@ -42,5 +42,5 @@
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate @settings_order_queue_stations %>
|
||||
</div>
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
<td colspan="8">
|
||||
<%= form_tag transactions_sales_path, :method => :get do %>
|
||||
<div class="input-append form-group pull-right col-md-6">
|
||||
<!-- <input class="datepicker col-md-3 form-control" name="date" id="date" type="text" placeholder="Receipt date" style="margin-right: 10px"> -->
|
||||
<input class="datepicker col-md-3 form-control" name="date" id="date" type="text" placeholder="Receipt date" style="margin-right: 10px">
|
||||
|
||||
<input type="text" name="receipt_no" class="col-md-6 form-control" placeholder="Receipt No" style="margin-right: 10px">
|
||||
<input type="text" name="receipt_no" class="col-md-5 form-control" placeholder="Receipt No" style="margin-right: 10px">
|
||||
<button type="submit" class="btn btn-primary btn">Search</button>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -41,23 +41,28 @@
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @sales.each do |sale| %>
|
||||
|
||||
<tr>
|
||||
<td><%= sale.sale_id %></td>
|
||||
<td><%= sale.receipt_no %></td>
|
||||
<td><%= sale.grand_total rescue '-' %></td>
|
||||
<td><%= sale.total_tax %></td>
|
||||
<td><%= sale.cashier_name rescue '-' %></td>
|
||||
<td> <%= sale.sale_status %> </td>
|
||||
<td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
|
||||
<td><%= link_to 'Show', transactions_sale_path(sale) %></td>
|
||||
</tr>
|
||||
<% if @sales != 0 %>
|
||||
<% @sales.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= sale.sale_id %></td>
|
||||
<td><%= sale.receipt_no %></td>
|
||||
<td><%= sale.grand_total rescue '-' %></td>
|
||||
<td><%= sale.total_tax %></td>
|
||||
<td><%= sale.cashier_name rescue '-' %></td>
|
||||
<td> <%= sale.sale_status %> </td>
|
||||
<td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
|
||||
<td><%= link_to 'Show', transactions_sale_path(sale) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<tr><td colspan="8"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<%= paginate @sales %>
|
||||
<% if @sales != 0 %>
|
||||
<%= paginate @sales %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -171,11 +171,11 @@
|
||||
</a>
|
||||
|
||||
<!-- Temporary No Needs -->
|
||||
<!-- <a href="<%= transactions_void_path(@sale)%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
||||
<a href="<%= transactions_void_path(@sale)%>" style="margin-top: 10px " class="btn btn-danger pull-right btn-lg">
|
||||
|
||||
<i class="fa fa-trash fa-lg"></i> Void Sale
|
||||
</a>
|
||||
<a href="<%= %>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg">
|
||||
<!-- <a href="<%= %>" style="margin-top: 10px " class="btn btn-success pull-right btn-lg">
|
||||
<i class="fa fa-invoice fa-lg"></i> Complete Sale
|
||||
</a> -->
|
||||
</div>
|
||||
|
||||
@@ -61,18 +61,16 @@
|
||||
var reason = $('input[type="radio"]:checked').val();
|
||||
console.log(reason)
|
||||
|
||||
var url = '<% transactions_manual_void_sale_path()%>';
|
||||
var url = 'manual_void_sale';alert(url)
|
||||
var sale_id = $(this).find(".customer-id").text();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'sales/manual_void_sale',
|
||||
url: 'manual_void_sale',
|
||||
data: {reason: reason, sale_id: sale_id},
|
||||
success: function(data){
|
||||
window.location.href = "transactions/sales"
|
||||
// window.location.href = "transactions/sales"
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -199,7 +199,7 @@ Rails.application.routes.draw do
|
||||
resources :sales
|
||||
resources :orders
|
||||
get "/sales/:sale_id/void" =>"sales#void", :as => "void"
|
||||
post "sales/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale"
|
||||
post "sales/:sale_id/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale"
|
||||
end
|
||||
|
||||
#--------- Reports Controller Sections ------------#
|
||||
|
||||
@@ -132,13 +132,13 @@ menu_item_attribute_size_large = MenuItemAttribute.create({attribute_type:"size"
|
||||
|
||||
|
||||
#Default Order Queue stations
|
||||
order_queue_station1 = OrderQueueStation.create({station_name: "Queue Station 1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
|
||||
order_queue_station2 = OrderQueueStation.create({station_name: "Queue Station 2", is_active: true,printer_name: "drink_printer", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
|
||||
zone_order_queue_station = OrderQueueStation.create({station_name: "Zone 1 Queue Station 2", is_active: true, printer_name: "print_station", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
|
||||
# order_queue_station1 = OrderQueueStation.create({station_name: "Queue Station 1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
|
||||
# order_queue_station2 = OrderQueueStation.create({station_name: "Queue Station 2", is_active: true,printer_name: "drink_printer", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
|
||||
# zone_order_queue_station = OrderQueueStation.create({station_name: "Zone 1 Queue Station 2", is_active: true, printer_name: "print_station", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
|
||||
|
||||
|
||||
#Default Order Queue Process By Zone
|
||||
#zone_queue_station = OrderQueueProcessByZone.create({order_queue_station: zone_order_queue_station, zone: zone2})
|
||||
# zone_queue_station = OrderQueueProcessByZone.create({order_queue_station: zone_order_queue_station, zone: zone2})
|
||||
|
||||
|
||||
#Create Adminstrator employee
|
||||
|
||||
@@ -615,5 +615,15 @@ zone3 = Zone.create({id:3, name: "H3", is_active:true, created_by: "SYSTEM DEFAU
|
||||
table = Table.create({name:"76", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"})
|
||||
table = Table.create({name:"77", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"})
|
||||
table = Table.create({name:"78", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"})
|
||||
|
||||
#Default Order Queue stations
|
||||
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
|
||||
order_queue_station2 = OrderQueueStation.create({station_name: "K2", is_active: true,printer_name: "drink_printer", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
|
||||
zone_order_queue_station = OrderQueueStation.create({station_name: "K3", is_active: true, printer_name: "print_station", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
|
||||
|
||||
# QueueStationZone
|
||||
zone_queue_station1 = OrderQueueProcessByZone.create({order_queue_station: order_queue_station1, zone: zone})
|
||||
zone_queue_station2 = OrderQueueProcessByZone.create({order_queue_station: order_queue_station2, zone: zone2})
|
||||
zone_queue_station3 = OrderQueueProcessByZone.create({order_queue_station: zone_order_queue_station, zone: zone3})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user