kaui 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Gemfile +1 -1
  4. data/README.md +10 -15
  5. data/app/assets/images/kaui/duck.png +0 -0
  6. data/app/assets/images/kaui/logo.png +0 -0
  7. data/app/assets/images/kaui/search.png +0 -0
  8. data/app/assets/images/kaui/search_white.png +0 -0
  9. data/app/assets/javascripts/application.js +3 -0
  10. data/app/assets/javascripts/kaui/bootstrap-tweaks.js +3 -0
  11. data/app/assets/javascripts/kaui/kaui.js +99 -0
  12. data/app/assets/stylesheets/application.css +3 -1
  13. data/app/assets/stylesheets/bootstrap_and_overrides.less +39 -0
  14. data/app/assets/stylesheets/kaui/common.less +538 -0
  15. data/app/assets/stylesheets/kaui/datatable.less +75 -0
  16. data/app/assets/stylesheets/kaui/header.less +186 -0
  17. data/app/assets/stylesheets/kaui/home.less +82 -0
  18. data/app/assets/stylesheets/kaui/invoice.less +54 -0
  19. data/app/assets/stylesheets/kaui/kaui.less +16 -0
  20. data/app/assets/stylesheets/kaui/payment.less +29 -0
  21. data/app/assets/stylesheets/kaui/subscription.less +5 -0
  22. data/app/assets/stylesheets/kaui/tags.less +175 -0
  23. data/app/assets/stylesheets/kaui/timeline.less +4 -0
  24. data/app/controllers/kaui/account_emails_controller.rb +18 -18
  25. data/app/controllers/kaui/account_tags_controller.rb +8 -30
  26. data/app/controllers/kaui/account_timelines_controller.rb +13 -23
  27. data/app/controllers/kaui/accounts_controller.rb +65 -62
  28. data/app/controllers/kaui/admin_allowed_users_controller.rb +48 -32
  29. data/app/controllers/kaui/admin_tenants_controller.rb +147 -142
  30. data/app/controllers/kaui/bundle_tags_controller.rb +9 -33
  31. data/app/controllers/kaui/bundles_controller.rb +23 -62
  32. data/app/controllers/kaui/chargebacks_controller.rb +5 -11
  33. data/app/controllers/kaui/charges_controller.rb +11 -18
  34. data/app/controllers/kaui/credits_controller.rb +19 -22
  35. data/app/controllers/kaui/custom_fields_controller.rb +44 -16
  36. data/app/controllers/kaui/engine_controller.rb +56 -3
  37. data/app/controllers/kaui/engine_controller_util.rb +75 -1
  38. data/app/controllers/kaui/home_controller.rb +19 -0
  39. data/app/controllers/kaui/invoice_items_controller.rb +16 -21
  40. data/app/controllers/kaui/invoices_controller.rb +31 -53
  41. data/app/controllers/kaui/payment_methods_controller.rb +14 -46
  42. data/app/controllers/kaui/payments_controller.rb +60 -69
  43. data/app/controllers/kaui/refunds_controller.rb +11 -25
  44. data/app/controllers/kaui/registrations_controller.rb +38 -0
  45. data/app/controllers/kaui/subscriptions_controller.rb +82 -95
  46. data/app/controllers/kaui/tag_definitions_controller.rb +1 -5
  47. data/app/controllers/kaui/tags_controller.rb +17 -17
  48. data/app/controllers/kaui/tenants_controller.rb +38 -55
  49. data/app/controllers/kaui/transactions_controller.rb +8 -15
  50. data/app/helpers/kaui/application_helper.rb +4 -0
  51. data/app/helpers/kaui/object_helper.rb +24 -0
  52. data/app/helpers/kaui/payment_method_helper.rb +9 -0
  53. data/app/helpers/kaui/subscription_helper.rb +1 -1
  54. data/app/helpers/kaui/uuid_helper.rb +1 -0
  55. data/app/models/kaui/ability.rb +7 -1
  56. data/app/models/kaui/account.rb +6 -2
  57. data/app/models/kaui/account_email.rb +10 -0
  58. data/app/models/kaui/allowed_user.rb +16 -4
  59. data/app/models/kaui/audit_log.rb +5 -3
  60. data/app/models/kaui/bundle.rb +6 -11
  61. data/app/models/kaui/credit.rb +3 -0
  62. data/app/models/kaui/invoice.rb +10 -15
  63. data/app/models/kaui/invoice_payment.rb +10 -13
  64. data/app/models/kaui/killbill_registerable.rb +7 -0
  65. data/app/models/kaui/payment.rb +19 -12
  66. data/app/models/kaui/payment_method.rb +9 -0
  67. data/app/models/kaui/payment_state.rb +52 -0
  68. data/app/models/kaui/tag.rb +14 -0
  69. data/app/models/kaui/tag_definition.rb +8 -2
  70. data/app/models/kaui/user.rb +5 -4
  71. data/app/views/kaui/account_emails/_account_emails_table.html.erb +12 -9
  72. data/app/views/kaui/account_emails/_form.html.erb +9 -9
  73. data/app/views/kaui/account_emails/new.html.erb +9 -2
  74. data/app/views/kaui/account_tags/_form.html.erb +20 -29
  75. data/app/views/kaui/account_tags/_form_bar.html.erb +21 -0
  76. data/app/views/kaui/account_tags/edit.html.erb +9 -4
  77. data/app/views/kaui/account_timelines/show.html.erb +204 -287
  78. data/app/views/kaui/accounts/_account_info.html.erb +108 -0
  79. data/app/views/kaui/accounts/_billing_info.html.erb +129 -0
  80. data/app/views/kaui/accounts/_form.html.erb +127 -115
  81. data/app/views/kaui/accounts/_payment_methods.html.erb +28 -0
  82. data/app/views/kaui/accounts/edit.html.erb +10 -0
  83. data/app/views/kaui/accounts/index.html.erb +38 -23
  84. data/app/views/kaui/accounts/new.html.erb +9 -4
  85. data/app/views/kaui/accounts/show.html.erb +4 -106
  86. data/app/views/kaui/admin_allowed_users/_form.html.erb +19 -0
  87. data/app/views/kaui/admin_allowed_users/index.html.erb +35 -18
  88. data/app/views/kaui/admin_allowed_users/new.html.erb +9 -21
  89. data/app/views/kaui/admin_allowed_users/show.html.erb +42 -50
  90. data/app/views/kaui/admin_tenants/_form.html.erb +25 -0
  91. data/app/views/kaui/admin_tenants/_tenants_table.html.erb +27 -0
  92. data/app/views/kaui/admin_tenants/index.html.erb +14 -23
  93. data/app/views/kaui/admin_tenants/new.html.erb +8 -37
  94. data/app/views/kaui/admin_tenants/show.html.erb +128 -113
  95. data/app/views/kaui/bundle_tags/_form.html.erb +20 -28
  96. data/app/views/kaui/bundle_tags/_form_bar.html.erb +21 -0
  97. data/app/views/kaui/bundle_tags/edit.html.erb +9 -4
  98. data/app/views/kaui/bundles/index.html.erb +76 -29
  99. data/app/views/kaui/bundles/transfer.html.erb +28 -28
  100. data/app/views/kaui/chargebacks/_form.html.erb +31 -29
  101. data/app/views/kaui/chargebacks/new.html.erb +9 -4
  102. data/app/views/kaui/charges/_form.html.erb +35 -59
  103. data/app/views/kaui/charges/new.html.erb +9 -4
  104. data/app/views/kaui/credits/_form.html.erb +32 -59
  105. data/app/views/kaui/credits/new.html.erb +9 -4
  106. data/app/views/kaui/custom_fields/_form.html.erb +31 -0
  107. data/app/views/kaui/custom_fields/index.html.erb +33 -20
  108. data/app/views/kaui/custom_fields/new.html.erb +10 -0
  109. data/app/views/kaui/home/index.html.erb +12 -9
  110. data/app/views/kaui/invoice_items/_edit_form.html.erb +30 -0
  111. data/app/views/kaui/invoice_items/edit.html.erb +10 -91
  112. data/app/views/kaui/invoices/_invoice_table.html.erb +113 -0
  113. data/app/views/kaui/invoices/index.html.erb +31 -22
  114. data/app/views/kaui/invoices/show.html.erb +77 -91
  115. data/app/views/kaui/layouts/kaui_account_navbar.html.erb +11 -0
  116. data/app/views/kaui/layouts/kaui_application.html.erb +14 -53
  117. data/app/views/kaui/layouts/kaui_flash.html.erb +17 -0
  118. data/app/views/kaui/layouts/kaui_footer.html.erb +2 -0
  119. data/app/views/kaui/layouts/kaui_header.html.erb +17 -0
  120. data/app/views/kaui/layouts/kaui_navbar.html.erb +75 -0
  121. data/app/views/kaui/payment_methods/_form.html.erb +26 -23
  122. data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +46 -41
  123. data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +25 -0
  124. data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +50 -52
  125. data/app/views/kaui/payment_methods/new.html.erb +9 -4
  126. data/app/views/kaui/payments/_form.html.erb +55 -0
  127. data/app/views/kaui/payments/_payment_table.html.erb +117 -0
  128. data/app/views/kaui/payments/index.html.erb +31 -22
  129. data/app/views/kaui/payments/new.html.erb +9 -92
  130. data/app/views/kaui/payments/show.html.erb +38 -2
  131. data/app/views/kaui/refunds/_form.html.erb +240 -0
  132. data/app/views/kaui/refunds/new.html.erb +8 -280
  133. data/app/views/kaui/registrations/_form.html.erb +19 -0
  134. data/app/views/kaui/registrations/new.html.erb +10 -0
  135. data/app/views/kaui/sessions/_form.html.erb +19 -0
  136. data/app/views/kaui/sessions/new.html.erb +7 -18
  137. data/app/views/kaui/subscriptions/_edit_form.html.erb +26 -0
  138. data/app/views/kaui/subscriptions/_form.html.erb +34 -31
  139. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +37 -24
  140. data/app/views/kaui/subscriptions/edit.html.erb +10 -30
  141. data/app/views/kaui/subscriptions/new.html.erb +14 -11
  142. data/app/views/kaui/tag_definitions/_form.html.erb +14 -11
  143. data/app/views/kaui/tag_definitions/index.html.erb +56 -30
  144. data/app/views/kaui/tag_definitions/new.html.erb +9 -2
  145. data/app/views/kaui/tags/_tags_table.html.erb +7 -10
  146. data/app/views/kaui/tags/index.html.erb +29 -20
  147. data/app/views/kaui/tenants/_form.html.erb +13 -0
  148. data/app/views/kaui/tenants/index.html.erb +9 -16
  149. data/app/views/kaui/transactions/_form.html.erb +47 -67
  150. data/app/views/kaui/transactions/new.html.erb +9 -2
  151. data/config/initializers/killbill_registerable.rb +4 -0
  152. data/config/routes.rb +88 -93
  153. data/kaui.gemspec +11 -2
  154. data/lib/kaui/engine.rb +6 -4
  155. data/lib/kaui/version.rb +1 -1
  156. data/lib/kaui.rb +24 -1
  157. data/test/dummy/config/application.rb +2 -0
  158. data/test/dummy/config/database.yml +6 -3
  159. data/test/dummy/config/initializers/killbill_client.rb +0 -2
  160. data/test/fixtures/catalog-v1.xml +74 -0
  161. data/test/fixtures/catalog_translation_fr-v1.properties +1 -0
  162. data/test/fixtures/invoice_template-v1.html +100 -0
  163. data/test/fixtures/invoice_translation_fr-v1.properties +23 -0
  164. data/test/fixtures/overdue-v1.xml +49 -0
  165. data/test/fixtures/stripe.yml +2 -0
  166. data/test/functional/kaui/account_emails_controller_test.rb +35 -8
  167. data/test/functional/kaui/account_tags_controller_test.rb +8 -8
  168. data/test/functional/kaui/account_timelines_controller_test.rb +6 -7
  169. data/test/functional/kaui/accounts_controller_test.rb +72 -10
  170. data/test/functional/kaui/admin_allowed_users_controller_test.rb +6 -5
  171. data/test/functional/kaui/admin_tenants_controller_test.rb +104 -48
  172. data/test/functional/kaui/bundle_tags_controller_test.rb +14 -9
  173. data/test/functional/kaui/bundles_controller_test.rb +59 -23
  174. data/test/functional/kaui/chargebacks_controller_test.rb +29 -7
  175. data/test/functional/kaui/charges_controller_test.rb +31 -10
  176. data/test/functional/kaui/credits_controller_test.rb +25 -6
  177. data/test/functional/kaui/custom_fields_controller_test.rb +25 -1
  178. data/test/functional/kaui/functional_test_helper_nosetup.rb +6 -4
  179. data/test/functional/kaui/home_controller_test.rb +24 -0
  180. data/test/functional/kaui/invoice_items_controller_test.rb +56 -8
  181. data/test/functional/kaui/invoices_controller_test.rb +27 -18
  182. data/test/functional/kaui/payment_methods_controller_test.rb +2 -22
  183. data/test/functional/kaui/payments_controller_test.rb +8 -3
  184. data/test/functional/kaui/refunds_controller_test.rb +40 -21
  185. data/test/functional/kaui/subscriptions_controller_test.rb +77 -24
  186. data/test/functional/kaui/tag_definitions_controller_test.rb +1 -7
  187. data/test/functional/kaui/tags_controller_test.rb +1 -1
  188. data/test/functional/kaui/tenants_controller_test.rb +9 -9
  189. data/test/functional/kaui/transactions_controller_test.rb +41 -16
  190. data/test/integration/kaui/integration_test_helper.rb +0 -1
  191. data/test/integration/kaui/navigation_test.rb +4 -6
  192. data/test/test_helper.rb +2 -0
  193. metadata +155 -28
  194. data/Gemfile.lock +0 -210
  195. data/app/assets/stylesheets/bootstrap_and_overrides.css +0 -7
  196. data/app/assets/stylesheets/datatables.scss +0 -14
  197. data/app/assets/stylesheets/layout.scss +0 -19
  198. data/app/views/kaui/account_emails/show.html.erb +0 -25
  199. data/app/views/kaui/account_tags/_account_tags_table.html.erb +0 -32
  200. data/app/views/kaui/account_tags/show.html.erb +0 -6
  201. data/app/views/kaui/account_timelines/index.html.erb +0 -14
  202. data/app/views/kaui/bundle_tags/_bundle_tags_table.html.erb +0 -31
  203. data/app/views/kaui/bundle_tags/show.html.erb +0 -6
  204. data/app/views/kaui/bundles/show.html.erb +0 -18
  205. data/app/views/kaui/payment_methods/index.html.erb +0 -30
  206. data/app/views/kaui/payment_methods/show.html.erb +0 -3
  207. data/app/views/kaui/payments/_payments_table.html.erb +0 -41
  208. data/app/views/kaui/subscriptions/index.html.erb +0 -15
  209. data/app/views/kaui/subscriptions/show.html.erb +0 -33
  210. data/app/views/kaui/tag_definitions/show.html.erb +0 -15
  211. data/vendor/assets/images/img/glyphicons-halflings-white.png +0 -0
  212. data/vendor/assets/images/img/glyphicons-halflings.png +0 -0
  213. data/vendor/assets/stylesheets/css/bootstrap-datepicker.cd46d38.css +0 -274
