kaui 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile.lock +51 -37
- data/README.md +5 -0
- data/Rakefile +1 -1
- data/app/controllers/kaui/account_emails_controller.rb +26 -44
- data/app/controllers/kaui/account_tags_controller.rb +26 -38
- data/app/controllers/kaui/account_timelines_controller.rb +47 -50
- data/app/controllers/kaui/accounts_controller.rb +68 -148
- data/app/controllers/kaui/bundle_tags_controller.rb +32 -21
- data/app/controllers/kaui/bundles_controller.rb +44 -69
- data/app/controllers/kaui/chargebacks_controller.rb +31 -61
- data/app/controllers/kaui/charges_controller.rb +19 -21
- data/app/controllers/kaui/credits_controller.rb +22 -36
- data/app/controllers/kaui/custom_fields_controller.rb +15 -13
- data/app/controllers/kaui/engine_controller.rb +8 -10
- data/app/controllers/kaui/invoice_items_controller.rb +24 -41
- data/app/controllers/kaui/invoices_controller.rb +36 -46
- data/app/controllers/kaui/payment_methods_controller.rb +84 -28
- data/app/controllers/kaui/payments_controller.rb +64 -26
- data/app/controllers/kaui/refunds_controller.rb +27 -107
- data/app/controllers/kaui/subscriptions_controller.rb +88 -132
- data/app/controllers/kaui/tag_definitions_controller.rb +32 -79
- data/app/controllers/kaui/tags_controller.rb +16 -14
- data/app/controllers/kaui/transactions_controller.rb +25 -0
- data/app/helpers/kaui/money_helper.rb +8 -0
- data/app/helpers/kaui/subscription_helper.rb +115 -0
- data/app/helpers/kaui/uuid_helper.rb +9 -0
- data/app/models/kaui/ability.rb +2 -2
- data/app/models/kaui/account.rb +25 -42
- data/app/models/kaui/account_email.rb +11 -48
- data/app/models/kaui/account_timeline.rb +1 -5
- data/app/models/kaui/audit_log.rb +1 -15
- data/app/models/kaui/base.rb +1 -126
- data/app/models/kaui/bundle.rb +47 -14
- data/app/models/kaui/catalog.rb +2 -0
- data/app/models/kaui/chargeback.rb +24 -36
- data/app/models/kaui/credit.rb +5 -20
- data/app/models/kaui/custom_field.rb +9 -5
- data/app/models/kaui/invoice.rb +9 -53
- data/app/models/kaui/invoice_item.rb +8 -18
- data/app/models/kaui/invoice_payment.rb +24 -0
- data/app/models/kaui/payment.rb +14 -32
- data/app/models/kaui/payment_method.rb +36 -0
- data/app/models/kaui/rails_methods.rb +7 -9
- data/app/models/kaui/refund.rb +5 -20
- data/app/models/kaui/subscription.rb +7 -27
- data/app/models/kaui/tag.rb +10 -6
- data/app/models/kaui/tag_definition.rb +26 -34
- data/app/models/kaui/transaction.rb +30 -0
- data/app/models/kaui/user.rb +2 -0
- data/app/views/kaui/account_emails/_form.html.erb +8 -28
- data/app/views/kaui/account_emails/show.html.erb +10 -10
- data/app/views/kaui/account_tags/_account_tags_table.html.erb +20 -18
- data/app/views/kaui/account_tags/_form.html.erb +42 -0
- data/app/views/kaui/account_tags/edit.html.erb +1 -41
- data/app/views/kaui/account_tags/show.html.erb +6 -3
- data/app/views/kaui/account_timelines/show.html.erb +273 -302
- data/app/views/kaui/accounts/_form.html.erb +116 -0
- data/app/views/kaui/accounts/index.html.erb +13 -11
- data/app/views/kaui/accounts/new.html.erb +5 -0
- data/app/views/kaui/accounts/show.html.erb +101 -99
- data/app/views/kaui/bundle_tags/_bundle_tags_table.html.erb +29 -9
- data/app/views/kaui/bundle_tags/_form.html.erb +41 -0
- data/app/views/kaui/bundle_tags/edit.html.erb +2 -34
- data/app/views/kaui/bundle_tags/show.html.erb +6 -0
- data/app/views/kaui/bundles/index.html.erb +9 -9
- data/app/views/kaui/bundles/show.html.erb +17 -15
- data/app/views/kaui/bundles/transfer.html.erb +25 -24
- data/app/views/kaui/chargebacks/_form.html.erb +44 -0
- data/app/views/kaui/chargebacks/new.html.erb +3 -115
- data/app/views/kaui/charges/_form.html.erb +73 -0
- data/app/views/kaui/charges/new.html.erb +2 -91
- data/app/views/kaui/credits/_form.html.erb +73 -0
- data/app/views/kaui/credits/new.html.erb +2 -85
- data/app/views/kaui/invoice_items/edit.html.erb +77 -78
- data/app/views/kaui/invoices/show.html.erb +3 -10
- data/app/views/kaui/layouts/kaui_application.html.erb +0 -2
- data/app/views/kaui/payment_methods/_form.html.erb +30 -0
- data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +19 -18
- data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +8 -5
- data/app/views/kaui/payment_methods/index.html.erb +10 -10
- data/app/views/kaui/payment_methods/new.html.erb +2 -20
- data/app/views/kaui/payment_methods/show.html.erb +2 -1
- data/app/views/kaui/payments/_payments_table.html.erb +30 -22
- data/app/views/kaui/payments/index.html.erb +1 -1
- data/app/views/kaui/payments/new.html.erb +5 -5
- data/app/views/kaui/payments/show.html.erb +3 -0
- data/app/views/kaui/refunds/new.html.erb +96 -104
- data/app/views/kaui/subscriptions/_form.html.erb +36 -0
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +39 -44
- data/app/views/kaui/subscriptions/edit.html.erb +24 -35
- data/app/views/kaui/subscriptions/index.html.erb +13 -12
- data/app/views/kaui/subscriptions/new.html.erb +6 -43
- data/app/views/kaui/subscriptions/show.html.erb +32 -25
- data/app/views/kaui/tag_definitions/_form.html.erb +10 -37
- data/app/views/kaui/tag_definitions/index.html.erb +3 -5
- data/app/views/kaui/tag_definitions/show.html.erb +1 -2
- data/app/views/kaui/transactions/_form.html.erb +77 -0
- data/app/views/kaui/transactions/new.html.erb +3 -0
- data/config/initializers/kilbill-client-init.rb +1 -1
- data/config/routes.rb +4 -15
- data/kaui.gemspec +8 -6
- data/lib/kaui/engine.rb +4 -1
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +2 -2
- data/test/functional/kaui/account_emails_controller_test.rb +28 -0
- data/test/functional/kaui/account_tags_controller_test.rb +29 -0
- data/test/functional/kaui/account_timelines_controller_test.rb +21 -0
- data/test/functional/kaui/accounts_controller_test.rb +56 -50
- data/test/functional/kaui/bundle_tags_controller_test.rb +29 -0
- data/test/functional/kaui/bundles_controller_test.rb +58 -13
- data/test/functional/kaui/chargebacks_controller_test.rb +16 -5
- data/test/functional/kaui/charges_controller_test.rb +39 -0
- data/test/functional/kaui/credits_controller_test.rb +35 -0
- data/test/functional/kaui/custom_fields_controller_test.rb +21 -0
- data/test/functional/kaui/functional_test_helper.rb +61 -0
- data/test/functional/kaui/invoice_items_controller_test.rb +24 -10
- data/test/functional/kaui/invoices_controller_test.rb +41 -13
- data/test/functional/kaui/payment_methods_controller_test.rb +49 -0
- data/test/functional/kaui/payments_controller_test.rb +32 -5
- data/test/functional/kaui/refunds_controller_test.rb +40 -5
- data/test/functional/kaui/subscriptions_controller_test.rb +82 -0
- data/test/functional/kaui/tag_definitions_controller_test.rb +27 -53
- data/test/functional/kaui/tags_controller_test.rb +21 -0
- data/test/functional/kaui/transactions_controller_test.rb +32 -0
- data/test/integration/kaui/integration_test_helper.rb +31 -0
- data/test/integration/kaui/navigation_test.rb +43 -0
- data/test/killbill_test_helper.rb +143 -0
- data/test/test_helper.rb +10 -227
- data/test/unit/kaui/account_email_test.rb +19 -0
- data/test/unit/kaui/account_test.rb +7 -35
- data/test/unit/kaui/base_test.rb +5 -46
- data/test/unit/kaui/date_helper_test.rb +6 -5
- data/test/unit/kaui/invoice_item_test.rb +5 -17
- data/test/unit/kaui/invoice_payment_test.rb +42 -0
- data/test/unit/kaui/invoice_test.rb +15 -15
- data/test/unit/kaui/money_helper_test.rb +10 -0
- data/test/unit/kaui/payment_test.rb +42 -0
- data/test/unit/kaui/tag_definition_test.rb +5 -28
- data/test/unit/kaui/uuid_helper_test.rb +10 -0
- metadata +134 -159
- data/app/controllers/kaui/analytics_controller.rb +0 -28
- data/app/helpers/kaui/killbill_helper.rb +0 -611
- data/app/models/kaui/analytics.rb +0 -19
- data/app/models/kaui/analytics_sanity.rb +0 -7
- data/app/models/kaui/business_account.rb +0 -12
- data/app/models/kaui/business_field.rb +0 -6
- data/app/models/kaui/business_invoice.rb +0 -31
- data/app/models/kaui/business_invoice_item.rb +0 -17
- data/app/models/kaui/business_invoice_payment.rb +0 -25
- data/app/models/kaui/business_overdue_status.rb +0 -8
- data/app/models/kaui/business_snapshot.rb +0 -9
- data/app/models/kaui/business_subscription_transition.rb +0 -53
- data/app/models/kaui/business_tag.rb +0 -5
- data/app/models/kaui/charge.rb +0 -14
- data/app/models/kaui/entitlement.rb +0 -2
- data/app/models/kaui/event.rb +0 -13
- data/app/models/kaui/external_payment.rb +0 -15
- data/app/models/kaui/overdue_state.rb +0 -10
- data/app/models/kaui/payment_attempt.rb +0 -27
- data/app/models/kaui/product.rb +0 -24
- data/app/models/kaui/time_series_data.rb +0 -8
- data/app/views/kaui/analytics/account_snapshot.html.erb +0 -211
- data/app/views/kaui/analytics/index.html.erb +0 -17
- data/app/views/kaui/chargebacks/index.html.erb +0 -14
- data/app/views/kaui/chargebacks/show.html.erb +0 -19
- data/app/views/kaui/credits/index.html.erb +0 -14
- data/app/views/kaui/credits/show.html.erb +0 -19
- data/app/views/kaui/invoice_items/index.html.erb +0 -20
- data/app/views/kaui/invoice_items/show.html.erb +0 -31
- data/app/views/kaui/refunds/_refunds_table.html.erb +0 -31
- data/app/views/kaui/refunds/index.html.erb +0 -43
- data/app/views/kaui/refunds/show.html.erb +0 -33
- data/app/views/kaui/tag_definitions/edit.html.erb +0 -3
- data/test/dummy/test/fixtures/accounts.yml +0 -32
- data/test/dummy/test/fixtures/bill_cycle_days.yml +0 -3
- data/test/dummy/test/fixtures/bundles.yml +0 -4
- data/test/dummy/test/fixtures/invoice_items.yml +0 -13
- data/test/dummy/test/fixtures/invoices.yml +0 -11
- data/test/dummy/test/fixtures/overdue_states.yml +0 -8
- data/test/dummy/test/fixtures/payment_methods.yml +0 -5
- data/test/dummy/test/fixtures/plugin_info_properties.yml +0 -59
- data/test/dummy/test/fixtures/plugin_infos.yml +0 -2
- data/test/dummy/test/fixtures/refunds.yml +0 -9
- data/test/dummy/test/fixtures/tag_definitions.yml +0 -20
- data/test/functional/kaui/account_timeline_controller_test.rb +0 -9
- data/test/functional/kaui/extpayments_controller_test.rb +0 -9
- data/test/functional/kaui/home_controller_test.rb +0 -11
- data/test/integration/navigation_test.rb +0 -10
- data/test/kaui_test.rb +0 -7
- data/test/unit/helpers/kaui/account_timeline_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/bundles_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/chargebacks_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/extpayments_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/home_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/invoices_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/payments_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/refunds_helper_test.rb +0 -6
- data/test/unit/kaui/overdue_state_test.rb +0 -18
- data/test/unit/kaui/refund_test.rb +0 -20
- data/test/unit/model_test.rb +0 -151
data/app/models/kaui/invoice.rb
CHANGED
@@ -1,60 +1,16 @@
|
|
1
|
-
class Kaui::Invoice <
|
2
|
-
define_attr :amount
|
3
|
-
define_attr :balance
|
4
|
-
define_attr :invoice_id
|
5
|
-
define_attr :account_id
|
6
|
-
define_attr :invoice_number
|
7
|
-
define_attr :payment_amount
|
8
|
-
define_attr :refund_adjustment
|
9
|
-
define_attr :credit_balance_adjustment
|
10
|
-
define_attr :credit_adjustment
|
11
|
-
define_attr :invoice_date
|
12
|
-
define_attr :payment_dt
|
13
|
-
define_attr :target_date
|
14
|
-
define_attr :bundle_keys
|
1
|
+
class Kaui::Invoice < KillBillClient::Model::Invoice
|
15
2
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
super(:account_id => data['accountId'],
|
21
|
-
:amount => data['amount'],
|
22
|
-
:balance => data['balance'],
|
23
|
-
:credit_balance_adjustment => data['cba'],
|
24
|
-
:credit_adjustment => data['creditAdj'],
|
25
|
-
:invoice_date => data['invoiceDate'],
|
26
|
-
:invoice_id => data['invoiceId'],
|
27
|
-
:invoice_number => data['invoiceNumber'],
|
28
|
-
:refund_adjustment => data['refundAdj'],
|
29
|
-
:target_date => data['targetDate'],
|
30
|
-
:items => data['items'] || [],
|
31
|
-
:bundle_keys => data['bundleKeys'],
|
32
|
-
:audit_logs => data['auditLogs'])
|
33
|
-
end
|
34
|
-
|
35
|
-
# TODO - fix invoice json to return the currency
|
36
|
-
|
37
|
-
def amount_to_money(currency)
|
38
|
-
Kaui::Base.to_money(amount, currency)
|
39
|
-
end
|
40
|
-
|
41
|
-
def balance_to_money(currency)
|
42
|
-
Kaui::Base.to_money(balance, currency)
|
43
|
-
end
|
44
|
-
|
45
|
-
def payment_amount_to_money(currency)
|
46
|
-
Kaui::Base.to_money(payment_amount, currency)
|
47
|
-
end
|
48
|
-
|
49
|
-
def refund_adjustment_to_money(currency)
|
50
|
-
Kaui::Base.to_money(refund_adjustment, currency)
|
3
|
+
[:amount, :balance, :credits].each do |type|
|
4
|
+
define_method "#{type}_to_money" do
|
5
|
+
Kaui::Base.to_money(send(type), currency)
|
6
|
+
end
|
51
7
|
end
|
52
8
|
|
53
|
-
def
|
54
|
-
Kaui::Base.to_money(
|
9
|
+
def refund_adjustment_to_money
|
10
|
+
Kaui::Base.to_money(refund_adj, currency)
|
55
11
|
end
|
56
12
|
|
57
|
-
def credit_adjustment_to_money
|
58
|
-
Kaui::Base.to_money(
|
13
|
+
def credit_adjustment_to_money
|
14
|
+
Kaui::Base.to_money(credit_adj, currency)
|
59
15
|
end
|
60
16
|
end
|
@@ -1,24 +1,14 @@
|
|
1
|
-
class Kaui::InvoiceItem <
|
2
|
-
SAMPLE_REASON_CODES = [ "100 - Courtesy",
|
3
|
-
"101 - Billing Error",
|
4
|
-
"199 - OTHER" ]
|
1
|
+
class Kaui::InvoiceItem < KillBillClient::Model::InvoiceItem
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
define_attr :bundle_id
|
10
|
-
define_attr :subscription_id
|
11
|
-
define_attr :plan_name
|
12
|
-
define_attr :phase_name
|
13
|
-
define_attr :description
|
14
|
-
define_attr :start_date
|
15
|
-
define_attr :end_date
|
16
|
-
define_attr :amount
|
17
|
-
define_attr :currency
|
18
|
-
define_attr :linked_invoice_item_id
|
19
|
-
define_attr :audit_logs
|
3
|
+
SAMPLE_REASON_CODES = ['100 - Courtesy',
|
4
|
+
'101 - Billing Error',
|
5
|
+
'199 - OTHER']
|
20
6
|
|
21
7
|
def amount_to_money
|
22
8
|
Kaui::Base.to_money(amount, currency)
|
23
9
|
end
|
10
|
+
|
11
|
+
def self.amount_to_money(invoice_item)
|
12
|
+
self.new(:amount => invoice_item.amount, :currency => invoice_item.currency).amount_to_money
|
13
|
+
end
|
24
14
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Kaui::InvoicePayment < KillBillClient::Model::InvoicePayment
|
2
|
+
|
3
|
+
SAMPLE_REASON_CODES = ['600 - Alt payment method',
|
4
|
+
'699 - OTHER']
|
5
|
+
|
6
|
+
[:auth, :captured, :purchased, :refunded, :credited].each do |type|
|
7
|
+
define_method "#{type}_amount_to_money" do
|
8
|
+
Kaui::Base.to_money(send("#{type}_amount"), currency)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def paid_amount_to_money
|
13
|
+
captured_amount_to_money + purchased_amount_to_money
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO Better name?
|
17
|
+
def returned_amount_to_money
|
18
|
+
refunded_amount_to_money + credited_amount_to_money
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_fully_refunded?
|
22
|
+
refunded_amount == captured_amount || refunded_amount == purchased_amount
|
23
|
+
end
|
24
|
+
end
|
data/app/models/kaui/payment.rb
CHANGED
@@ -1,42 +1,24 @@
|
|
1
|
-
class Kaui::Payment <
|
1
|
+
class Kaui::Payment < KillBillClient::Model::Payment
|
2
2
|
|
3
|
-
SAMPLE_REASON_CODES = [
|
4
|
-
|
3
|
+
SAMPLE_REASON_CODES = ['600 - Alt payment method',
|
4
|
+
'699 - OTHER']
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
define_attr :effective_date
|
11
|
-
define_attr :paid_amount
|
12
|
-
define_attr :payment_id
|
13
|
-
define_attr :payment_method_id
|
14
|
-
# TODO - is this used?
|
15
|
-
define_attr :refund_amount
|
16
|
-
define_attr :requested_date
|
17
|
-
define_attr :retry_count
|
18
|
-
define_attr :status
|
19
|
-
define_attr :bundle_keys
|
20
|
-
define_attr :ext_first_payment_id_ref
|
21
|
-
define_attr :ext_second_payment_id_ref
|
22
|
-
define_attr :gateway_error_code
|
23
|
-
define_attr :gateway_error_msg
|
24
|
-
define_attr :external
|
25
|
-
|
26
|
-
has_many :refunds, Kaui::Refund
|
27
|
-
has_many :chargebacks, Kaui::Chargeback
|
28
|
-
has_many :audit_logs, Kaui::AuditLog
|
29
|
-
|
30
|
-
def amount_to_money
|
31
|
-
Kaui::Base.to_money(amount, currency)
|
6
|
+
[:auth, :captured, :purchased, :refunded, :credited].each do |type|
|
7
|
+
define_method "#{type}_amount_to_money" do
|
8
|
+
Kaui::Base.to_money(send("#{type}_amount"), currency)
|
9
|
+
end
|
32
10
|
end
|
33
11
|
|
34
12
|
def paid_amount_to_money
|
35
|
-
|
13
|
+
captured_amount_to_money + purchased_amount_to_money
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO Better name?
|
17
|
+
def returned_amount_to_money
|
18
|
+
refunded_amount_to_money + credited_amount_to_money
|
36
19
|
end
|
37
20
|
|
38
21
|
def is_fully_refunded?
|
39
|
-
|
40
|
-
paid_amount == 0
|
22
|
+
refunded_amount == captured_amount || refunded_amount == purchased_amount
|
41
23
|
end
|
42
24
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Kaui::PaymentMethod < KillBillClient::Model::PaymentMethod
|
2
|
+
|
3
|
+
def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {})
|
4
|
+
if search_key.present?
|
5
|
+
find_in_batches_by_search_key(search_key, offset, limit, options)
|
6
|
+
else
|
7
|
+
find_in_batches(offset, limit, options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_non_external_by_account_id(account_id, with_plugin_info = false, options = {})
|
12
|
+
payment_methods = find_all_by_account_id(account_id, with_plugin_info, options)
|
13
|
+
payment_methods.reject { |x| x.plugin_name == '__EXTERNAL_PAYMENT__' }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.payment_methods_for_payments(payments = [], options = {})
|
17
|
+
payment_method_per_payment = {}
|
18
|
+
payment_methods_cache = {}
|
19
|
+
deleted_payment_methods = Set.new
|
20
|
+
|
21
|
+
payments.each do |payment|
|
22
|
+
next if deleted_payment_methods.include?(payment.payment_method_id)
|
23
|
+
|
24
|
+
# The payment method may have been deleted
|
25
|
+
payment_methods_cache[payment.payment_method_id] ||= Kaui::PaymentMethod.find_by_id(payment.payment_method_id, true, options) rescue nil
|
26
|
+
|
27
|
+
if payment_methods_cache[payment.payment_method_id].nil?
|
28
|
+
deleted_payment_methods.add(payment.payment_method_id)
|
29
|
+
else
|
30
|
+
payment_method_per_payment[payment.payment_id] = payment_methods_cache[payment.payment_method_id]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
payment_method_per_payment
|
35
|
+
end
|
36
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
module Kaui
|
2
2
|
module RailsMethods
|
3
|
-
|
4
|
-
# let all the rails mocks and overrides be here
|
3
|
+
|
5
4
|
def self.included(base_class)
|
6
5
|
base_class.class_eval do
|
6
|
+
# Required to build urls in views
|
7
7
|
extend ActiveModel::Naming
|
8
8
|
include ActiveModel::Validations
|
9
|
+
# Required to make form_for work
|
9
10
|
include ActiveModel::Conversion
|
10
11
|
|
11
12
|
def ==(other)
|
@@ -13,7 +14,8 @@ module Kaui
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def persisted?
|
16
|
-
|
17
|
+
# Hard to know...
|
18
|
+
false
|
17
19
|
end
|
18
20
|
|
19
21
|
def new_record?
|
@@ -21,8 +23,8 @@ module Kaui
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def to_param
|
24
|
-
#
|
25
|
-
|
26
|
+
# Hard to know (depends on the model)...
|
27
|
+
nil
|
26
28
|
end
|
27
29
|
|
28
30
|
def read_attribute_for_validation(attr)
|
@@ -66,11 +68,7 @@ module Kaui
|
|
66
68
|
def self.find(id)
|
67
69
|
nil
|
68
70
|
end
|
69
|
-
|
70
71
|
end # end class methods
|
71
|
-
|
72
72
|
end # end def included
|
73
|
-
|
74
|
-
|
75
73
|
end
|
76
74
|
end
|
data/app/models/kaui/refund.rb
CHANGED
@@ -1,22 +1,7 @@
|
|
1
|
-
class Kaui::Refund
|
2
|
-
SAMPLE_REASON_CODES = [ "500 - Courtesy",
|
3
|
-
"501 - Billing Error",
|
4
|
-
"502 - Alt payment method",
|
5
|
-
"599 - OTHER" ]
|
1
|
+
class Kaui::Refund
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
define_attr :currency
|
12
|
-
define_attr :requested_date
|
13
|
-
define_attr :effective_date
|
14
|
-
define_attr :adjustment_type
|
15
|
-
|
16
|
-
has_many :audit_logs, Kaui::AuditLog
|
17
|
-
has_many :adjustments, Kaui::InvoiceItem
|
18
|
-
|
19
|
-
def amount_to_money
|
20
|
-
Kaui::Base.to_money(amount, currency)
|
21
|
-
end
|
3
|
+
SAMPLE_REASON_CODES = ['500 - Courtesy',
|
4
|
+
'501 - Billing Error',
|
5
|
+
'502 - Alt payment method',
|
6
|
+
'599 - OTHER']
|
22
7
|
end
|
@@ -1,30 +1,10 @@
|
|
1
|
-
class Kaui::Subscription <
|
2
|
-
define_attr :account_id
|
3
|
-
define_attr :subscription_id
|
4
|
-
define_attr :bundle_id
|
5
|
-
define_attr :external_key
|
6
|
-
define_attr :product_category
|
7
|
-
define_attr :product_name
|
8
|
-
define_attr :billing_period
|
9
|
-
define_attr :charged_through_date
|
10
|
-
define_attr :price_list
|
11
|
-
define_attr :start_date
|
12
|
-
define_attr :canceled_date
|
1
|
+
class Kaui::Subscription < KillBillClient::Model::Subscription
|
13
2
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
:external_key => data['externalKey'] || data['external_key'],
|
21
|
-
:product_category => data['productCategory'] || data['product_category'],
|
22
|
-
:product_name => data['productName'] || data['product_name'],
|
23
|
-
:billing_period => data['billingPeriod'] || data['billing_period'],
|
24
|
-
:charged_through_date => data['chargedThroughDate'] || data['charged_through_date'],
|
25
|
-
:price_list => data['priceList'] || data['price_list'],
|
26
|
-
:start_date => data['startDate'] || data['start_date'],
|
27
|
-
:canceled_date => data['cancelledDate'] || data['canceled_date'],
|
28
|
-
:events => data['events'])
|
3
|
+
def cancel_entitlement_immediately(user = nil, reason = nil, comment = nil, options = {})
|
4
|
+
requested_date = nil
|
5
|
+
entitlement_policy = 'IMMEDIATE'
|
6
|
+
billing_policy = nil
|
7
|
+
use_requested_date_for_billing = true
|
8
|
+
cancel(user, reason, comment, requested_date, entitlement_policy, billing_policy, use_requested_date_for_billing, options)
|
29
9
|
end
|
30
10
|
end
|
data/app/models/kaui/tag.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
class Kaui::Tag <
|
1
|
+
class Kaui::Tag < KillBillClient::Model::Tag
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {})
|
4
|
+
if search_key.present?
|
5
|
+
find_in_batches_by_search_key(search_key, offset, limit, options)
|
6
|
+
else
|
7
|
+
find_in_batches(offset, limit, options)
|
8
|
+
end
|
9
|
+
end
|
6
10
|
|
7
11
|
def is_system_tag?
|
8
12
|
Kaui::TagDefinition(:id => tag_definition_id).is_system_tag?
|
9
13
|
end
|
10
14
|
|
11
15
|
def <=>(tag)
|
12
|
-
|
16
|
+
tag_definition_name.downcase <=> tag.tag_definition_name.downcase
|
13
17
|
end
|
14
|
-
end
|
18
|
+
end
|
@@ -1,36 +1,28 @@
|
|
1
|
-
class Kaui::TagDefinition <
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
Kaui::KillbillHelper.create_tag_definition(self, user, reason, comment, options_for_klient)
|
27
|
-
# TODO - we should return the newly created id and update the model
|
28
|
-
# @persisted = true
|
29
|
-
end
|
30
|
-
|
31
|
-
def destroy(user = nil, reason = nil, comment = nil, options_for_klient = {})
|
32
|
-
Kaui::KillbillHelper.delete_tag_definition(@id, user, reason, comment, options_for_klient)
|
33
|
-
@persisted = false
|
1
|
+
class Kaui::TagDefinition < KillBillClient::Model::TagDefinition
|
2
|
+
|
3
|
+
# See org.killbill.billing.ObjectType in killbill-api
|
4
|
+
%w(ACCOUNT
|
5
|
+
ACCOUNT_EMAIL
|
6
|
+
BLOCKING_STATES
|
7
|
+
BUNDLE
|
8
|
+
CUSTOM_FIELD
|
9
|
+
INVOICE
|
10
|
+
PAYMENT
|
11
|
+
TRANSACTION
|
12
|
+
INVOICE_ITEM
|
13
|
+
INVOICE_PAYMENT
|
14
|
+
SUBSCRIPTION
|
15
|
+
SUBSCRIPTION_EVENT
|
16
|
+
PAYMENT_ATTEMPT
|
17
|
+
PAYMENT_METHOD
|
18
|
+
REFUND
|
19
|
+
TAG
|
20
|
+
TAG_DEFINITION
|
21
|
+
TENANT
|
22
|
+
TENANT_KVS).each do |object_type|
|
23
|
+
define_singleton_method "all_for_#{object_type.downcase}" do |options_for_klient|
|
24
|
+
(self.all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include? object_type }).sort
|
25
|
+
end
|
34
26
|
end
|
35
27
|
|
36
28
|
def is_system_tag?
|
@@ -51,6 +43,6 @@ class Kaui::TagDefinition < Kaui::Base
|
|
51
43
|
# System tags last
|
52
44
|
return 1 if is_system_tag? and !tag_definition.is_system_tag?
|
53
45
|
return -1 if !is_system_tag? and tag_definition.is_system_tag?
|
54
|
-
|
46
|
+
name <=> tag_definition.name
|
55
47
|
end
|
56
48
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Kaui::Transaction < KillBillClient::Model::Transaction
|
2
|
+
|
3
|
+
def create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
|
4
|
+
if transaction_type == 'AUTHORIZE'
|
5
|
+
auth(account_id, payment_method_id, user, reason, comment, options)
|
6
|
+
elsif transaction_type == 'CAPTURE'
|
7
|
+
capture(user, reason, comment, options)
|
8
|
+
elsif transaction_type == 'CHARGEBACK'
|
9
|
+
chargeback(user, reason, comment, options)
|
10
|
+
elsif transaction_type == 'CREDIT'
|
11
|
+
credit(account_id, payment_method_id, user, reason, comment, options)
|
12
|
+
elsif transaction_type == 'PURCHASE'
|
13
|
+
purchase(account_id, payment_method_id, user, reason, comment, options)
|
14
|
+
elsif transaction_type == 'REFUND'
|
15
|
+
refund(user, reason, comment, options)
|
16
|
+
elsif transaction_type == 'VOID'
|
17
|
+
void(user, reason, comment, options)
|
18
|
+
else
|
19
|
+
raise ArgumentError.new("Unknown transaction type #{transaction_type}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def amount_to_money
|
24
|
+
Kaui::Base.to_money(amount, currency)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.amount_to_money(transaction)
|
28
|
+
self.new(:amount => transaction.amount, :currency => transaction.currency).amount_to_money
|
29
|
+
end
|
30
|
+
end
|
data/app/models/kaui/user.rb
CHANGED
@@ -1,33 +1,13 @@
|
|
1
1
|
<%= form_for(@account_email) do |f| %>
|
2
|
-
|
3
|
-
<div class='
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<li><%= msg %></li>
|
9
|
-
<% end %>
|
10
|
-
</ul>
|
2
|
+
<%= f.hidden_field :account_id %>
|
3
|
+
<div class='control-group'>
|
4
|
+
<%= f.label :email, 'Email *', :class => 'control-label' %>
|
5
|
+
<div class='controls'>
|
6
|
+
<%= f.text_field :email, :required => true %>
|
7
|
+
</div>
|
11
8
|
</div>
|
12
|
-
<% end %>
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
<div class='controls'>
|
17
|
-
<%= f.text_field :account_id, :class => 'input-xlarge' %>
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
<div class='control-group'>
|
21
|
-
<%= f.label :email, 'Email:', :class => 'control-label' %>
|
22
|
-
<div class='controls'>
|
23
|
-
<%= f.text_field :email %>
|
10
|
+
<div class="form-actions">
|
11
|
+
<%= button_tag 'Create email', :class => 'btn btn-primary' %>
|
24
12
|
</div>
|
25
|
-
</div>
|
26
|
-
<div class='form-actions'>
|
27
|
-
<%= f.submit @account_email.new_record? ? 'Create' : 'Update', :class => 'btn btn-primary' %>
|
28
|
-
<% unless @account_email.new_record? %>
|
29
|
-
<%= link_to 'Show', @account_email, :class => 'btn' %>
|
30
|
-
<% end %>
|
31
|
-
<%= link_to 'Back', :back, :class => 'btn' %>
|
32
|
-
</div>
|
33
13
|
<% end %>
|
@@ -2,24 +2,24 @@
|
|
2
2
|
|
3
3
|
<table id='invoice_table' class='table table-condensed data-table'>
|
4
4
|
<thead>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
<tr>
|
6
|
+
<th style='width: 45%'>Account id</th>
|
7
|
+
<th style='width: 45%'>Email</th>
|
8
|
+
<th style='width: 10%'></th>
|
9
|
+
</tr>
|
10
10
|
</thead>
|
11
11
|
<tbody>
|
12
|
-
|
12
|
+
<% @account_emails.each do |account_email| %>
|
13
13
|
<tr>
|
14
|
-
<td><%= link_to account_email.account_id, kaui_engine.account_path(account_email.account_id) %></td>
|
14
|
+
<td><%= link_to truncate_uuid(account_email.account_id), kaui_engine.account_path(account_email.account_id) %></td>
|
15
15
|
<td><%= account_email.email %></td>
|
16
16
|
<td><%= link_to 'Destroy', kaui_engine.account_email_path(account_email.account_id, :email => account_email.email), :confirm => 'Are you sure?', :method => :delete %></td>
|
17
17
|
</tr>
|
18
|
-
|
18
|
+
<% end %>
|
19
19
|
</tbody>
|
20
20
|
</table>
|
21
21
|
|
22
|
-
<br
|
22
|
+
<br/>
|
23
23
|
|
24
24
|
<%= link_to 'New account email', kaui_engine.new_account_email_path(:account_id => @account_id), :class => 'btn btn-primary' %>
|
25
|
-
<%= link_to 'Back to account', kaui_engine.account_path(@account_id), :class => 'btn' %>
|
25
|
+
<%= link_to 'Back to account', kaui_engine.account_path(@account_id), :class => 'btn' %>
|
@@ -3,28 +3,30 @@
|
|
3
3
|
</div>
|
4
4
|
<table class="table table-condensed table-striped data-table">
|
5
5
|
<thead>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
<tr>
|
7
|
+
<th>Tag Name</th>
|
8
|
+
<th>Executed date</th>
|
9
|
+
<th>Execution type</th>
|
10
|
+
<th>Executed by</th>
|
11
|
+
<th>Comments</th>
|
12
|
+
</tr>
|
13
13
|
</thead>
|
14
14
|
<tbody>
|
15
|
-
|
15
|
+
<% if @tags.present? %>
|
16
16
|
<% @tags.each do |tag| %>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
17
|
+
<% tag.audit_logs.each do |log| %>
|
18
|
+
<tr>
|
19
|
+
<td><%= link_to tag.tag_definition_name, tag_definition_path(:id => tag.tag_definition_id) %></td>
|
20
|
+
<td><%= format_date(log.change_date, @account.time_zone).html_safe if log.change_date.present? %></td>
|
21
|
+
<td><span
|
22
|
+
<% if log.change_type != 'INSERT' %>class='alert-error'
|
23
|
+
<% else %>class='alert-success' <% end %>><%= log.change_type %></span></td>
|
24
|
+
<td><%= log.changed_by %></td>
|
25
|
+
<td><%= log.reason_code %> <%= log.comments %></td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
26
28
|
<% end %>
|
27
|
-
|
29
|
+
<% end %>
|
28
30
|
</tbody>
|
29
31
|
</table>
|
30
32
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%= form_tag update_account_tags_path, :class => 'form-horizontal' do %>
|
2
|
+
<%= hidden_field_tag :account_id, @account.account_id %>
|
3
|
+
<fieldset>
|
4
|
+
<div class='control-group'>
|
5
|
+
<label class='control-label'>Account name</label>
|
6
|
+
|
7
|
+
<div class='controls'>
|
8
|
+
<label class='checkbox'>
|
9
|
+
<%= link_to @account.name, @account %><br/>
|
10
|
+
<%= @account.email %>
|
11
|
+
</label>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<div class='control-group'>
|
15
|
+
<%= label_tag :name, 'Tag', :class => 'control-label' %>
|
16
|
+
<div class='controls'>
|
17
|
+
<% @available_tags.each do |tag| %>
|
18
|
+
<label class='checkbox'>
|
19
|
+
<%= check_box_tag "tag_#{tag.id}", tag.name, @tag_names.include?(tag.name) %>
|
20
|
+
<span href='#' class='tag-description' rel='tooltip' title='<%= tag.description %>'><%= tag.name %></span>
|
21
|
+
</label>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class='control-group'>
|
27
|
+
<%= label_tag :comment, 'Comment', :class => "control-label" %>
|
28
|
+
<div class="controls">
|
29
|
+
<%= text_area_tag :comment, '', :rows => 3, :class => 'input-xlarge' %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class='form-actions'>
|
34
|
+
<%= button_tag 'Update', :class => 'btn btn-primary' %>
|
35
|
+
</div>
|
36
|
+
</fieldset>
|
37
|
+
<% end %>
|
38
|
+
<%= javascript_tag do %>
|
39
|
+
$(function() {
|
40
|
+
$('.tag-description').tooltip();
|
41
|
+
});
|
42
|
+
<% end %>
|