Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -179,6 +179,11 @@ class Ability
|
||||
can :remove_all_discount, :discount
|
||||
can :member_discount, :discount
|
||||
|
||||
can :move_dining, :movetable
|
||||
can :moving, :movetable
|
||||
|
||||
can :move_dining, :moveroom
|
||||
|
||||
can :manage, Customer
|
||||
can :manage, DiningQueue
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
class DisplayImage < ApplicationRecord
|
||||
mount_uploader :image, DisplayImageUploader
|
||||
belongs_to :shop
|
||||
|
||||
end
|
||||
|
||||
@@ -238,6 +238,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
self.print("tmp/print_queue_no.pdf")
|
||||
end
|
||||
|
||||
#Move Table Print
|
||||
def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by)
|
||||
pdf.render_file "tmp/print_move_table.pdf"
|
||||
self.print("tmp/print_move_table.pdf")
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_crm_order(booking,order_items,setting)
|
||||
#Use CUPS service
|
||||
|
||||
@@ -950,7 +950,7 @@ def self.get_menu_item_query(order_by)
|
||||
" LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" +
|
||||
" LEFT JOIN sales s ON s.sale_id = si.sale_id")
|
||||
.where("(CASE WHEN s.sale_status IS NOT NULL THEN s.sale_status='completed' ELSE 1 END)")
|
||||
.group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE mii.item_instance_name END)")
|
||||
.group("mc.id, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END)")
|
||||
.order("si.qty #{order_by}, menu_items.menu_category_id #{order_by}")
|
||||
end
|
||||
#product sale report query
|
||||
@@ -1109,6 +1109,16 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
return all_total,sale_type
|
||||
end
|
||||
|
||||
def self.get_wastes_and_spoilages(from,to,status)
|
||||
if status == "spoile"
|
||||
type = "and sales.sale_status = 'spoile'"
|
||||
else
|
||||
type = "and sales.sale_status = 'waste'"
|
||||
end
|
||||
query = Sale.all.where("sales.receipt_date between ? and ? #{type}",from,to)
|
||||
.group("sales.receipt_no")
|
||||
end
|
||||
|
||||
# def self.get_separate_tax(from,to,payment_method=nil)
|
||||
|
||||
# query = SaleTax.select("SUM(tax_payable_amount) AS st_amount,tax_name")
|
||||
|
||||
@@ -49,8 +49,12 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = paypar_payment
|
||||
when "foc"
|
||||
payment_status = foc_payment
|
||||
when "paymal"
|
||||
payment_status = paymal_payment
|
||||
when "JunctionPay"
|
||||
payment_status = junction_pay_payment
|
||||
when "alipay"
|
||||
payment_status = external_terminal_card_payment(:alipay)
|
||||
else
|
||||
puts "it was something else"
|
||||
end
|
||||
@@ -162,6 +166,60 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
return response;
|
||||
|
||||
end
|
||||
|
||||
def self.create_payment(paypar_url,token,membership_id,received_amount,sale_id)
|
||||
membership_actions_data = MembershipAction.find_by_membership_type("create_payment");
|
||||
|
||||
if !membership_actions_data.nil?
|
||||
|
||||
url = paypar_url.to_s + membership_actions_data.gateway_url.to_s
|
||||
merchant_uid = membership_actions_data.merchant_account_id
|
||||
auth_token = membership_actions_data.auth_token
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
|
||||
if sale_data
|
||||
others = 0
|
||||
sale_data.sale_payments.each do |sale_payment|
|
||||
others = others + sale_payment.payment_amount
|
||||
end
|
||||
payment_prices = sale_data.grand_total - others
|
||||
# Control for Paypar Cloud
|
||||
begin
|
||||
response = HTTParty.post(url,
|
||||
:body => { membership_id:membership_id,
|
||||
amount:received_amount,
|
||||
receipt_no:sale_data.receipt_no,
|
||||
merchant_uid:merchant_uid,
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = false
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
else
|
||||
response = false;
|
||||
end
|
||||
|
||||
else
|
||||
response =false;
|
||||
end
|
||||
|
||||
Rails.logger.debug "Payment response"
|
||||
Rails.logger.debug response.to_json
|
||||
|
||||
return response;
|
||||
|
||||
end
|
||||
|
||||
# Check for Card Payment
|
||||
@@ -230,7 +288,7 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = false
|
||||
self.payment_method = method
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.card_payment_reference
|
||||
# self.payment_reference = self.card_payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
@@ -299,6 +357,35 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def paymal_payment
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
customer_data = Customer.find_by_customer_id(self.sale.customer_id)
|
||||
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
|
||||
|
||||
#record an payment in sale-audit
|
||||
remark = "#{membership_data} PayMal Payment- 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, 1)
|
||||
|
||||
if membership_data["status"]==true
|
||||
self.payment_method = "paymal"
|
||||
self.payment_amount = self.received_amount
|
||||
self.payment_reference = self.voucher_no
|
||||
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
|
||||
self.payment_status = "pending"
|
||||
payment_method = self.save!
|
||||
SalePayment.where(:sale_payment_id => self.sale_payment_id).update_all(:payment_status => 'paid')
|
||||
sale_update_payment_status(self.received_amount.to_f)
|
||||
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
|
||||
return payment_status
|
||||
end
|
||||
|
||||
def junction_pay_payment
|
||||
payment_status = false
|
||||
|
||||
@@ -310,9 +397,7 @@ class SalePayment < ApplicationRecord
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
return payment_status
|
||||
|
||||
end
|
||||
|
||||
def sale_update_payment_status(paid_amount,check_foc = false)
|
||||
@@ -418,7 +503,7 @@ class SalePayment < ApplicationRecord
|
||||
bookings.each do |tablebooking|
|
||||
if tablebooking.booking_status != 'moved'
|
||||
if tablebooking.sale_id
|
||||
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void'
|
||||
if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' && tablebooking.sale.sale_status != 'spoile' && tablebooking.sale.sale_status != 'waste'
|
||||
status = false
|
||||
sale_count += 1
|
||||
else
|
||||
|
||||
@@ -6,4 +6,8 @@ class Shop < ApplicationRecord
|
||||
|
||||
has_many :display_images
|
||||
accepts_nested_attributes_for :display_images
|
||||
|
||||
def file_data=(input_data)
|
||||
self.data = input_data.read
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user