kaui 0.1.18 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. data/.gitignore +10 -0
  2. data/.travis.yml +30 -0
  3. data/Gemfile +21 -0
  4. data/Gemfile.lock +107 -0
  5. data/README.md +60 -0
  6. data/app/assets/images/kaui/.gitkeep +0 -0
  7. data/{test/dummy/tmp/cache/assets/D07/DA0/sprockets%2Ffaad9b18203975dbf0c60f3234a51874 → app/assets/javascripts/kaui/analytics.js} +0 -0
  8. data/{test/dummy/tmp/cache/assets/C8D/080/sprockets%2F4556c595251e3b8d4f688467e330da26 → app/assets/javascripts/kaui/bootstrap-tweaks.js} +0 -0
  9. data/app/assets/javascripts/kaui/validation.js +21 -0
  10. data/app/assets/stylesheets/kaui/analytics.css +26 -0
  11. data/app/controllers/kaui/accounts_controller.rb +0 -3
  12. data/app/controllers/kaui/analytics_controller.rb +20 -11
  13. data/app/controllers/kaui/engine_controller.rb +13 -4
  14. data/app/controllers/kaui/invoices_controller.rb +1 -1
  15. data/app/controllers/kaui/refunds_controller.rb +16 -1
  16. data/app/controllers/kaui/subscriptions_controller.rb +6 -0
  17. data/app/controllers/kaui/tag_definitions_controller.rb +7 -2
  18. data/app/helpers/kaui/date_helper.rb +2 -3
  19. data/app/helpers/kaui/killbill_helper.rb +0 -3
  20. data/app/models/kaui/account.rb +0 -2
  21. data/app/models/kaui/account_timeline.rb +0 -2
  22. data/app/models/kaui/audit_log.rb +0 -2
  23. data/app/models/kaui/bundle.rb +0 -2
  24. data/app/models/kaui/invoice.rb +1 -3
  25. data/app/models/kaui/invoice_item.rb +1 -3
  26. data/app/models/kaui/payment.rb +7 -3
  27. data/app/models/kaui/payment_attempt.rb +1 -3
  28. data/app/models/kaui/payment_method.rb +1 -3
  29. data/app/models/kaui/plugin_info.rb +1 -3
  30. data/app/models/kaui/plugin_info_property.rb +1 -3
  31. data/app/models/kaui/refund.rb +1 -3
  32. data/app/models/kaui/time_series_data.rb +5 -1
  33. data/app/views/kaui/account_timelines/show.html.erb +10 -10
  34. data/app/views/kaui/accounts/show.html.erb +1 -1
  35. data/app/views/kaui/bundles/show.html.erb +1 -1
  36. data/app/views/kaui/home/index.html.erb +10 -0
  37. data/app/views/kaui/invoices/show.html.erb +6 -6
  38. data/app/views/kaui/layouts/kaui_application.html.erb +48 -0
  39. data/app/views/kaui/payments/_payments_table.html.erb +2 -2
  40. data/app/views/kaui/refunds/show.html.erb +2 -2
  41. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +20 -39
  42. data/app/views/kaui/subscriptions/show.html.erb +2 -2
  43. data/bin/kaui +4 -0
  44. data/config/routes.rb +2 -2
  45. data/kaui.gemspec +27 -0
  46. data/lib/generators/kaui/install/install_generator.rb +68 -0
  47. data/lib/generators/kaui/install/templates/app/assets/javascripts/kaui/all.js +16 -0
  48. data/lib/generators/kaui/install/templates/app/assets/stylesheets/kaui/all.css +11 -0
  49. data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -0
  50. data/lib/kaui/engine.rb +12 -0
  51. data/lib/kaui/installer/installer.rb +82 -0
  52. data/lib/kaui/version.rb +1 -1
  53. data/lib/kaui.rb +13 -1
  54. data/script/rails +8 -0
  55. data/script/sandbox +25 -0
  56. data/test/dummy/app/assets/javascripts/application.js +5 -3
  57. data/test/dummy/app/assets/stylesheets/application.css +2 -1
  58. data/test/dummy/app/mailers/.gitkeep +0 -0
  59. data/test/dummy/app/models/.gitkeep +0 -0
  60. data/test/dummy/lib/assets/.gitkeep +0 -0
  61. data/test/dummy/log/.gitkeep +0 -0
  62. data/test/test_helper.rb +18 -0
  63. data/{test/dummy/vendor → vendor}/assets/images/img/glyphicons-halflings-white.png +0 -0
  64. data/{test/dummy/vendor → vendor}/assets/images/img/glyphicons-halflings.png +0 -0
  65. data/vendor/assets/javascripts/js/bootstrap-datepicker.cd46d38.js +1211 -0
  66. data/{test/dummy/vendor/assets/javascripts → vendor/assets/javascripts/js}/bootstrap.v2.0.4.min.js +0 -0
  67. data/{test/dummy/vendor/assets/javascripts → vendor/assets/javascripts/js}/jquery.dataTables.v1.9.3.min.js +0 -0
  68. data/vendor/assets/stylesheets/css/bootstrap-datepicker.cd46d38.css +274 -0
  69. data/{test/dummy/vendor/assets/stylesheets → vendor/assets/stylesheets/css}/bootstrap.v2.0.4.min.css +0 -0
  70. metadata +131 -130
  71. data/README.rdoc +0 -36
  72. data/app/assets/javascripts/kaui/account_timeline.js +0 -2
  73. data/app/assets/javascripts/kaui/application.js +0 -15
  74. data/app/assets/javascripts/kaui/bundles.js +0 -2
  75. data/app/assets/javascripts/kaui/chargebacks.js +0 -2
  76. data/app/assets/javascripts/kaui/extpayments.js +0 -2
  77. data/app/assets/javascripts/kaui/home.js +0 -2
  78. data/app/assets/javascripts/kaui/invoices.js +0 -2
  79. data/app/assets/javascripts/kaui/payments.js +0 -2
  80. data/app/assets/javascripts/kaui/refunds.js +0 -2
  81. data/app/assets/stylesheets/kaui/account_timeline.css +0 -4
  82. data/app/assets/stylesheets/kaui/application.css +0 -13
  83. data/app/assets/stylesheets/kaui/bundles.css +0 -4
  84. data/app/assets/stylesheets/kaui/chargebacks.css +0 -4
  85. data/app/assets/stylesheets/kaui/extpayments.css +0 -4
  86. data/app/assets/stylesheets/kaui/home.css +0 -4
  87. data/app/assets/stylesheets/kaui/invoices.css +0 -4
  88. data/app/assets/stylesheets/kaui/payments.css +0 -4
  89. data/app/assets/stylesheets/kaui/refunds.css +0 -4
  90. data/app/controllers/kaui/tags_controller.rb +0 -85
  91. data/app/views/kaui/account_emails/edit.html.erb +0 -6
  92. data/app/views/kaui/analytics/payments_over_time.html.erb +0 -9
  93. data/app/views/kaui/tags/_form.html.erb +0 -25
  94. data/app/views/kaui/tags/edit.html.erb +0 -6
  95. data/app/views/kaui/tags/index.html.erb +0 -25
  96. data/app/views/kaui/tags/new.html.erb +0 -5
  97. data/app/views/kaui/tags/show.html.erb +0 -15
  98. data/test/dummy/log/development.log +0 -99013
  99. data/test/dummy/log/test.log +0 -127459
  100. data/test/dummy/tmp/cache/assets/C94/4E0/sprockets%2Fea1476dc10a3348303f74d111f70441a +0 -0
  101. data/test/dummy/tmp/cache/assets/C95/690/sprockets%2Fc4b083702793f7599f4a3069c50f89a8 +0 -0
  102. data/test/dummy/tmp/cache/assets/CAA/680/sprockets%2F3824d037523f650518fb22acab75559d +0 -0
  103. data/test/dummy/tmp/cache/assets/CC2/520/sprockets%2F9637f46d37325381f96d96d94ae0bc50 +0 -0
  104. data/test/dummy/tmp/cache/assets/CD0/9D0/sprockets%2F5c9508c21501c73fbe00473a09b1f5f4 +0 -0
  105. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  106. data/test/dummy/tmp/cache/assets/CDF/1F0/sprockets%2F76ac5628a0c4d1b976cb622ec4493751 +0 -381
  107. data/test/dummy/tmp/cache/assets/CE0/8A0/sprockets%2Fc18dc7330236e7db17d280973d617b9a +0 -0
  108. data/test/dummy/tmp/cache/assets/CEA/300/sprockets%2Fdf2ad5c9d0990441c2bf59883383d652 +0 -0
  109. data/test/dummy/tmp/cache/assets/CEC/5B0/sprockets%2F1695e8510891108e3950e2a3e4fdf9df +0 -0
  110. data/test/dummy/tmp/cache/assets/CF7/710/sprockets%2F86d43448e1fc383cb6f3d752ef288882 +0 -0
  111. data/test/dummy/tmp/cache/assets/CFF/A00/sprockets%2F642f58fb154eff788f45c881b294e818 +0 -0
  112. data/test/dummy/tmp/cache/assets/D04/1D0/sprockets%2F3baf64d90ead2434455d2296227ba8a2 +0 -7038
  113. data/test/dummy/tmp/cache/assets/D05/510/sprockets%2F1c14866e2401c27b0ff5e33d1b92c4e8 +0 -0
  114. data/test/dummy/tmp/cache/assets/D17/DD0/sprockets%2F665455ecdc7609b23f4ecb366d86055a +0 -9409
  115. data/test/dummy/tmp/cache/assets/D32/200/sprockets%2Ffa467106e01bda5d6246baea72159d64 +0 -0
  116. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  117. data/test/dummy/tmp/cache/assets/D39/5E0/sprockets%2F59fd338be48a81a17a2a785cbd1612b4 +0 -0
  118. data/test/dummy/tmp/cache/assets/D44/170/sprockets%2Fac15571bce3f926a498da7cd09322d97 +0 -0
  119. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  120. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  121. data/test/dummy/tmp/cache/assets/D6C/710/sprockets%2F1765773caead06c0a6a19ea9de2453f7 +0 -0
  122. data/test/dummy/tmp/cache/assets/D76/910/sprockets%2Ff99b4bdc434e11e8634e6af62fe805e0 +0 -0
  123. data/test/dummy/tmp/cache/assets/D79/1E0/sprockets%2F97b08ebe07a73d8195ba124ffb45f98b +0 -7038
  124. data/test/dummy/tmp/cache/assets/D9F/160/sprockets%2F510462e1ebd5dbb7ae20888b77f9bed2 +0 -0
  125. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  126. data/test/dummy/tmp/cache/assets/DDF/650/sprockets%2Fbe16f0bf3d2b7af18010acbd53ba22f5 +0 -0
  127. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  128. data/test/dummy/tmp/cache/assets/E07/1E0/sprockets%2F5a3fe6e98fdf72bbe75c605e54ebc5b0 +0 -9409
  129. data/test/dummy/tmp/cache/assets/E10/BE0/sprockets%2F9c06f8f8da4e736ccf6de8360cd39bfa +0 -0
  130. data/test/dummy/tmp/cache/assets/E20/230/sprockets%2F7d3b1348fdf74cf1b6ba2107fbbac5af +0 -0
  131. data/test/dummy/tmp/cache/assets/E22/F40/sprockets%2Faffacf2e6be325520bd3bfd2096b6dd4 +0 -0
  132. data/test/dummy/tmp/cache/assets/E24/9D0/sprockets%2Fb966ab0a50fda3c156fbad4d8ab73ef6 +0 -381
  133. data/test/functional/kaui/account_emails_controller_test.rb +0 -51
  134. data/test/functional/kaui/tags_controller_test.rb +0 -51
