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

This commit is contained in:
Nweni
2017-06-20 19:00:02 +06:30
28 changed files with 330 additions and 170 deletions

View File

@@ -122,11 +122,13 @@ $(document).ready(function(){
// Print Order Summary // Print Order Summary
$('#print_order_summary').on('click',function(){ $('#print_order_summary').on('click',function(){
var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'id':assigned_item_id }; var params = { 'table_name':table_name };
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '/oqs/print/print_order_summary/'+assigned_item_id, url: '/oqs/print/print_order_summary/'+assigned_item_id,
data: params,
success: function(data){ } success: function(data){ }
}); });
}); });

View File

@@ -40,7 +40,7 @@ $(document).on('turbolinks:load', function() {
items.push($(value).attr("data-id")); items.push($(value).attr("data-id"));
}); });
$("#order_queue_station_processing_items").val(items); $("#order_queue_station_processing_items").val(JSON.stringify(items));
//$(this).submit(); //$(this).submit();
}) })
}) })

View File

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

View File

@@ -6,7 +6,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(@sale_id) sale_data = Sale.find_by_sale_id(@sale_id)
# limit redeem_amount # limit redeem_amount
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items) rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
nonrebate_prices = sale_data.total_amount - rebate_prices
@payparcount = 0 @payparcount = 0
others = 0 others = 0
sale_data.sale_payments.each do |sale_payment| sale_data.sale_payments.each do |sale_payment|
@@ -16,11 +17,11 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
others = others + sale_payment.payment_amount others = others + sale_payment.payment_amount
end end
end end
is_bervage_exceed = others - (beverage_prices + sale_data.total_tax) non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
if is_bervage_exceed < 0 if non_rebate_exceed < 0
@food_prices = food_prices - @payparcount @redeem_prices = rebate_prices - @payparcount
else else
@food_prices = food_prices - @payparcount -is_bervage_exceed @redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
end end
if sale_data if sale_data

View File

@@ -68,6 +68,6 @@ class Settings::AccountsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def account_params def account_params
params.require(:account).permit(:title, :account_type) params.require(:account).permit(:title, :account_type,:discount,:point,:bonus,:rebate)
end end
end end

View File

@@ -27,6 +27,7 @@ class Settings::OrderQueueStationsController < ApplicationController
def create def create
@settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params) @settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params)
@settings_order_queue_station.created_by = current_login_employee.name @settings_order_queue_station.created_by = current_login_employee.name
@settings_order_queue_station.processing_items = "[]"
respond_to do |format| respond_to do |format|
if @settings_order_queue_station.save if @settings_order_queue_station.save
format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' } format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' }
@@ -41,7 +42,7 @@ class Settings::OrderQueueStationsController < ApplicationController
# PATCH/PUT /settings/order_queue_stations/1 # PATCH/PUT /settings/order_queue_stations/1
# PATCH/PUT /settings/order_queue_stations/1.json # PATCH/PUT /settings/order_queue_stations/1.json
def update def update
params[:order_queue_station][:processing_items] = params[:order_queue_station][:processing_items].split(/,/).inspect # params[:order_queue_station][:processing_items] = params[:order_queue_station][:processing_items].split(/,/).inspect
respond_to do |format| respond_to do |format|
if @settings_order_queue_station.update(settings_order_queue_station_params) if @settings_order_queue_station.update(settings_order_queue_station_params)
format.html { redirect_to settings_order_queue_station_path(@settings_order_queue_station), notice: 'Order queue station was successfully updated.' } format.html { redirect_to settings_order_queue_station_path(@settings_order_queue_station), notice: 'Order queue station was successfully updated.' }

View File

