52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
class RecurrentPayment < ActiveRecord::Base
|
|
belongs_to :origine_transaction, :class_name => "DonatorTransaction"
|
|
has_many :transaction_items, :dependent => :destroy
|
|
def generate_infos
|
|
|
|
if !self.infos_ok
|
|
|
|
|
|
tr_payement = self.origine_transaction.tr_payment_ok
|
|
self.ogone_alias = tr_payement.ogone_alias
|
|
self.ogone_cb_expiration = tr_payement.ogone_cb_expiration
|
|
self.ogone_brand = tr_payement.ogone_brand
|
|
self.ogone_subbrand = tr_payement.ogone_subbrand
|
|
self.ogone_cn = tr_payement.ogone_cn
|
|
self.ogone_cardno = tr_payement.ogone_cardno
|
|
|
|
|
|
|
|
self.origine_transaction.transaction_items.each do |transaction_item|
|
|
puts transaction_item.id
|
|
t_item = transaction_item.dup
|
|
if transaction_item.transaction_content
|
|
t_content = transaction_item.transaction_content.id
|
|
|
|
t_item.transaction_content_id = t_content
|
|
end
|
|
|
|
t_item.donator_transaction_id = nil
|
|
t_item.recurrent_payment_id = self.id
|
|
t_item.save
|
|
|
|
|
|
|
|
end
|
|
|
|
self.infos_ok = true
|
|
self.save
|
|
end
|
|
|
|
end
|
|
|
|
def export_actif
|
|
self.active ? "oui" : "non"
|
|
end
|
|
|
|
def export_phone
|
|
"_ "+self.origine_transaction.particular_bill.tel.to_s
|
|
#ERB::Util.html_escape(ActiveSupport::NumberHelper.number_to_phone(self.origine_transaction.particular_bill.tel.to_s))
|
|
end
|
|
|
|
end
|