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

This commit is contained in:
superuser
2017-06-22 18:26:36 +06:30
45 changed files with 545 additions and 318 deletions

View File

@@ -122,6 +122,7 @@ GEM
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
pdf-core (0.7.0)
pg (0.21.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
@@ -260,6 +261,7 @@ DEPENDENCIES
kaminari (~> 1.0.1)
listen (~> 3.0.5)
mysql2 (>= 0.3.18, < 0.5)
pg
prawn
prawn-table
puma (~> 3.0)

View File

@@ -112,8 +112,9 @@ $(document).ready(function(){
// Print Order Item
$('#print_order_item').on('click',function(){
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'id':assigned_item_id };
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,

View File

@@ -179,3 +179,11 @@ select.form-control {
tr.discount-item-row:hover {
background-color: #e3e3e3 !important;
}
.required abbr{
color: red !important;
}
/* Jquery Confirm */
.jconfirm-box-container{
margin-left:-40px !important
}

View File

@@ -22,27 +22,19 @@ class Api::OrdersController < Api::ApiController
if booking
if booking.dining_facility_id.to_i == table_id.to_i
@booking = booking
if booking.booking_status == 'assign'
if booking.sale_id.nil?
@booking = booking
end
end
else
table = DiningFacility.find(table_id)
booking = table.get_current_booking
if booking
if booking.dining_facility_id.to_i == table_id.to_i
@booking = booking
end
end
@booking = table.get_booking
end
end
else
puts "only table"
table = DiningFacility.find(table_id)
booking = table.get_current_booking
puts booking
if booking
if booking.dining_facility_id.to_i == table_id.to_i
@booking = booking
end
end
@booking = table.get_booking
end
end
@@ -73,54 +65,47 @@ class Api::OrdersController < Api::ApiController
# check booking id is already completed.
booking = Booking.find(params[:booking_id])
if booking
if booking.dining_facility_id.to_i == params[:table_id].to_i
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
if !booking.sale_id.nil?
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
check_order_with_booking(booking)
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
puts "booking sale is null"
end
else
# booking.table id not equal current table
table = DiningFacility.find(params[:table_id])
if table
booking = table.get_current_booking
if booking
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
end
end
check_order_with_table(params[:table_id])
end
end #booking exists
else
#no booking id
table = DiningFacility.find(params[:table_id])
if table
booking = table.get_current_booking
if booking
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
end
check_order_with_table(params[:table_id])
end
end
@status, @booking = @order.generate
end
def check_order_with_table(table_id)
table = DiningFacility.find(table_id)
if table
booking = table.get_current_booking
if booking
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = booking.booking_id
end
end
end
end
def check_order_with_booking(booking)
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true
else
@order.new_booking = false
@order.booking_id = params[:booking_id]
end
end
# Description
# This API - allow order to add new items to existing orders, does not allow you to remove confirm items
# Update customer info, Guest Info

View File

@@ -46,7 +46,7 @@ class Crm::CustomersController < BaseCrmController
end
#get customer amount
@customer = Customer.find(params[:id])
@customer = Customer.find(params[:id])
@response = Customer.get_membership_transactions(@customer)
#end customer amount
@@ -93,7 +93,8 @@ class Crm::CustomersController < BaseCrmController
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
},
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
@@ -163,7 +164,8 @@ end
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
},
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
@@ -201,6 +203,6 @@ end
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salution,:gender,:nrc_no,:address,:card_no)
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no)
end
end

View File

@@ -2,8 +2,10 @@ 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 = queue_items_query(true)
@queue_stations_items=Array.new
@@ -79,29 +81,17 @@ class Oqs::HomeController < BaseOqsController
render :json => removed_item.to_json
end
# Query for OQS with status
def queue_items_query(status)
puts status
puts "put what is status"
# AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
# .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
# left join dining_facilities as df on df.zone_id = oqpz.zone_id
# 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
# left join customers as cus ON cus.customer_id = od.customer_id")
# .where("assigned_order_items.delivery_status = #{status}")
# .group("assigned_order_items.assigned_order_item_id")
# .order("odt.item_name DESC")
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
# Query for OQS with delivery status
def queue_items_query(status)
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, 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 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
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}")
.group("assigned_order_items.assigned_order_item_id,oqs.station_name,oqs.is_active,df.name,odt.item_code,odt.item_name,odt.price, odt.qty, odt.item_order_by,cus.name,odt.created_at")
.group("odt.order_items_id")
end
end