@@ -1,6 +1,6 @@
class Settings::RoomsController < ApplicationController class Settings::RoomsController < ApplicationController
before_action :set_settings_room, only: [:show, :edit, :update, :destroy] before_action :set_settings_room, only: [:show, :edit, :update, :destroy]
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create] before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create,:destroy]
# GET /settings/rooms # GET /settings/rooms
# GET /settings/rooms.json # GET /settings/rooms.json
def index def index
@@ -28,9 +28,10 @@ class Settings::RoomsController < ApplicationController
@settings_room = Room.new(settings_room_params) @settings_room = Room.new(settings_room_params)
@settings_room.type = DiningFacility::ROOM_TYPE @settings_room.type = DiningFacility::ROOM_TYPE
@settings_room.zone_id = params[:zone_id] @settings_room.zone_id = params[:zone_id]
@settings_room.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_room.save if @settings_room.save
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully created.' } format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @settings_room } format.json { render :show, status: :created, location: @settings_room }
else else
puts "abc" puts "abc"
@@ -43,9 +44,10 @@ class Settings::RoomsController < ApplicationController
# PATCH/PUT /settings/rooms/1 # PATCH/PUT /settings/rooms/1
# PATCH/PUT /settings/rooms/1.json # PATCH/PUT /settings/rooms/1.json
def update def update
@settings_room.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_room.update(settings_room_params) if @settings_room.update(settings_room_params)
format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully updated.' } format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_room } format.json { render :show, status: :ok, location: @settings_room }
else else
format.html { render :edit } format.html { render :edit }
@@ -59,7 +61,7 @@ class Settings::RoomsController < ApplicationController
def destroy def destroy
@settings_room.destroy @settings_room.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to settings_zones_path, notice: 'Room was successfully destroyed.' } format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully destroyed.' }
format.json { head :no_content } format.json { head :no_content }
end end
end end

View File

@@ -28,12 +28,12 @@ class Settings::TablesController < ApplicationController
@settings_table = Table.new(settings_table_params) @settings_table = Table.new(settings_table_params)
@settings_table.type = DiningFacility::TABLE_TYPE @settings_table.type = DiningFacility::TABLE_TYPE
@settings_table.zone_id = params[:zone_id] @settings_table.zone_id = params[:zone_id]
@settings_table.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_table.save if @settings_table.save
format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully created.' } format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully created.' }
format.json { render :show, status: :created, location: @settings_table } format.json { render :show, status: :created, location: @settings_table }
else else
puts "abc"
format.html { render :new } format.html { render :new }
format.json { render json: @settings_table.errors, status: :unprocessable_entity } format.json { render json: @settings_table.errors, status: :unprocessable_entity }
end end
@@ -43,9 +43,10 @@ class Settings::TablesController < ApplicationController
# PATCH/PUT /settings/tables/1 # PATCH/PUT /settings/tables/1
# PATCH/PUT /settings/tables/1.json # PATCH/PUT /settings/tables/1.json
def update def update
@settings_table.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_table.update(settings_table_params) if @settings_table.update(settings_table_params)
format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully updated.' } format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_table } format.json { render :show, status: :ok, location: @settings_table }
else else
format.html { render :edit } format.html { render :edit }
@@ -59,7 +60,7 @@ class Settings::TablesController < ApplicationController
def destroy def destroy
@settings_table.destroy @settings_table.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to settings_zones_path, notice: 'Table was successfully destroyed.' } format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully destroyed.' }
format.json { head :no_content } format.json { head :no_content }
end end
end end

View File

@@ -27,7 +27,7 @@ class Settings::ZonesController < ApplicationController
# POST /settings/zones.json # POST /settings/zones.json
def create def create
@settings_zone = Zone.new(settings_zone_params) @settings_zone = Zone.new(settings_zone_params)
@settings_zone.created_by = current_login_employee.name
respond_to do |format| respond_to do |format|
if @settings_zone.save if @settings_zone.save
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully created.' } format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully created.' }
@@ -43,6 +43,7 @@ class Settings::ZonesController < ApplicationController
# PATCH/PUT /settings/zones/1.json # PATCH/PUT /settings/zones/1.json
def update def update
respond_to do |format| respond_to do |format|
@settings_zone.created_by = current_login_employee.name
if @settings_zone.update(settings_zone_params) if @settings_zone.update(settings_zone_params)
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully updated.' } format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_zone } format.json { render :show, status: :ok, location: @settings_zone }
@@ -56,6 +57,8 @@ class Settings::ZonesController < ApplicationController
# DELETE /settings/zones/1 # DELETE /settings/zones/1
# DELETE /settings/zones/1.json # DELETE /settings/zones/1.json
def destroy def destroy
@settings_zone.rooms.destroy
@settings_zone.tables.destroy
@settings_zone.destroy @settings_zone.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to settings_zones_path, notice: 'Zone was successfully destroyed.' } format.html { redirect_to settings_zones_path, notice: 'Zone was successfully destroyed.' }