@@ -110,14 +110,14 @@
110
110
  <tr title="<%= bundles %>">
111
111
  <td>
112
112
  <% if refund.requested_date.present? %>
113
- <%= format_date(refund.requested_date).html_safe %>
113
+ <%= format_date(refund.requested_date, @account.timezone).html_safe %>
114
114
  <% else %>
115
115
  [unknown]
116
116
  <% end %>
117
117
  </td>
118
118
  <td>
119
119
  <% if refund.effective_date.present? %>
120
- <%= format_date(refund.effective_date).html_safe %>
120
+ <%= format_date(refund.effective_date, @account.timezone).html_safe %>
121
121
  <% else %>
122
122
  [unknown]
123
123
  <% end %>
@@ -148,14 +148,14 @@
148
148
  <tr title="<%= bundles %>">
149
149
  <td>
150
150
  <% if chargeback.effective_date.present? %>
151
- <%= format_date(chargeback.effective_date).html_safe %>
151
+ <%= format_date(chargeback.effective_date, @account.timezone).html_safe %>
152
152
  <% else %>
153
153
  [unknown]
154
154
  <% end %>
155
155
  </td>
156
156
  <td>
157
157
  <% if chargeback.effective_date.present? %>
158
- <%= format_date(chargeback.effective_date).html_safe %>
158
+ <%= format_date(chargeback.effective_date, @account.timezone).html_safe %>
159
159
  <% else %>
