Merge branch 'r-1902001-01' of gitlab.com:code2lab/SXRestaurant into r-1902001-01

This commit is contained in:
Myat Zin Wai Maw
2020-02-03 09:59:29 +06:30
8 changed files with 58 additions and 69 deletions

View File

@@ -233,9 +233,9 @@ class SalePayment < ApplicationRecord
return response;
end
def self.redeem(paypar_url,token,membership_id,received_amount,sale_id)
# membership_actions_data = MembershipAction.find_by_membership_type("redeem");
membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
def redeem(paypar_url,token,membership_id,received_amount,sale_id)
membership_actions_data = MembershipAction.find_by_membership_type("redeem");
# membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem")
puts "This is membership_actions_data"
puts membership_actions_data.to_json
if !membership_actions_data.nil?
@@ -243,8 +243,9 @@ class SalePayment < ApplicationRecord
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 = JSON.parse(membership_actions_data.additional_parameters)["campaign_type_id"]
campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"]
sale_data = Sale.find_by_sale_id(sale_id)
account_no = Customer.find_by_customer_id(self.sale.customer_id).paypar_account_no
if sale_data
others = 0
@@ -261,7 +262,7 @@ class SalePayment < ApplicationRecord
redeem_amount:received_amount,
receipt_no:sale_data.receipt_no,
campaign_type_id:campaign_type_id,
account_no:"",
account_no: account_no,
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json,
:headers => {
@@ -504,7 +505,7 @@ class SalePayment < ApplicationRecord
#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.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id)
membership_data = redeem(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} Redeem- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} "
@@ -722,7 +723,10 @@ class SalePayment < ApplicationRecord
# update for shift with credit payment
def update_shift_for_credit_payment
shift_credit = ShiftSale.find_by_id(self.sale.shift_sale_id)
shift = ShiftSale.find_by_id(ShiftSale.current_shift)
shift = self.action_by.current_shift
if !shift.nil?
shift = ShiftSale.current_shift
end
if !shift.nil?
credit_payment_left = get_credit_payment_left[0].payment_amount.to_f
if self.payment_method == "cash"