View File

@@ -16,6 +16,10 @@ class OrderQueueStation < ApplicationRecord
oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
order_items = order.order_items order_items = order.order_items
# get dining
booking = Booking.find_by_dining_facility_id(dining.id)
#Assign OQS id to order Items #Assign OQS id to order Items
oqs_stations.each do |oqs| oqs_stations.each do |oqs|
#Get List of items - #Get List of items -
@@ -26,29 +30,53 @@ class OrderQueueStation < ApplicationRecord
#Processing through the looping items #Processing through the looping items
order_items.each do |order_item| order_items.each do |order_item|
if (pq_item == order_item.item_code) if (pq_item == order_item.item_code)
if oqs.id == oqpbz.order_queue_station_id # if oqs.id == oqpbz.order_queue_station_id
#Same Order_items can appear in two location. # #Same Order_items can appear in two location.
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
else # else
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
end
end
end
end
end
#Print OQS where printing is require AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# end
if oqs.auto_print
print_slip(oqs, order, order_items)
end
end
end
end
end
end end
private private
#Print order_items in 1 slip #Print order_items in 1 slip
def print_slip def print_slip(oqs, order, order_items)
unique_code="OrderSummaryPdf"
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(oqs,order.order_id, print_status="")
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# update print status for order items
ai.print_status=true
ai.save
end
end end
#Print order_items in 1 slip per item #Print order_item in 1 slip per item
def print_slip_item def print_slip_item(oqs, assigned_order_item)
unique_code="OrderItemPdf"
# 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,item.order_id, item.item_code, print_status="" )
# update print status for completed same order items
assigned_order_item.each do |ai|
ai.print_status=true
ai.save
end
end end
end end

View File

@@ -1,21 +1,28 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker class Printer::OrderQueuePrinter < Printer::PrinterWorker
def print_order_item(oqs,order_id, item_code) def print_order_item(oqs,order_id, item_code, print_status)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) order_item = print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
pdf = OrderItemPdf.new(order_item[0])
pdf.render_file "tmp/receipt.pdf" filename = "tmp/order_item_#{order_item[0].item_name}" + ".pdf"
pdf = OrderItemPdf.new(order_item[0], print_status)
pdf.render_file filename
if oqs.print_copy if oqs.print_copy
self.print("tmp/receipt.pdf", oqs.printer_name) self.print(filename, oqs.printer_name)
self.print("tmp/receipt.pdf", oqs.printer_name)
#For print copy
pdf.render_file filename.gsub(".","-copy.")
self.print(filename.gsub(".","-copy."), oqs.printer_name)
else else
self.print("tmp/receipt.pdf", oqs.printer_name) self.print(filename, oqs.printer_name)
end end
end end
def print_order_summary(oqs,order_id) # Query for per order
def print_order_summary(oqs, order_id, print_status)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -23,44 +30,99 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Per Item # For Print Per Item
if oqs.cut_per_item if oqs.cut_per_item
order.each do|odi| order.each do|odi|
pdf = OrderItemPdf.new(odi) filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
pdf.render_file "tmp/receipt.pdf" pdf = OrderItemPdf.new(odi, print_status)
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
if oqs.print_copy if oqs.print_copy
self.print("tmp/receipt.pdf", oqs.printer_name) self.print(filename, oqs.printer_name)
self.print("tmp/receipt.pdf", oqs.printer_name) self.print(filename.gsub(".","-copy."), oqs.printer_name)
else else
self.print("tmp/receipt.pdf", oqs.printer_name) self.print(filename, oqs.printer_name)
end end
end end
# For Print Order Summary # For Print Order Summary
else else
filename = "tmp/order_summary_#{ order_id }" + ".pdf" filename = "tmp/order_summary_#{ order_id }" + ".pdf"
pdf = OrderSummaryPdf.new(order) pdf = OrderSummaryPdf.new(order, print_status)
pdf.render_file filename pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name) self.print(filename, oqs.printer_name)
#For print copy
pdf.render_file filename.gsub(".","-copy.")
self.print(filename.gsub(".","-copy."), oqs.printer_name)
else
self.print(filename, oqs.printer_name)
end
end
end
# Print for orders in booking
def print_booking_summary(oqs, booking_id, print_status)
order=print_query('booking_summary', booking_id)
# For Print Per Item
if oqs.cut_per_item
order.each do|odi|
filename = "tmp/order_item_#{odi.item_name}" + ".pdf"
pdf = OrderItemPdf.new(odi, print_status)
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)
#For print copy
pdf.render_file filename.gsub(".","-copy.")
self.print(filename.gsub(".","-copy."), oqs.printer_name)
else
self.print(filename, oqs.printer_name)
end
end
# For Print Order Summary
else
filename = "tmp/booking_summary_#{ booking_id }" + ".pdf"
pdf = OrderSummaryPdf.new(order, print_status)
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)
#For print copy
pdf.render_file filename.gsub(".","-copy.")
self.print(filename.gsub(".","-copy."), oqs.printer_name)
else
self.print(filename, oqs.printer_name)
end
end end
end end
# Query for OQS with status # Query for OQS with status
def print_query(type, code) def print_query(type, id)
if type == 'order_item' 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.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 .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 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 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 dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id") left join customers as cus ON cus.customer_id = orders.customer_id")
.where("order_items.item_code='" + code + "'") .where("order_items.item_code = '#{ id }'")
.group("order_items.item_code") .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")
.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 }'")
else 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.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 .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 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 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 dining_facilities AS df ON df.id = b.dining_facility_id
left join customers as cus ON cus.customer_id = orders.customer_id") left join customers as cus ON cus.customer_id = orders.customer_id")
.where("orders.order_id='" + code + "'") .where("b.booking_id = '#{ id }'")
.group("order_items.item_code")
end end
end end