@@ -0,0 +1,21 @@
1
+ <% can_change_tags = can?(:add, Kaui::Tag) || can?(:delete, Kaui::Tag) %>
2
+ <%= form_tag update_account_tags_path do %>
3
+ <%= hidden_field_tag :account_id, account_id %>
4
+
5
+ <% available_tags.each do |tag| %>
6
+ <%= check_box_tag "tag_#{tag.id}", tag.name, tag_names.include?(tag.name), :disabled => !can_change_tags, :readonly => !can_change_tags %>
7
+ <label class='tag-description' rel='tooltip' title='<%= tag.description %>'><%= tag.name %></label>
8
+ <% end %>
9
+
10
+ <% if can_change_tags %>
11
+ <%= label_tag :comment, 'Comment', :class => 'col-sm-2 control-label' %>
12
+ <%= text_area_tag :comment, nil, :rows => 3, :class => 'form-control' %>
13
+ <%= submit_tag 'Update', :class => 'btn btn-default' %>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <%= javascript_tag do %>
18
+ $(function() {
19
+ $('.tag-description').tooltip();
20
+ });
21
+ <% end %>
@@ -1,5 +1,10 @@
1
- <div class='page-header'>
2
- <h1>Add/Remove Tags</h1>
3
- </div>
1
+ <div class="register">
2
+ <div class="col-md-8 col-md-offset-2">
3
+
4
+ <div class="column-block">
5
+ <h1>Add/Remove Tags</h1>
6
+ <%= render 'form' %>
7
+ </div>
4
8
 
