erp_commerce 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/app/models/accepted_credit_card.rb +10 -0
- data/app/models/bank_account.rb +13 -0
- data/app/models/bank_account_type.rb +9 -0
- data/app/models/credit_card.rb +54 -19
- data/app/models/credit_card_account.rb +31 -9
- data/app/models/credit_card_account_party_role.rb +17 -0
- data/app/models/credit_card_account_purpose.rb +24 -0
- data/app/models/extensions/financial_txn.rb +62 -1
- data/app/models/extensions/order_txn.rb +48 -0
- data/app/models/extensions/party.rb +26 -13
- data/app/models/extensions/simple_product_offer.rb +3 -0
- data/app/models/payment.rb +21 -0
- data/app/models/payment_gateway.rb +12 -0
- data/app/models/payment_gateway_action.rb +12 -0
- data/app/models/pricing_plan.rb +29 -1
- data/db/data_migrations/20150125202814_add_payment_transaction_types.rb +14 -0
- data/db/migrate/20100823174238_erp_commerce_base.rb +196 -192
- data/db/migrate/20160310163057_add_created_by_updated_by_to_erp_commerce.rb +35 -0
- data/lib/erp_commerce.rb +1 -2
- data/lib/erp_commerce/config.rb +2 -3
- data/lib/erp_commerce/engine.rb +1 -5
- data/lib/erp_commerce/extensions/active_record/acts_as_priceable.rb +1 -2
- data/lib/erp_commerce/version.rb +1 -1
- metadata +12 -32
- data/app/mailers/checkout_mailer.rb +0 -9
- data/app/views/checkout_mailer/email_confirmation.html.erb +0 -15
- data/app/widgets/orders/base.rb +0 -36
- data/app/widgets/orders/javascript/orders.js +0 -12
- data/app/widgets/orders/views/index.html.erb +0 -63
- data/app/widgets/product_catalog/base.rb +0 -52
- data/app/widgets/product_catalog/javascript/product_catalog.js +0 -64
- data/app/widgets/product_catalog/views/add_to_cart.html.erb +0 -10
- data/app/widgets/product_catalog/views/index.html.erb +0 -69
- data/app/widgets/product_catalog/views/show.html.erb +0 -23
- data/app/widgets/shopping_cart/base.rb +0 -175
- data/app/widgets/shopping_cart/javascript/shopping_cart.js +0 -110
- data/app/widgets/shopping_cart/views/cart_items.html.erb +0 -83
- data/app/widgets/shopping_cart/views/confirmation.html.erb +0 -11
- data/app/widgets/shopping_cart/views/demographics.html.erb +0 -142
- data/app/widgets/shopping_cart/views/login.html.erb +0 -1
- data/app/widgets/shopping_cart/views/payment.html.erb +0 -81
- data/app/widgets/shopping_cart/views/price_summary.html.erb +0 -4
- data/lib/erp_commerce/active_merchant_wrappers.rb +0 -3
- data/lib/erp_commerce/active_merchant_wrappers/authorize_net_wrapper.rb +0 -66
- data/lib/erp_commerce/active_merchant_wrappers/brain_tree_gateway_wrapper.rb +0 -68
- data/lib/erp_commerce/active_merchant_wrappers/credit_card_validation.rb +0 -34
- data/lib/erp_commerce/order_helper.rb +0 -245
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a6407956b3a3bc60b5271fd3fa5f00682d0f7ac
|
4
|
+
data.tar.gz: 4124637d314b584201f71d652975e2c05729df26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb84968b78265e2ba95216c81a2f124b71d839be133d849857b810f1463f1fd4c85d7cb9afa2d12b1af141ee1dc2eecee74595bf682e7504d96dc112ddf8fef2
|
7
|
+
data.tar.gz: d3d8c59cde92c6c51e800fbb246aa236ced5c6daa37c876b568e4f11336db5e1c8bceb49789e4c5757e030333122928327f2b5e31555910cb3f65910383f2d03
|
data/README.md
CHANGED
@@ -8,6 +8,5 @@ To override these settings simple create a erp_commerce.rb file in your initiali
|
|
8
8
|
|
9
9
|
Rails.application.config.erp_commerce.configure do |config|
|
10
10
|
config.encryption_key = 'my_secret_code'
|
11
|
-
config.active_merchant_gateway_wrapper = ErpCommerce::ActiveMerchantWrappers::BrainTreeGatewayWrapper
|
12
11
|
end
|
13
12
|
Rails.application.config.erp_commerce.configure!
|
@@ -1,3 +1,13 @@
|
|
1
|
+
### Table Definition ###############################
|
2
|
+
# create_table :accepted_credit_cards do |t|
|
3
|
+
#
|
4
|
+
# t.references :organization
|
5
|
+
# t.string :card_type
|
6
|
+
#
|
7
|
+
# t.timestamps
|
8
|
+
# end
|
9
|
+
###################################################
|
10
|
+
|
1
11
|
class AcceptedCreditCard < ActiveRecord::Base
|
2
12
|
attr_protected :created_at, :updated_at
|
3
13
|
|
data/app/models/bank_account.rb
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
### Table Definition ###############################
|
2
|
+
# create_table :bank_accounts do |t|
|
3
|
+
# t.string :routing_number
|
4
|
+
# t.string :crypted_private_account_number
|
5
|
+
# t.string :name_on_account
|
6
|
+
# t.references :bank_account_type
|
7
|
+
#
|
8
|
+
# t.timestamps
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# add_index :bank_accounts, :bank_account_type_id, :name => 'bank_accounts_account_type_idx'
|
12
|
+
####################################################
|
13
|
+
|
1
14
|
class BankAccount < ActiveRecord::Base
|
2
15
|
attr_protected :created_at, :updated_at
|
3
16
|
|
@@ -1,3 +1,12 @@
|
|
1
|
+
### Table Definition ###############################
|
2
|
+
# create_table :bank_account_types do |t|
|
3
|
+
# t.string :description
|
4
|
+
# t.string :internal_identifier
|
5
|
+
#
|
6
|
+
# t.timestamps
|
7
|
+
# end
|
8
|
+
####################################################
|
9
|
+
|
1
10
|
class BankAccountType < ActiveRecord::Base
|
2
11
|
attr_protected :created_at, :updated_at
|
3
12
|
|
data/app/models/credit_card.rb
CHANGED
@@ -1,13 +1,30 @@
|
|
1
|
+
#### Table Definition ####################################
|
2
|
+
# create_table :credit_cards do |t|
|
3
|
+
#
|
4
|
+
# t.column :crypted_private_card_number, :string
|
5
|
+
# t.column :crypted_private_cvc, :string
|
6
|
+
# t.column :expiration_month, :integer
|
7
|
+
# t.column :expiration_year, :integer
|
8
|
+
#
|
9
|
+
# t.column :description, :string
|
10
|
+
# t.column :name_one_card, :string
|
11
|
+
# t.column :card_type, :string
|
12
|
+
#
|
13
|
+
# t.column :postal_address_id, :integer
|
14
|
+
# t.column :credit_card_token, :string
|
15
|
+
#
|
16
|
+
# t.timestamps
|
17
|
+
# end
|
18
|
+
#########################################################
|
19
|
+
|
1
20
|
class CreditCard < ActiveRecord::Base
|
2
21
|
attr_protected :created_at, :updated_at
|
3
22
|
|
4
|
-
|
5
|
-
|
6
|
-
belongs_to
|
7
|
-
has_one
|
23
|
+
tracks_created_by_updated_by
|
24
|
+
|
25
|
+
belongs_to :postal_address
|
26
|
+
has_one :credit_card_account_party_role, :dependent => :destroy
|
8
27
|
|
9
|
-
validates :first_name_on_card, :presence => {:message => 'First name on card cannot be blank.'}
|
10
|
-
validates :last_name_on_card, :presence => {:message => 'Last name on card cannot be blank.'}
|
11
28
|
#validates :card_type, :presence => {:message => 'Card type cannot be blank.'}
|
12
29
|
validates :expiration_month, :presence => {:message => 'Expiration month cannot be blank.'}
|
13
30
|
validates :expiration_year, :presence => {:message => 'Expiration year cannot be blank.'}
|
@@ -15,13 +32,24 @@ class CreditCard < ActiveRecord::Base
|
|
15
32
|
|
16
33
|
#the function EncryptionKey.get_key is meant to be overridden to provide a means for implementations to specify their
|
17
34
|
#own encryption schemes and locations. It will default to a simple string for development and testing
|
18
|
-
attr_encrypted :private_card_number, :key => Rails.application.config.erp_commerce.encryption_key, :
|
35
|
+
attr_encrypted :private_card_number, :key => Rails.application.config.erp_commerce.encryption_key, :attribute => :crypted_private_card_number
|
36
|
+
attr_encrypted :private_cvc, :key => Rails.application.config.erp_commerce.encryption_key, :attribute => :crypted_private_cvc
|
19
37
|
|
20
38
|
# These methods are exposed for the purposes of displaying a version of the card number
|
21
39
|
# string containing the last four digits of the card number. The idea is to make it
|
22
40
|
# painfully obvious when any coder is using the private_card_number, which should
|
23
41
|
# be used only in limited circumstances.
|
24
42
|
|
43
|
+
#these two methods allow us to assign instance level attributes that are not persisted. These are used for validators
|
44
|
+
def instance_attributes
|
45
|
+
@instance_attrs.nil? ? {} : @instance_attrs
|
46
|
+
end
|
47
|
+
|
48
|
+
def add_instance_attribute(k, v)
|
49
|
+
@instance_attrs = {} if @instance_attrs.nil?
|
50
|
+
@instance_attrs[k] = v
|
51
|
+
end
|
52
|
+
|
25
53
|
def card_number
|
26
54
|
if self.private_card_number
|
27
55
|
CreditCard.mask_number(self.private_card_number)
|
@@ -30,29 +58,36 @@ class CreditCard < ActiveRecord::Base
|
|
30
58
|
end
|
31
59
|
end
|
32
60
|
|
33
|
-
|
34
|
-
|
35
|
-
|
61
|
+
def last_4
|
62
|
+
card_number[card_number.length-4..card_number.length]
|
63
|
+
end
|
64
|
+
|
65
|
+
def expires
|
66
|
+
"#{expiration_month}/#{expiration_year}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def cvc=(cvc)
|
70
|
+
self.private_cvc=cvc
|
71
|
+
end
|
72
|
+
|
36
73
|
def card_number=(num)
|
37
74
|
self.private_card_number=num
|
38
75
|
end
|
39
|
-
|
76
|
+
|
40
77
|
def to_label
|
41
78
|
"#{card_type}: #{card_number}"
|
42
79
|
end
|
43
|
-
|
80
|
+
|
44
81
|
def to_s
|
45
82
|
"#{card_type}: #{card_number}"
|
46
83
|
end
|
47
84
|
|
48
|
-
def add_party_with_role(party, role_type)
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
85
|
def cardholder
|
53
|
-
|
86
|
+
if self.credit_card_account_party_role
|
87
|
+
self.credit_card_account_party_role.party
|
88
|
+
end
|
54
89
|
end
|
55
|
-
|
90
|
+
|
56
91
|
def before_create
|
57
92
|
token = CreditCardToken.new
|
58
93
|
self.credit_card_token = token.cc_token.strip
|
@@ -63,7 +98,7 @@ class CreditCard < ActiveRecord::Base
|
|
63
98
|
'XXXX-XXXX-XXXX-' + number[number.length-4..number.length]
|
64
99
|
end
|
65
100
|
end
|
66
|
-
|
101
|
+
|
67
102
|
end
|
68
103
|
|
69
104
|
|
@@ -1,3 +1,9 @@
|
|
1
|
+
### Table Definition ###############################
|
2
|
+
# create_table :credit_card_accounts do |t|
|
3
|
+
# t.timestamps
|
4
|
+
# end
|
5
|
+
####################################################
|
6
|
+
|
1
7
|
class CreditCardAccount < ActiveRecord::Base
|
2
8
|
attr_protected :created_at, :updated_at
|
3
9
|
|
@@ -34,7 +40,6 @@ class CreditCardAccount < ActiveRecord::Base
|
|
34
40
|
def authorize(financial_txn, cvv, gateway_wrapper, gateway_options={}, credit_card_to_use=nil)
|
35
41
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
36
42
|
|
37
|
-
gateway_options[:debug] = true
|
38
43
|
result = gateway_wrapper.authorize(credit_card_to_use, financial_txn.money.amount, cvv, gateway_options)
|
39
44
|
|
40
45
|
unless result[:payment].nil?
|
@@ -58,7 +63,6 @@ class CreditCardAccount < ActiveRecord::Base
|
|
58
63
|
def purchase(financial_txn, cvv, gateway_wrapper, gateway_options={}, credit_card_to_use=nil)
|
59
64
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
60
65
|
|
61
|
-
gateway_options[:debug] = true
|
62
66
|
result = gateway_wrapper.purchase(credit_card_to_use, financial_txn.money.amount, cvv, gateway_options)
|
63
67
|
|
64
68
|
unless result[:payment].nil?
|
@@ -71,6 +75,29 @@ class CreditCardAccount < ActiveRecord::Base
|
|
71
75
|
result
|
72
76
|
end
|
73
77
|
|
78
|
+
# purchase with credit card associated to this CreditCardAccount
|
79
|
+
def purchase_with_existing_card(financial_txn, gateway_wrapper, gateway_options={})
|
80
|
+
result = gateway_wrapper.purchase_with_existing_card(self.credit_card, financial_txn.money.amount, gateway_options)
|
81
|
+
|
82
|
+
unless result[:payment].nil?
|
83
|
+
result[:payment].financial_txn = financial_txn
|
84
|
+
result[:payment].save
|
85
|
+
financial_txn.payments << result[:payment]
|
86
|
+
financial_txn.save
|
87
|
+
end
|
88
|
+
|
89
|
+
result
|
90
|
+
end
|
91
|
+
|
92
|
+
# purchase with credit card associated to this CreditCardAccount
|
93
|
+
def refund(financial_txn, gateway_wrapper, gateway_options={}, amount=nil)
|
94
|
+
if amount.nil?
|
95
|
+
amount = financial_txn.money.amount
|
96
|
+
end
|
97
|
+
|
98
|
+
gateway_wrapper.refund(financial_txn.most_recent_payment, amount, gateway_options)
|
99
|
+
end
|
100
|
+
|
74
101
|
#params
|
75
102
|
#financial_txn
|
76
103
|
#cvv
|
@@ -83,7 +110,7 @@ class CreditCardAccount < ActiveRecord::Base
|
|
83
110
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
84
111
|
|
85
112
|
result = {:success => true}
|
86
|
-
payment = Payment.
|
113
|
+
payment = Payment.where("current_state = ? and success = ? and financial_txn_id = ?",'authorized', 1, financial_txn.id).order('created_at desc').first
|
87
114
|
#only capture this payment if it was authorized
|
88
115
|
if !payment.nil? && payment.current_state.to_sym == :authorized
|
89
116
|
gateway_options[:debug] = true
|
@@ -104,7 +131,7 @@ class CreditCardAccount < ActiveRecord::Base
|
|
104
131
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
105
132
|
|
106
133
|
result = {:success => true}
|
107
|
-
payment = Payment.
|
134
|
+
payment = Payment.where("current_state = ? and success = ? and financial_txn_id = ?",'authorized', 1, financial_txn.id).order('created_at desc').first
|
108
135
|
#only reverse this payment if it was authorized
|
109
136
|
if !payment.nil? && payment.current_state.to_sym == :authorized
|
110
137
|
gateway_options[:debug] = true
|
@@ -118,10 +145,6 @@ class CreditCardAccount < ActiveRecord::Base
|
|
118
145
|
# implement a void transaction of a transaction
|
119
146
|
end
|
120
147
|
|
121
|
-
def refund
|
122
|
-
# implement a refund on a card
|
123
|
-
end
|
124
|
-
|
125
148
|
#params
|
126
149
|
#financial_txn
|
127
150
|
#gateway_wrapper
|
@@ -134,7 +157,6 @@ class CreditCardAccount < ActiveRecord::Base
|
|
134
157
|
credit_card_to_use = self.credit_card unless credit_card_to_use
|
135
158
|
result = {:success => true}
|
136
159
|
|
137
|
-
gateway_options[:debug] = true
|
138
160
|
if money_amount == nil
|
139
161
|
money_amount = financial_txn.money.amount
|
140
162
|
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
### Table Definition #####################################
|
2
|
+
# create_table :credit_card_account_party_roles do |t|
|
3
|
+
# t.column :credit_card_account_id, :integer
|
4
|
+
# t.column :role_type_id, :integer
|
5
|
+
# t.column :party_id, :integer
|
6
|
+
# t.column :credit_card_id, :integer
|
7
|
+
#
|
8
|
+
# t.timestamps
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# add_index :credit_card_account_party_roles, :credit_card_account_id
|
12
|
+
# add_index :credit_card_account_party_roles, :role_type_id
|
13
|
+
# add_index :credit_card_account_party_roles, :party_id
|
14
|
+
# add_index :credit_card_account_party_roles, :credit_card_id
|
15
|
+
#
|
16
|
+
##########################################################
|
17
|
+
|
1
18
|
class CreditCardAccountPartyRole < ActiveRecord::Base
|
2
19
|
attr_protected :created_at, :updated_at
|
3
20
|
|
@@ -1,3 +1,27 @@
|
|
1
|
+
### Table Definition #####################################
|
2
|
+
# create_table :credit_card_account_purposes do |t|
|
3
|
+
#
|
4
|
+
# t.column :parent_id, :integer
|
5
|
+
# t.column :lft, :integer
|
6
|
+
# t.column :rgt, :integer
|
7
|
+
#
|
8
|
+
# #custom columns go here
|
9
|
+
#
|
10
|
+
# t.column :description, :string
|
11
|
+
# t.column :comments, :string
|
12
|
+
#
|
13
|
+
# t.column :internal_identifier, :string
|
14
|
+
# t.column :external_identifier, :string
|
15
|
+
# t.column :external_id_source, :string
|
16
|
+
#
|
17
|
+
# t.timestamps
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# add_index :credit_card_account_purposes, :parent_id
|
21
|
+
# add_index :credit_card_account_purposes, :lft
|
22
|
+
# add_index :credit_card_account_purposes, :rgt
|
23
|
+
#########################################################
|
24
|
+
|
1
25
|
class CreditCardAccountPurpose < ActiveRecord::Base
|
2
26
|
attr_protected :created_at, :updated_at
|
3
27
|
|
@@ -1,4 +1,65 @@
|
|
1
1
|
FinancialTxn.class_eval do
|
2
2
|
has_many :payments
|
3
|
-
|
3
|
+
|
4
|
+
def has_captured_payment?
|
5
|
+
has_payments? and self.payments.last.current_state == 'captured'
|
6
|
+
end
|
7
|
+
|
8
|
+
def has_pending_payment?
|
9
|
+
has_payments? and self.payments.last.current_state == 'pending'
|
10
|
+
end
|
11
|
+
|
12
|
+
def is_pending?
|
13
|
+
self.is_scheduled? || self.has_pending_payment?
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_scheduled?
|
17
|
+
((self.apply_date > Date.today) or (!self.has_payments?))
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_payments?
|
21
|
+
!self.payments.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def most_recent_payment
|
25
|
+
Payment.order('created_at DESC').where('financial_txn_id = ?', self.id).first
|
26
|
+
end
|
27
|
+
|
28
|
+
def refund(gateway_wrapper, gateway_options={})
|
29
|
+
begin
|
30
|
+
ActiveRecord::Base.transaction do
|
31
|
+
# make sure we have payments and they are captured
|
32
|
+
if has_payments? && has_captured_payment?
|
33
|
+
result = {success: true}
|
34
|
+
|
35
|
+
if txn_type.internal_identifier == 'credit_card_payment'
|
36
|
+
result = CreditCardAccount.new.refund(self, gateway_wrapper, gateway_options)
|
37
|
+
|
38
|
+
else
|
39
|
+
payment = most_recent_payment
|
40
|
+
payment.refund
|
41
|
+
payment.save
|
42
|
+
|
43
|
+
result[:message] = 'Payment Refunded'
|
44
|
+
end
|
45
|
+
|
46
|
+
# if the refund was a success un-apply the payments
|
47
|
+
if result[:success]
|
48
|
+
payment_applications.each do |payment_application|
|
49
|
+
payment_application.unapply_payment
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
result
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue => ex
|
58
|
+
Rails.logger.error(ex.message)
|
59
|
+
Rails.logger.error(ex.backtrace.join("\n"))
|
60
|
+
|
61
|
+
{success: false, message: 'Could not refund'}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
4
65
|
end
|
@@ -1,3 +1,51 @@
|
|
1
|
+
# create_table :order_txns do |t|
|
2
|
+
# t.column :state_machine, :string
|
3
|
+
# t.column :description, :string
|
4
|
+
# t.column :order_txn_type_id, :integer
|
5
|
+
#
|
6
|
+
# # Multi-table inheritance info
|
7
|
+
# t.column :order_txn_record_id, :integer
|
8
|
+
# t.column :order_txn_record_type, :string
|
9
|
+
#
|
10
|
+
# # Contact Information
|
11
|
+
# t.column :email, :string
|
12
|
+
# t.column :phone_number, :string
|
13
|
+
#
|
14
|
+
# # Shipping Address
|
15
|
+
# t.column :ship_to_first_name, :string
|
16
|
+
# t.column :ship_to_last_name, :string
|
17
|
+
# t.column :ship_to_address_line_1, :string
|
18
|
+
# t.column :ship_to_address_line_2, :string
|
19
|
+
# t.column :ship_to_city, :string
|
20
|
+
# t.column :ship_to_state, :string
|
21
|
+
# t.column :ship_to_postal_code, :string
|
22
|
+
# t.column :ship_to_country, :string
|
23
|
+
#
|
24
|
+
# # Billing Address
|
25
|
+
# t.column :bill_to_first_name, :string
|
26
|
+
# t.column :bill_to_last_name, :string
|
27
|
+
# t.column :bill_to_address_line_1, :string
|
28
|
+
# t.column :bill_to_address_line_2, :string
|
29
|
+
# t.column :bill_to_city, :string
|
30
|
+
# t.column :bill_to_state, :string
|
31
|
+
# t.column :bill_to_postal_code, :string
|
32
|
+
# t.column :bill_to_country, :string
|
33
|
+
#
|
34
|
+
# # Private parts
|
35
|
+
# t.column :customer_ip, :string
|
36
|
+
# t.column :order_number, :integer
|
37
|
+
# t.column :status, :string
|
38
|
+
# t.column :error_message, :string
|
39
|
+
#
|
40
|
+
# t.timestamps
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# add_index :order_txns, :order_txn_type_id
|
44
|
+
# add_index :order_txns, [:order_txn_record_id, :order_txn_record_type], :name => 'order_txn_record_idx'
|
45
|
+
#
|
46
|
+
# add_index :order_txns, :order_txn_type_id
|
47
|
+
# add_index :order_txns, [:order_txn_record_id, :order_txn_record_type], :name => 'order_txn_record_idx'
|
48
|
+
|
1
49
|
OrderTxn.class_eval do
|
2
50
|
acts_as_priceable
|
3
51
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Party.class_eval do
|
2
2
|
|
3
3
|
#credit cards
|
4
|
-
|
5
|
-
|
4
|
+
has_many :credit_card_account_party_roles, :dependent => :destroy
|
5
|
+
|
6
6
|
# return primary credit card
|
7
7
|
def primary_credit_card
|
8
8
|
return get_credit_card('primary')
|
@@ -10,20 +10,33 @@ Party.class_eval do
|
|
10
10
|
|
11
11
|
# return credit card by credit card account purpose using internal identifier
|
12
12
|
def get_credit_card(internal_identifier)
|
13
|
+
credit_card = nil
|
14
|
+
|
13
15
|
self.credit_card_account_party_roles.each do |ccapr|
|
14
16
|
if ccapr.credit_card_account.credit_card_account_purpose.internal_identifier.eql?(internal_identifier)
|
15
|
-
|
17
|
+
credit_card = ccapr.credit_card
|
16
18
|
end
|
17
|
-
end
|
18
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
credit_card
|
22
|
+
end
|
23
|
+
|
24
|
+
def credit_cards
|
25
|
+
credit_cards = []
|
26
|
+
|
27
|
+
self.credit_card_account_party_roles.each do |ccapr|
|
28
|
+
credit_cards << ccapr.credit_card
|
29
|
+
end
|
30
|
+
|
31
|
+
credit_cards
|
19
32
|
end
|
20
33
|
|
21
34
|
def credit_card_accounts
|
22
|
-
|
35
|
+
self.accounts.where('biz_txn_acct_type = ?', 'CreditCardAccount').all.collect(&:account)
|
23
36
|
end
|
24
37
|
|
25
38
|
def bank_accounts
|
26
|
-
|
39
|
+
self.accounts.where('biz_txn_acct_type = ?', 'BankAccount').all.collect(&:account)
|
27
40
|
end
|
28
41
|
|
29
42
|
def payment_accounts
|
@@ -35,12 +48,12 @@ Party.class_eval do
|
|
35
48
|
#displaying in CSR, website, etc.
|
36
49
|
def payment_accounts_hash
|
37
50
|
cc_results = credit_card_accounts.map do |cca|
|
38
|
-
{
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
51
|
+
{id: cca.id,
|
52
|
+
description: cca.credit_card.description,
|
53
|
+
card_type: cca.credit_card.card_type,
|
54
|
+
last_four: nil, #not stored yet
|
55
|
+
exp_dt: "#{cca.credit_card.expiration_month}-#{cca.credit_card.expiration_year}",
|
56
|
+
account_type: 'Credit Card'}
|
44
57
|
end
|
45
58
|
|
46
59
|
ba_results = bank_accounts.map do |ba|
|