160
160
  [unknown]
161
161
  <% end %>
@@ -190,14 +190,14 @@
190
190
  <tr title="<%= bundles %>">
191
191
  <td>
192
192
  <% if payment.requested_date.present? %>
193
- <%= format_date(payment.requested_date).html_safe %>
193
+ <%= format_date(payment.requested_date, @account.timezone).html_safe %>
194
194
  <% else %>
195
195
  [unknown]
196
196
  <% end %>
197
197
  </td>
198
198
  <td>
199
199
  <% if payment.effective_date.present? %>
200
- <%= format_date(payment.effective_date).html_safe %>
200
+ <%= format_date(payment.effective_date, @account.timezone).html_safe %>
201
201
  <% else %>
202
202
  [unknown]
203
203
  <% end %>
@@ -231,13 +231,13 @@
231
231
  <%= link_to 'Refund', kaui_engine.new_refund_path(:params => { :payment_id => payment.payment_id,
232
232
  :account_id => @account.account_id,
233
233
  :invoice_id => payment.invoice_id }),
234
- :class => "btn btn-mini #{"disabled" unless payment.payment_id.present?}" %>
234
+ :class => "btn btn-mini #{"disabled" unless payment.payment_id.present? and payment.status == 'SUCCESS' and !payment.is_fully_refunded?}" %>
235
235
  </nobr>
236
236
  <nobr>
237
237
  <%= link_to 'Chargeback', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
238
238
  :account_id => @account.account_id,
239
239
  :invoice_id => payment.invoice_id }),
240
- :class => "btn btn-mini #{"disabled" unless payment.payment_id.present?}" %>
240
+ :class => "btn btn-mini #{"disabled" unless payment.payment_id.present? and payment.status == 'SUCCESS'}" %>
241
241
  </nobr>
242
242
  </td>
243
243
  </tr>
@@ -250,14 +250,14 @@
250
250
  <tr title="<%= @bundle_names[bundle.external_key] %>">
251
251
  <td>
252
252
  <% if event.requested_date.present? %>