View File

@@ -2,9 +2,10 @@ class Oqs::PrintController < ApplicationController
# Print Order Item
def print
unique_code="OrderItemPdf"
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 + "'");
assigned_item_id = params[:id]
options = params[:options]
assigned_item = AssignedOrderItem.find(assigned_item_id)
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# order queue stations
oqs = assigned_item.order_queue_station
@@ -13,9 +14,9 @@ class Oqs::PrintController < ApplicationController
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status )
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status, options )
# update print status for completed same order items
assigned_items.each do |ai|
@@ -27,10 +28,10 @@ class Oqs::PrintController < ApplicationController
# Print Order Details with booking id
def print_order_summary
unique_code="OrderSummaryPdf"
assigned_item_id=params[:id]
table_name=params[:table_name]
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
assigned_item_id = params[:id]
table_name = params[:table_name]
assigned_item = AssignedOrderItem.find(assigned_item_id)
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# order queue stations
oqs = assigned_item.order_queue_station
@@ -43,13 +44,13 @@ class Oqs::PrintController < ApplicationController
booking = Booking.find_by_dining_facility_id(dining.id)
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
print_settings = PrintSetting.find_by_unique_code(unique_code)
order_queue_printer = Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_booking_summary(oqs, booking.booking_id, print_status)
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status=true
ai.print_status = true
ai.save
end
end

View File

@@ -39,5 +39,29 @@ class Origami::CustomersController < BaseOrigamiController
end
end
def update_sale_by_customer
id = params[:sale_id][0,3]
if(id == "SAL")
sale = Sale.find(params[:sale_id])
status = sale.update_attributes(customer_id: params[:customer_id])
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)
@orders.each do |bo|
order = Order.find(bo.order_id)
status = order.update_attributes(customer_id: params[:customer_id])
end
end
if status == true
render json: JSON.generate({:status => true})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
end

View File

@@ -4,7 +4,7 @@ class Origami::HomeController < BaseOrigamiController
def index
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.complete_sale
@complete = Sale.all
@orders = Order.all.order('date desc')
end
@@ -12,27 +12,30 @@ class Origami::HomeController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.complete_sale
@complete = Sale.all
@orders = Order.all.order('date desc')
@status_order = ""
@status_sale = ""
@sale_array = Array.new
@dining.bookings.each do |booking|
if booking.sale_id.nil?
@order_items = Array.new
booking.booking_orders.each do |booking_order|
@dining.bookings.active.each do |booking|
if booking.sale_id.nil? && booking.booking_status != 'moved'
@order_items = Array.new
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@obj_order = order
@date = order.created_at
order.order_items.each do |item|
@order_items.push(item)
if (order.status == "new")
@obj_order = order
@date = order.created_at
order.order_items.each do |item|
@order_items.push(item)
end
end
end
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed"
puts "enter"
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
@@ -42,7 +45,7 @@ class Origami::HomeController < BaseOrigamiController
@obj_sale = sale
end
end
end
end
end
private

View File

@@ -44,7 +44,7 @@ class Origami::MovetableController < BaseOrigamiController
bookings = Booking.where('dining_facility_id=?',change_from)
booking_array = Array.new
bookings.each do | booking |
if booking.sale_id.nil? || booking.sale.sale_status != 'completed'
if booking.sale_id.nil? || booking.sale.sale_status != 'completed' || booking.booking_status != 'moved'
booking_array.push(booking)
end
end

View File

@@ -3,7 +3,7 @@ class Origami::OrdersController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.complete_sale
@complete = Sale.all
@orders = Order.all.order('status desc')
@order = Order.find(params[:order_id])
sale_order = SaleOrder.find_by_order_id(@order.order_id)

View File

@@ -6,8 +6,24 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(@sale_id)
# limit redeem_amount
rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
nonrebate_prices = sale_data.total_amount - rebate_prices
# rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
# nonrebate_prices = sale_data.total_amount - rebate_prices
# @payparcount = 0
# others = 0
# sale_data.sale_payments.each do |sale_payment|
# if sale_payment.payment_method == "paypar"
# @payparcount = @payparcount + sale_payment.payment_amount
# else
# others = others + sale_payment.payment_amount
# end
# end
# non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
# if non_rebate_exceed < 0
# @redeem_prices = rebate_prices - @payparcount
# else
# @redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
# end
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
@@ -17,12 +33,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
others = others + sale_payment.payment_amount
end
end
non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
if non_rebate_exceed < 0
@redeem_prices = rebate_prices - @payparcount
else
@redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
end
@redeem_prices = sale_data.grand_total - @payparcount -others
if sale_data
if sale_data.customer_id

