merge with master
This commit is contained in:
@@ -11,6 +11,7 @@ class SalePayment < ApplicationRecord
|
||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil)
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
self.payment_reference = remark
|
||||
amount_due = invoice.grand_total
|
||||
|
||||
#get all payment for this invoices
|
||||
@@ -48,8 +49,15 @@ class SalePayment < ApplicationRecord
|
||||
payment_status = paypar_payment
|
||||
when "foc"
|
||||
payment_status = foc_payment
|
||||
<<<<<<< HEAD
|
||||
when "paymal"
|
||||
payment_status = paymal_payment
|
||||
=======
|
||||
when "JunctionPay"
|
||||
payment_status = junction_pay_payment
|
||||
when "alipay"
|
||||
payment_status = external_terminal_card_payment(:alipay)
|
||||
>>>>>>> 996392a041cb5f92a3b2985cbd0379210132d829
|
||||
else
|
||||
puts "it was something else"
|
||||
end
|
||||
@@ -87,7 +95,7 @@ class SalePayment < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
@@ -135,7 +143,7 @@ class SalePayment < ApplicationRecord
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -261,8 +269,7 @@ class SalePayment < ApplicationRecord
|
||||
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)
|
||||
return payment_status
|
||||
end
|
||||
|
||||
@@ -284,7 +291,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!
|
||||
@@ -353,6 +360,7 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
<<<<<<< HEAD
|
||||
def paymal_payment
|
||||
payment_status = false
|
||||
|
||||
@@ -378,6 +386,20 @@ class SalePayment < ApplicationRecord
|
||||
else
|
||||
sale_update_payment_status(0)
|
||||
end
|
||||
=======
|
||||
def junction_pay_payment
|
||||
payment_status = false
|
||||
|
||||
#Next time - validate if the vochure number is valid - within
|
||||
self.payment_method = "JunctionPay"
|
||||
self.payment_amount = self.received_amount
|
||||
# self.payment_reference = self.payment_reference
|
||||
self.outstanding_amount = self.sale.grand_total- self.received_amount
|
||||
self.payment_status = "paid"
|
||||
payment_method = self.save!
|
||||
sale_update_payment_status(self.received_amount)
|
||||
|
||||
>>>>>>> 996392a041cb5f92a3b2985cbd0379210132d829
|
||||
return payment_status
|
||||
|
||||
end
|
||||
@@ -391,6 +413,7 @@ class SalePayment < ApplicationRecord
|
||||
sObj = Sale.find(self.sale_id)
|
||||
is_credit = 0
|
||||
is_foc = 0
|
||||
method_status = false
|
||||
sObj.sale_payments.each do |spay|
|
||||
all_received_amount += spay.payment_amount.to_f
|
||||
if spay.payment_method == "creditnote"
|
||||
@@ -399,8 +422,12 @@ class SalePayment < ApplicationRecord
|
||||
if spay.payment_method == "foc"
|
||||
is_foc = 1
|
||||
end
|
||||
if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote"
|
||||
method_status = true
|
||||
end
|
||||
end
|
||||
if (self.sale.grand_total <= all_received_amount)
|
||||
|
||||
if (self.sale.grand_total <= all_received_amount) && method_status
|
||||
if is_credit == 0
|
||||
self.sale.payment_status = "paid"
|
||||
else
|
||||
@@ -440,11 +467,15 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
|
||||
self.sale.save!
|
||||
table_update_status(sObj)
|
||||
|
||||
if check_foc
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
elsif method_status && paid_amount.to_f == 0
|
||||
table_update_status(sObj)
|
||||
update_shift
|
||||
end
|
||||
end
|
||||
@@ -476,7 +507,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
|
||||
@@ -540,7 +571,7 @@ class SalePayment < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status": false , "message": " Connection timeout" }
|
||||
@@ -585,7 +616,8 @@ class SalePayment < ApplicationRecord
|
||||
end
|
||||
rebate_arr.push(data)
|
||||
end
|
||||
|
||||
Rails.logger.debug "Rebage Response"
|
||||
Rails.logger.debug rebate_arr.to_json
|
||||
total_amount = rebate_prices - payparcost - overall_dis
|
||||
|
||||
if credit == 1
|
||||
@@ -616,7 +648,7 @@ class SalePayment < ApplicationRecord
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=2'
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10)
|
||||
rescue Net::OpenTimeout
|
||||
response = { "status": false , "message": "Connect To" }
|
||||
|
||||
Reference in New Issue
Block a user