253
- <%= format_date(event.requested_date).html_safe %>
253
+ <%= format_date(event.requested_date, @account.timezone).html_safe %>
254
254
  <% else %>
255
255
  [unknown]
256
256
  <% end %>
257
257
  </td>
258
258
  <td>
259
259
  <% if event.effective_date.present? %>
260
- <%= format_date(event.effective_date).html_safe %>
260
+ <%= format_date(event.effective_date, @account.timezone).html_safe %>
261
261
  <% else %>
262
262
  [unknown]
263
263
  <% end %>
@@ -89,7 +89,7 @@
89
89
  <% else %>
90
90
  <span class='label label-important'><%= @overdue_state_by_bundle_id[bundle.bundle_id].name %></span>
91
91
  <% end %>
92
- <%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => subs } %>
92
+ <%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => subs, :account => @account } %>
93
93
  <% end %>
94
94
  <% end %>
95
95
  <% else %>
@@ -17,7 +17,7 @@
17
17
  <% end %>
18
18
  <%= link_to "Transfer Ownership", kaui_engine.transfer_bundle_path(@bundle.bundle_id), :class => "btn btn-mini" %></dd>
19
19
  <% if @subscriptions.present? %>
20
- <%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => @subscriptions } %>
20
+ <%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => @subscriptions, :account => @account } %>
21
21
  <% end %>
22
22
  <% else %>
23
23
  <p>Bundle not found</p>
@@ -0,0 +1,10 @@
1
+ <header class='hero-unit'>
2
+ <h1>Welcome to Kaui!</h1>
3
+ <p class='lead'>Online documentation can be found at <a href='http://killbilling.org/' target='_blank'>http://killbilling.org/</a></p>
4
+
5
+ <p>About your application&rsquo;s environment:
6
+ <ul>
7
+ <li>Killbill url: <%= Kaui.killbill_finder.call %></li>
8
+ </ul>
9
+ </p>
10
+ </header>
@@ -5,9 +5,9 @@
5
5
  <dd><%= @account.name %>&nbsp;</dd>
6
6
  <dd><%= link_to @account.email, Kaui.account_home_path.call(@account.external_key) %>&nbsp;</dd>
7
7
  <dt>Invoice date:</dt>
8
- <dd><%= format_date(@invoice.invoice_date).html_safe %>&nbsp;</dd>
8
+ <dd><%= @invoice.invoice_date.html_safe %>&nbsp;</dd>
9
9
  <dt>Target date:</dt>
10
- <dd><%= format_date(@invoice.target_date).html_safe %>&nbsp;</dd>
10
+ <dd><%= @invoice.target_date.html_safe %>&nbsp;</dd>
11
11
  <dt>Amount:</dt>
12
12
  <dd><%= humanized_money_with_symbol @invoice.amount_to_money(@account.currency) %> (<%= @account.currency %>)&nbsp;</dd>
13
13
  <dt>Balance:</dt>
@@ -54,9 +54,9 @@
54
54
  <%= link_to Kaui.bundle_key_display_string.call(bundle.external_key), Kaui.bundle_home_path.call(bundle.bundle_id) if bundle.present? and bundle.external_key.present? %>
55
55
  </td>
56
56
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.description %></td>
57
- <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= format_date(item.start_date).html_safe if item.start_date %></td>
58
- <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= format_date(item.end_date).html_safe if item.end_date %></td>
59
- <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= format_date(sub.charged_through_date).html_safe if sub.present? %></td>
57
+ <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.start_date.html_safe if item.start_date %></td>
58
+ <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= item.end_date.html_safe if item.end_date %></td>
59
+ <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= format_date(sub.charged_through_date, @account.timezone).html_safe if sub.present? %></td>
60
60
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= sub.price_list.downcase.capitalize if sub.present? and sub.price_list.present? %></td>
61
61
  <td onClick="hightlightLinkedItems('<%= item.invoice_item_id %>', '<%= item.linked_invoice_item_id %>'); return false;"><%= humanized_money_with_symbol item.amount_to_money %> (<%= item.currency %>)</td>
62
62
  <td>
@@ -86,7 +86,7 @@
86
86
  <p>Invoice not found</p>
87
87
  <% end %>
88
88
  <%= link_to 'Back', :back, :class => 'btn' %>
89
- <%= link_to "View customer invoice html", kaui_engine.show_html_invoice_path(@invoice.invoice_id), :class => 'btn', :target => "_blank" %>
89
+ <%= link_to "View customer invoice html", kaui_engine.show_html_invoice_path(@invoice.invoice_id), :class => 'btn', :target => "_blank" unless @invoice.blank? %>
90
90
  <%= javascript_tag do %>
