Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into pre_master
This commit is contained in:
@@ -34,12 +34,17 @@ class Customer < ApplicationRecord
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
end
|
||||
|
||||
# def self.search(search)
|
||||
# where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",)
|
||||
# end
|
||||
|
||||
def lastest_invoices
|
||||
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class Order < ApplicationRecord
|
||||
booking = nil
|
||||
|
||||
if self.new_booking
|
||||
puts "a"
|
||||
|
||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "assign" })
|
||||
@@ -311,6 +311,15 @@ class Order < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
where("order_id LIKE ?", "%#{search}%")
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_custom_id
|
||||
|
||||
@@ -12,7 +12,8 @@ class Sale < ApplicationRecord
|
||||
has_many :sale_taxes
|
||||
has_many :sale_payments
|
||||
has_many :sale_orders
|
||||
|
||||
has_many :bookings
|
||||
|
||||
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
|
||||
|
||||
def generate_invoice_from_booking(booking_id, requested_by)
|
||||
@@ -260,7 +261,8 @@ class Sale < ApplicationRecord
|
||||
|
||||
def self.search(search)
|
||||
if search
|
||||
find(:all, :conditions => ['receipt_no LIKE ?', "%#{search}%"])
|
||||
# find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"])
|
||||
where("receipt_no LIKE ?", "%#{search}%",)
|
||||
else
|
||||
find(:all)
|
||||
end
|
||||
|
||||
@@ -66,9 +66,9 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid)
|
||||
def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token)
|
||||
response = HTTParty.get(url,
|
||||
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid}.to_json,
|
||||
:body => { app_token: token,membership_id:membership_id,campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
@@ -83,11 +83,12 @@ class SalePayment < ApplicationRecord
|
||||
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
|
||||
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
|
||||
sale_data = Sale.find_by_sale_id(sale_id)
|
||||
if sale_data
|
||||
response = HTTParty.post(url,
|
||||
:body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid}.to_json,
|
||||
:body => { generic_customer_id:membership_id,redeem_amount:received_amount,receipt_no:sale_data.receipt_no,campaign_type_id:campaign_type_id,account_no:"",merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
@@ -211,7 +212,8 @@ class SalePayment < ApplicationRecord
|
||||
def sale_update_payment_status(paid_amount)
|
||||
#update amount_outstanding
|
||||
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
|
||||
self.sale.amount_changed = paid_amount.to_f - self.sale.amount_received.to_f
|
||||
|
||||
self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f
|
||||
all_received_amount = 0.0
|
||||
sObj = Sale.find(self.sale_id)
|
||||
sObj.sale_payments.each do |spay|
|
||||
@@ -255,10 +257,10 @@ class SalePayment < ApplicationRecord
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("rebate")
|
||||
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
|
||||
app_token = membership.auth_token.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_amount: total_amount,campaign_type_id: campaign_type_id,
|
||||
receipt_no: receipt_no}.to_json,
|
||||
receipt_no: receipt_no,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user