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
@@ -5,440 +5,411 @@
|
|
5
5
|
<form class="form-horizontal">
|
6
6
|
<div class="control-group">
|
7
7
|
<label for="bundles" class="control-label">Filter by bundle name</label>
|
8
|
+
|
8
9
|
<div class="controls">
|
9
|
-
<%= select_tag
|
10
|
+
<%= select_tag 'bundles', options_for_select([''] + @bundle_names.values.sort, @selected_bundle || 'all') %>
|
10
11
|
</div>
|
11
12
|
|
12
13
|
<label for="events" class="control-label">Filter by event type</label>
|
14
|
+
|
13
15
|
<div class="controls">
|
14
|
-
<%= select_tag
|
16
|
+
<%= select_tag 'event_types', options_for_select('<option value="all">ALL</option><option value="invoice">INVOICE</option><option value="payment">PAYMENT</option><option value="entitlement">ENTITLEMENTS</option>'.html_safe) %>
|
15
17
|
</div>
|
16
18
|
|
17
19
|
<dl class="dl-horizontal">
|
18
20
|
<dt>Billing timezone:</dt>
|
19
|
-
<dd><%= @account.
|
21
|
+
<dd><%= @account.time_zone %></dd>
|
20
22
|
</dl>
|
21
23
|
</div>
|
22
24
|
</form>
|
23
25
|
<hr/>
|
24
26
|
<table id="timeline-table" class="table table-condensed">
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
<thead>
|
28
|
+
<tr>
|
29
|
+
<th>Requested Date</th>
|
30
|
+
<th>Effective Date</th>
|
31
|
+
<th>Bundle Name</th>
|
32
|
+
<th>Event Type</th>
|
33
|
+
<th>Details</th>
|
34
|
+
<th>Reason Code / Comments</th>
|
35
|
+
<th>Actions</th>
|
36
|
+
</tr>
|
37
|
+
</thead>
|
38
|
+
<tbody>
|
39
|
+
<% if @account.present? && @timeline.present? %>
|
40
|
+
<% @timeline.invoices.each do |invoice_stub| %>
|
39
41
|
<% if invoice_stub.bundle_keys.present? %>
|
40
|
-
|
42
|
+
<% bundles = invoice_stub.bundle_keys.split(',').map { |bundle_key| @bundle_names[bundle_key] }.join(',') %>
|
41
43
|
<% end %>
|
42
44
|
<% if invoice_stub.invoice_id.present? && @invoices_by_id.has_key?(invoice_stub.invoice_id) %>
|
43
|
-
|
45
|
+
<% invoice = @invoices_by_id[invoice_stub.invoice_id] %>
|
44
46
|
<% else %>
|
45
|
-
|
47
|
+
<% invoice = invoice_stub %>
|
46
48
|
<% end %>
|
47
49
|
<tr title="<%= bundles %>" data-event_type="INVOICE">
|
48
50
|
<td>
|
49
51
|
<% if invoice.invoice_date.present? %>
|
50
|
-
|
52
|
+
<%= invoice.invoice_date %>
|
51
53
|
<% else %>
|
52
|
-
|
54
|
+
[unknown]
|
53
55
|
<% end %>
|
54
56
|
</td>
|
55
57
|
<td>
|
56
58
|
<% if invoice.target_date.present? %>
|
57
|
-
|
59
|
+
<%= invoice.target_date %>
|
58
60
|
<% else %>
|
59
|
-
|
61
|
+
[unknown]
|
60
62
|
<% end %>
|
61
63
|
</td>
|
62
64
|
<td>
|
63
65
|
<% if invoice_stub.bundle_keys.present? %>
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
<% invoice_stub.bundle_keys.split(',').each do |bundle_key| %>
|
67
|
+
<%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %>
|
68
|
+
<br/>
|
69
|
+
<% end %>
|
67
70
|
<% end %>
|
68
71
|
</td>
|
69
|
-
<td><%=
|
72
|
+
<td><%= 'INVOICE' %></td>
|
70
73
|
<td><span class="hide" title="<%= invoice.invoice_number %>"></span>
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
<%=
|
81
|
-
|
82
|
-
|
83
|
-
|
74
|
+
<%= 'Amount:' %> <%= humanized_money_with_symbol invoice.amount_to_money %>
|
75
|
+
(<%= @account.currency %>)<br/>
|
76
|
+
<%= 'Balance:' %> <%= humanized_money_with_symbol invoice.balance_to_money %>
|
77
|
+
(<%= @account.currency %>)<br/>
|
78
|
+
<% if invoice.credit_adj.present? && invoice.credit_adj > 0 %>
|
79
|
+
<%= 'Credit adjustment:' %> <%= humanized_money_with_symbol invoice.credit_adjustment_to_money %>
|
80
|
+
(<%= @account.currency %>)<br/>
|
81
|
+
<% end %>
|
82
|
+
<% if invoice.credits.present? && invoice.credits > 0 %>
|
83
|
+
<%= 'Credit balance adjustment:' %> <%= humanized_money_with_symbol invoice.credits_to_money %>
|
84
|
+
(<%= @account.currency %>)<br/>
|
85
|
+
<% end %>
|
86
|
+
<% if invoice.refund_adj.present? && invoice.refund_adj < 0 %>
|
87
|
+
<%= 'Refund adjustment:' %> <%= humanized_money_with_symbol invoice.refund_adjustment_to_money %>
|
88
|
+
(<%= @account.currency %>)<br/>
|
89
|
+
<% end %>
|
90
|
+
<%= 'Invoice #' %>
|
91
|
+
<%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
|
84
92
|
</td>
|
85
93
|
<td>
|
86
94
|
<% if invoice_stub.audit_logs.present? %>
|
87
|
-
|
88
|
-
|
89
|
-
|
95
|
+
<% invoice_stub.audit_logs.each do |entry| %>
|
96
|
+
<%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'Transition' %>
|
97
|
+
<br/>
|
98
|
+
<% end %>
|
90
99
|
<% end %>
|
91
100
|
</td>
|
92
101
|
<td>
|
93
102
|
<nobr>
|
94
|
-
<%= link_to
|
95
|
-
kaui_engine.new_payment_path(:params => {
|
96
|
-
|
97
|
-
:class => "btn btn-mini #{
|
103
|
+
<%= link_to 'Payment',
|
104
|
+
kaui_engine.new_payment_path(:params => {:account_id => invoice.account_id,
|
105
|
+
:invoice_id => invoice.invoice_id}),
|
106
|
+
:class => "btn btn-mini #{'disabled' unless invoice.balance > 0}" %>
|
98
107
|
</nobr>
|
99
108
|
<% if can? :credit, Kaui::Invoice %>
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
109
|
+
<nobr>
|
110
|
+
<%= link_to 'Credit',
|
111
|
+
kaui_engine.new_credit_path(:params => {:account_id => invoice.account_id,
|
112
|
+
:invoice_id => invoice.invoice_id}),
|
113
|
+
:class => 'btn btn-mini' %>
|
114
|
+
</nobr>
|
106
115
|
<% end %>
|
107
116
|
<% if can? :charge, Kaui::Invoice %>
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
117
|
+
<nobr>
|
118
|
+
<%= link_to 'Charge',
|
119
|
+
kaui_engine.new_charge_path(:params => {:account_id => invoice.account_id,
|
120
|
+
:invoice_id => invoice.invoice_id}),
|
121
|
+
:class => 'btn btn-mini' %>
|
122
|
+
</nobr>
|
114
123
|
<% end %>
|
115
124
|
</td>
|
116
125
|
</tr>
|
117
|
-
|
118
|
-
|
119
|
-
<% payment.
|
120
|
-
|
121
|
-
|
122
|
-
<td>
|
123
|
-
<% if refund.requested_date.present? %>
|
124
|
-
<%= format_date(refund.requested_date, @account.timezone).html_safe %>
|
125
|
-
<% else %>
|
126
|
-
[unknown]
|
127
|
-
<% end %>
|
128
|
-
</td>
|
129
|
-
<td>
|
130
|
-
<% if refund.effective_date.present? %>
|
131
|
-
<%= format_date(refund.effective_date, @account.timezone).html_safe %>
|
132
|
-
<% else %>
|
133
|
-
[unknown]
|
134
|
-
<% end %>
|
135
|
-
</td>
|
136
|
-
<td>
|
137
|
-
<% payment.bundle_keys.split(",").each do |bundle_key| %>
|
138
|
-
<%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
|
139
|
-
<% end %>
|
140
|
-
</td>
|
141
|
-
<td><%= "REFUND" %></td>
|
142
|
-
<td>
|
143
|
-
<%= "Adjusted:" %> <% if refund.adjusted %>yes<% else %>no<% end %><br/>
|
144
|
-
<%= "Payment id:" %> <%= refund.payment_id %><br/>
|
145
|
-
<%= "Refund Amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(refund.amount, refund.currency) %> (<%= refund.currency %>)<br/>
|
146
|
-
<span <% if refund.status != 'COMPLETED' %>class="alert-error" <% else %>class="alert-success" <% end %>>
|
147
|
-
<%= refund.status %>
|
148
|
-
</span>
|
149
|
-
<br/>
|
150
|
-
</td>
|
151
|
-
<td>
|
152
|
-
<% if refund.audit_logs.present? %>
|
153
|
-
<%= Kaui::AuditLog.description(refund.audit_logs[0])%><br/>
|
154
|
-
<% end %>
|
155
|
-
</td>
|
156
|
-
<td></td>
|
157
|
-
</tr>
|
158
|
-
<% end %>
|
159
|
-
<% end %>
|
160
|
-
<% @timeline.payments.each do |payment| %>
|
161
|
-
<% payment.chargebacks.each do |chargeback| %>
|
162
|
-
<% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
|
163
|
-
<tr title="<%= bundles %>" data-event_type="CHARGEBACK">
|
164
|
-
<td>
|
165
|
-
<% if chargeback.effective_date.present? %>
|
166
|
-
<%= format_date(chargeback.effective_date, @account.timezone).html_safe %>
|
167
|
-
<% else %>
|
168
|
-
[unknown]
|
169
|
-
<% end %>
|
170
|
-
</td>
|
171
|
-
<td>
|
172
|
-
<% if chargeback.effective_date.present? %>
|
173
|
-
<%= format_date(chargeback.effective_date, @account.timezone).html_safe %>
|
174
|
-
<% else %>
|
175
|
-
[unknown]
|
176
|
-
<% end %>
|
177
|
-
</td>
|
178
|
-
<td>
|
179
|
-
<% payment.bundle_keys.split(",").each do |bundle_key| %>
|
180
|
-
<%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
|
181
|
-
<% end %>
|
182
|
-
</td>
|
183
|
-
<td><%= "CHARGEBACK" %></td>
|
184
|
-
<td>
|
185
|
-
<%= "Payment id:" %> <%= chargeback.payment_id %><br/>
|
186
|
-
<%= "Chargeback Amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(chargeback.amount, payment.currency) %> (<%= payment.currency %>)<br/>
|
187
|
-
</td>
|
188
|
-
<td>
|
189
|
-
<% if chargeback.audit_logs.present? %>
|
190
|
-
<%= Kaui::AuditLog.description(chargeback.audit_logs[0]) %><br/>
|
191
|
-
<% end %>
|
192
|
-
</td>
|
193
|
-
<td></td>
|
194
|
-
<% end %>
|
195
|
-
<% end %>
|
196
|
-
<% @timeline.payments.each do |payment| %>
|
197
|
-
<% if payment.bundle_keys.present? %>
|
198
|
-
<% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
|
199
|
-
<% end %>
|
200
|
-
<% if payment.invoice_id.present? %>
|
201
|
-
<% invoice = @invoices_by_id[payment.invoice_id] %>
|
126
|
+
<% end %>
|
127
|
+
<% @timeline.payments.each do |payment| %>
|
128
|
+
<% if payment.target_invoice_id.present? %>
|
129
|
+
<% bundles = @bundle_names_by_invoice_id[payment.target_invoice_id].to_a.join(',') %>
|
130
|
+
<% invoice = @invoices_by_id[payment.target_invoice_id] %>
|
202
131
|
<% else %>
|
203
|
-
|
132
|
+
<% bundles = nil %>
|
133
|
+
<% invoice = nil %>
|
204
134
|
<% end %>
|
205
|
-
|
206
|
-
|
207
|
-
<% if payment.requested_date.present? %>
|
208
|
-
<%= format_date(payment.requested_date, @account.timezone).html_safe %>
|
209
|
-
<% else %>
|
210
|
-
[unknown]
|
211
|
-
<% end %>
|
212
|
-
</td>
|
213
|
-
<td>
|
214
|
-
<% if payment.effective_date.present? %>
|
215
|
-
<%= format_date(payment.effective_date, @account.timezone).html_safe %>
|
216
|
-
<% else %>
|
217
|
-
[unknown]
|
218
|
-
<% end %>
|
219
|
-
</td>
|
220
|
-
<td>
|
221
|
-
<% payment.bundle_keys.split(",").each do |bundle_key| %>
|
222
|
-
<%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
|
223
|
-
<% end %>
|
224
|
-
</td>
|
225
|
-
<td><%= "PAYMENT" %></td>
|
226
|
-
<td>
|
227
|
-
<span class="hide" title="<%= invoice.invoice_number %>"></span>
|
228
|
-
<%= "Payment id:" %> <%= payment.payment_id %><br/>
|
229
|
-
<%= "Total amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(payment.amount, payment.currency) %> (<%= payment.currency %>)<br/>
|
230
|
-
<%= "Paid amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(payment.paid_amount, payment.currency) %> (<%= payment.currency %>)<br/>
|
231
|
-
<span <% if payment.status == 'FAILED' %>class="alert-error" <% elsif payment.status == 'SUCCESS' %>class="alert-success" <% end %>>
|
232
|
-
<%= payment.status %>
|
233
|
-
</span>
|
234
|
-
<br/>
|
235
|
-
<%= "Invoice #" %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
|
236
|
-
</td>
|
237
|
-
<td>
|
238
|
-
<% if payment.audit_logs.present? %>
|
239
|
-
<% payment.audit_logs.each do |entry| %>
|
240
|
-
<%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'PaymentRequestProcessor' %><br/>
|
241
|
-
<% end %>
|
242
|
-
<% end %>
|
243
|
-
</td>
|
244
|
-
<td>
|
245
|
-
<% if can? :refund, Kaui::Payment %>
|
246
|
-
<nobr>
|
247
|
-
<%= link_to 'Refund', kaui_engine.new_refund_path(:params => { :payment_id => payment.payment_id,
|
248
|
-
:account_id => @account.account_id,
|
249
|
-
:invoice_id => payment.invoice_id }),
|
250
|
-
:class => "btn btn-mini #{"disabled" unless payment.payment_id.present? and payment.status == 'SUCCESS' and payment.paid_amount != 0}" %>
|
251
|
-
</nobr>
|
252
|
-
<% end %>
|
253
|
-
<% if can? :chargeback, Kaui::Payment %>
|
254
|
-
<nobr>
|
255
|
-
<%= link_to 'Chargeback', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
|
256
|
-
:account_id => @account.account_id,
|
257
|
-
:invoice_id => payment.invoice_id }),
|
258
|
-
:class => "btn btn-mini #{"disabled" unless payment.payment_id.present? and payment.status == 'SUCCESS'}" %>
|
259
|
-
</nobr>
|
260
|
-
<% end %>
|
261
|
-
</td>
|
262
|
-
</tr>
|
263
|
-
<% end %>
|
264
|
-
<% @timeline.bundles.each do |bundle| %>
|
265
|
-
<% bundle.subscriptions.each do |sub| %>
|
266
|
-
<% sub.events.each do |event| %>
|
267
|
-
<!-- SKIP SERVICE_STATE_CHANGE -->
|
268
|
-
<% next if event.event_type == 'SERVICE_STATE_CHANGE' %>
|
269
|
-
<tr title="<%= @bundle_names[bundle.external_key] %>" data-event_type="<%= event.event_type %>">
|
135
|
+
<% payment.transactions.each do |transaction| %>
|
136
|
+
<tr title="<%= bundles %>" data-event_type="PAYMENT">
|
270
137
|
<td>
|
271
|
-
<% if
|
272
|
-
|
138
|
+
<% if transaction.effective_date.present? %>
|
139
|
+
<%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
|
273
140
|
<% else %>
|
274
|
-
|
141
|
+
[unknown]
|
275
142
|
<% end %>
|
276
143
|
</td>
|
277
144
|
<td>
|
278
|
-
<% if
|
279
|
-
|
145
|
+
<% if transaction.effective_date.present? %>
|
146
|
+
<%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
|
280
147
|
<% else %>
|
281
|
-
|
148
|
+
[unknown]
|
149
|
+
<% end %>
|
150
|
+
</td>
|
151
|
+
<td>
|
152
|
+
<% (@bundle_keys_by_invoice_id[payment.target_invoice_id] || []).each do |bundle_key| %>
|
153
|
+
<%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %>
|
154
|
+
<br/>
|
155
|
+
<% end %>
|
156
|
+
</td>
|
157
|
+
<td><%= transaction.transaction_type %></td>
|
158
|
+
<td>
|
159
|
+
<span class="hide" title="<%= invoice.invoice_number unless invoice.nil? %>"></span>
|
160
|
+
<%= 'Transaction id:' %> <%= truncate_uuid(transaction.transaction_id) %>
|
161
|
+
<br/>
|
162
|
+
<%= 'Amount:' %> <%= humanized_money_with_symbol Kaui::Transaction.amount_to_money(transaction) %>
|
163
|
+
(<%= transaction.currency %>)<br/>
|
164
|
+
<span
|
165
|
+
<% if transaction.status == 'FAILED' %>class="alert-error"
|
166
|
+
<% elsif transaction.status == 'SUCCESS' %>class="alert-success" <% end %>>
|
167
|
+
<%= transaction.status %>
|
168
|
+
</span>
|
169
|
+
<br/>
|
170
|
+
<%= 'Payment #' %> <%= link_to payment.payment_number, payment_path(:id => payment.payment_id) %>
|
171
|
+
<% unless invoice.nil? %>
|
172
|
+
<br/><%= 'Invoice #' %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
|
282
173
|
<% end %>
|
283
174
|
</td>
|
284
175
|
<td>
|
285
|
-
|
176
|
+
<% if transaction.audit_logs.present? %>
|
177
|
+
<% transaction.audit_logs.each do |entry| %>
|
178
|
+
<%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'PaymentRequestProcessor' %>
|
179
|
+
<br/>
|
180
|
+
<% end %>
|
181
|
+
<% end %>
|
286
182
|
</td>
|
287
|
-
<td><%= event.event_type %></td>
|
288
|
-
<td><span class="hide" title="<%= sub.product_category %>"></span><%= event.product %> <%= event.billing_period == 'NO_BILLING_PERIOD' || event.billing_period.nil? ? "" : event.billing_period.downcase.capitalize %> <%= event.phase.downcase.capitalize if event.phase.present? %></td>
|
289
183
|
<td>
|
290
|
-
<% if
|
291
|
-
|
292
|
-
|
293
|
-
|
184
|
+
<% if invoice.present? and %w(CAPTURE PURCHASE).include?(transaction.transaction_type) %>
|
185
|
+
<% if can? :refund, Kaui::Payment %>
|
186
|
+
<nobr>
|
187
|
+
<%= link_to 'Refund', kaui_engine.new_refund_path(:params => {:payment_id => payment.payment_id,
|
188
|
+
:account_id => @account.account_id,
|
189
|
+
:invoice_id => payment.target_invoice_id}),
|
190
|
+
:class => "btn btn-mini #{'disabled' unless payment.payment_id.present? and transaction.status == 'SUCCESS' }" %>
|
191
|
+
</nobr>
|
192
|
+
<% end %>
|
193
|
+
<% if can? :chargeback, Kaui::Payment %>
|
194
|
+
<nobr>
|
195
|
+
<%= link_to 'Chargeback', kaui_engine.new_chargeback_path(:params => {:payment_id => payment.payment_id,
|
196
|
+
:account_id => @account.account_id,
|
197
|
+
:invoice_id => payment.target_invoice_id}),
|
198
|
+
:class => "btn btn-mini #{'disabled' unless payment.payment_id.present? and transaction.status == 'SUCCESS'}" %>
|
199
|
+
</nobr>
|
200
|
+
<% end %>
|
201
|
+
<% elsif !invoice.present? %>
|
202
|
+
<% if transaction.transaction_type == 'AUTHORIZE' %>
|
203
|
+
<% %w(CAPTURE VOID).each do |transaction_type| %>
|
204
|
+
<nobr>
|
205
|
+
<%= link_to transaction_type.downcase.capitalize, kaui_engine.new_transaction_path(:account_id => payment.account_id,
|
206
|
+
:payment_id => transaction.payment_id,
|
207
|
+
:payment_method_id => payment.payment_method_id,
|
208
|
+
:amount => transaction.amount,
|
209
|
+
:currency => transaction.currency,
|
210
|
+
:transaction_type => transaction_type), :class => 'btn btn-mini' %>
|
211
|
+
</nobr>
|
212
|
+
<% end %>
|
213
|
+
<% elsif %w(CAPTURE PURCHASE).include?(transaction.transaction_type) %>
|
214
|
+
<% %w(REFUND CHARGEBACK).each do |transaction_type| %>
|
215
|
+
<nobr>
|
216
|
+
<%= link_to transaction_type.downcase.capitalize, kaui_engine.new_transaction_path(:account_id => payment.account_id,
|
217
|
+
:payment_id => transaction.payment_id,
|
218
|
+
:payment_method_id => payment.payment_method_id,
|
219
|
+
:amount => transaction.amount,
|
220
|
+
:currency => transaction.currency,
|
221
|
+
:transaction_type => transaction_type), :class => 'btn btn-mini' %>
|
222
|
+
</nobr>
|
223
|
+
<% end %>
|
224
|
+
<% end %>
|
294
225
|
<% end %>
|
295
226
|
</td>
|
296
|
-
<td> </td>
|
297
227
|
</tr>
|
298
|
-
<% end %>
|
299
228
|
<% end %>
|
300
|
-
<% end %>
|
301
229
|
<% end %>
|
302
|
-
|
230
|
+
<% @timeline.bundles.each do |bundle| %>
|
231
|
+
<% bundle.subscriptions.each do |sub| %>
|
232
|
+
<% sub.events.each do |event| %>
|
233
|
+
<!-- SKIP SERVICE_STATE_CHANGE -->
|
234
|
+
<% next if event.event_type == 'SERVICE_STATE_CHANGE' %>
|
235
|
+
<tr title="<%= @bundle_names[bundle.external_key] %>" data-event_type="<%= event.event_type %>">
|
236
|
+
<td>
|
237
|
+
<% if event.requested_date.present? %>
|
238
|
+
<%= format_date(event.requested_date, @account.time_zone).html_safe %>
|
239
|
+
<% else %>
|
240
|
+
[unknown]
|
241
|
+
<% end %>
|
242
|
+
</td>
|
243
|
+
<td>
|
244
|
+
<% if event.effective_date.present? %>
|
245
|
+
<%= format_date(event.effective_date, @account.time_zone).html_safe %>
|
246
|
+
<% else %>
|
247
|
+
[unknown]
|
248
|
+
<% end %>
|
249
|
+
</td>
|
250
|
+
<td>
|
251
|
+
<%= link_to @bundle_names[bundle.external_key], Kaui.bundle_home_path.call(bundle.external_key) %>
|
252
|
+
<br/>
|
253
|
+
</td>
|
254
|
+
<td><%= event.event_type %></td>
|
255
|
+
<td>
|
256
|
+
<span class="hide" title="<%= sub.product_category %>"></span><%= event.product %> <%= event.billing_period == 'NO_BILLING_PERIOD' || event.billing_period.nil? ? '' : event.billing_period.downcase.capitalize %> <%= event.phase.downcase.capitalize if event.phase.present? %>
|
257
|
+
</td>
|
258
|
+
<td>
|
259
|
+
<% if event.audit_logs.present? %>
|
260
|
+
<% event.audit_logs.each do |entry| %>
|
261
|
+
<%= Kaui::AuditLog.description(entry) %>
|
262
|
+
<br/>
|
263
|
+
<% end %>
|
264
|
+
<% end %>
|
265
|
+
</td>
|
266
|
+
<td></td>
|
267
|
+
</tr>
|
268
|
+
<% end %>
|
269
|
+
<% end %>
|
270
|
+
<% end %>
|
271
|
+
<% end %>
|
272
|
+
</tbody>
|
303
273
|
</table>
|
304
274
|
<div class="form-actions">
|
305
275
|
<%= link_to 'Back', :back, :class => 'btn' %>
|
306
276
|
</div>
|
307
277
|
<%= javascript_tag do %>
|
308
|
-
|
278
|
+
function disableLinks() {
|
309
279
|
$('a.btn.disabled').click(function (e) {
|
310
|
-
|
280
|
+
e.preventDefault();
|
311
281
|
});
|
312
|
-
|
282
|
+
}
|
313
283
|
|
314
|
-
|
284
|
+
eventsOrder = ["START_ENTITLEMENT", "START_BILLING", "PAUSE_ENTITLEMENT", "PAUSE_BILLING", "RESUME_ENTITLEMENT",
|
285
|
+
"RESUME_BILLING", "PHASE", "CHANGE", "STOP_ENTITLEMENT", "STOP_BILLING", "INVOICE", "PAYMENT"];
|
315
286
|
|
316
|
-
|
287
|
+
jQuery.fn.dataTableExt.oSort['timeline-event-asc'] = function(e1,e2) {
|
317
288
|
var x = eventsOrder.indexOf(e1);
|
318
289
|
var y = eventsOrder.indexOf(e2);
|
319
|
-
return ((x < y) ? -1 : ((x > y) ?
|
320
|
-
|
290
|
+
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
291
|
+
};
|
321
292
|
|
322
|
-
|
293
|
+
jQuery.fn.dataTableExt.oSort['timeline-event-desc'] = function(e1,e2) {
|
323
294
|
var x = eventsOrder.indexOf(e1);
|
324
295
|
var y = eventsOrder.indexOf(e2);
|
325
|
-
return ((x < y) ?
|
326
|
-
|
296
|
+
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
297
|
+
};
|
327
298
|
|
328
|
-
|
299
|
+
function extractTitleAttributeFromText(txt) {
|
329
300
|
// Ugly - better way of doing this?
|
330
301
|
var matches = txt.match(/title="\w+"/g);
|
331
302
|
if (matches == null || matches.size == 0) {
|
332
|
-
|
303
|
+
return null;
|
333
304
|
}
|
334
305
|
return matches[0].split('=')[1];
|
335
|
-
|
306
|
+
}
|
336
307
|
|
337
|
-
|
308
|
+
jQuery.fn.dataTableExt.oSort['timeline-details-asc'] = function(e1,e2) {
|
338
309
|
var x = extractTitleAttributeFromText(e1);
|
339
310
|
var y = extractTitleAttributeFromText(e2);
|
340
|
-
return ((x < y) ? -1 : ((x > y) ?
|
341
|
-
|
311
|
+
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
312
|
+
};
|
342
313
|
|
343
|
-
|
314
|
+
jQuery.fn.dataTableExt.oSort['timeline-details-desc'] = function(e1,e2) {
|
344
315
|
var x = extractTitleAttributeFromText(e1);
|
345
316
|
var y = extractTitleAttributeFromText(e2);
|
346
|
-
return ((x < y) ?
|
347
|
-
|
317
|
+
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
|
318
|
+
};
|
348
319
|
|
349
|
-
|
320
|
+
function initTable() {
|
350
321
|
return $("#timeline-table").dataTable({
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
322
|
+
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
|
323
|
+
"sPaginationType": "bootstrap",
|
324
|
+
"oLanguage": {
|
325
|
+
"sLengthMenu": "_MENU_ records per page"
|
326
|
+
},
|
327
|
+
"iDisplayLength": 100,
|
328
|
+
"bRetrieve": true,
|
329
|
+
// Force a predictive order for event types, invoices and payments
|
330
|
+
"aaSorting": [[1, 'desc'], [4, 'asc'], [3, 'desc']],
|
331
|
+
"aoColumns": [
|
332
|
+
{ "sType": 'date' },
|
333
|
+
{ "sType": 'date' },
|
334
|
+
null,
|
335
|
+
{ "sType": 'timeline-event' },
|
336
|
+
{ "sType": 'timeline-details' },
|
337
|
+
null,
|
338
|
+
null
|
339
|
+
]
|
369
340
|
});
|
370
|
-
|
341
|
+
}
|
371
342
|
|
372
|
-
function filterEachNode(rows) {
|
343
|
+
function filterEachNode(rows) {
|
373
344
|
var bundle = $("#bundles").val();
|
374
345
|
var event_to_filter = $('#event_types').val().toUpperCase();
|
375
346
|
|
376
347
|
for (i = 0; i < rows.length; i++)
|
377
348
|
{
|
378
|
-
|
349
|
+
tr = $(rows[i]);
|
379
350
|
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
351
|
+
//filter bundles
|
352
|
+
if (bundle == "" || tr.attr("title").split(",").indexOf(bundle) >= 0) {
|
353
|
+
//first level filtering, so can remove hide
|
354
|
+
tr.removeClass("hide");
|
355
|
+
}
|
356
|
+
else {
|
357
|
+
//remove tr's not under this filter mode
|
358
|
+
tr.addClass("hide");
|
359
|
+
}
|
389
360
|
|
390
|
-
|
391
|
-
|
392
|
-
|
361
|
+
//filter events
|
362
|
+
if ("ALL" != event_to_filter)
|
363
|
+
filterEvents(tr, event_to_filter);
|
393
364
|
|
394
|
-
|
395
|
-
|
365
|
+
//add more filters here
|
366
|
+
//do not unhide any rows
|
396
367
|
}
|
397
368
|
|
398
|
-
}
|
369
|
+
}
|
399
370
|
|
400
|
-
function filterEvents(tr, event_to_filter) {
|
371
|
+
function filterEvents(tr, event_to_filter) {
|
401
372
|
tr_event_type = tr.data().event_type;
|
402
|
-
|
403
|
-
core_events = ["INVOICE", "PAYMENT"
|
373
|
+
|
374
|
+
core_events = ["INVOICE", "PAYMENT"]; //events which are not entitlements
|
404
375
|
|
405
376
|
//is tr event not an event in question
|
406
|
-
tr_event_does_not_match_filter = ("ENTITLEMENT" != event_to_filter &&
|
407
|
-
|
377
|
+
tr_event_does_not_match_filter = ("ENTITLEMENT" != event_to_filter &&
|
378
|
+
tr_event_type != event_to_filter);
|
408
379
|
|
409
380
|
//tr event is not an entitlement
|
410
|
-
tr_event_is_not_entitlement = ("ENTITLEMENT" == event_to_filter &&
|
411
|
-
|
381
|
+
tr_event_is_not_entitlement = ("ENTITLEMENT" == event_to_filter &&
|
382
|
+
core_events.indexOf(tr_event_type) >= 0);
|
412
383
|
|
413
384
|
if ( tr_event_does_not_match_filter || tr_event_is_not_entitlement )
|
414
385
|
{
|
415
|
-
|
416
|
-
|
386
|
+
//add hide to all who dont deserve the filter
|
387
|
+
tr.addClass("hide");
|
388
|
+
}
|
417
389
|
}
|
418
|
-
}
|
419
390
|
|
420
|
-
function filterTable()
|
421
|
-
{
|
391
|
+
function filterTable()
|
392
|
+
{
|
422
393
|
var dataTable = initTable();
|
423
394
|
var all_nodes = dataTable.fnGetNodes();
|
424
|
-
|
395
|
+
|
425
396
|
filterEachNode(all_nodes);
|
426
|
-
|
397
|
+
|
427
398
|
//my rows are filtered, draw table
|
428
399
|
dataTable.fnDraw();
|
429
|
-
}
|
400
|
+
}
|
430
401
|
|
431
402
|
|
432
|
-
$(document).ready(function() {
|
403
|
+
$(document).ready(function() {
|
433
404
|
disableLinks();
|
434
405
|
// When going through the pages of the table, disable links as needed
|
435
406
|
$('#timeline-table').bind('draw', function (e) {
|
436
|
-
|
407
|
+
disableLinks();
|
437
408
|
});
|
438
409
|
|
439
410
|
initTable();
|
440
411
|
|
441
412
|
$("#bundles, #event_types").change(filterTable);
|
442
413
|
filterTable();
|
443
|
-
});
|
414
|
+
});
|
444
415
|
<% end %>
|