91
91
  function disableLinks() {
92
92
  $('a.btn.disabled').click(function (e) {
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Kaui app</title>
5
+ <%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <div class="navbar">
11
+ <div class="navbar-inner">
12
+ <div class="container">
13
+ <ul class="nav">
14
+ <li <%= "class='active'" if params[:controller] == 'accounts' %>><%= link_to "Accounts", kaui_engine.accounts_path %></li>
15
+ <li <%= "class='active'" if params[:controller] == 'account_timelines' %>><%= link_to "Account timelines", kaui_engine.account_timelines_path %></li>
16
+ <li <%= "class='active'" if params[:controller] == 'bundles' %>><%= link_to "Bundles", kaui_engine.bundles_path %></li>
17
+ <li <%= "class='active'" if params[:controller] == 'subscriptions' %>><%= link_to "Subscriptions", kaui_engine.subscriptions_path %></li>
18
+ <li <%= "class='active'" if params[:controller] == 'chargebacks' %>><%= link_to "Chargebacks", kaui_engine.chargebacks_path %></li>
19
+ <li <%= "class='active'" if params[:controller] == 'credits' %>><%= link_to "Credits", kaui_engine.credits_path %></li>
20
+ <li <%= "class='active'" if params[:controller] == 'external_payments' %>><%= link_to "External payments", kaui_engine.external_payments_path %></li>
21
+ <li <%= "class='active'" if params[:controller] == 'refunds' %>><%= link_to "Refunds", kaui_engine.refunds_path %></li>
22
+ <li <%= "class='active'" if params[:controller] == 'invoices' %>><%= link_to "Invoices", kaui_engine.invoices_path %></li>
23
+ <li <%= "class='active'" if params[:controller] == 'invoice_items' %>><%= link_to "Invoice items", kaui_engine.invoice_items_path %></li>
24
+ <li <%= "class='active'" if params[:controller] == 'tag_definitions' %>><%= link_to "Tag definitions", kaui_engine.tag_definitions_path %></li>
25
+ <li <%= "class='active'" if params[:controller] == 'analytics' %>><%= link_to "Analytics", kaui_engine.analytics_path %></li>
26
+ </ul>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ <div class="container">
31
+ <% if flash[:error] %>
32
+ <div class="row-fluid">
33
+ <div class="span12">
34
+ <div class="alert alert-error"><%= flash[:error] %></div>
35
+ </div>
36
+ </div>
37
+ <% end %>
38
+ <% if flash[:notice] %>
39
+ <div class="row-fluid">
40
+ <div class="span12">
41
+ <div class="alert alert-info"><%= flash[:notice] %></div>
42
+ </div>
43
+ </div>
44
+ <% end %>
45
+ <%= yield %>
46
+ </div>
47
+ </body>
48
+ </html>
@@ -18,8 +18,8 @@
18
18
  <% if @payments.present? %>
19
19
  <% @payments.each do |payment| %>
20
20
  <tr>
21
- <td><%= format_date(payment.requested_date).html_safe if payment.requested_date.present? %></td>
22
- <td><%= format_date(payment.effective_date).html_safe if payment.effective_date.present? %></td>
21
+ <td><%= format_date(payment.requested_date, @account.timezone).html_safe if payment.requested_date.present? %></td>
22
+ <td><%= format_date(payment.effective_date, @account.timezone).html_safe if payment.effective_date.present? %></td>
23
23
  <td><%= humanized_money_with_symbol payment.amount_to_money %> (<%= payment.currency %>)</td>
24
24
  <td><%= humanized_money_with_symbol payment.paid_amount_to_money %> (<%= payment.currency %>)</td>
25
25
  <td></td>
@@ -21,8 +21,8 @@
21
21
  <td><%= link_to refund.payment_id, payment_path(refund.payment_id) %></td>
22
22
  <td><%= refund.amount %>&nbsp;<%= refund.currency %></td>
23
23
  <td><%= refund.adjusted %></td>
24
- <td><%= format_date(refund.requested_date).html_safe %></td>
25
- <td><%= format_date(refund.effective_date).html_safe %></td>
24
+ <td><%= format_date(refund.requested_date, @account.timezone).html_safe %></td>
25
+ <td><%= format_date(refund.effective_date, @account.timezone).html_safe %></td>
26
26
  <td><%= refund.adjustments %></td>
27
27
  </tr>
28
28
  <% end %>
@@ -18,53 +18,34 @@
18
18
  <tr>
19
19
  <td><%= sub.product_category.downcase.capitalize if sub.product_category.present? %></td>
20
20
  <td><%= sub.product_name.downcase.capitalize if sub.product_name.present? %> <%= sub.billing_period.downcase.capitalize if sub.billing_period.present? %> <% if sub.price_list.present? && sub.price_list.upcase != "DEFAULT" %> ( <%= sub.price_list.downcase.capitalize %> pricelist ) <% end %></td>
21
- <td><%= format_date(sub.start_date).html_safe if sub.start_date.present? %></td>
22
- <td><%= format_date(sub.charged_through_date).html_safe if sub.charged_through_date.present? %></td>
21
+ <td><%= format_date(sub.start_date, account.timezone).html_safe if sub.start_date.present? %></td>
22
+ <td><%= format_date(sub.charged_through_date, account.timezone).html_safe if sub.charged_through_date.present? %></td>
23
23
  <td>
24
24
  <% if sub.canceled_date.present? && !sub.canceled_date.nil? %>
25
- <% if Time.parse(sub.canceled_date) > Time.now %> <%= "Pending cancellation on " %> <% else %> <%= "Canceled on " %> <% end %> <%= format_date(sub.canceled_date).html_safe %>
25
+ <% if Time.parse(sub.canceled_date) > Time.now %> <%= "Pending cancellation on " %> <% else %> <%= "Canceled on " %> <% end %> <%= format_date(sub.canceled_date, account.timezone).html_safe %>
26
26
  <% end %>
27
27
  </td>
28
28
  <td>
29
29
  <nobr>
30
- <% if sub.product_category == 'BASE' %>
31
- <% if sub.canceled_date.present? && Time.parse(sub.canceled_date) > Time.now %>
32
- <%= link_to "Reinstate", kaui_engine.reinstate_subscription_path(:id => sub.subscription_id), :method => :put, :class => "btn btn-mini" %>
33
- <% elsif !sub.canceled_date.present? %>
34
- <%= link_to "Change", kaui_engine.edit_subscription_path(sub.subscription_id), :class => "btn btn-mini" %>
35
- <div class="btn-group">
36
- <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
37
- Cancel
38
- <span class="caret"></span>
39
- </a>
40
- <ul class="dropdown-menu">
41
- <li><%= link_to "Cancel (default policy)", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :delete %></li>
42
- <li><%= link_to "Cancel at previous CTD (no proration)", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE', :ctd => sub.charged_through_date, :billing_period => sub.billing_period), :method => :delete %></li>
43
- <li><%= link_to "Cancel immediately (generate proration)", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE'), :method => :delete %></li>
44
- <li><%= link_to "Cancel end of term", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'END_OF_TERM'), :method => :delete %></li>
45
- </ul>
46
- </div>
30
+ <% if sub.canceled_date.present? && Time.parse(sub.canceled_date) > Time.now %>
31
+ <%= link_to "Reinstate", kaui_engine.reinstate_subscription_path(:id => sub.subscription_id), :method => :put, :class => "btn btn-mini" %>
32
+ <% elsif !sub.canceled_date.present? %>
33
+ <%= link_to "Change", kaui_engine.edit_subscription_path(sub.subscription_id), :class => "btn btn-mini" %>
34
+ <div class="btn-group">
35
+ <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
36
+ Cancel
37
+ <span class="caret"></span>
38
+ </a>
39
+ <ul class="dropdown-menu">
40
+ <li><%= link_to "Cancel (default policy)", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :delete %></li>
41
+ <li><%= link_to "Cancel at previous CTD (no proration)", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE', :ctd => sub.charged_through_date, :billing_period => sub.billing_period), :method => :delete %></li>
42
+ <li><%= link_to "Cancel immediately (generate proration)", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE'), :method => :delete %></li>
43
+ <li><%= link_to "Cancel end of term", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'END_OF_TERM'), :method => :delete %></li>
44
+ </ul>
45
+ </div>
46
+ <% if sub.product_category == 'BASE' %>
47
47
  <%= link_to "Add Addons", kaui_engine.new_subscription_path(:params => { :bundle_id => sub.bundle_id, :base_subscription => sub.product_name }), :class => "btn btn-mini" %>
48
48
  <% end %>
49
- <% else %>
50
- <% end %>
51
- <% if sub.product_category == 'ADD_ON' %>
52
- <% if !sub.canceled_date.present? %>
53
- <div class="btn-group">
54
- <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
55
- Cancel
56
- <span class="caret"></span>
57
- </a>
58
- <ul class="dropdown-menu">
59
- <li><%= link_to "Cancel (default policy)", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :delete %></li>
60
- <li><%= link_to "Cancel immediately", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE'), :method => :delete %></li>
61
- <li><%= link_to "Cancel end of term", kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'END_OF_TERM'), :method => :delete %></li>
62
- </ul>
63
- </div>
64
- <% end %>
65
- <% if sub.canceled_date.present? && Time.parse(sub.canceled_date) > Time.now %>
66
- <%= link_to "Reinstate", kaui_engine.reinstate_subscription_path(:id => sub.subscription_id), :method => :put, :class => "btn btn-mini" %>
67
- <% end %>
68
49
  <% end %>
