Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -147,7 +147,7 @@ class Customer < ApplicationRecord
|
||||
response = self.rebat(Sale.find(sale.sale_id))
|
||||
#record an payment in sale-audit
|
||||
remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.received_amount} "
|
||||
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, "CronJob")
|
||||
sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1)
|
||||
|
||||
if response["status"] == true
|
||||
status = sale.update_attributes(rebate_status: "true")
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
class MembershipSetting < ApplicationRecord
|
||||
MembershipSetting = MembershipSetting.find_by_id(1)
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
|
||||
order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code)
|
||||
|
||||
filename = "tmp/order_item.pdf"
|
||||
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
|
||||
|
||||
# check for item not to show
|
||||
# if order_item[0].price != 0
|
||||
@@ -47,7 +47,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item.pdf"
|
||||
filename = "tmp/order_item_#{order_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -68,7 +68,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/order_summary.pdf"
|
||||
filename = "tmp/order_summary_#{order_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
@@ -96,7 +96,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
# For Print Per Item
|
||||
if oqs.cut_per_item
|
||||
order.each do|odi|
|
||||
filename = "tmp/order_item.pdf"
|
||||
filename = "tmp/order_item_#{booking_id}" + ".pdf"
|
||||
# For Item Options
|
||||
options = odi.options == "[]"? "" : odi.options
|
||||
|
||||
@@ -120,7 +120,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
|
||||
end
|
||||
# For Print Order Summary
|
||||
else
|
||||
filename = "tmp/booking_summary.pdf"
|
||||
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
|
||||
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
|
||||
pdf.render_file filename
|
||||
if oqs.print_copy
|
||||
|
||||
@@ -117,4 +117,15 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
pdf.render_file "tmp/print_crm_order.pdf"
|
||||
self.print("tmp/print_crm_order.pdf")
|
||||
end
|
||||
|
||||
#Queue No Print
|
||||
def print_call_waiter(printer_settings,table,time,shop_detail)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
|
||||
pdf.render_file "tmp/print_call_waiter.pdf"
|
||||
self.print("tmp/print_call_waiter.pdf")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -659,7 +659,7 @@ def self.get_item_query()
|
||||
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
|
||||
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
|
||||
# query = query.where("i.item_instance_code IS NOT NULL")
|
||||
query = query.group("i.product_name").order("mi.account_id asc","mi.menu_category_id asc")
|
||||
query = query.group("i.product_name").order("mi.account_id desc")
|
||||
end
|
||||
|
||||
def self.get_other_charges()
|
||||
@@ -1107,7 +1107,7 @@ end
|
||||
def self.top_items(today)
|
||||
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
|
||||
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
|
||||
.where("sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
|
||||
.group("a.product_code")
|
||||
.order("SUM(a.qty) DESC")
|
||||
.first()
|
||||
|
||||
@@ -173,13 +173,20 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
private
|
||||
def cash_payment
|
||||
status = false
|
||||
sale_payments_data = SalePayment.find_by_sale_id(self.sale_id)
|
||||
if sale_payments_data.nil?
|
||||
status = true
|
||||
end
|
||||
|
||||
payment_status = false
|
||||
self.payment_method = "cash"
|
||||
self.payment_amount = self.received_amount
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
sale_update_payment_status(self.received_amount,status)
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -187,7 +194,7 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = false
|
||||
|
||||
# add to sale item with foc
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'")
|
||||
sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }' and remark is null")
|
||||
|
||||
sale_items.each do|item|
|
||||
SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price)
|
||||
@@ -271,7 +278,7 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
#record an payment in sale-audit
|
||||
remark = "#{membership_data} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier")
|
||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||
|
||||
if membership_data["status"]==true
|
||||
self.payment_method = "paypar"
|
||||
@@ -290,7 +297,7 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount)
|
||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
self.sale.save!
|
||||
@@ -328,7 +335,7 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
#record an payment in sale-audit
|
||||
remark = "#{response} Rebate- for Customer #{self.sale.customer_id} | Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
|
||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, "Cashier")
|
||||
sale_audit = SaleAudit.record_paymal(self.sale.sale_id, remark, 1)
|
||||
|
||||
if !response.nil?
|
||||
if response["status"] == true
|
||||
@@ -349,8 +356,10 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
self.sale.save!
|
||||
table_update_status(sObj)
|
||||
|
||||
if paid_amount != "0.0"
|
||||
|
||||
if check_foc
|
||||
update_shift
|
||||
elsif paid_amount != "0.0"
|
||||
update_shift
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user