View File

@@ -22,7 +22,7 @@ class Origami::RequestBillsController < BaseOrigamiController
unique_code = "ReceiptBillPdf"
# customer= Customer.where('customer_id=' +.customer_id)
customer= Customer.find( @sale_data.customer_id)
customer= Customer.find(@sale_data.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info

View File

@@ -3,7 +3,7 @@ class Origami::RoomsController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.complete_sale
@complete = Sale.all
@orders = Order.all.order('date desc')
@room = DiningFacility.find(params[:room_id])
@room.bookings.each do |booking|

View File

@@ -3,8 +3,42 @@ class Origami::SalesController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.complete_sale
@complete = Sale.all
@orders = Order.all.order('date desc')
@sale = Sale.find(params[:sale_id])
end
def add_to_existing_invoice
dining = params[:dining_id]
sale_id = params[:sale_id]
table = DiningFacility.find(dining)
table.bookings.each do |booking|
if booking.sale_id.nil?
booking.booking_orders.each do |booking_order|
booking.booking_status = 'moved'
order = Order.find(booking_order.order_id)
order.status = 'billed'
order.order_items.each do |item|
item.order_item_status = 'billed'
end
# create sale item
saleobj = Sale.find(sale_id)
order.order_items.each do |orer_item|
saleobj.add_item (orer_item)
end
saleobj.save
order.save
booking.save
end
existing_booking = Booking.find_by_sale_id(sale_id)
booking_order = BookingOrder.where('booking_id=?',booking)
booking_order.each do |bo|
bo.booking_id = existing_booking.booking_id
bo.save
end
end
end
end
end

View File

@@ -4,6 +4,10 @@ class Reports::DailySaleController < BaseReportController
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
respond_to do |format|
format.html
format.xls
end
end
def show

View File

@@ -8,6 +8,10 @@ class Reports::ReceiptNoController < BaseReportController
puts to
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
respond_to do |format|
format.html
format.xls
end
end
def show

View File

@@ -5,6 +5,11 @@ class Reports::SaleItemController < BaseReportController
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
respond_to do |format|
format.html
format.xls
end
end
def show

View File

@@ -9,12 +9,30 @@ class Booking < ApplicationRecord
belongs_to :sale, :optional => true
has_many :booking_orders
has_many :orders, :through => :booking_orders
scope :active, -> {where("booking_status != 'moved'")}
def self.update_dining_facility(booking_arr, newd, old)
booking_arr.each do |booking|
booking.dining_facility_id = newd
booking.save
end
table = DiningFacility.find(newd)
exist = table.get_booking
if exist
# order exists
booking_arr.each do |booking|
booking.dining_facility_id = newd
booking.booking_status = 'moved'
booking.save
booking.booking_orders.each do |bo|
bo.booking_id = exist.booking_id
bo.save
end
end
else
# new table
booking_arr.each do |booking|
booking.dining_facility_id = newd
booking.save
end
end
new_dining = DiningFacility.find(newd)
new_dining.make_occupied
old_dining = DiningFacility.find(old)

View File

@@ -6,7 +6,7 @@ class Customer < ApplicationRecord
has_many :orders
has_many :sales
validates_presence_of :name, :contact_no, :email,:company,:card_no
validates_presence_of :name, :contact_no, :email,:card_no
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
validates :card_no, uniqueness: true
@@ -34,7 +34,7 @@ class Customer < ApplicationRecord
end
return response;
end
def self.get_membership_transactions(customer)
@@ -58,13 +58,13 @@ class Customer < ApplicationRecord
end
return response;
end
def self.search(search)
if search
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ?", "%#{search}%", "%#{search}%", "%#{search}%",)
else
find(:all)
end
@@ -80,8 +80,8 @@ class Customer < ApplicationRecord
end
WALKIN = "CUS-000000000001"
TAKEAWAY = "CUS-000000000002"
WALKIN = "CUS-000000000001"
TAKEAWAY = "CUS-000000000002"
private
def generate_custom_id

View File

@@ -18,6 +18,19 @@ class DiningFacility < ApplicationRecord
self.save
end
def get_booking
booking = self.get_current_booking
puts "is bookig?"
puts booking
if booking
if booking.dining_facility_id.to_i == self.id
if booking.booking_status == 'assign'
return booking
end
end
end
end
def get_current_booking
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)