69
50
  </nobr>
70
51
  </td>
@@ -10,11 +10,11 @@
10
10
  <dt>Period</dt>
11
11
  <dd><%= @subscription.billing_period.downcase.capitalize if @subscription.billing_period.present? %></dd>
12
12
  <dt>Charged through</dt>
13
- <dd> <%= format_date(@subscription.charged_through_date).html_safe if @subscription.charged_through_date.present? %>
13
+ <dd> <%= format_date(@subscription.charged_through_date, @account.timezone).html_safe if @subscription.charged_through_date.present? %>
14
14
  <dt>Price List</dt>
15
15
  <dd><%= @subscription.price_list %></dd>
16
16
  <dt>Start Date</dt>
17
- <dd> <%= format_date(@subscription.start_date).html_safe if @subscription.start_date.present? %>
17
+ <dd> <%= format_date(@subscription.start_date, @account.timezone).html_safe if @subscription.start_date.present? %>
18
18
  </dl>
19
19
  <hr/>
20
20
  <%= link_to "Change", kaui_engine.edit_subscription_path(@subscription.subscription_id), :class => "btn btn-mini" %>
data/bin/kaui ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'kaui/installer/installer'
4
+ KauiCmd::Installer.start
data/config/routes.rb CHANGED
@@ -4,7 +4,7 @@ Kaui::Engine.routes.draw do
4
4
  root :to => "home#index"