View File

@@ -32,48 +32,49 @@ class SaleItem < ApplicationRecord
# Calculate food total and beverage total # Calculate food total and beverage total
def self.calculate_food_beverage(sale_items) def self.calculate_food_beverage(sale_items)
food_prices=0
beverage_prices=0
sale_items.each do |si| rebateacc = Account.where("rebate=?",true)
food_price, beverage_price = self.get_price(si.sale_item_id) puts "Account that can rebate"
rebateacc.each do |i|
food_prices = food_prices + food_price puts i.title
beverage_prices = beverage_prices + beverage_price
end end
puts food_prices prices=0
puts beverage_prices sale_items.each do |si|
return food_prices, beverage_prices price = self.get_price(si.sale_item_id,rebateacc)
prices = prices + price
end
return prices
end end
# get food price or beverage price for item # get food price or beverage price for item
def self.get_price(sale_item_id) def self.get_price(sale_item_id,rebateacc)
food_price=0 price=0
beverage_price=0
item=SaleItem.select("sale_items.price , menu_items.account_id") item=SaleItem.select("sale_items.price , menu_items.account_id")
.joins("left join menu_items on menu_items.item_code = sale_items.product_code") .joins("left join menu_items on menu_items.item_code = sale_items.product_code")
.where("sale_items.sale_item_id=?", sale_item_id.to_s) .where("sale_items.sale_item_id=?", sale_item_id.to_s)
if item[0].account_id == 1
food_price = item[0].price rebateacc.each do |i|
else if item[0].account_id == i.id
beverage_price = item[0].price price = item[0].price
end end
return food_price, beverage_price
end
def self.get_overall_discount(sale_id)
price = 0.0
item=SaleItem.where("product_code=?", sale_id)
item.each do|i|
price += i.price
end end
return price return price
end end
# def self.get_overall_discount(sale_id)
# price = 0.0
# item=SaleItem.where("product_code=?", sale_id)
#
# item.each do|i|
# price += i.price
# end
#
# return price
# end
private private
def generate_custom_id def generate_custom_id
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")

View File

