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
@@ -1,45 +1,18 @@
|
|
1
1
|
<%= form_for(@tag_definition) do |f| %>
|
2
|
-
|
3
|
-
<div class='alert alert-error'>
|
4
|
-
<h2><%= pluralize(@tag_definition.errors.count, 'error') %> prohibited this tag definition from being saved:</h2>
|
5
|
-
|
6
|
-
<ul>
|
7
|
-
<% @tag_definition.errors.full_messages.each do |msg| %>
|
8
|
-
<li><%= msg %></li>
|
9
|
-
<% end %>
|
10
|
-
</ul>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<% unless @tag_definition.new_record? %>
|
2
|
+
<%= f.hidden_field :id %>
|
15
3
|
<div class='control-group'>
|
16
|
-
<%= f.label :
|
4
|
+
<%= f.label :name, 'Name:', :class => 'control-label' %>
|
17
5
|
<div class='controls'>
|
18
|
-
<%= f.text_field :
|
6
|
+
<%= f.text_field :name %>
|
19
7
|
</div>
|
20
8
|
</div>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<%= f.text_field :name, :class => 'input-large disabled', :readonly => true %>
|
27
|
-
<% else %>
|
28
|
-
<%= f.text_field :name %>
|
29
|
-
<% end %>
|
9
|
+
<div class='control-group'>
|
10
|
+
<%= f.label :description, 'Description:', :class => 'control-label' %>
|
11
|
+
<div class='controls'>
|
12
|
+
<%= f.text_field :description, :class => 'input-xxlarge' %>
|
13
|
+
</div>
|
30
14
|
</div>
|
31
|
-
|
32
|
-
|
33
|
-
<%= f.label :description, 'Description:', :class => 'control-label' %>
|
34
|
-
<div class='controls'>
|
35
|
-
<%= f.text_field :description, :class => 'input-xxlarge' %>
|
15
|
+
<div class='form-actions'>
|
16
|
+
<%= f.submit 'Create', :class => 'btn btn-primary' %>
|
36
17
|
</div>
|
37
|
-
</div>
|
38
|
-
<div class='form-actions'>
|
39
|
-
<%= f.submit @tag_definition.new_record? ? 'Create' : 'Update', :class => 'btn btn-primary' %>
|
40
|
-
<% unless @tag_definition.new_record? %>
|
41
|
-
<%= link_to 'Show', @tag_definition, :class => 'btn' %>
|
42
|
-
<% end %>
|
43
|
-
<%= link_to 'Back', :back, :class => 'btn' %>
|
44
|
-
</div>
|
45
18
|
<% end %>
|
@@ -9,23 +9,21 @@
|
|
9
9
|
<th style='width: 5%'>System tag?</th>
|
10
10
|
<th style='width: 15%'>Applicable types</th>
|
11
11
|
<th style='width: 5%'></th>
|
12
|
-
<!-- <th style='width: 5%'></th> -->
|
13
12
|
<th style='width: 5%'></th>
|
14
13
|
</tr>
|
15
14
|
</thead>
|
16
15
|
<tbody>
|
17
16
|
<% @tag_definitions.each do |tag_definition| %>
|
18
17
|
<tr>
|
19
|
-
<td><%= tag_definition.id %></td>
|
18
|
+
<td><%= truncate_uuid(tag_definition.id) %></td>
|
20
19
|
<td><%= tag_definition.name %></td>
|
21
20
|
<td><%= tag_definition.description %></td>
|
22
21
|
<td><%= tag_definition.is_system_tag? %></td>
|
23
22
|
<td><%= !tag_definition.is_system_tag? ? 'Any' : tag_definition.applicable_object_types.join(', ') %></td>
|
24
|
-
<td><%= link_to 'Show', tag_definition %></td>
|
25
|
-
<!-- ><td><%= link_to 'Edit', edit_tag_definition_path(tag_definition) %></td> -->
|
23
|
+
<td><%= link_to 'Show', kaui_engine.tag_definition_path(tag_definition.id) %></td>
|
26
24
|
<td>
|
27
25
|
<% unless tag_definition.is_system_tag? %>
|
28
|
-
<%= link_to 'Destroy', tag_definition, :confirm => 'Are you sure?', :method => :delete %>
|
26
|
+
<%= link_to 'Destroy', kaui_engine.tag_definition_path(tag_definition.id), :confirm => 'Are you sure?', :method => :delete %>
|
29
27
|
<% end %>
|
30
28
|
</td>
|
31
29
|
</tr>
|
@@ -12,5 +12,4 @@
|
|
12
12
|
<dd><%= @tag_definition.applicable_object_types.join(', ') %> </dd>
|
13
13
|
</dl>
|
14
14
|
|
15
|
-
|
16
|
-
<%= link_to 'Back', kaui_engine.tag_definitions_path, :class => 'btn' %>
|
15
|
+
<%= link_to 'Tag definitions', kaui_engine.tag_definitions_path, :class => 'btn' %>
|
@@ -0,0 +1,77 @@
|
|
1
|
+
<%= form_for(@transaction) do |f| %>
|
2
|
+
<fieldset>
|
3
|
+
<% if @account_id.present? %>
|
4
|
+
<div class="control-group">
|
5
|
+
<%= label_tag :account_id, 'Account id:', :class => 'control-label' %>
|
6
|
+
<div class="controls">
|
7
|
+
<%= text_field_tag :account_id, @account_id, :class => 'input-xlarge disabled', :readonly => true %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
<% if @payment_method_id.present? %>
|
12
|
+
<div class="control-group">
|
13
|
+
<%= label_tag :payment_method_id, 'Payment method id:', :class => 'control-label' %>
|
14
|
+
<div class="controls">
|
15
|
+
<%= text_field_tag :payment_method_id, @payment_method_id, :class => 'input-xlarge disabled', :readonly => true %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
<% if @transaction.payment_id.present? %>
|
20
|
+
<div class="control-group">
|
21
|
+
<%= f.label :payment_id, 'Payment id:', :class => 'control-label' %>
|
22
|
+
<div class="controls">
|
23
|
+
<%= f.text_field :payment_id, :class => 'input-xlarge disabled', :readonly => true %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
<div class="control-group">
|
28
|
+
<%= f.label :transaction_type, 'Transaction type', :class => 'control-label' %>
|
29
|
+
<div class="controls">
|
30
|
+
<%= f.select :transaction_type, %w(AUTHORIZE CAPTURE CHARGEBACK CREDIT PURCHASE REFUND VOID), {}, :class => 'input-medium' %>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<% unless @transaction.transaction_type == 'VOID' %>
|
34
|
+
<div class="control-group">
|
35
|
+
<%= f.label :amount, 'Amount', :class => 'control-label' %>
|
36
|
+
<div class="controls">
|
37
|
+
<%= f.text_field :amount, :id => 'amount', :class => 'input-small' %>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
<div class="control-group">
|
41
|
+
<%= f.label :currency, 'Currency', :class => 'control-label' %>
|
42
|
+
<div class="controls">
|
43
|
+
<%= f.select :currency, currencies, {}, :class => 'input-small' %>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
<% end %>
|
47
|
+
<% unless @transaction.payment_id.present? %>
|
48
|
+
<div class="control-group">
|
49
|
+
<%= f.label :payment_external_key, 'Payment external key', :class => 'control-label' %>
|
50
|
+
<div class="controls">
|
51
|
+
<%= f.text_field :payment_external_key, :class => 'input-medium' %>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
<% end %>
|
55
|
+
<div class="control-group">
|
56
|
+
<%= f.label :transaction_external_key, 'Transaction external key', :class => 'control-label' %>
|
57
|
+
<div class="controls">
|
58
|
+
<%= f.text_field :transaction_external_key, :class => 'input-medium' %>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
<div class="control-group">
|
62
|
+
<%= label_tag :reason, 'Reason', :class => 'control-label' %>
|
63
|
+
<div class="controls">
|
64
|
+
<%= select_tag :reason, options_for_select(Kaui::Payment::SAMPLE_REASON_CODES) %>
|
65
|
+
</div>
|
66
|
+
</div>
|
67
|
+
<div class="control-group">
|
68
|
+
<%= label_tag :comment, 'Comment', :class => 'control-label' %>
|
69
|
+
<div class="controls">
|
70
|
+
<%= text_area_tag :comment, '', :rows => 3, :class => 'input-xlarge' %>
|
71
|
+
</div>
|
72
|
+
</div>
|
73
|
+
<div class='form-actions'>
|
74
|
+
<%= f.submit 'Create', :class => 'btn btn-primary' %>
|
75
|
+
</div>
|
76
|
+
</fieldset>
|
77
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -11,12 +11,9 @@ Kaui::Engine.routes.draw do
|
|
11
11
|
scope "/accounts" do
|
12
12
|
match "/pagination" => "accounts#pagination", :via => :get, :as => "accounts_pagination"
|
13
13
|
end
|
14
|
-
resources :accounts, :only => [ :index, :show ] do
|
14
|
+
resources :accounts, :only => [ :index, :new, :create, :show ] do
|
15
15
|
member do
|
16
|
-
get :payment_methods
|
17
16
|
put :set_default_payment_method
|
18
|
-
get :add_payment_method
|
19
|
-
post :do_add_payment_method
|
20
17
|
delete :delete_payment_method
|
21
18
|
post :toggle_email_notifications
|
22
19
|
post :pay_all_invoices
|
@@ -35,7 +32,7 @@ Kaui::Engine.routes.draw do
|
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
38
|
-
resources :chargebacks, :only => [ :
|
35
|
+
resources :chargebacks, :only => [ :create, :new ]
|
39
36
|
|
40
37
|
resources :credits, :only => [ :create, :new ]
|
41
38
|
|
@@ -47,11 +44,12 @@ Kaui::Engine.routes.draw do
|
|
47
44
|
match "/pagination" => "payments#pagination", :via => :get, :as => "payments_pagination"
|
48
45
|
end
|
49
46
|
resources :payments, :only => [ :create, :new, :index, :show ]
|
47
|
+
resources :transactions, :only => [ :create, :new ]
|
50
48
|
|
51
49
|
scope "/payment_methods" do
|
52
50
|
match "/pagination" => "payment_methods#pagination", :via => :get, :as => "payment_methods_pagination"
|
53
51
|
end
|
54
|
-
resources :payment_methods, :only => [ :index, :show, :destroy ]
|
52
|
+
resources :payment_methods, :only => [ :index, :new, :create, :show, :destroy ]
|
55
53
|
|
56
54
|
scope "/refunds" do
|
57
55
|
match "/pagination" => "refunds#pagination", :via => :get, :as => "refunds_pagination"
|
@@ -85,15 +83,6 @@ Kaui::Engine.routes.draw do
|
|
85
83
|
end
|
86
84
|
end
|
87
85
|
|
88
|
-
scope "/analytics" do
|
89
|
-
match "/" => "analytics#index", :via => :get, :as => "analytics"
|
90
|
-
match "/account_snapshot" => "analytics#account_snapshot", :via => :get, :as => "account_snapshot"
|
91
|
-
match "/refresh_account" => "analytics#refresh_account", :via => :post, :as => "refresh_account"
|
92
|
-
match "/accounts_over_time" => "analytics#accounts_over_time", :via => :get, :as => "analytics_accounts_over_time"
|
93
|
-
match "/subscriptions_over_time" => "analytics#subscriptions_over_time", :via => :get, :as => "analytics_subscriptions_over_time"
|
94
|
-
match "/sanity" => "analytics#sanity", :via => :get, :as => "analytics_sanity"
|
95
|
-
end
|
96
|
-
|
97
86
|
scope "/account_tags" do
|
98
87
|
match "/" => "account_tags#show", :via => :get, :as => "account_tags"
|
99
88
|
match "/edit" => "account_tags#edit", :via => :get, :as => "edit_account_tags"
|
data/kaui.gemspec
CHANGED
@@ -24,19 +24,21 @@ Gem::Specification.new do |s|
|
|
24
24
|
|
25
25
|
s.add_dependency 'rails', '~> 3.2.14'
|
26
26
|
s.add_dependency 'jquery-rails', '~> 3.0.4'
|
27
|
-
s.add_dependency 'rest-client', '~> 1.6.7'
|
28
27
|
s.add_dependency 'money-rails', '~> 0.8.1'
|
29
28
|
s.add_dependency 'd3_rails', '~> 3.2.8'
|
30
|
-
s.add_dependency 'killbill-client', '~> 0.
|
29
|
+
s.add_dependency 'killbill-client', '~> 0.7.3'
|
31
30
|
s.add_dependency 'devise', '~> 3.0.2'
|
32
31
|
s.add_dependency 'cancan', '~> 1.6.10'
|
32
|
+
s.add_dependency 'carmen-rails', '~> 1.0.0'
|
33
33
|
|
34
|
-
s.add_development_dependency
|
34
|
+
s.add_development_dependency 'fakeweb', '~> 1.3'
|
35
|
+
s.add_development_dependency 'rake', '>= 0.8.7'
|
36
|
+
s.add_development_dependency 'simplecov'
|
35
37
|
|
36
38
|
if defined?(JRUBY_VERSION)
|
37
|
-
s.add_development_dependency 'activerecord-jdbc-adapter', '~> 1.
|
38
|
-
s.add_development_dependency 'activerecord-jdbcmysql-adapter', '~> 1.
|
39
|
-
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 1.
|
39
|
+
s.add_development_dependency 'activerecord-jdbc-adapter', '~> 1.3.9'
|
40
|
+
s.add_development_dependency 'activerecord-jdbcmysql-adapter', '~> 1.3.9'
|
41
|
+
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter', '~> 1.3.9'
|
40
42
|
s.add_development_dependency 'jdbc-mysql', '~> 5.1.25'
|
41
43
|
else
|
42
44
|
s.add_development_dependency 'sqlite3'
|
data/lib/kaui/engine.rb
CHANGED
@@ -8,10 +8,10 @@ require 'jquery-rails'
|
|
8
8
|
require 'd3_rails'
|
9
9
|
require 'json'
|
10
10
|
require 'money-rails'
|
11
|
-
require 'rest_client'
|
12
11
|
require 'killbill_client'
|
13
12
|
require 'devise'
|
14
13
|
require 'cancan'
|
14
|
+
require 'carmen-rails'
|
15
15
|
|
16
16
|
module Kaui
|
17
17
|
class Engine < ::Rails::Engine
|
@@ -20,6 +20,9 @@ module Kaui
|
|
20
20
|
initializer 'kaui_engine.action_controller' do |app|
|
21
21
|
ActiveSupport.on_load :action_controller do
|
22
22
|
helper Kaui::DateHelper
|
23
|
+
helper Kaui::MoneyHelper
|
24
|
+
helper Kaui::SubscriptionHelper
|
25
|
+
helper Kaui::UuidHelper
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/kaui/version.rb
CHANGED
data/lib/kaui.rb
CHANGED
@@ -10,7 +10,6 @@ module Kaui
|
|
10
10
|
mattr_accessor :invoice_home_path
|
11
11
|
mattr_accessor :bundle_key_display_string
|
12
12
|
mattr_accessor :creditcard_plugin_name
|
13
|
-
mattr_accessor :default_current_user
|
14
13
|
mattr_accessor :layout
|
15
14
|
mattr_accessor :killbill_url
|
16
15
|
|
@@ -24,11 +23,12 @@ module Kaui
|
|
24
23
|
def self.config(&block)
|
25
24
|
# TODO
|
26
25
|
{
|
27
|
-
:default_current_user => default_current_user || 'Kaui admin user',
|
28
26
|
:layout => layout || 'kaui/layouts/kaui_application',
|
29
27
|
:killbill_url => killbill_url || ENV['KILLBILL_URL'] || 'http://127.0.0.1:8080'
|
30
28
|
}
|
31
29
|
end
|
30
|
+
|
31
|
+
KillBillClient.url = Kaui.killbill_finder.call
|
32
32
|
end
|
33
33
|
|
34
34
|
# ruby-1.8 compatibility
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Kaui::AccountEmailsControllerTest < Kaui::FunctionalTestHelper
|
4
|
+
|
5
|
+
test 'should list emails' do
|
6
|
+
get :show, :id => @account.account_id
|
7
|
+
assert_response 200
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should add and destroy email' do
|
11
|
+
get :new, :account_id => @account.account_id
|
12
|
+
assert_response 200
|
13
|
+
assert_not_nil assigns(:account_email)
|
14
|
+
|
15
|
+
email = SecureRandom.uuid.to_s + '@example.com'
|
16
|
+
post :create,
|
17
|
+
:account_email => {
|
18
|
+
:account_id => @account.account_id,
|
19
|
+
:email => email
|
20
|
+
}
|
21
|
+
assert_redirected_to account_email_path(@account.account_id)
|
22
|
+
assert_equal 'Account email was successfully added', flash[:notice]
|
23
|
+
|
24
|
+
delete :destroy, :id => @account.account_id, :email => email
|
25
|
+
assert_redirected_to account_email_path(@account.account_id)
|
26
|
+
assert_equal 'Account email was successfully deleted', flash[:notice]
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Kaui::AccountTagsControllerTest < Kaui::FunctionalTestHelper
|
4
|
+
|
5
|
+
test 'should show tags' do
|
6
|
+
get :show, :account_id => @account.account_id
|
7
|
+
assert_response 200
|
8
|
+
assert_not_nil assigns(:account)
|
9
|
+
assert_not_nil assigns(:tags)
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'should get edit' do
|
13
|
+
get :edit, :account_id => @account.account_id
|
14
|
+
assert_response 200
|
15
|
+
assert_not_nil assigns(:account)
|
16
|
+
assert_not_nil assigns(:tag_names)
|
17
|
+
assert_not_nil assigns(:available_tags)
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should update tags' do
|
21
|
+
post :update,
|
22
|
+
:account_id => @account.account_id,
|
23
|
+
'tag_00000000-0000-0000-0000-000000000001' => 'AUTO_PAY_OFF',
|
24
|
+
'tag_00000000-0000-0000-0000-000000000005' => 'MANUAL_PAY',
|
25
|
+
'tag_00000000-0000-0000-0000-000000000003' => 'OVERDUE_ENFORCEMENT_OFF'
|
26
|
+
assert_redirected_to account_tags_path(:account_id => @account.account_id)
|
27
|
+
assert_equal 'Account tags successfully set', flash[:notice]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Kaui::AccountTimelinesControllerTest < Kaui::FunctionalTestHelper
|
4
|
+
|
5
|
+
test 'should show the lookup page' do
|
6
|
+
get :index
|
7
|
+
assert_response 200
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should show the timeline page' do
|
11
|
+
get :show, :id => @account.account_id
|
12
|
+
assert_response 200
|
13
|
+
|
14
|
+
assert_not_nil assigns(:account)
|
15
|
+
assert_not_nil assigns(:timeline)
|
16
|
+
assert_not_nil assigns(:invoices_by_id)
|
17
|
+
|
18
|
+
assert_equal @account.account_id, assigns(:account).account_id
|
19
|
+
assert_equal @invoice_item.invoice_id, assigns(:invoices_by_id)[@invoice_item.invoice_id].invoice_id
|
20
|
+
end
|
21
|
+
end
|
@@ -1,63 +1,69 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
+
class Kaui::AccountsControllerTest < Kaui::FunctionalTestHelper
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test_regex("<dt>Account balance:</dt>")
|
9
|
-
|
10
|
-
|
11
|
-
class Kaui::AccountsControllerTest < ActionController::TestCase
|
12
|
-
fixtures :accounts
|
13
|
-
|
14
|
-
test "should get index" do
|
15
|
-
get :index, :use_route => 'kaui'
|
16
|
-
assert_response :success
|
5
|
+
test 'should get index' do
|
6
|
+
get :index
|
7
|
+
assert_response 200
|
17
8
|
end
|
18
9
|
|
19
|
-
test
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
assert_response :success
|
24
|
-
assert_equal assigns(:account).account_id, pierre["accountId"]
|
10
|
+
test 'should list accounts' do
|
11
|
+
# Test pagination
|
12
|
+
get :pagination, :format => :json
|
13
|
+
verify_pagination_results!
|
25
14
|
end
|
26
15
|
|
16
|
+
test 'should search accounts' do
|
17
|
+
# Test search
|
18
|
+
get :pagination, :sSearch => 'foo', :format => :json
|
19
|
+
verify_pagination_results!
|
20
|
+
end
|
27
21
|
|
28
|
-
test
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
assert_select "dd" do |elements|
|
38
|
-
elements.each do |element|
|
39
|
-
if /span/.match(element.to_s)
|
40
|
-
assert_select "span" do |inner|
|
41
|
-
assert /"label label-important"/.match(inner[0].to_s)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
22
|
+
test 'should find account by id' do
|
23
|
+
get :show, :id => @account.account_id
|
24
|
+
assert_response 200
|
25
|
+
assert_not_nil assigns(:tags)
|
26
|
+
assert_not_nil assigns(:account_emails)
|
27
|
+
assert_not_nil assigns(:overdue_state)
|
28
|
+
assert_not_nil assigns(:payment_methods)
|
29
|
+
assert_not_nil assigns(:bundles)
|
30
|
+
end
|
47
31
|
|
48
|
-
test
|
49
|
-
|
32
|
+
test 'should create account' do
|
33
|
+
get :new
|
34
|
+
assert_response 200
|
35
|
+
assert_not_nil assigns(:account)
|
36
|
+
|
37
|
+
post :create,
|
38
|
+
:account => {
|
39
|
+
:name => SecureRandom.uuid.to_s,
|
40
|
+
:external_key => SecureRandom.uuid.to_s,
|
41
|
+
:email => SecureRandom.uuid.to_s + '@example.com',
|
42
|
+
:time_zone => '-06:00',
|
43
|
+
:country => 'AR',
|
44
|
+
:is_migrated => '1'
|
45
|
+
}
|
46
|
+
assert_redirected_to account_path(assigns(:account).account_id)
|
47
|
+
assert_equal 'Account was successfully created', flash[:notice]
|
48
|
+
|
49
|
+
assert_equal '-06:00', assigns(:account).time_zone
|
50
|
+
assert_equal 'AR', assigns(:account).country
|
51
|
+
assert assigns(:account).is_migrated
|
52
|
+
assert !assigns(:account).is_notified_for_invoices
|
53
|
+
end
|
50
54
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
+
test 'should set default payment method' do
|
56
|
+
put :set_default_payment_method, :id => @account.account_id, :payment_method_id => @payment_method.payment_method_id
|
57
|
+
assert_response 302
|
58
|
+
end
|
55
59
|
|
56
|
-
test
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
assert assigns(:account).balance == 0
|
61
|
-
end
|
60
|
+
test 'should toggle email notifications' do
|
61
|
+
put :toggle_email_notifications, :id => @account.account_id, :is_notified => true
|
62
|
+
assert_response 302
|
63
|
+
end
|
62
64
|
|
65
|
+
test 'should pay all invoices' do
|
66
|
+
post :pay_all_invoices, :id => @account.account_id, :is_external_payment => true
|
67
|
+
assert_response 302
|
68
|
+
end
|
63
69
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Kaui::BundleTagsControllerTest < Kaui::FunctionalTestHelper
|
4
|
+
|
5
|
+
test 'should show tags' do
|
6
|
+
get :show, :bundle_id => @bundle.bundle_id
|
7
|
+
assert_response 200
|
8
|
+
assert_not_nil assigns(:bundle)
|
9
|
+
assert_not_nil assigns(:tags)
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'should get edit' do
|
13
|
+
get :edit, :bundle_id => @bundle.bundle_id
|
14
|
+
assert_response 200
|
15
|
+
assert_not_nil assigns(:bundle)
|
16
|
+
assert_not_nil assigns(:tag_names)
|
17
|
+
assert_not_nil assigns(:available_tags)
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'should update tags' do
|
21
|
+
post :update,
|
22
|
+
:bundle_id => @bundle.bundle_id,
|
23
|
+
'tag_00000000-0000-0000-0000-000000000001' => 'AUTO_PAY_OFF',
|
24
|
+
'tag_00000000-0000-0000-0000-000000000005' => 'MANUAL_PAY',
|
25
|
+
'tag_00000000-0000-0000-0000-000000000003' => 'OVERDUE_ENFORCEMENT_OFF'
|
26
|
+
assert_redirected_to bundle_tags_path(:bundle_id => @bundle.bundle_id)
|
27
|
+
assert_equal 'Bundle tags successfully set', flash[:notice]
|
28
|
+
end
|
29
|
+
end
|
@@ -1,21 +1,66 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class Kaui::BundlesControllerTest <
|
4
|
-
fixtures :accounts, :bundles
|
3
|
+
class Kaui::BundlesControllerTest < Kaui::FunctionalTestHelper
|
5
4
|
|
6
|
-
test
|
7
|
-
get :index
|
8
|
-
assert_response
|
5
|
+
test 'should get index' do
|
6
|
+
get :index
|
7
|
+
assert_response 200
|
9
8
|
end
|
10
9
|
|
11
|
-
test
|
12
|
-
|
13
|
-
|
10
|
+
test 'should list bundles' do
|
11
|
+
# Test pagination
|
12
|
+
get :pagination, :format => :json
|
13
|
+
verify_pagination_results!
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'should search bundles' do
|
17
|
+
# Test search
|
18
|
+
get :pagination, :sSearch => 'foo', :format => :json
|
19
|
+
verify_pagination_results!
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'should find bundle by id' do
|
23
|
+
get :show, :id => @bundle.bundle_id
|
24
|
+
assert_response 200
|
25
|
+
assert_not_nil assigns(:bundle)
|
26
|
+
assert_not_nil assigns(:account)
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should get transfer' do
|
30
|
+
get :transfer, :id => @bundle.bundle_id
|
31
|
+
assert_response 200
|
32
|
+
assert_not_nil assigns(:bundle)
|
33
|
+
assert_not_nil assigns(:account)
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'should transfer bundle default policy' do
|
37
|
+
check_bundle_owner(@account.account_id)
|
38
|
+
|
39
|
+
post :do_transfer,
|
40
|
+
:id => @bundle.bundle_id,
|
41
|
+
:new_account_key => @account2.external_key
|
42
|
+
assert_response 302
|
43
|
+
assert_equal 'Bundle was successfully transferred', flash[:notice]
|
44
|
+
|
45
|
+
check_bundle_owner(@account2.account_id)
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'should transfer bundle immediately' do
|
49
|
+
check_bundle_owner(@account.account_id)
|
50
|
+
|
51
|
+
post :do_transfer,
|
52
|
+
:id => @bundle.bundle_id,
|
53
|
+
:new_account_key => @account2.external_key,
|
54
|
+
:billing_policy => 'IMMEDIATE'
|
55
|
+
assert_response 302
|
56
|
+
assert_equal 'Bundle was successfully transferred', flash[:notice]
|
57
|
+
|
58
|
+
check_bundle_owner(@account2.account_id)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
14
62
|
|
15
|
-
|
16
|
-
|
17
|
-
assert_equal assigns(:account).account_id, pierre["accountId"]
|
18
|
-
assert_equal assigns(:bundle).bundle_id, bundle["bundleId"]
|
19
|
-
assert_equal assigns(:bundle).account_id, pierre["accountId"]
|
63
|
+
def check_bundle_owner(new_owner)
|
64
|
+
assert_equal new_owner, Kaui::Bundle.find_by_external_key(@bundle.external_key, options).account_id
|
20
65
|
end
|
21
66
|
end
|
@@ -1,9 +1,20 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class Kaui::ChargebacksControllerTest < Kaui::FunctionalTestHelper
|
4
|
+
|
5
|
+
test 'should get index' do
|
6
|
+
get :new, :payment_id => @payment.payment_id
|
7
|
+
assert_response 200
|
8
|
+
end
|
9
|
+
|
10
|
+
test 'should create payment methods' do
|
11
|
+
post :create,
|
12
|
+
:chargeback => {
|
13
|
+
:payment_id => @payment.payment_id,
|
14
|
+
:amount => @payment.paid_amount_to_money.to_f,
|
15
|
+
:currency => @payment.currency
|
16
|
+
},
|
17
|
+
:cancel_all_subs => '1'
|
18
|
+
assert_response 302
|
8
19
|
end
|
9
20
|
end
|