sync data records
This commit is contained in:
@@ -8,6 +8,25 @@ class SalePayment < ApplicationRecord
|
||||
|
||||
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
|
||||
|
||||
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.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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false)
|
||||
self.sale = invoice
|
||||
self.received_amount = cash_amount
|
||||
|
||||
Reference in New Issue
Block a user