before sync
This commit is contained in:
@@ -11,19 +11,21 @@ class SalePayment < ApplicationRecord
|
||||
def self.sync_sale_payment_records(sale_payments)
|
||||
if !sale_payments.nil?
|
||||
sale_payments.each do |sp|
|
||||
unless SalePayment.exists?(sp['sale_payment_id'])
|
||||
payment = SalePayment.find_by_sale_payment_id(sp['sale_payment_id'])
|
||||
# unless SalePayment.exists?(sp['sale_payment_id'])
|
||||
if payment.nil?
|
||||
payment = SalePayment.new
|
||||
payment.sale_payment_id = sp['sale_payment_id']
|
||||
payment.sale_id = sp['sale_id']
|
||||
payment.payment_method = sp['payment_method']
|
||||
payment.payment_amount = sp['payment_amount']
|
||||
payment.outstanding_amount = sp['outstanding_amount']
|
||||
payment.payment_reference = sp['payment_reference']
|
||||
payment.payment_status = sp['payment_status']
|
||||
payment.save
|
||||
puts '....... Sale Payment has been created ......'
|
||||
end
|
||||
payment.sale_payment_id = sp['sale_payment_id']
|
||||
payment.sale_id = sp['sale_id']
|
||||
payment.payment_method = sp['payment_method']
|
||||
payment.payment_amount = sp['payment_amount']
|
||||
payment.outstanding_amount = sp['outstanding_amount']
|
||||
payment.payment_reference = sp['payment_reference']
|
||||
payment.payment_status = sp['payment_status']
|
||||
payment.save
|
||||
end
|
||||
puts '....... Sale Payment sync completed ......'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user