View File

@@ -1,13 +1,13 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker
def print_order_item(oqs,order_id, item_code, print_status)
def print_order_item(oqs,order_id, item_code, print_status, options="")
#Use CUPS service
#Generate PDF
#Print
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf"
pdf = OrderItemPdf.new(order_item[0], print_status)
pdf = OrderItemPdf.new(order_item[0], print_status, options)
pdf.render_file filename
if oqs.print_copy
@@ -31,7 +31,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
pdf = OrderItemPdf.new(odi, print_status)
# For Item Options
options = odi.options == "[]"? "" : odi.options
pdf = OrderItemPdf.new(odi, print_status, options)
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
if oqs.print_copy
@@ -65,7 +67,10 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
pdf = OrderItemPdf.new(odi, print_status)
# For Item Options
options = odi.options == "[]"? "" : odi.options
pdf = OrderItemPdf.new(odi, print_status, options)
pdf.render_file filename
if oqs.print_copy
@@ -98,7 +103,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# Query for OQS with status
def print_query(type, id)
if type == "order_item"
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
@@ -107,16 +112,17 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
.where("order_items.item_code = '#{ id }'")
.group("order_items.item_code")
elsif type == "order_summary"
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id
left join dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id")
.where("orders.order_id = '#{ id }'")
.group("order_items.order_items_id")
else
# order summary for booking
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining")
.joins("left join orders ON orders.order_id = order_items.order_id
left join booking_orders AS bo ON bo.order_id=order_items.order_id
left join bookings AS b ON b.booking_id = bo.booking_id

View File

@@ -15,7 +15,7 @@ class Sale < ApplicationRecord
has_many :bookings
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") }
REPORT_TYPE = {
"daily" => 0,

View File

@@ -251,9 +251,11 @@ class SalePayment < ApplicationRecord
table = DiningFacility.find(booking.dining_facility_id)
bookings = table.bookings
bookings.each do |tablebooking|
if tablebooking.booking_status != 'moved'
if tablebooking.sale.sale_status != 'completed'
status = false
end
end
end
if status
table.status = "available"

View File

@@ -1,6 +1,6 @@
class OrderItemPdf < 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
def initialize(order_item, print_status)
def initialize(order_item, print_status, options)
self.page_width = 210
self.page_height = 2500
self.margin = 5
@@ -29,7 +29,7 @@ class OrderItemPdf < Prawn::Document
order_info(order_item.order_by,order_item.order_at)
# order items
order_items(order_item)
order_items(order_item, options)
end
# Write Order Information to PDF
@@ -52,23 +52,11 @@ class OrderItemPdf < Prawn::Document
end
# Write Order items to PDF
def order_items(order_item)
def order_items(order_item, options)
y_position = cursor
# No Need for Order Item
# bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
# text "Item", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do
# text "Qty", :size => self.item_font_size,:align => :right
# end
# stroke_horizontal_rule
# move_down 5
#Add Order Item
add_order_items(order_item)
add_order_items(order_item, options)
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
@@ -76,7 +64,7 @@ class OrderItemPdf < Prawn::Document
end
# Add order items under order info
def add_order_items(order_item)
def add_order_items(order_item, options)
y_position = cursor
move_down 5
@@ -91,6 +79,14 @@ class OrderItemPdf < Prawn::Document
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
move_down 5
end
end

View File

@@ -92,6 +92,18 @@ class OrderSummaryPdf < Prawn::Document
end
move_down 5
# add option
options = odi.options == "[]"? "" : odi.options
if options != ""
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
move_down 5
end
end
end

View File

@@ -1,3 +1,3 @@
json.array! @customers, :id, :name, :company, :contact_no,:salution,
json.array! @customers, :id, :name, :company, :contact_no,:salutation,
:gender,:nrc_no,:address,:card_no, :membership_type,
:membership_id, :created_at

View File

@@ -1,4 +1,4 @@
json.extract! @customer, :id, :name, :company, :contact_no,:salution,
json.extract! @customer, :id, :name, :company, :contact_no,:salutation,
:gender,:nrc_no,:address,:card_no, :membership_type,
:membership_id, :created_at
json.invoices do

View File

@@ -23,9 +23,9 @@ if (@booking)
order_items = []
@booking.booking_orders.each do |bo|
order = Order.find(bo.order_id)
#if (order.status == "new")
if (order.status == "new")
order_items = order_items + order.order_items
#end
end
end
json.order_items order_items do |item|

View File

@@ -1,2 +1,2 @@
json.extract! crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at
json.extract! crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code, :created_at, :updated_at,:salutation, :gender,:nrc_no,:address,:card_no
json.url crm_customer_url(crm_customer, format: :json)

View File

@@ -120,7 +120,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email);
$('#customer_salution').val(data.salution);
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no);
$('#customer_address').val(data.address);
@@ -133,11 +133,11 @@ $(document).on('click',".customer_tr",function(){
$('.female').prop( "checked", true )
}
if(data.salution == 'Mr') {
if(data.salutation == 'Mr') {
$('.mr').prop( "checked", true )
}else if(data.salution == 'Miss') {
}else if(data.salutation == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salution == 'Mrs'){
}else if(data.salutation == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )

View File

@@ -1,5 +1,4 @@
json.extract! @crm_customer, :id, :name, :company, :contact_no, :email, :date_of_birth,
:membership_id, :membership_type, :membership_authentication_code,
:created_at, :updated_at,
:salution, :gender,:nrc_no,:address,:card_no
:salutation, :gender,:nrc_no,:address,:card_no
json.url crm_customer_url(@crm_customer, format: :json)

View File

@@ -49,10 +49,9 @@
<%= qid.qty %>
</span> ]
</h4>
<!--
Item Options
<p class="card-text">Medium, Fries, Salad</p>
-->
<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">
@@ -99,11 +98,10 @@
<span class="order-qty">
<%= qid.qty %>
</span> ]
</h4>
<!--
Item Options
<p class="card-text">Medium, Fries, Salad</p>
-->
</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">