5
- <%= render 'form' %>
9
+ </div>
10
+ </div>
@@ -1,279 +1,201 @@
1
- <div class="page-header">
2
- <h3>Account <%= @account.name %></h3>
3
- <%= link_to @account.email, Kaui.account_home_path.call(@account.external_key) %>
4
- </div>
5
- <form class="form-horizontal">
6
- <div class="control-group">
7
- <label for="bundles" class="control-label">Filter by bundle name</label>
1
+ <div class="search">
8
2
 
9
- <div class="controls">
10
- <%= select_tag 'bundles', options_for_select([''] + @bundle_names.values.sort, @selected_bundle || 'all') %>
11
- </div>
3
+ <div class="column-block">
12
4
 
13
- <label for="events" class="control-label">Filter by event type</label>
5
+ <h1>Account timeline</h1>
14
6
 
15
- <div class="controls">
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) %>
17
- </div>
7
+ <form class="form-horizontal">
8
+ <div class="form-group">
9
+ <label for="bundles" class="col-sm-2 control-label">Filter by bundle</label>
18
10
 
19
- <dl class="dl-horizontal">
20
- <dt>Billing timezone:</dt>
21
- <dd><%= @account.time_zone %></dd>
22
- </dl>
23
- </div>
24
- </form>
25
- <hr/>
26
- <table id="timeline-table" class="table table-condensed">
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| %>
41
- <% if invoice_stub.bundle_keys.present? %>
42
- <% bundles = invoice_stub.bundle_keys.split(',').map { |bundle_key| @bundle_names[bundle_key] }.join(',') %>
43
- <% end %>
44
- <% if invoice_stub.invoice_id.present? && @invoices_by_id.has_key?(invoice_stub.invoice_id) %>
45
- <% invoice = @invoices_by_id[invoice_stub.invoice_id] %>
46
- <% else %>
47
- <% invoice = invoice_stub %>
48
- <% end %>
49
- <tr title="<%= bundles %>" data-event_type="INVOICE">
50
- <td>
51
- <% if invoice.invoice_date.present? %>
52
- <%= invoice.invoice_date %>
53
- <% else %>
54
- [unknown]
55
- <% end %>
56
- </td>
57
- <td>
58
- <% if invoice.target_date.present? %>
59
- <%= invoice.target_date %>
60
- <% else %>
61
- [unknown]
62
- <% end %>
63
- </td>
64
- <td>
65
- <% if invoice_stub.bundle_keys.present? %>
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 %>
70
- <% end %>
71
- </td>
72
- <td><%= 'INVOICE' %></td>
73
- <td><span class="hide" title="<%= invoice.invoice_number %>"></span>
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) %>
92
- </td>
93
- <td>
94
- <% if invoice_stub.audit_logs.present? %>
95
- <% invoice_stub.audit_logs.each do |entry| %>
96
- <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'Transition' %>
97
- <br/>
98
- <% end %>
99
- <% end %>
100
- </td>
101
- <td>
102
- <nobr>
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-xs #{'disabled' unless invoice.balance > 0}" %>
107
- </nobr>
108
- <% if can? :credit, Kaui::Invoice %>
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-xs' %>
114
- </nobr>
115
- <% end %>
116
- <% if can? :charge, Kaui::Invoice %>
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-xs' %>
122
- </nobr>
123
- <% end %>
124
- </td>
125
- </tr>
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] %>
131
- <% else %>
132
- <% bundles = nil %>
133
- <% invoice = nil %>
134
- <% end %>
135
- <% payment.transactions.each do |transaction| %>
136
- <tr title="<%= bundles %>" data-event_type="PAYMENT">
137
- <td>
138
- <% if transaction.effective_date.present? %>
139
- <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
140
- <% else %>
141
- [unknown]
142
- <% end %>
143
- </td>
144
- <td>
145
- <% if transaction.effective_date.present? %>
146
- <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
147
- <% else %>
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) %>
173
- <% end %>
174
- </td>
175
- <td>
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 %>
182
- </td>
183
- <td>
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-xs #{'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-xs #{'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-xs' %>
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-xs' %>
222
- </nobr>
11
+ <div class="col-sm-10">
12
+ <%= select_tag 'bundles', options_for_select([''] + @bundle_names.values.sort, @selected_bundle || 'all'), :class => 'form-control' %>
13
+ </div>
14
+ </div>
15
+ <div class="form-group">
16
+ <label for="events" class="col-sm-2 control-label">Filter by event type</label>
17
+
18
+ <div class="col-sm-10 ">
19
+ <%= 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), :class => 'form-control' %>
20
+ </div>
21
+ </div>
22
+ </form>
23
+
24
+ <hr/>
25
+
26
+ <table id="timeline-table" class="table table-condensed mobile-data">
27
+ <thead>
28
+ <tr>
29
+ <th>Effective Date</th>
30
+ <th>Bundle</th>
31
+ <th>Event Type</th>
32
+ <th>Details</th>
33
+ <th>Reason Code / Comments</th>
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ <% if @account.present? %>
38
+ <% @invoices.each do |invoice_stub| %>
39
+ <% if invoice_stub.bundle_keys.present? %>
40
+ <% bundles = invoice_stub.bundle_keys.split(',').map { |bundle_key| @bundle_names[bundle_key] }.join(',') %>
41
+ <% end %>
42
+ <% if invoice_stub.invoice_id.present? && @invoices_by_id.has_key?(invoice_stub.invoice_id) %>
43
+ <% invoice = @invoices_by_id[invoice_stub.invoice_id] %>
44
+ <% else %>
45
+ <% invoice = invoice_stub %>
46
+ <% end %>
47
+ <tr title="<%= bundles %>" data-event_type="INVOICE">
48
+ <td>
49
+ <% if invoice.target_date.present? %>
50
+ <%= invoice.target_date %>
51
+ <% else %>
52
+ [unknown]
53
+ <% end %>
54
+ </td>
55
+ <td>
56
+ <% if invoice_stub.bundle_keys.present? %>
57
+ <ul>
58
+ <% invoice_stub.bundle_keys.split(',').each do |bundle_key| %>
59
+ <li><%= truncate_uuid(@bundle_names[bundle_key]) %></li>
223
60
  <% end %>