@@ -256,7 +256,9 @@ class SalePayment < ApplicationRecord
end end
def rebat(sObj) def rebat(sObj)
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sObj.sale_items) rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
puts "rebate_prices"
puts rebate_prices
generic_customer_id = sObj.customer.membership_id generic_customer_id = sObj.customer.membership_id
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
paypar = sObj.sale_payments paypar = sObj.sale_payments
@@ -266,12 +268,10 @@ class SalePayment < ApplicationRecord
payparcost = payparcost + pp.payment_amount payparcost = payparcost + pp.payment_amount
end end
end end
overall_dis = SaleItem.get_overall_discount(sObj.id) # overall_dis = SaleItem.get_overall_discount(sObj.id)
total_amount = food_prices - payparcost + overall_dis overall_dis = sObj.total_discount
puts "total_amount"
puts food_prices total_amount = rebate_prices - payparcost + overall_dis
puts payparcost
puts total_amount
if total_amount > 0 if total_amount > 0
receipt_no = sObj.receipt_no receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url") membership = MembershipSetting.find_by_membership_type("paypar_url")

View File

@@ -1,16 +1,16 @@
class OrderItemPdf < Prawn::Document 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 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) def initialize(order_item, print_status)
self.page_width = 254 self.page_width = 210
self.page_height = 1450 self.page_height = 2500
self.margin = 10 self.margin = 5
self.price_width = 40 # No Need for item self.price_width = 40 # No Need for item
self.qty_width = 34 self.qty_width = 30
self.total_width = 40 # No Need for item self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width + (self.margin*4)) self.item_width = self.page_width - self.qty_width
self.item_height = 15 self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=80 self.label_width=100
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400])
@@ -21,7 +21,7 @@ class OrderItemPdf < Prawn::Document
self.header_font_size = 14 self.header_font_size = 14
self.item_font_size = 12 self.item_font_size = 12
text "#{order_item.dining}", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order_item.dining+print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
@@ -71,7 +71,7 @@ class OrderItemPdf < Prawn::Document
add_order_items(order_item) add_order_items(order_item)
dash(1, :space => 1, :phase => 1) dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, self.page_width stroke_horizontal_line 0, (self.page_width - self.margin)
move_down 5 move_down 5
end end

View File

@@ -1,13 +1,13 @@
class OrderSummaryPdf < Prawn::Document class OrderSummaryPdf < 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 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) def initialize(order, print_status)
self.page_width = 254 self.page_width = 210
self.page_height = 1450 self.page_height = 2500
self.margin = 10 self.margin = 5
self.price_width = 40 # No Need for item self.price_width = 40 # No Need for item
self.qty_width = 34 self.qty_width = 30
self.total_width = 40 # No Need for item self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width + (self.margin*4)) self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15 self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=100 self.label_width=100
@@ -20,7 +20,7 @@ class OrderSummaryPdf < Prawn::Document
self.header_font_size = 12 self.header_font_size = 12
self.item_font_size = 10 self.item_font_size = 10
text "#{order[0].dining}", :size => self.header_font_size,:align => :center, :left_margin => -20 text "#{ order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
@@ -59,7 +59,7 @@ class OrderSummaryPdf < Prawn::Document
text "Item", :size => self.item_font_size,:align => :left text "Item", :size => self.item_font_size,:align => :left
end end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do bounding_box([self.item_width-2,y_position], :width => self.qty_width, :height => self.item_height) do
text "Qty", :size => self.item_font_size,:align => :left text "Qty", :size => self.item_font_size,:align => :left
end end
@@ -77,16 +77,22 @@ class OrderSummaryPdf < Prawn::Document
move_down 5 move_down 5
order_item.each do|odi| order_item.each do|odi|
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do y_position = cursor
text "#{odi.item_name}", :size => self.item_font_size,:align => :left
# pad_top(15) {
# text_box "#{odi.item_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
# text_box "#{odi.qty}", :at =>[self.item_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
# }
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_name}", :size => self.item_font_size,:align => :left, :height => self.item_height
end end
bounding_box([self.item_width,y_position], :width => self.qty_width, :height => self.item_height) do bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{odi.qty}", :size => self.item_font_size,:align => :left text "#{odi.qty}", :size => self.item_font_size,:align => :left, :height => self.item_height
end
end end
move_down 5 move_down 5
end
end end
end end

View File

@@ -23,6 +23,8 @@
<li><%= link_to "Payment Method", settings_payment_method_settings_path, :tabindex =>"-1" %></li> <li><%= link_to "Payment Method", settings_payment_method_settings_path, :tabindex =>"-1" %></li>
<li><%= link_to "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li> <li><%= link_to "Tax Profile", settings_tax_profiles_path, :tabindex =>"-1" %></li>
<li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li> <li><%= link_to "Print Setting", print_settings_path, :tabindex =>"-1" %></li>
<hr>
<li><%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %></li>
</ul> </ul>
</li> </li>

