rescue member call and update oqs and js route bug

This commit is contained in:
Yan
2017-06-18 03:20:19 +06:30
parent 80320b6d3e
commit f33f11df64
12 changed files with 102 additions and 51 deletions

View File

@@ -39,12 +39,17 @@ class Customer < ApplicationRecord
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
},
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
end
return response;

View File

@@ -246,7 +246,7 @@ class Order < ApplicationRecord
.joins("left join orders on orders.order_id = booking_orders.order_id")
.joins("left join sales on sales.sale_id = bookings.sale_id")
.where("sales.sale_status='completed'")
.group("sales.sale_id,bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id")
.group("sales.sale_id")
# For PG
#bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id
end

View File

@@ -195,28 +195,28 @@ class Sale < ApplicationRecord
existing_tax.delete
end
total_tax_amount = 0
#tax_profile - list by order_by
tax_profiles = TaxProfile.all.order("order_by asc")
# total_tax_amount = 0
# #tax_profile - list by order_by
# tax_profiles = TaxProfile.all.order("order_by asc")
#Creat new tax records
tax_profiles.each do |tax|
sale_tax = SaleTax.new(:sale => self)
sale_tax.tax_name = tax.name
sale_tax.tax_rate = tax.rate
#include or execulive
# sale_tax.tax_payable_amount = total_taxable * tax.rate
sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
#new taxable amount
total_taxable = total_taxable + sale_tax.tax_payable_amount
# #Creat new tax records
# tax_profiles.each do |tax|
# sale_tax = SaleTax.new(:sale => self)
# sale_tax.tax_name = tax.name
# sale_tax.tax_rate = tax.rate
# #include or execulive
# # sale_tax.tax_payable_amount = total_taxable * tax.rate
# sale_tax.tax_payable_amount = total_taxable * tax.rate / 100
# #new taxable amount
# total_taxable = total_taxable + sale_tax.tax_payable_amount
sale_tax.inclusive = tax.inclusive
sale_tax.save
# sale_tax.inclusive = tax.inclusive
# sale_tax.save
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
# total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
# end
self.total_tax = total_tax_amount
# self.total_tax = total_tax_amount
end

View File

@@ -30,6 +30,7 @@ class SaleItem < ApplicationRecord
# end
end
# Calculate food total and beverage total
def self.calculate_food_beverage(sale_items)
food_prices=0
beverage_prices=0
@@ -43,6 +44,7 @@ class SaleItem < ApplicationRecord
return food_prices, beverage_prices
end
# get food price or beverage price for item
def self.get_price(sale_item_id)
food_price=0
beverage_price=0

View File

@@ -260,12 +260,17 @@ class SalePayment < ApplicationRecord
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
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 ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
begin
response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id,
receipt_no: receipt_no,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
})
}, :timeout => 10)
rescue Net::OpenTimeout
response = { status: false }
end
puts response.to_json
end