View File

@@ -75,7 +75,15 @@
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>
@@ -225,7 +233,7 @@
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code);
$('#customer_salution').val(data.salution);
$('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no);
if (data.gender == 'Male') {
@@ -234,11 +242,11 @@
$('.female').prop( "checked", true )
}
if (data.salution == 'Mr') {
if (data.salutation == 'Mr') {
$('.mr').prop( "checked", true )
} else if(data.salution == 'Miss') {
} else if(data.salutation == 'Miss') {
$('.miss').prop( "checked", true )
}else if(data.salution == 'Mrs'){
}else if(data.salutation == 'Mrs'){
$('.mrs').prop( "checked", true )
}else{
$('.mdm').prop( "checked", true )
@@ -246,7 +254,7 @@
$('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled');
// $('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+$('#customer_id').val();

View File

@@ -137,7 +137,6 @@
count = 0
sub_total = 0
if @status_sale == "sale"
puts @sale_array[0]
@sale_array[0].sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
@@ -162,8 +161,6 @@
unless @order_items.nil?
count = 0
@order_items.each do |order_item |
puts @order_items.size
puts "view"
count += 1
sub_total = sub_total + order_item.price
@@ -215,10 +212,13 @@
Pending New Order
<table class="table table-striped">
<%
count = 0
@order_items.each do |order_item |
count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
@@ -228,14 +228,15 @@
end
%>
</table>
<button class='btn btn-primary'> Add to existing invoice </button>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice </button>
<%
else
end
@sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
Pending New Invoice
<br><br>
Pending Payment
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
@@ -243,7 +244,6 @@
</tr>
</table>
<%
end
end
end
end
@@ -261,17 +261,23 @@
<% if @dining.bookings.length >= 1 %>
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status_order == 'order' %>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<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="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button>
<% else %>
<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="pay" class="btn btn-primary btn-block">Pay</button>
<button type="button" class="btn btn-primary btn-block" > Void </button>
<% end %>
<!-- Cashier Buttons -->
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button>
<% end %>
</div>
@@ -301,7 +307,7 @@ $(document).ready(function(){
// bind customer to order or sale
$("#customer").on('click', function(){
var sale = $('#sale_id').val();
if (sale!="") {
if (sale) {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
@@ -338,6 +344,7 @@ $('#pay').on('click',function() {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
// Bill Request
$('#request_bills').click(function() {
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
@@ -360,4 +367,19 @@ $('#move').on('click',function(){
$('#back').on('click',function(){
window.location.href = '/origami/';
})
$('#add_invoice').on('click',function(){
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var ajax_url = "/origami/sale/append_order";
$.ajax({
type: "POST",
url: ajax_url,
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
success:function(result){
alert("Invoice updated")
window.location.reload();
}
});
})
</script>

View File

@@ -180,7 +180,7 @@
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
Pending New Invoice
Pending Payment
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>

View File

@@ -24,7 +24,8 @@
<table >
<!-- <thead> -->
<tr>
<th style="width:80%;">Items</th>
<th style="width:5%">#</th>
<th style="width:76%;">Items</th>
<th style="width:20%;">QTY</td>
<th style="width:20%;">Price</td>
</tr>
@@ -34,10 +35,16 @@
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table" id="append-table">
<tbody>
<% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %>
<% sub_total = 0
count = 0
%>
<% @sale_data.sale_items.each do |sale_item|
count += 1
%>
<% sub_total += sale_item.qty*sale_item.unit_price%>
<tr>
<td><%= count %></td>
<td style="width:60%; text-align:left">
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
@@ -236,7 +243,6 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block"> FOC </button>
<button type="button" class="btn btn-primary btn-block"> Void </button>
</div>
</div>

View File

@@ -6,7 +6,7 @@
<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 redeem upto </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @redeem_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
<input type="text" name="" id="redeemamt" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%= @redeem_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>">
</div>
<hr>
</div>
@@ -131,8 +131,8 @@ $(document).on('click', '.cashier_number', function(event){
$('#used_amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
alert($('#valid_amount').text())
$('#used_amount').text($('#valid_amount').text());
var remain_amount = $('#redeemamt').val();
$('#used_amount').text(remain_amount);
break;
}

View File

@@ -98,7 +98,7 @@
<div class="card" >
<div class="card-header">
<% if @status == "order" %>
<div><strong id="order-title">ORDER DETAILS </strong></div>
<div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div>
<% else %>
<div><strong id="order-title">INVOICE DETAILS </strong></div>
<% end %>
@@ -139,7 +139,7 @@
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @obj.sale_id %>">
<% unless sale_item.price <= 0 %>
<% unless sale_item.price == 0 %>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
@@ -155,7 +155,7 @@
@order_items.each do |order_item |
sub_total = sub_total + order_item.price
unless order_item.price <= 0 %>
unless order_item.price == 0 %>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
@@ -259,15 +259,65 @@ $(document).ready(function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
})
// bind customer to order or sale
$("#customer").on('click', function(){
var sale = $('#sale_id').val();
if (sale) {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
}
window.location.href = '/origami/'+ sale_id + "/customers"
});
// Discount for Payment
$('#discount').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 + '/discount'
}
else {
alert("Please select an table!");
}
return false;
});
});
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
// Bill Request
$('#request_bills').click(function() {
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "POST",
url: ajax_url,
data: 'order_id='+ order_id,
success:function(result){
location.reload();
}
});
});
$('#move').on('click',function(){
var dining_id = "<%= @room.id %>"
window.location.href = '/origami/table/'+ dining_id + "/moveroom";
})
$('#back').on('click',function(){
window.location.href = '/origami/';
})

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -1,116 +1,136 @@
<div class="card row">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<% if params[:from]%>
<tr>
<th colspan="17"> Sale (<%= params[:from] rescue '-' %> - <%= params[:to] rescue '-'%>)</th>
</tr>
<% end %>
<tr>
<th style='text-align:center;'>Sr.no</th>
<th style='text-align:center;'>Date</th>
<th style='text-align:center;'>Daily Void Amount</th>
<th style='text-align:center;'>Daily mpu Sales</th>
<th style='text-align:center;'>Daily master Sales</th>
<th style='text-align:center;'>Daily visa Sales</th>
<th style='text-align:center;'>Daily jcb Sales</th>
<th style='text-align:center;'>Daily paypar Sales</th>
<th style='text-align:center;'>Daily Cash Sales</th>
<th style='text-align:center;'>Daily Credit Sales</th>
<th style='text-align:center;'>Daily FOC Sales</th>
<th style='text-align:center;'>(Daily Discount)</th>
<th style='text-align:center;'>Grand Total + <br/> Rounding Adj.</th>
<th style='text-align:center;'>Rounding Adj.</th>
<th style='text-align:center;'>Grand Total</th>
</tr>
</thead>
<% unless @sale_data.empty? %>
<tbody>
<% void = 0 %>
<% mpu = 0 %>
<% master = 0 %>
<% visa = 0 %>
<% jcb = 0 %>
<% paypar = 0 %>
<% cash = 0 %>
<% credit = 0 %>
<% foc = 0 %>
<% discount = 0 %>
<% total = 0 %>
<% grand_total = 0 %>
<% count = 1 %> <% rounding_adj = 0 %>
<% @sale_data.each do |sale| %>
<% void += sale[:void_amount] %>
<% mpu += sale[:mpu_amount] %>
<% master += sale[:master_amount] %>
<% visa += sale[:visa_amount] %>
<% jcb += sale[:jcb_amount] %>
<% paypar += sale[:paypar_amount] %>
<% cash += sale[:cash_amount] %>
<% credit += sale[:credit_amount] %>
<% foc += sale[:foc_amount] %>
<% discount += sale[:total_discount] %>
<% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %>
<% grand_total += sale[:grand_total].to_f %>
<% rounding_adj += sale[:rounding_adj].to_f %>
<tr>
<td style='text-align:right;'><%= count %></td>
<td><%= sale[:sale_date].strftime("#{sale[:sale_date].day.ordinalize} %b") rescue '-' %></td>
<td style='color:red;text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:void_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:mpu_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:master_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:visa_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:jcb_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:paypar_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:cash_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%></td>
</tr>
<% count = count + 1 %>
<% end %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-type" content="application/vnd.ms-excel; charset=UTF-8">
</head>
<body>
<div class="span12">
<% unless @sale_data.blank? %>
<tr style="font-weight:600;">
<td colspan="3" style='text-align:center;'>Total</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",mpu_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",master_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",visa_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",jcb_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",paypar_amount), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",cash), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",credit), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",foc), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'>(<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>)</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%></td>
</tr>
<table class="table table-striped" id="items_table" border="0">
<thead>
<% total_tax = 0 %>
<% unless @tax.empty? %>
<% @tax.each do |tax| %>
<% total_tax += tax.tax_amount.to_f %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'><%= tax.tax_name rescue '-'%></td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",tax.tax_amount), :delimiter => ',') rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>
<% net = total - total_tax %>
<tr style="font-weight:600;">
<td colspan="12" style='text-align:right;'>Net Amount</td>
<td style='text-align:right;'><%= number_with_delimiter(sprintf("%.2f",net), :delimiter => ',') rescue '-'%></td>
<td colspan="2">&nbsp;</td>
</tr>
<% end %>
</tbody>
<% if !params[:from].blank?%>
<tr>
<th colspan="7">From Date : <%= params[:from] %> , To Date : <%= params[:to] %></th>
</tr>
<% end %>
<% if @shift_from %>
<tr>
<% if @shift_data.employee %>
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
<% end %>
<th colspan="7">Shift Name = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<tr>
<th>&nbsp;</th>
<th>Menu Category</th>
<th>Code</th>
<th>Product</th>
<th>Total Item</th>
<th>Unit Price</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
<% acc_arr = Array.new %>
<% cate_arr = Array.new %>
<% sub_total = 0.0 %>
<% count = 0%>
<% total_price = 0.0 %>
<% cate_count = 0 %>
<% acc_count = 0%>
<% grand_total = 0%>
<% total_discount = 0.0 %>
<% @sale_data.order("total_item desc").each do |sale| %>
<% if !acc_arr.include?(sale.account_id) %>
<tr>
<td><b><%= sale.account_name %></b></td>
<td colspan="4">&nbsp;</td>
<td>Total Price By <%= sale.account_name %></td>
<td>
<% @totalByAccount.each do |account, total| %>
<% if sale.account_id == account %>
<b><%= total %></b>
<% end %>
<% end %>
</td>
</tr>
<% acc_arr.push(sale.account_id) %>
<% end %>
<tr>
<td>&nbsp;</td>
<% if !cate_arr.include?(sale.menu_category_id) %>
<td><%= sale.menu_category_name %></td>
<% cate_arr.push(sale.menu_category_id) %>
<% else %>
<td>&nbsp;</td>
<% end %>
</table>
</div>
</div>
<td><%= sale.code rescue '-' %></td>
<% if @item_table == 'sale' %>
<% if sale.item_remark == 'FOC' %>
<td><%= '[PROMO] '.to_s + sale.product_name.to_s rescue '-' %></td>
<% elsif sale.item_remark == 'FOC ITEM' %>
<td><%= '[DIS:QTY] '.to_s + sale.product_name.to_s rescue '-' %></td>
<% elsif sale.item_remark == 'DISCOUNT' %>
<td><%= '[DIS:TP] '.to_s + sale.product_name.to_s rescue '-' %></td>
<% else %>
<td><%= sale.product_name.to_s rescue '-' %></td>
<% end %>
<% if sale.item_remark == 'DISCOUNT' %>
<td> - </td>
<td> - </td>
<td><%= sale.total_price.abs rescue '-' %></td>
<% total_price += sale.total_price %>
<% else %>
<td><%= sale.total_item.abs rescue '-' %></td>
<td><%= sale.unit_price rescue '-' %></td>
<td><%= sale.grand_total.abs rescue '-' %></td>
<% end %>
<% else %>
<td><%= sale.product_name.to_s rescue '-' %></td>
<td><%= sale.total_item.abs rescue '-' %></td>
<td><%= sale.unit_price rescue '-' %></td>
<td><%= sale.grand_total.abs rescue '-' %></td>
<% end %>
</tr>
<!-- sub total -->
<% @menu_cate_count.each do |key,value| %>
<% if sale.menu_category_id == key %>
<% count = count + 1 %>
<% sub_total += sale.grand_total %>
<% if count == value %>
<tr>
<td colspan="5">&nbsp;</td>
<td>Sub Total</td>
<td ><span class="underline"><%= sub_total + total_price %></span></td>
</tr>
<% sub_total = 0.0%>
<% total_discount = total_discount + total_price %>
<% total_price = 0.0%>
<% count = 0%>
<% end %>
<% end %>
<% end %>
<!-- end sub total -->
<% grand_total += sale.grand_total%>
<% end %>
<tr>
<td colspan="5">&nbsp;</td>
<td>Grand Total</td>
<td><span class="double_underline"><%= grand_total + total_discount %></span></td>
</tr>
</tbody>
</table>
<% end %>
</div>
</body>
</html>

View File

@@ -2,3 +2,4 @@
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
Mime::Type.register 'application/vnd.ms-excel', :xls

View File

@@ -80,6 +80,7 @@ Rails.application.routes.draw do
get 'table/:dining_id/movetable' => "movetable#move_dining"
get 'table/:dining_id/moveroom' => "moveroom#move_dining"
get 'sale/:sale_id' => 'sales#show'
post 'sale/append_order' => 'sales#add_to_existing_invoice'
get 'room/:room_id' => 'rooms#show'
get 'order/:order_id' => "orders#show"
@@ -112,7 +113,7 @@ Rails.application.routes.draw do
#resources :customers
get '/:sale_id/customers', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer'
post '/:sale_id/update_sale' , to: "home#update_sale_by_customer"#update customer id in sale table
post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table
end
#--------- Waiter/Ordering Station ------------#

View File

@@ -1,22 +1,20 @@
class CreateCustomers < ActiveRecord::Migration[5.1]
def change
create_table :customers, :id => false do |t|
create_table :customers, :id => false do |t|
t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync
t.string :name, :null => false
t.string :company
t.string :contact_no, :unique => true
t.string :email
t.date :date_of_birth
t.string :membership_id
t.string :membership_type
t.string :membership_authentication_code
t.string :salution
t.string :contact_no, :unique => true
t.date :date_of_birth
t.string :salutation
t.string :gender
t.string :nrc_no
t.string :address
t.string :card_no, :unique => true
t.timestamps
t.string :membership_id
t.string :membership_type
t.string :membership_authentication_code
end
end
end

View File

@@ -79,12 +79,13 @@ account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value
# sale void reason
void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manager', value: 'Approve By Manager'},
{lookup_type:'void_reason', name: 'Customer Mistake', value: 'Customer Mistake'},
{lookup_type:'void_reason', name: 'Cashier Mistake', value: 'Cashier Mistake'},
{lookup_type:'void_reason', name: 'Cashier Mistake', value: 'Cashier Mistake'},
{lookup_type:'void_reason', name: 'Waiter Mistake', value: 'Waiter Mistake'}])
#WALK CUSTOMER - Default CUSTOMER (take key 1)
customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000", card_no:'000' })
customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111", card_no:'111' })
customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"})
customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"111"})
#Default ZOne
# zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"})