merge with discount
This commit is contained in:
@@ -25,26 +25,26 @@ class Api::BillController < Api::ApiController
|
|||||||
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
|
||||||
end
|
end
|
||||||
|
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
# Not Use for these printed bill cannot give customer
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
# @sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
|
# @sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||||
|
|
||||||
unique_code = "ReceiptBillPdf"
|
# unique_code = "ReceiptBillPdf"
|
||||||
|
# #shop detail
|
||||||
|
# shop_details = Shop.find(1)
|
||||||
|
|
||||||
#shop detail
|
# customer= Customer.find(@sale_data.customer_id)
|
||||||
shop_details = Shop.find(1)
|
# # get member information
|
||||||
|
# member_info = Customer.get_member_account(customer)
|
||||||
|
|
||||||
customer= Customer.find(@sale_data.customer_id)
|
# # get printer info
|
||||||
# get member information
|
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
member_info = Customer.get_member_account(customer)
|
|
||||||
|
|
||||||
# get printer info
|
# # Calculate Price by accounts
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||||
|
|
||||||
# Calculate Price by accounts
|
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
|
||||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,10 @@ class Api::OrdersController < Api::ApiController
|
|||||||
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
if booking.dining_facility_id.to_i == params[:table_id].to_i && booking.booking_status != 'moved'
|
||||||
if !booking.sale_id.nil?
|
if !booking.sale_id.nil?
|
||||||
sale_status = check_order_with_booking(booking)
|
sale_status = check_order_with_booking(booking)
|
||||||
|
puts "WWwwWWWWWWww"
|
||||||
|
puts sale_status
|
||||||
if sale_status
|
if sale_status
|
||||||
return false
|
return false , @message = "bill requested"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@order.new_booking = false
|
@order.new_booking = false
|
||||||
@@ -77,22 +79,38 @@ class Api::OrdersController < Api::ApiController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
sale_status = check_order_with_table(params[:table_id])
|
sale_status = check_order_with_table(params[:table_id])
|
||||||
|
puts "OOOOOOOOO"
|
||||||
|
puts sale_status
|
||||||
if sale_status
|
if sale_status
|
||||||
return false
|
return false , @message = "bill requested"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end #booking exists
|
end #booking exists
|
||||||
else
|
else
|
||||||
check_order_with_table(params[:table_id])
|
sale_status = check_order_with_table(params[:table_id])
|
||||||
end
|
puts "MMMMMMMM"
|
||||||
|
puts sale_status
|
||||||
|
if sale_status
|
||||||
|
return false , @message = "bill requested"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@status, @booking = @order.generate
|
@status, @booking = @order.generate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# render json for http status code 202
|
||||||
|
def return_json_status_with_code(code, msg, booking_id)
|
||||||
|
render status: code, json: {
|
||||||
|
message: msg,
|
||||||
|
booking_id: booking_id
|
||||||
|
}.to_json
|
||||||
|
end
|
||||||
|
|
||||||
def check_order_with_table(table_id)
|
def check_order_with_table(table_id)
|
||||||
table = DiningFacility.find(table_id)
|
table = DiningFacility.find(table_id)
|
||||||
if table
|
if table
|
||||||
booking = table.get_current_booking
|
booking = table.get_current_booking
|
||||||
|
puts booking
|
||||||
if booking
|
if booking
|
||||||
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
|
||||||
@order.new_booking = true
|
@order.new_booking = true
|
||||||
|
|||||||
@@ -4,6 +4,34 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
def index
|
def index
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def first_bill
|
||||||
|
sale_id = params[:sale_id] # sale_id
|
||||||
|
sale_data = Sale.find_by_sale_id(sale_id)
|
||||||
|
sale_items = SaleItem.where("sale_id=?",sale_id)
|
||||||
|
|
||||||
|
# Print for First Bill to Customer
|
||||||
|
unique_code = "ReceiptBillPdf"
|
||||||
|
#shop detail
|
||||||
|
shop_details = Shop.find(1)
|
||||||
|
# customer= Customer.where('customer_id=' +.customer_id)
|
||||||
|
customer= Customer.find(sale_data.customer_id)
|
||||||
|
# get member information
|
||||||
|
member_info = Customer.get_member_account(customer)
|
||||||
|
# get printer info
|
||||||
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|
||||||
|
# find order id by sale id
|
||||||
|
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||||
|
|
||||||
|
# Calculate price_by_accounts
|
||||||
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale_items)
|
||||||
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale_items)
|
||||||
|
|
||||||
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
|
printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details)
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
cash = params[:cash]
|
cash = params[:cash]
|
||||||
sale_id = params[:sale_id]
|
sale_id = params[:sale_id]
|
||||||
@@ -26,9 +54,10 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
# Calculate Food and Beverage Total
|
# Calculate Food and Beverage Total
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -104,10 +133,9 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
# Calculate price_by_accounts
|
# Calculate price_by_accounts
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||||
|
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||||
if check_booking.sale_id.nil?
|
if check_booking.sale_id.nil?
|
||||||
# Create Sale if it doesn't exist
|
# Create Sale if it doesn't exist
|
||||||
puts "current_login_employee"
|
# puts "current_login_employee"
|
||||||
puts current_login_employee.name
|
# puts current_login_employee.name
|
||||||
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
|
@status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, cashier = nil)
|
||||||
@sale_data = Sale.find_by_sale_id(@sale_id)
|
@sale_data = Sale.find_by_sale_id(@sale_id)
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
||||||
@@ -20,26 +20,25 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
@sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
unique_code = "ReceiptBillPdf"
|
# Not Use for these printed bill cannot give customer
|
||||||
#shop detail
|
# unique_code = "ReceiptBillPdf"
|
||||||
shop_details = Shop.find(1)
|
# #shop detail
|
||||||
# customer= Customer.where('customer_id=' +.customer_id)
|
# shop_details = Shop.find(1)
|
||||||
customer= Customer.find(@sale_data.customer_id)
|
# # customer= Customer.where('customer_id=' +.customer_id)
|
||||||
# get member information
|
# customer= Customer.find(@sale_data.customer_id)
|
||||||
member_info = Customer.get_member_account(customer)
|
# # get member information
|
||||||
# get printer info
|
# member_info = Customer.get_member_account(customer)
|
||||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
# # get printer info
|
||||||
|
# print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||||
|
|
||||||
# find order id by sale id
|
# # find order id by sale id
|
||||||
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
# # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
|
||||||
|
|
||||||
# Calculate price_by_accounts
|
# # Calculate price_by_accounts
|
||||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
|
||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
# printer = Printer::ReceiptPrinter.new(print_settings)
|
||||||
|
|
||||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
|
||||||
# redirect_to origami_path(@sale_data.sale_id)
|
|
||||||
|
|
||||||
|
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Origami::SaleEditController < BaseOrigamiController
|
|||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
@newsaleitem.qty = saleitemObj.qty * -1
|
@newsaleitem.qty = saleitemObj.qty * -1
|
||||||
@newsaleitem.price = saleitemObj.price * -1
|
@newsaleitem.price = saleitemObj.price * -1
|
||||||
|
@newsaleitem.is_taxable = 0
|
||||||
@newsaleitem.product_name = saleitemObj.product_name + " - void"
|
@newsaleitem.product_name = saleitemObj.product_name + " - void"
|
||||||
@newsaleitem.save
|
@newsaleitem.save
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,9 +25,8 @@ class Order < ApplicationRecord
|
|||||||
booking = nil
|
booking = nil
|
||||||
|
|
||||||
if self.new_booking
|
if self.new_booking
|
||||||
|
|
||||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||||
:checkin_at => Time.now.utc.getlocal, :checkin_by => self.employee_name,
|
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||||
:booking_status => "assign" })
|
:booking_status => "assign" })
|
||||||
table = DiningFacility.find(self.table_id)
|
table = DiningFacility.find(self.table_id)
|
||||||
table.status = "occupied"
|
table.status = "occupied"
|
||||||
@@ -55,7 +54,7 @@ class Order < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false, @message = "booking fail"
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#Bill Receipt Print
|
||||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
|
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details)
|
||||||
#Use CUPS service
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount,shop_details)
|
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details)
|
||||||
|
|
||||||
# print as print copies in printer setting
|
# print as print copies in printer setting
|
||||||
count = printer_settings.print_copies
|
count = printer_settings.print_copies
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ class SaleItem < ApplicationRecord
|
|||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get Prices for each accounts (eg: food, beverage)
|
||||||
def self.calculate_price_by_accounts(sale_items)
|
def self.calculate_price_by_accounts(sale_items)
|
||||||
price_accounts = []
|
price_accounts = []
|
||||||
Account.all.each do |a|
|
Account.all.each do |a|
|
||||||
account_price = {:name => a.title, :price => 0}
|
account_price = {:name => a.title, :price => 0}
|
||||||
|
|
||||||
|
# Check for actual sale items
|
||||||
sale_items.each do |si|
|
sale_items.each do |si|
|
||||||
if si.account_id == a.id
|
if si.account_id == a.id
|
||||||
account_price[:price] = account_price[:price] + si.price
|
account_price[:price] = account_price[:price] + si.price
|
||||||
@@ -46,6 +48,24 @@ class SaleItem < ApplicationRecord
|
|||||||
return price_accounts
|
return price_accounts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get discount Prices for each accounts (eg: food, beverage)
|
||||||
|
def self.get_discount_price_by_accounts(sale_items)
|
||||||
|
discount_accounts = []
|
||||||
|
Account.all.each do |a|
|
||||||
|
discount_account = {:name => a.title, :price => 0}
|
||||||
|
|
||||||
|
# Check for actual sale items
|
||||||
|
sale_items.where("is_taxable = 0 AND remark = 'Discount'").find_each do |si|
|
||||||
|
if si.account_id == a.id
|
||||||
|
discount_account[:price] = (discount_account[:price] + si.price) * -1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
discount_accounts.push(discount_account)
|
||||||
|
end
|
||||||
|
|
||||||
|
return discount_accounts
|
||||||
|
end
|
||||||
|
|
||||||
# Calculate rebate_by_account
|
# Calculate rebate_by_account
|
||||||
def self.calculate_rebate_by_account(sale_items)
|
def self.calculate_rebate_by_account(sale_items)
|
||||||
rebateacc = Account.where("rebate=?",true)
|
rebateacc = Account.where("rebate=?",true)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class ReceiptBillPdf < Prawn::Document
|
class ReceiptBillPdf < 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(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details)
|
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details)
|
||||||
self.page_width = 210
|
self.page_width = 210
|
||||||
self.page_height = 7000
|
self.page_height = 7000
|
||||||
self.margin = 5
|
self.margin = 5
|
||||||
@@ -39,6 +39,10 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
|
|
||||||
customer(customer_name)
|
customer(customer_name)
|
||||||
|
|
||||||
|
if discount_price_by_accounts.length > 0
|
||||||
|
discount_account(discount_price_by_accounts)
|
||||||
|
end
|
||||||
|
|
||||||
items_account(item_price_by_accounts)
|
items_account(item_price_by_accounts)
|
||||||
|
|
||||||
footer
|
footer
|
||||||
@@ -158,7 +162,7 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
y_position = cursor
|
y_position = cursor
|
||||||
|
|
||||||
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
text "Discount", :size => self.item_font_size,:align => :left
|
text "Overall Discount", :size => self.item_font_size,:align => :left
|
||||||
end
|
end
|
||||||
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right
|
||||||
@@ -302,6 +306,22 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def discount_account(discount_price_by_accounts)
|
||||||
|
move_down 5
|
||||||
|
stroke_horizontal_rule
|
||||||
|
move_down 5
|
||||||
|
y_position = cursor
|
||||||
|
discount_price_by_accounts.each do |ipa|
|
||||||
|
y_position = cursor
|
||||||
|
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
|
||||||
|
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
|
||||||
|
end
|
||||||
|
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
|
||||||
|
text "(" + "#{ ipa[:price] }" + ")" , :size => self.item_font_size,:align => :right
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def items_account(item_price_by_accounts)
|
def items_account(item_price_by_accounts)
|
||||||
move_down 5
|
move_down 5
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|||||||
@@ -289,6 +289,7 @@
|
|||||||
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
|
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
|
||||||
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
||||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||||
|
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First Bill</button>
|
||||||
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</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>
|
<button type="button" class="btn btn-primary btn-block" disabled> Void </button>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -297,6 +298,7 @@
|
|||||||
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
|
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
|
||||||
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
|
||||||
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
|
||||||
|
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||||
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
|
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -391,7 +393,18 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Print for first bill
|
||||||
|
$("#first_bill").on('click', function(){
|
||||||
|
var sale_id = $('#sale_id').val();
|
||||||
|
var ajax_url = "/origami/sale/"+ sale_id + "/first_bill";
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: ajax_url,
|
||||||
|
success:function(result){
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$('#pay').on('click',function() {
|
$('#pay').on('click',function() {
|
||||||
var sale_id = $('#sale_id').val();
|
var sale_id = $('#sale_id').val();
|
||||||
@@ -403,9 +416,9 @@ $('#request_bills').click(function() {
|
|||||||
var order_id = $('#save_order_id').attr('data-order');
|
var order_id = $('#save_order_id').attr('data-order');
|
||||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "GET",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'order_id='+ order_id,
|
// data: 'order_id='+ order_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -469,31 +482,29 @@ function show_customer_details(customer_id){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
//End Ajax
|
//End Ajax
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#edit').on('click',function(){
|
$('#edit').on('click',function(){
|
||||||
var dining_id = "<%= @dining.id %>"
|
var dining_id = "<%= @dining.id %>"
|
||||||
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||||
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
|
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
|
||||||
})
|
});
|
||||||
|
|
||||||
$('#void').on('click',function () {
|
$('#void').on('click',function () {
|
||||||
var sure = confirm("Are you sure want to Void");
|
var sure = confirm("Are you sure want to Void");
|
||||||
if (sure == true) {
|
if (sure == true) {
|
||||||
var sale_id = $('#sale_id').val();
|
var sale_id = $('#sale_id').val();
|
||||||
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
success: function () {
|
success: function () {
|
||||||
window.location.href = '/origami/';
|
window.location.href = '/origami/';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -268,61 +268,128 @@
|
|||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<!-- Waiter Buttons -->
|
<!-- Waiter Buttons -->
|
||||||
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
|
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
|
||||||
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
|
<% if @dining.bookings.length >= 1 %>
|
||||||
<button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
|
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</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' && @status_sale != 'sale' %>
|
||||||
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
<button type="button" class="btn btn-primary btn-block" >Add Order</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
|
||||||
|
<button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
|
||||||
|
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
|
||||||
|
<button type="button" id="first_bill" class="btn btn-primary btn-block" disabled>First 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" disabled>Add Order</button>
|
||||||
|
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
|
||||||
|
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
|
||||||
|
<button type="button" 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="first_bill" class="btn btn-primary btn-block">First Bill</button>
|
||||||
|
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
||||||
|
<button type="button" id="void" class="btn btn-primary btn-block" > Void </button>
|
||||||
|
<% end %>
|
||||||
<!-- Cashier Buttons -->
|
<!-- Cashier Buttons -->
|
||||||
<button type="button" id="discount" class="btn btn-primary btn-block">Discount</button>
|
|
||||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
|
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button> -->
|
||||||
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
|
<% end %>
|
||||||
<!-- <button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button> -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
// $(".tables").on('click', function(){
|
||||||
|
// var customer_id=$(".customer-id").text();
|
||||||
|
// show_customer_details(customer_id);
|
||||||
|
|
||||||
|
// var dining_id = $(this).attr("data-id");
|
||||||
|
// window.location.href = '/origami/table/' + dining_id;
|
||||||
|
// })
|
||||||
|
// $(".sales").on('click',function(){
|
||||||
|
// var customer_id=$(".customer-id").text();
|
||||||
|
// show_customer_details(customer_id);
|
||||||
|
|
||||||
|
// var sale_id = $(this).attr("data-id");
|
||||||
|
// window.location.href = '/origami/sale/' + sale_id;
|
||||||
|
// })
|
||||||
|
// $(".rooms").on('click', function(){
|
||||||
|
// var customer_id=$(".customer-id").text();
|
||||||
|
// show_customer_details(customer_id);
|
||||||
|
|
||||||
|
// var dining_id = $(this).attr("data-id");
|
||||||
|
// window.location.href = '/origami/room/' + dining_id;
|
||||||
|
// })
|
||||||
|
// $(".orders").on('click',function(){
|
||||||
|
// var customer_id=$(".customer-id").text();
|
||||||
|
// show_customer_details(customer_id);
|
||||||
|
|
||||||
|
// var order_id = $(this).attr("data-id");
|
||||||
|
// window.location.href = '/origami/order/' + order_id;
|
||||||
|
// })
|
||||||
|
|
||||||
|
$('.invoicedetails').on('click',function(){
|
||||||
|
var dining_id = "<%= @dining.id %>";
|
||||||
|
var sale_id = this.id;
|
||||||
|
window.location.href = '/origami/table/'+ dining_id + "/table_invoice/"+sale_id;
|
||||||
|
})
|
||||||
$(".tables").on('click', function(){
|
$(".tables").on('click', function(){
|
||||||
|
|
||||||
var customer_id=$(".customer-id").text();
|
var customer_id=$(".customer-id").text();
|
||||||
show_customer_details(customer_id);
|
show_customer_details(customer_id);
|
||||||
|
|
||||||
var dining_id = $(this).attr("data-id");
|
var dining_id = $(this).attr("data-id");
|
||||||
window.location.href = '/origami/table/' + dining_id;
|
window.location.href = '/origami/table/' + dining_id;
|
||||||
})
|
});
|
||||||
|
|
||||||
$(".sales").on('click',function(){
|
$(".sales").on('click',function(){
|
||||||
|
|
||||||
var customer_id=$(".customer-id").text();
|
var customer_id=$(".customer-id").text();
|
||||||
show_customer_details(customer_id);
|
show_customer_details(customer_id);
|
||||||
|
|
||||||
var sale_id = $(this).attr("data-id");
|
var sale_id = $(this).attr("data-id");
|
||||||
window.location.href = '/origami/sale/' + sale_id;
|
window.location.href = '/origami/sale/' + sale_id;
|
||||||
})
|
});
|
||||||
|
|
||||||
$(".rooms").on('click', function(){
|
$(".rooms").on('click', function(){
|
||||||
|
|
||||||
var customer_id=$(".customer-id").text();
|
var customer_id=$(".customer-id").text();
|
||||||
show_customer_details(customer_id);
|
show_customer_details(customer_id);
|
||||||
|
|
||||||
var dining_id = $(this).attr("data-id");
|
var dining_id = $(this).attr("data-id");
|
||||||
window.location.href = '/origami/room/' + dining_id;
|
window.location.href = '/origami/room/' + dining_id;
|
||||||
})
|
});
|
||||||
|
|
||||||
$(".orders").on('click',function(){
|
$(".orders").on('click',function(){
|
||||||
|
|
||||||
var customer_id=$(".customer-id").text();
|
var customer_id=$(".customer-id").text();
|
||||||
show_customer_details(customer_id);
|
show_customer_details(customer_id);
|
||||||
|
|
||||||
var order_id = $(this).attr("data-id");
|
var order_id = $(this).attr("data-id");
|
||||||
window.location.href = '/origami/order/' + order_id;
|
window.location.href = '/origami/order/' + order_id;
|
||||||
})
|
});
|
||||||
|
|
||||||
// bind customer to order or sale
|
// bind customer to order or sale
|
||||||
$("#customer").on('click', function(){
|
$("#customer").on('click', function(){
|
||||||
var sale = $('#sale_id').val();
|
var sale = $('#sale_id').val();
|
||||||
if (sale) {
|
if (sale) {
|
||||||
var sale_id = sale
|
var sale_id = sale
|
||||||
}else{
|
}else{
|
||||||
var sale_id = $('#save_order_id').attr('data-order');
|
var sale_id = $('#save_order_id').attr('data-order');
|
||||||
}
|
}
|
||||||
|
var table_id = $('.tables').attr("data-id");
|
||||||
|
|
||||||
window.location.href = '/origami/'+ sale_id + "/customers"
|
window.location.href = '/origami/'+ sale_id + "/customers"
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#re-print').click(function() {
|
||||||
|
var sale_id = $('#sale_id').val();
|
||||||
|
window.location.href = '/origami/'+ sale_id + "/reprint"
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Discount for Payment
|
// Discount for Payment
|
||||||
$('#discount').click(function() {
|
$('#discount').click(function() {
|
||||||
var sale = $('#sale_id').val();
|
var sale = $('#sale_id').val();
|
||||||
@@ -341,6 +408,20 @@ $("#customer").on('click', function(){
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Print for first bill
|
||||||
|
$("#first_bill").on('click', function(){
|
||||||
|
var sale_id = $('#sale_id').val();
|
||||||
|
var ajax_url = "/origami/sale/"+ sale_id + "/first_bill";
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: ajax_url,
|
||||||
|
success:function(result){
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -354,9 +435,9 @@ $('#request_bills').click(function() {
|
|||||||
var order_id = $('#save_order_id').attr('data-order');
|
var order_id = $('#save_order_id').attr('data-order');
|
||||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "GET",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
data: 'order_id='+ order_id,
|
// data: 'order_id='+ order_id,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
@@ -373,39 +454,109 @@ $('#back').on('click',function(){
|
|||||||
window.location.href = '/origami/';
|
window.location.href = '/origami/';
|
||||||
})
|
})
|
||||||
|
|
||||||
//show cusotmer rebate amount
|
$('#add_invoice').on('click',function(){
|
||||||
function show_customer_details(customer_id){
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// //show cusotmer rebate amount
|
||||||
|
// function show_customer_details(customer_id){
|
||||||
|
// var url = '<%= @show_customer_details_path %>'
|
||||||
|
// //Start Ajax
|
||||||
|
// $.ajax({
|
||||||
|
// type: "GET",
|
||||||
|
// url: url,
|
||||||
|
// data: {},
|
||||||
|
// dataType: "json",
|
||||||
|
// success: function(data) {
|
||||||
|
// $("#customer_name").text(data["customer"].name);
|
||||||
|
// if (data["response_data"]["data"].length) {
|
||||||
|
// $.each(data["response_data"]["data"], function (i) {
|
||||||
|
// if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
|
||||||
|
// var balance = data["response_data"]["data"][i]["balance"];
|
||||||
|
// if (data["response_data"]["status"]==true) {
|
||||||
|
// $('.rebate_amount').removeClass('hide');
|
||||||
|
// row =
|
||||||
|
// '<td class="charges-name">' + "Rebate Balance" +'</td>'
|
||||||
|
// +'<td class="item-attr">' + balance + '</td>';
|
||||||
|
|
||||||
|
// $(".rebate_amount").html(row);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }else{
|
||||||
|
// $('.rebate_amount').addClass('hide');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// //End Ajax
|
||||||
|
// }
|
||||||
|
|
||||||
|
//show cusotmer rebate amount
|
||||||
|
function show_customer_details(customer_id){
|
||||||
var url = '<%= @show_customer_details_path %>'
|
var url = '<%= @show_customer_details_path %>'
|
||||||
|
//Start Ajax
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: url,
|
||||||
|
data: {},
|
||||||
|
dataType: "json",
|
||||||
|
success: function(data) {
|
||||||
|
$("#customer_name").text(data["customer"].name);
|
||||||
|
if (data["response_data"]["data"].length) {
|
||||||
|
$.each(data["response_data"]["data"], function (i) {
|
||||||
|
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
|
||||||
|
var balance = data["response_data"]["data"][i]["balance"];
|
||||||
|
if (data["response_data"]["status"]==true) {
|
||||||
|
$('.rebate_amount').removeClass('hide');
|
||||||
|
row =
|
||||||
|
'<td class="charges-name">' + "Rebate Balance" +'</td>'
|
||||||
|
+'<td class="item-attr">' + balance + '</td>';
|
||||||
|
|
||||||
//Start Ajax
|
$(".rebate_amount").html(row);
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: url,
|
|
||||||
data: {},
|
|
||||||
dataType: "json",
|
|
||||||
success: function(data) {
|
|
||||||
$("#customer_name").text(data["customer"].name);
|
|
||||||
if (data["response_data"]["data"].length) {
|
|
||||||
$.each(data["response_data"]["data"], function (i) {
|
|
||||||
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
|
|
||||||
var balance = data["response_data"]["data"][i]["balance"];
|
|
||||||
if (data["response_data"]["status"]==true) {
|
|
||||||
$('.rebate_amount').removeClass('hide');
|
|
||||||
row =
|
|
||||||
'<td class="charges-name">' + "Rebate Balance" +'</td>'
|
|
||||||
+'<td class="item-attr">' + balance + '</td>';
|
|
||||||
|
|
||||||
$(".rebate_amount").html(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}else{
|
|
||||||
$('.rebate_amount').addClass('hide');
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}else{
|
||||||
//End Ajax
|
$('.rebate_amount').addClass('hide');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//End Ajax
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#edit').on('click',function(){
|
||||||
|
var dining_id = "<%= @dining.id %>"
|
||||||
|
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
|
||||||
|
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#void').on('click',function () {
|
||||||
|
var sure = confirm("Are you sure want to Void");
|
||||||
|
if (sure == true) {
|
||||||
|
var sale_id = $('#sale_id').val();
|
||||||
|
var ajax_url = "/origami/sale/" + sale_id + '/void';
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: ajax_url,
|
||||||
|
success: function () {
|
||||||
|
window.location.href = '/origami/';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module SXRestaurants
|
|||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
config.active_record.time_zone_aware_types = [:datetime, :time]
|
config.active_record.time_zone_aware_types = [:datetime, :time]
|
||||||
config.active_job.queue_adapter = :sidekiq
|
config.active_job.queue_adapter = :sidekiq
|
||||||
# config.time_zone = 'Asia/Rangoon'
|
config.time_zone = 'Asia/Rangoon'
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ Rails.application.routes.draw do
|
|||||||
get "/:id/remove_all_discount" => "discounts#remove_all_discount"
|
get "/:id/remove_all_discount" => "discounts#remove_all_discount"
|
||||||
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
|
post "/:id/remove_discount_items" => "discounts#remove_discount_items"
|
||||||
|
|
||||||
post "/:id/request_bills" => "request_bills#print",:as => "request_bill" ,:defaults => { :format => 'json' }
|
get "/:id/request_bills" => "request_bills#print",:as => "request_bill"
|
||||||
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
|
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
|
||||||
|
|
||||||
#---------Shift ---------------#
|
#---------Shift ---------------#
|
||||||
@@ -112,6 +112,7 @@ Rails.application.routes.draw do
|
|||||||
#payment - Outing payments - Cash only [ *Misc expeness tracking]
|
#payment - Outing payments - Cash only [ *Misc expeness tracking]
|
||||||
|
|
||||||
#--------- Payment ------------#
|
#--------- Payment ------------#
|
||||||
|
get 'sale/:sale_id/first_bill' => 'payments#first_bill', :defaults => { :format => 'json' }
|
||||||
get 'sale/:sale_id/payment' => 'payments#show'
|
get 'sale/:sale_id/payment' => 'payments#show'
|
||||||
|
|
||||||
post 'payment/cash' => 'payments#create'
|
post 'payment/cash' => 'payments#create'
|
||||||
|
|||||||
Reference in New Issue
Block a user