5
5
 
6
6
  resources :accounts, :only => [ :index, :show ] do
7
- member do
7
+ member do
8
8
  get :payment_methods
9
9
  put :set_default_payment_method
10
10
  get :add_payment_method
@@ -12,7 +12,7 @@ Kaui::Engine.routes.draw do
12
12
  delete :delete_payment_method
13
13
  post :toggle_email_notifications
14
14
  post :pay_all_invoices
15
- end
15
+ end
16
16
  end
17
17
 
18
18
  resources :account_emails, :only => [ :create, :new, :show, :destroy ]
data/kaui.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "kaui/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "kaui"
9
+ s.version = Kaui::VERSION
10
+ s.authors = ["Alena Dudzinskaya"]
11
+ s.email = ["alenad@glam.com"]
12
+ s.homepage = "https://github.com/killbill/killbill-admin-ui"
13
+ s.summary = "Killbill Admin UI plugin"
14
+ s.description = "Rails UI plugin for Killbill administration."
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.bindir = 'bin'
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'rails', '~> 3.2.3'
23
+ s.add_dependency 'jquery-rails', '~> 2.0'
24
+ s.add_dependency 'rest-client', '~> 1.6.7'
25
+ s.add_dependency 'money-rails', '~> 0.5.0'
26
+ s.add_dependency 'd3_rails', '~> 2.10.3'
27
+ end
@@ -0,0 +1,68 @@
1
+ require 'rails/generators'
2
+ require 'kaui/version'
3
+
4
+ module Kaui
5
+ class InstallGenerator < Rails::Generators::Base
6
+ class_option :lib_name, :type => :string, :default => 'kaui'
7
+
8
+ def self.source_paths
9
+ paths = self.superclass.source_paths
10
+ paths << File.expand_path('../templates', "../../#{__FILE__}")
11
+ paths << File.expand_path('../templates', "../#{__FILE__}")
12
+ paths << File.expand_path('../templates', __FILE__)
13
+ paths.flatten
14
+ end
15
+
16
+ def add_files
17
+ template 'config/initializers/kaui.rb', 'config/initializers/kaui.rb'
18
+ end
19
+
20
+ def config_kaui_yml
21
+ create_file "config/kaui.yml" do
22
+ settings = { 'version' => Kaui::VERSION }
23
+
24
+ settings.to_yaml
25
+ end
26
+ end
27
+
28
+ def additional_tweaks
29
+ return unless File.exists? 'public/robots.txt'
30
+ append_file "public/robots.txt", <<-ROBOTS
31
+ User-agent: *
32
+ Disallow: /kaui
33
+ ROBOTS
34
+ end
35
+
36
+ def setup_assets
37
+ @lib_name = 'kaui'
38
+ %w{javascripts stylesheets images}.each do |path|
39
+ empty_directory "app/assets/#{path}/kaui"
40
+ end
41
+
42
+ template "app/assets/javascripts/kaui/all.js"
43
+ template "app/assets/stylesheets/kaui/all.css"
44
+ end
45
+
46
+ def update_routes
47
+ insert_into_file File.join('config', 'routes.rb'), :after => "Application.routes.draw do\n" do
48
+ %Q{
49
+ # This line mounts Kaui's routes at the root of your application.
50
+ # If you're mounting this engine into an existing application, change it to e.g.
51
+ # mount Kaui::Engine, :at => '/kaui', :as => "kaui_engine"
52
+ #
53
+ # Don't modify the :as => "kaui_engine" option though.
54
+ mount Kaui::Engine, :at => '/', :as => "kaui_engine"
55
+ }
56
+ end
57
+ end
58
+
59
+ def complete
60
+ unless options[:quiet]
61
+ puts "*" * 50
62
+ puts "Kaui has been installed successfully. You're all ready to go!"
63
+ puts " "
64
+ puts "Enjoy!"
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require d3.v2
10
+ //= require js/bootstrap.v2.0.4.min
11
+ //= require js/bootstrap-datepicker.cd46d38
12
+ //= require js/jquery.dataTables.v1.9.3.min
13
+ //= require kaui/bootstrap-tweaks
14
+ //= require kaui/validation
15
+ //= require kaui/analytics
16
+ //= require_tree .
@@ -0,0 +1,11 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *
6
+ *= require css/bootstrap.v2.0.4.min
7
+ *= require css/bootstrap-datepicker.cd46d38
8
+ *= require kaui/analytics
9
+ *= require_self
10
+ *= require_tree .
11
+ */
@@ -0,0 +1,3 @@
1
+ # Configure Kaui Preferences
2
+ Kaui.config do |config|
3
+ end
data/lib/kaui/engine.rb CHANGED
@@ -1,3 +1,15 @@
1
+ # Dependencies
2
+ #
3
+ # Sigh. Rails autoloads the gems specified in the Gemfile and nothing else.
4
+ # We need to explicitly require all of our dependencies listed in kaui.gemspec
5
+ #
6
+ # See also https://github.com/carlhuda/bundler/issues/49
7
+ require 'jquery-rails'
8
+ require 'd3_rails'
9
+ require 'json'
10
+ require 'money-rails'
11
+ require 'rest_client'
12
+
1
13
  module Kaui