61
+ </ul>
62
+ <% end %>
63
+ </td>
64
+ <td>INVOICE</td>
65
+ <td>
66
+ <ul>
67
+ <li><span class="hide" title="<%= invoice.invoice_number %>"></span>
68
+ <%= 'Amount:' %> <%= humanized_money_with_symbol invoice.amount_to_money %>
69
+ (<%= @account.currency %>)
70
+ </li>
71
+ <li><%= 'Balance:' %> <%= humanized_money_with_symbol invoice.balance_to_money %>
72
+ (<%= @account.currency %>)
73
+ </li>
74
+ </li>
75
+ <% if invoice.credit_adj.present? && invoice.credit_adj > 0 %>
76
+ <li><%= 'Credit adjustment:' %> <%= humanized_money_with_symbol invoice.credit_adjustment_to_money %>
77
+ (<%= @account.currency %>)
78
+ </li>
224
79
  <% end %>
225
- <% end %>
226
- </td>
227
- </tr>
228
- <% end %>
229
- <% end %>
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]
80
+ <% if invoice.refund_adj.present? && invoice.refund_adj < 0 %>
81
+ <li><%= 'Refund adjustment:' %> <%= humanized_money_with_symbol invoice.refund_adjustment_to_money %>
82
+ (<%= @account.currency %>)
83
+ </li>
248
84
  <% 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/>