View File

@@ -49,7 +49,10 @@
<%= qid.qty %> <%= qid.qty %>
</span> ] </span> ]
</h4> </h4>
<!--
Item Options
<p class="card-text">Medium, Fries, Salad</p> <p class="card-text">Medium, Fries, Salad</p>
-->
<p class="card-text"> <p class="card-text">
<small class="text-muted">Order at <small class="text-muted">Order at
<span class="order-at"> <span class="order-at">
@@ -97,7 +100,10 @@
<%= qid.qty %> <%= qid.qty %>
</span> ] </span> ]
</h4> </h4>
<!--
Item Options
<p class="card-text">Medium, Fries, Salad</p> <p class="card-text">Medium, Fries, Salad</p>
-->
<p class="card-text"> <p class="card-text">
<small class="text-muted">Order at <small class="text-muted">Order at
<span class="order-at"> <span class="order-at">

View File

@@ -6,7 +6,7 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12"> <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> <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="<%= @food_prices %>" data-value="<%=@sale_id %>" data-member-value="<%= @membership_id %>"> <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 %>">
</div> </div>
<hr> <hr>
</div> </div>
@@ -38,10 +38,10 @@
<!-- <% if @payparcount > 0 %> <!-- <% if @payparcount > 0 %>
<p class="">Last time rebate amount is <%= @payparcount %></p> <p class="">Last time rebate amount is <%= @payparcount %></p>
<% end %> <% end %>
<p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @food_prices %></span></p> --> <p class="">You can rebate upto <span style="color:red;" id="food_prices"><%= @redeem_prices %></span></p> -->
</div> </div>
<div class="col-lg-7 col-md-7 col-sm-7"> <div class="col-lg-6 col-md-7 col-sm-7">
<div class="row"> <div class="row">
<div class="col-lg-6 col-md-1 col-sm-1"> <div class="col-lg-6 col-md-1 col-sm-1">
@@ -84,8 +84,14 @@
<div class="pay purple" id="redeem">Pay</div> <div class="pay purple" id="redeem">Pay</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-lg btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment';"> Back </button>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@@ -145,7 +151,7 @@ $("#redeem").click(function(){
}else if(valid_amount< redeem_amount){ }else if(valid_amount< redeem_amount){
alert(" Insufficient Amount!") alert(" Insufficient Amount!")
}else{ }else{
if(redeem_amount <= "<%= @food_prices %>"){ if(redeem_amount <= "<%= @redeem_prices %>"){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<%=origami_payment_paypar_path%>", url: "<%=origami_payment_paypar_path%>",

View File

@@ -4,6 +4,10 @@
<div class="form-inputs"> <div class="form-inputs">
<%= f.input :title %> <%= f.input :title %>
<%= f.input :account_type, :collection => Lookup.collection_of("account_type") %> <%= f.input :account_type, :collection => Lookup.collection_of("account_type") %>
<%= f.input :discount %>
<%= f.input :point %>
<%= f.input :bonus %>
<%= f.input :rebate %>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@@ -11,4 +15,3 @@
</div> </div>
<% end %> <% end %>

View File

@@ -14,9 +14,14 @@
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th style="width:40%">Title</th> <th>Title</th>
<th style="width:40%">Account Type</th> <th>Account Type</th>
<th style="width:20%">Action</th> <th>Can get Discount</th>
<th>Can get Points</th>
<th>Can get Bonus</th>
<th>Can rebate</th>
<th style="">Action</th>
</tr> </tr>
</thead> </thead>
@@ -25,6 +30,10 @@
<tr> <tr>
<td><%= account.title %></td> <td><%= account.title %></td>
<td><%= account.account_type %></td> <td><%= account.account_type %></td>
<td><%= account.discount %></td>
<td><%= account.point %></td>
<td><%= account.bonus %></td>
<td><%= account.rebate %></td>
<td> <td>
<%= link_to 'Edit', edit_settings_account_path(account) %> | <%= link_to 'Edit', edit_settings_account_path(account) %> |
<%= link_to 'Destroy', settings_account_path(account), method: :delete, data: { confirm: 'Are you sure?' } %> <%= link_to 'Destroy', settings_account_path(account), method: :delete, data: { confirm: 'Are you sure?' } %>

View File

@@ -17,6 +17,10 @@
<tr> <tr>
<th>Title</th> <th>Title</th>
<th>Account type</th> <th>Account type</th>
<th>Can get Discount</th>
<th>Can get Points</th>
<th>Can get Bonus</th>
<th>Can rebate</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
</thead> </thead>
@@ -25,6 +29,10 @@
<tr> <tr>
<td><%= @settings_account.title %></td> <td><%= @settings_account.title %></td>
<td><%= @settings_account.account_type %></td> <td><%= @settings_account.account_type %></td>
<td><%= @settings_account.discount %></td>
<td><%= @settings_account.point %></td>
<td><%= @settings_account.bonus %></td>
<td><%= @settings_account.rebate %></td>
<td><%= link_to 'Edit', edit_settings_account_path(@settings_account, @settings_account) %></td> <td><%= link_to 'Edit', edit_settings_account_path(@settings_account, @settings_account) %></td>
</tr> </tr>

View File

@@ -9,7 +9,6 @@
<%= f.input :auth_token %> <%= f.input :auth_token %>
<%= f.input :merchant_account_id %> <%= f.input :merchant_account_id %>
<%= f.input :created_by %> <%= f.input :created_by %>
<%= f.input :additional_parameter %>
</div> </div>
<div class="form-actions"> <div class="form-actions">

View File

@@ -1,8 +1,17 @@
<p id="notice"><%= notice %></p>
<h1>Settings Membership Actions</h1> <div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li>Settings Membership Actions</li>
<span style="float: right">
<%= link_to 'New Settings Membership Action', new_settings_membership_action_path,:class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</div>
<table> <br>
<div class="card">
<table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Membership type</th> <th>Membership type</th>
@@ -35,7 +44,4 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
</div>
<br>
<%= link_to 'New Settings Membership Action', new_settings_membership_action_path %>

View File

@@ -13,6 +13,7 @@ div.form-inputs span{
<%= f.input :printer_name %> <%= f.input :printer_name %>
<%= f.input :font_size %> <%= f.input :font_size %>
<%= f.input :print_copy %> <%= f.input :print_copy %>
<%= f.hidden_field :processing_items %>
<%= f.label "Select Zones", :class => 'control-label' %> <%= f.label "Select Zones", :class => 'control-label' %>
<%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'ta'%> <%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'ta'%>
<%= f.input :cut_per_item %> <%= f.input :cut_per_item %>

View File

@@ -7,7 +7,6 @@
<%= f.input :seater %> <%= f.input :seater %>
<%= f.input :order_by %> <%= f.input :order_by %>
<%= f.input :is_active %> <%= f.input :is_active %>
<%= f.input :created_by, :collection => Employee.collection %>
</div> </div>
<div class="form-actions"> <div class="form-actions">

View File

@@ -7,7 +7,6 @@
<%= f.input :seater %> <%= f.input :seater %>
<%= f.input :order_by %> <%= f.input :order_by %>
<%= f.input :is_active %> <%= f.input :is_active %>
<%= f.input :created_by, :collection => Employee.collection %>
</div> </div>
<div class="form-actions"> <div class="form-actions">

View File

@@ -4,7 +4,7 @@
<div class="form-inputs"> <div class="form-inputs">
<%= f.input :name %> <%= f.input :name %>
<%= f.input :is_active %> <%= f.input :is_active %>
<%= f.input :created_by, :collection => Employee.collection %> <!-- <%= f.input :created_by, :collection => Employee.collection %> -->
</div> </div>
<div class="form-actions"> <div class="form-actions">

View File

@@ -3,6 +3,10 @@ class CreateAccounts < ActiveRecord::Migration[5.1]
create_table :accounts do |t| create_table :accounts do |t|
t.string :title t.string :title
t.string :account_type t.string :account_type
t.boolean :discount, :null => false, :default => false
t.boolean :point, :null => false, :default => false
t.boolean :bonus, :null => false, :default => false
t.boolean :rebate, :null => false, :default => false
t.timestamps t.timestamps
end end