accounts and discount updated
This commit is contained in:
@@ -18,14 +18,15 @@ class OrderQueueStation < ApplicationRecord
|
||||
order_items = order.order_items
|
||||
|
||||
# get dining
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
|
||||
#Assign OQS id to order Items
|
||||
oqs_stations.each do |oqs|
|
||||
oqs_stations.each do |oqs|
|
||||
is_auto_printed = false
|
||||
#Get List of items -
|
||||
pq_items = JSON.parse(oqs.processing_items)
|
||||
|
||||
#Loop through the processing items
|
||||
#Loop through the processing items
|
||||
pq_items.each do |pq_item|
|
||||
#Processing through the looping items
|
||||
order_items.each do |order_item|
|
||||
@@ -36,11 +37,13 @@ class OrderQueueStation < ApplicationRecord
|
||||
# else
|
||||
|
||||
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
|
||||
# end
|
||||
|
||||
if oqs.auto_print
|
||||
# end
|
||||
|
||||
# Auto Printing
|
||||
if oqs.auto_print && is_auto_printed == false
|
||||
print_slip(oqs, order, order_items)
|
||||
end
|
||||
is_auto_printed = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil)
|
||||
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount)
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount)
|
||||
|
||||
pdf.render_file "tmp/receipt_bill.pdf"
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
|
||||
@@ -30,9 +30,24 @@ class SaleItem < ApplicationRecord
|
||||
# end
|
||||
end
|
||||
|
||||
# Calculate food total and beverage total
|
||||
def self.calculate_food_beverage(sale_items)
|
||||
def self.calculate_price_by_accounts(sale_items)
|
||||
price_accounts = []
|
||||
Account.all.each do |a|
|
||||
account_price = {:name => a.title, :price => 0}
|
||||
|
||||
sale_items.each do |si|
|
||||
if si.account_id == a.id
|
||||
account_price[:price] = account_price[:price] + si.price
|
||||
end
|
||||
end
|
||||
price_accounts.push(account_price)
|
||||
end
|
||||
|
||||
return price_accounts
|
||||
end
|
||||
|
||||
# Calculate rebate_by_account
|
||||
def self.calculate_rebate_by_account(sale_items)
|
||||
rebateacc = Account.where("rebate=?",true)
|
||||
puts "Account that can rebate"
|
||||
rebateacc.each do |i|
|
||||
@@ -40,7 +55,7 @@ class SaleItem < ApplicationRecord
|
||||
end
|
||||
prices=0
|
||||
sale_items.each do |si|
|
||||
price = self.get_price(si.sale_item_id,rebateacc)
|
||||
price = self.get_rebate_price(si.sale_item_id,rebateacc)
|
||||
|
||||
prices = prices + price
|
||||
end
|
||||
@@ -48,7 +63,7 @@ class SaleItem < ApplicationRecord
|
||||
end
|
||||
|
||||
# get food price or beverage price for item
|
||||
def self.get_price(sale_item_id,rebateacc)
|
||||
def self.get_rebate_price(sale_item_id,rebateacc)
|
||||
price=0
|
||||
|
||||
item=SaleItem.select("sale_items.price , menu_items.account_id")
|
||||
|
||||
@@ -265,7 +265,7 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
def rebat(sObj)
|
||||
rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items)
|
||||
rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items)
|
||||
puts "eeeeeeeeeeeeeeeeeeeeeeee"
|
||||
puts rebate_prices
|
||||
generic_customer_id = sObj.customer.membership_id
|
||||
|
||||
Reference in New Issue
Block a user