merge with discount

This commit is contained in:
Yan
2017-06-29 11:41:29 +06:30
13 changed files with 374 additions and 126 deletions

View File

@@ -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)
end
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
# Not Use for these printed bill cannot give customer
# @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
shop_details = Shop.find(1)
# customer= Customer.find(@sale_data.customer_id)
# # get member information
# member_info = Customer.get_member_account(customer)
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)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# # Calculate Price by accounts
# item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
# Calculate Price by accounts
item_price_by_accounts = SaleItem.calculate_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, 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

View File

@@ -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.sale_id.nil?
sale_status = check_order_with_booking(booking)
puts "WWwwWWWWWWww"
puts sale_status
if sale_status
return false
return false , @message = "bill requested"
end
else
@order.new_booking = false
@@ -77,22 +79,38 @@ class Api::OrdersController < Api::ApiController
end
else
sale_status = check_order_with_table(params[:table_id])
puts "OOOOOOOOO"
puts sale_status
if sale_status
return false
return false , @message = "bill requested"
end
end
end #booking exists
else
check_order_with_table(params[:table_id])
end
sale_status = check_order_with_table(params[:table_id])
puts "MMMMMMMM"
puts sale_status
if sale_status
return false , @message = "bill requested"
end
end
@status, @booking = @order.generate
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)
table = DiningFacility.find(table_id)
if table
booking = table.get_current_booking
puts booking
if booking
if booking.sale.sale_status == "completed" || booking.sale.sale_status == "billed"
@order.new_booking = true