85
+ <li><%= 'Invoice #' %>&nbsp;<%= link_to invoice.invoice_number, account_invoice_path(invoice.account_id, invoice.invoice_id) %></li>
86
+ </ul>
87
+ </td>
88
+ <td>
89
+ <% if invoice_stub.audit_logs.present? %>
90
+ <ul>
91
+ <% invoice_stub.audit_logs.each do |entry| %>
92
+ <li><%= Kaui::AuditLog.description(entry) %></li>
263
93
  <% end %>
264
- <% end %>
265
- </td>
266
- <td></td>
267
- </tr>
268
- <% end %>
269
- <% end %>
270
- <% end %>
271
- <% end %>
272
- </tbody>
273
- </table>
274
- <div class="form-actions">
275
- <%= link_to 'Back', :back, :class => 'btn' %>
94
+ </ul>
95
+ <% end %>
96
+ </td>
97
+ </tr>
98
+ <% end %>
99
+ <% @payments.each do |payment| %>
100
+ <% if payment.target_invoice_id.present? %>
101
+ <% bundles = @bundle_names_by_invoice_id[payment.target_invoice_id].to_a.join(',') %>
102
+ <% invoice = @invoices_by_id[payment.target_invoice_id] %>
103
+ <% else %>
104
+ <% bundles = nil %>
105
+ <% invoice = nil %>
106
+ <% end %>
107
+ <% payment.transactions.each do |transaction| %>
108
+ <tr title="<%= bundles %>" data-event_type="PAYMENT">
109
+ <td>
110
+ <% if transaction.effective_date.present? %>
111
+ <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
112
+ <% else %>
113
+ [unknown]
114
+ <% end %>
115
+ </td>
116
+ <td>
117
+ <% if @bundle_keys_by_invoice_id[payment.target_invoice_id].present? %>
118
+ <ul>
119
+ <% @bundle_keys_by_invoice_id[payment.target_invoice_id].each do |bundle_key| %>
120
+ <li><%= truncate_uuid(@bundle_names[bundle_key]) %></li>
121
+ <% end %>
122
+ </ul>
123
+ <% end %>
124
+ </td>
125
+ <td><%= transaction.transaction_type %></td>
126
+ <td>
127
+ <ul>
128
+ <li><%= 'Amount:' %>&nbsp;<%= humanized_money_with_symbol Kaui::Transaction.amount_to_money(transaction) %>
129
+ (<%= transaction.currency %>)
130
+ </li>
131
+ <li>
132
+ <span
133
+ <% if transaction.status != 'SUCCESS' %>class="alert-danger"
134
+ <% else %>class="alert-success" <% end %>>
135
+ <%= transaction.status %>
136
+ </span>
137
+ </li>
138
+ <li><%= 'Payment #' %>&nbsp;<%= link_to payment.payment_number, account_payment_path(payment.account_id, payment.payment_id) %></li>
139
+ <% unless invoice.nil? %>
140
+ <li><%= 'Invoice #' %>&nbsp;<%= link_to invoice.invoice_number, account_invoice_path(invoice.account_id, invoice.invoice_id) %></li>
141
+ <% end %>
142
+ </ul>
143
+ </td>
144
+ <td>
145
+ <% if transaction.audit_logs.present? %>
146
+ <ul>
147
+ <% transaction.audit_logs.each do |entry| %>
148
+ <li><%= Kaui::AuditLog.description(entry) %></li>
149
+ <% end %>
150
+ </ul>
151
+ <% end %>
152
+ </td>
153
+ </tr>
154
+ <% end %>
155
+ <% end %>
156
+ <% @bundles.each do |bundle| %>
157
+ <% bundle.subscriptions.each do |sub| %>
158
+ <% sub.events.each do |event| %>
159
+ <!-- SKIP SERVICE_STATE_CHANGE -->
160
+ <% next if event.event_type == 'SERVICE_STATE_CHANGE' %>
161
+ <tr title="<%= @bundle_names[bundle.external_key] %>" data-event_type="<%= event.event_type %>">
162
+ <td>
163
+ <% if event.effective_date.present? %>
164
+ <%= format_date(event.effective_date, @account.time_zone).html_safe %>
165
+ <% else %>
166
+ [unknown]
167
+ <% end %>
168
+ </td>
169
+ <td>
170
+ <ul>
171
+ <li><%= truncate_uuid(@bundle_names[bundle.external_key]) %></li>
172
+ </ul>
173
+ </td>
174
+ <td><%= event.event_type %></td>
175
+ <td>
176
+ <ul>
177
+ <li><span class="hide" title="<%= sub.product_category %>"></span><%= event.phase %></li>
178
+ </ul>
179
+ </td>
180
+ <td>
181
+ <% if event.audit_logs.present? %>
182
+ <ul>
183
+ <% event.audit_logs.each do |entry| %>
184
+ <li><%= Kaui::AuditLog.description(entry) %></li>
185
+ <% end %>
186
+ </ul>
187
+ <% end %>
188
+ </td>
189
+ </tr>
190
+ <% end %>
191
+ <% end %>
192
+ <% end %>
193
+ <% end %>
194
+ </tbody>
195
+ </table>
196
+ </div>
276
197
  </div>
198
+
277
199
  <%= javascript_tag do %>
278
200
  function disableLinks() {
279
201
  $('a.btn.disabled').click(function (e) {
@@ -318,26 +240,21 @@
318
240
  };
319
241
 
320
242
  function initTable() {
321
- return $("#timeline-table").dataTable({
322
- "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
323
- "sPaginationType": "simple_numbers",
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
- ]
340
- });
243
+ return $("#timeline-table").dataTable({
244
+ "dom": "t",
245
+ "paging": "false",
246
+ "iDisplayLength": 100,
247
+ "retrieve": true,
248
+ // Force a predictive order for event types, invoices and payments
249
+ "order": [[0, 'desc'], [2, 'desc']],
250
+ "columns": [
251
+ { "type": 'date' },
252
+ null,
253
+ { "type": 'timeline-event' },
254
+ { "type": 'timeline-details' },
255
+ null
256
+ ]
257
+ });
341
258
  }
342
259
 
343
260
  function filterEachNode(rows) {