2
14
  class Engine < ::Rails::Engine
3
15
  isolate_namespace Kaui
@@ -0,0 +1,82 @@
1
+ require 'rbconfig'
2
+ require 'active_support/core_ext/string'
3
+ require 'thor'
4
+ require 'thor/group'
5
+ require 'kaui/version'
6
+
7
+ module KauiCmd
8
+
9
+ class Installer < Thor::Group
10
+ include Thor::Actions
11
+
12
+ desc 'Install Kaui inside an existing rails project'
13
+
14
+ argument :app_path, :type => :string, :desc => 'rails app_path', :default => '.'
15
+
16
+ class_option :version, :type => :string, :desc => 'Kaui Version to use'
17
+
18
+ class_option :edge, :type => :boolean
19
+
20
+ class_option :path, :type => :string, :desc => 'Kaui gem path'
21
+ class_option :git, :type => :string, :desc => 'Kaui gem git url'
22
+ class_option :ref, :type => :string, :desc => 'Kaui gem git ref'
23
+ class_option :branch, :type => :string, :desc => 'Kaui gem git branch'
24
+ class_option :tag, :type => :string, :desc => 'Kaui gem git tag'
25
+
26
+ class_option :skip_bundle, :type => :boolean, :desc => "Don't run bundle install"
27
+
28
+ def verify_rails
29
+ unless rails_project?
30
+ say "#{@app_path} is not a rails project."
31
+ exit 1
32
+ end
33
+ end
34
+
35
+ def prepare_options
36
+ @kaui_gem_options = {}
37
+
38
+ if options[:edge]
39
+ @kaui_gem_options[:git] = 'git://github.com/killbill/killbill-admin-ui.git'
40
+ elsif options[:path]
41
+ @kaui_gem_options[:path] = options[:path]
42
+ elsif options[:git]
43
+ @kaui_gem_options[:git] = options[:git]
44
+ @kaui_gem_options[:ref] = options[:ref] if options[:ref]
45
+ @kaui_gem_options[:branch] = options[:branch] if options[:branch]
46
+ @kaui_gem_options[:tag] = options[:tag] if options[:tag]
47
+ elsif options[:version]
48
+ @kaui_gem_options[:version] = options[:version]
49
+ else
50
+ version = Kaui::VERSION
51
+ @kaui_gem_options[:version] = version.to_s
52
+ end
53
+ end
54
+
55
+ def add_gems
56
+ inside @app_path do
57
+ gem :kaui, @kaui_gem_options
58
+ run 'bundle install', :capture => true unless options[:skip_bundle]
59
+ end
60
+ end
61
+
62
+ def initialize_kaui
63
+ inside @app_path do
64
+ run "rails generate kaui:install", :verbose => false
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def rails_project?
71
+ File.exists? File.join(@app_path, 'script', 'rails')
72
+ end
73
+
74
+ def gem(name, gem_options={})
75
+ say_status :gemfile, name
76
+ parts = ["'#{name}'"]
77
+ parts << ["'#{gem_options.delete(:version)}'"] if gem_options[:version]
78
+ gem_options.each { |key, value| parts << ":#{key} => '#{value}'" }
79
+ append_file 'Gemfile', "gem #{parts.join(', ')}\n", :verbose => false
80
+ end
81
+ end
82
+ end
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.1.18"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/kaui.rb CHANGED
@@ -10,13 +10,25 @@ 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
+ mattr_accessor :layout
15
+ mattr_accessor :killbill_url
13
16
 
14
- self.killbill_finder = lambda { Kaui::Engine.config.killbill_url }
17
+ self.killbill_finder = lambda { self.config[:killbill_url] }
15
18
  self.account_home_path = lambda {|account_id| Kaui::Engine.routes.url_helpers.account_path(account_id) }
16
19
  self.bundle_home_path = lambda {|bundle_id| Kaui::Engine.routes.url_helpers.bundle_path(:id => bundle_id) }
17
20
  self.invoice_home_path = lambda {|invoice_id| Kaui::Engine.routes.url_helpers.invoice_path(:id => invoice_id) }
18
21
  self.bundle_key_display_string = lambda {|bundle_key| bundle_key }
19
22
  self.creditcard_plugin_name = lambda { nil }
23
+
24
+ def self.config(&block)
25
+ # TODO
26
+ {
27
+ :default_current_user => default_current_user || 'Kaui admin user',
28
+ :layout => layout || 'kaui/layouts/kaui_application',
29
+ :killbill_url => killbill_url || ENV['KILLBILL_URL'] || 'http://127.0.0.1:8080'
30
+ }
31
+ end
20
32
  end
21
33
 
22
34
  # ruby-1.8 compatibility
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/kaui/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'