kaui 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/Gemfile.lock +51 -37
  4. data/README.md +5 -0
  5. data/Rakefile +1 -1
  6. data/app/controllers/kaui/account_emails_controller.rb +26 -44
  7. data/app/controllers/kaui/account_tags_controller.rb +26 -38
  8. data/app/controllers/kaui/account_timelines_controller.rb +47 -50
  9. data/app/controllers/kaui/accounts_controller.rb +68 -148
  10. data/app/controllers/kaui/bundle_tags_controller.rb +32 -21
  11. data/app/controllers/kaui/bundles_controller.rb +44 -69
  12. data/app/controllers/kaui/chargebacks_controller.rb +31 -61
  13. data/app/controllers/kaui/charges_controller.rb +19 -21
  14. data/app/controllers/kaui/credits_controller.rb +22 -36
  15. data/app/controllers/kaui/custom_fields_controller.rb +15 -13
  16. data/app/controllers/kaui/engine_controller.rb +8 -10
  17. data/app/controllers/kaui/invoice_items_controller.rb +24 -41
  18. data/app/controllers/kaui/invoices_controller.rb +36 -46
  19. data/app/controllers/kaui/payment_methods_controller.rb +84 -28
  20. data/app/controllers/kaui/payments_controller.rb +64 -26
  21. data/app/controllers/kaui/refunds_controller.rb +27 -107
  22. data/app/controllers/kaui/subscriptions_controller.rb +88 -132
  23. data/app/controllers/kaui/tag_definitions_controller.rb +32 -79
  24. data/app/controllers/kaui/tags_controller.rb +16 -14
  25. data/app/controllers/kaui/transactions_controller.rb +25 -0
  26. data/app/helpers/kaui/money_helper.rb +8 -0
  27. data/app/helpers/kaui/subscription_helper.rb +115 -0
  28. data/app/helpers/kaui/uuid_helper.rb +9 -0
  29. data/app/models/kaui/ability.rb +2 -2
  30. data/app/models/kaui/account.rb +25 -42
  31. data/app/models/kaui/account_email.rb +11 -48
  32. data/app/models/kaui/account_timeline.rb +1 -5
  33. data/app/models/kaui/audit_log.rb +1 -15
  34. data/app/models/kaui/base.rb +1 -126
  35. data/app/models/kaui/bundle.rb +47 -14
  36. data/app/models/kaui/catalog.rb +2 -0
  37. data/app/models/kaui/chargeback.rb +24 -36
  38. data/app/models/kaui/credit.rb +5 -20
  39. data/app/models/kaui/custom_field.rb +9 -5
  40. data/app/models/kaui/invoice.rb +9 -53
  41. data/app/models/kaui/invoice_item.rb +8 -18
  42. data/app/models/kaui/invoice_payment.rb +24 -0
  43. data/app/models/kaui/payment.rb +14 -32
  44. data/app/models/kaui/payment_method.rb +36 -0
  45. data/app/models/kaui/rails_methods.rb +7 -9
  46. data/app/models/kaui/refund.rb +5 -20
  47. data/app/models/kaui/subscription.rb +7 -27
  48. data/app/models/kaui/tag.rb +10 -6
  49. data/app/models/kaui/tag_definition.rb +26 -34
  50. data/app/models/kaui/transaction.rb +30 -0
  51. data/app/models/kaui/user.rb +2 -0
  52. data/app/views/kaui/account_emails/_form.html.erb +8 -28
  53. data/app/views/kaui/account_emails/show.html.erb +10 -10
  54. data/app/views/kaui/account_tags/_account_tags_table.html.erb +20 -18
  55. data/app/views/kaui/account_tags/_form.html.erb +42 -0
  56. data/app/views/kaui/account_tags/edit.html.erb +1 -41
  57. data/app/views/kaui/account_tags/show.html.erb +6 -3
  58. data/app/views/kaui/account_timelines/show.html.erb +273 -302
  59. data/app/views/kaui/accounts/_form.html.erb +116 -0
  60. data/app/views/kaui/accounts/index.html.erb +13 -11
  61. data/app/views/kaui/accounts/new.html.erb +5 -0
  62. data/app/views/kaui/accounts/show.html.erb +101 -99
  63. data/app/views/kaui/bundle_tags/_bundle_tags_table.html.erb +29 -9
  64. data/app/views/kaui/bundle_tags/_form.html.erb +41 -0
  65. data/app/views/kaui/bundle_tags/edit.html.erb +2 -34
  66. data/app/views/kaui/bundle_tags/show.html.erb +6 -0
  67. data/app/views/kaui/bundles/index.html.erb +9 -9
  68. data/app/views/kaui/bundles/show.html.erb +17 -15
  69. data/app/views/kaui/bundles/transfer.html.erb +25 -24
  70. data/app/views/kaui/chargebacks/_form.html.erb +44 -0
  71. data/app/views/kaui/chargebacks/new.html.erb +3 -115
  72. data/app/views/kaui/charges/_form.html.erb +73 -0
  73. data/app/views/kaui/charges/new.html.erb +2 -91
  74. data/app/views/kaui/credits/_form.html.erb +73 -0
  75. data/app/views/kaui/credits/new.html.erb +2 -85
  76. data/app/views/kaui/invoice_items/edit.html.erb +77 -78
  77. data/app/views/kaui/invoices/show.html.erb +3 -10
  78. data/app/views/kaui/layouts/kaui_application.html.erb +0 -2
  79. data/app/views/kaui/payment_methods/_form.html.erb +30 -0
  80. data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +19 -18
  81. data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +8 -5
  82. data/app/views/kaui/payment_methods/index.html.erb +10 -10
  83. data/app/views/kaui/payment_methods/new.html.erb +2 -20
  84. data/app/views/kaui/payment_methods/show.html.erb +2 -1
  85. data/app/views/kaui/payments/_payments_table.html.erb +30 -22
  86. data/app/views/kaui/payments/index.html.erb +1 -1
  87. data/app/views/kaui/payments/new.html.erb +5 -5
  88. data/app/views/kaui/payments/show.html.erb +3 -0
  89. data/app/views/kaui/refunds/new.html.erb +96 -104
  90. data/app/views/kaui/subscriptions/_form.html.erb +36 -0
  91. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +39 -44
  92. data/app/views/kaui/subscriptions/edit.html.erb +24 -35
  93. data/app/views/kaui/subscriptions/index.html.erb +13 -12
  94. data/app/views/kaui/subscriptions/new.html.erb +6 -43
  95. data/app/views/kaui/subscriptions/show.html.erb +32 -25
  96. data/app/views/kaui/tag_definitions/_form.html.erb +10 -37
  97. data/app/views/kaui/tag_definitions/index.html.erb +3 -5
  98. data/app/views/kaui/tag_definitions/show.html.erb +1 -2
  99. data/app/views/kaui/transactions/_form.html.erb +77 -0
  100. data/app/views/kaui/transactions/new.html.erb +3 -0
  101. data/config/initializers/kilbill-client-init.rb +1 -1
  102. data/config/routes.rb +4 -15
  103. data/kaui.gemspec +8 -6
  104. data/lib/kaui/engine.rb +4 -1
  105. data/lib/kaui/version.rb +1 -1
  106. data/lib/kaui.rb +2 -2
  107. data/test/functional/kaui/account_emails_controller_test.rb +28 -0
  108. data/test/functional/kaui/account_tags_controller_test.rb +29 -0
  109. data/test/functional/kaui/account_timelines_controller_test.rb +21 -0
  110. data/test/functional/kaui/accounts_controller_test.rb +56 -50
  111. data/test/functional/kaui/bundle_tags_controller_test.rb +29 -0
  112. data/test/functional/kaui/bundles_controller_test.rb +58 -13
  113. data/test/functional/kaui/chargebacks_controller_test.rb +16 -5
  114. data/test/functional/kaui/charges_controller_test.rb +39 -0
  115. data/test/functional/kaui/credits_controller_test.rb +35 -0
  116. data/test/functional/kaui/custom_fields_controller_test.rb +21 -0
  117. data/test/functional/kaui/functional_test_helper.rb +61 -0
  118. data/test/functional/kaui/invoice_items_controller_test.rb +24 -10
  119. data/test/functional/kaui/invoices_controller_test.rb +41 -13
  120. data/test/functional/kaui/payment_methods_controller_test.rb +49 -0
  121. data/test/functional/kaui/payments_controller_test.rb +32 -5
  122. data/test/functional/kaui/refunds_controller_test.rb +40 -5
  123. data/test/functional/kaui/subscriptions_controller_test.rb +82 -0
  124. data/test/functional/kaui/tag_definitions_controller_test.rb +27 -53
  125. data/test/functional/kaui/tags_controller_test.rb +21 -0
  126. data/test/functional/kaui/transactions_controller_test.rb +32 -0
  127. data/test/integration/kaui/integration_test_helper.rb +31 -0
  128. data/test/integration/kaui/navigation_test.rb +43 -0
  129. data/test/killbill_test_helper.rb +143 -0
  130. data/test/test_helper.rb +10 -227
  131. data/test/unit/kaui/account_email_test.rb +19 -0
  132. data/test/unit/kaui/account_test.rb +7 -35
  133. data/test/unit/kaui/base_test.rb +5 -46
  134. data/test/unit/kaui/date_helper_test.rb +6 -5
  135. data/test/unit/kaui/invoice_item_test.rb +5 -17
  136. data/test/unit/kaui/invoice_payment_test.rb +42 -0
  137. data/test/unit/kaui/invoice_test.rb +15 -15
  138. data/test/unit/kaui/money_helper_test.rb +10 -0
  139. data/test/unit/kaui/payment_test.rb +42 -0
  140. data/test/unit/kaui/tag_definition_test.rb +5 -28
  141. data/test/unit/kaui/uuid_helper_test.rb +10 -0
  142. metadata +134 -159
  143. data/app/controllers/kaui/analytics_controller.rb +0 -28
  144. data/app/helpers/kaui/killbill_helper.rb +0 -611
  145. data/app/models/kaui/analytics.rb +0 -19
  146. data/app/models/kaui/analytics_sanity.rb +0 -7
  147. data/app/models/kaui/business_account.rb +0 -12
  148. data/app/models/kaui/business_field.rb +0 -6
  149. data/app/models/kaui/business_invoice.rb +0 -31
  150. data/app/models/kaui/business_invoice_item.rb +0 -17
  151. data/app/models/kaui/business_invoice_payment.rb +0 -25
  152. data/app/models/kaui/business_overdue_status.rb +0 -8
  153. data/app/models/kaui/business_snapshot.rb +0 -9
  154. data/app/models/kaui/business_subscription_transition.rb +0 -53
  155. data/app/models/kaui/business_tag.rb +0 -5
  156. data/app/models/kaui/charge.rb +0 -14
  157. data/app/models/kaui/entitlement.rb +0 -2
  158. data/app/models/kaui/event.rb +0 -13
  159. data/app/models/kaui/external_payment.rb +0 -15
  160. data/app/models/kaui/overdue_state.rb +0 -10
  161. data/app/models/kaui/payment_attempt.rb +0 -27
  162. data/app/models/kaui/product.rb +0 -24
  163. data/app/models/kaui/time_series_data.rb +0 -8
  164. data/app/views/kaui/analytics/account_snapshot.html.erb +0 -211
  165. data/app/views/kaui/analytics/index.html.erb +0 -17
  166. data/app/views/kaui/chargebacks/index.html.erb +0 -14
  167. data/app/views/kaui/chargebacks/show.html.erb +0 -19
  168. data/app/views/kaui/credits/index.html.erb +0 -14
  169. data/app/views/kaui/credits/show.html.erb +0 -19
  170. data/app/views/kaui/invoice_items/index.html.erb +0 -20
  171. data/app/views/kaui/invoice_items/show.html.erb +0 -31
  172. data/app/views/kaui/refunds/_refunds_table.html.erb +0 -31
  173. data/app/views/kaui/refunds/index.html.erb +0 -43
  174. data/app/views/kaui/refunds/show.html.erb +0 -33
  175. data/app/views/kaui/tag_definitions/edit.html.erb +0 -3
  176. data/test/dummy/test/fixtures/accounts.yml +0 -32
  177. data/test/dummy/test/fixtures/bill_cycle_days.yml +0 -3
  178. data/test/dummy/test/fixtures/bundles.yml +0 -4
  179. data/test/dummy/test/fixtures/invoice_items.yml +0 -13
  180. data/test/dummy/test/fixtures/invoices.yml +0 -11
  181. data/test/dummy/test/fixtures/overdue_states.yml +0 -8
  182. data/test/dummy/test/fixtures/payment_methods.yml +0 -5
  183. data/test/dummy/test/fixtures/plugin_info_properties.yml +0 -59
  184. data/test/dummy/test/fixtures/plugin_infos.yml +0 -2
  185. data/test/dummy/test/fixtures/refunds.yml +0 -9
  186. data/test/dummy/test/fixtures/tag_definitions.yml +0 -20
  187. data/test/functional/kaui/account_timeline_controller_test.rb +0 -9
  188. data/test/functional/kaui/extpayments_controller_test.rb +0 -9
  189. data/test/functional/kaui/home_controller_test.rb +0 -11
  190. data/test/integration/navigation_test.rb +0 -10
  191. data/test/kaui_test.rb +0 -7
  192. data/test/unit/helpers/kaui/account_timeline_helper_test.rb +0 -6
  193. data/test/unit/helpers/kaui/bundles_helper_test.rb +0 -6
  194. data/test/unit/helpers/kaui/chargebacks_helper_test.rb +0 -6
  195. data/test/unit/helpers/kaui/extpayments_helper_test.rb +0 -6
  196. data/test/unit/helpers/kaui/home_helper_test.rb +0 -6
  197. data/test/unit/helpers/kaui/invoices_helper_test.rb +0 -6
  198. data/test/unit/helpers/kaui/payments_helper_test.rb +0 -6
  199. data/test/unit/helpers/kaui/refunds_helper_test.rb +0 -6
  200. data/test/unit/kaui/overdue_state_test.rb +0 -18
  201. data/test/unit/kaui/refund_test.rb +0 -20
  202. data/test/unit/model_test.rb +0 -151
@@ -1,123 +1,115 @@
1
1
  <div class="page-header">
2
2
  <h1>Refund Payment</h1>
3
3
  </div>
4
- <%= form_for(@refund, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
-
6
- <%= hidden_field_tag :account_id, @account_id %>
7
- <%= hidden_field_tag :payment_id, @payment_id %>
8
- <%= hidden_field_tag :invoice_id, @invoice_id%>
9
- <fieldset>
10
- <div class="control-group">
11
- <label class="control-label">Date</label>
12
- <div class="controls">
13
- <label class="checkbox">
14
- <%= DateTime.now.to_s(:pretty) %>
15
- </label>
4
+ <%= form_for(@refund, :url => {:action => :create}, :html => {:class => "form-horizontal"}) do |f| %>
5
+ <%= hidden_field_tag :account_id, @account.account_id %>
6
+ <%= hidden_field_tag :payment_id, @payment.payment_id %>
7
+ <%= hidden_field_tag :invoice_id, @invoice.invoice_id %>
8
+ <fieldset>
9
+ <div class="control-group">
10
+ <label class="control-label">Date</label>
11
+ <div class="controls">
12
+ <label class="checkbox">
13
+ <%= DateTime.now.to_s(:pretty) %>
14
+ </label>
15
+ </div>
16
16
  </div>
17
- </div>
18
- <div class="control-group">
19
- <label class="control-label">Invoice number</label>
20
- <div class="controls">
21
- <label class="checkbox">
17
+ <div class="control-group">
18
+ <label class="control-label">Invoice number</label>
19
+ <div class="controls">
20
+ <label class="checkbox">
22
21
  <%= @invoice.invoice_number %><br/>
23
- </label>
24
- </div>
25
- </div>
26
- <div class="control-group">
27
- <label class="control-label">Account name</label>
28
- <div class="controls">
29
- <label class="checkbox">
30
- <%= @account.name %><br/>
31
- <%= @account.email %>
32
- </label>
33
- </div>
34
- </div>
35
- <div class="control-group">
36
- <label class="control-label">Status</label>
37
- <div class="controls">
38
- <label class="checkbox">
39
- <%= @payment.status %>
40
- </label>
41
- </div>
42
- </div>
43
- <div class="control-group">
44
- <%= f.label :adjustment_type, "Adjustment Type", :class => "control-label" %>
45
- <div class="controls">
46
- <label class="radio">
47
- <%= f.radio_button :adjustment_type, 'noInvoiceAdjustment', :checked => true %>
48
- No Invoice Adjustment
49
- </label>
22
+ </label>
23
+ </div>
50
24
  </div>
51
- <% if can? :adjust, Kaui::Invoice %>
25
+ <div class="control-group">
26
+ <label class="control-label">Account name</label>
52
27
  <div class="controls">
53
- <label class="radio">
54
- <%= f.radio_button :adjustment_type, 'invoiceAdjustment' %>
55
- Invoice Adjustment
28
+ <label class="checkbox">
29
+ <%= @account.name %><br/>
30
+ <%= @account.email %>
56
31
  </label>
57
32
  </div>
58
- <% end %>
59
- <% if can? :item_adjust, Kaui::Invoice %>
33
+ </div>
34
+ <div class="control-group">
35
+ <%= label_tag :adjustment_type, 'Adjustment Type', :class => 'control-label' %>
60
36
  <div class="controls">
61
37
  <label class="radio">
62
- <%= f.radio_button :adjustment_type, 'invoiceItemAdjustment' %>
38
+ <%= radio_button_tag :adjustment_type, 'noInvoiceAdjustment', :checked => true %>
39
+ No Invoice Adjustment
40
+ </label>
41
+ </div>
42
+ <% if can? :adjust, Kaui::Invoice %>
43
+ <div class="controls">
44
+ <label class="radio">
45
+ <%= radio_button_tag :adjustment_type, 'invoiceAdjustment' %>
46
+ Invoice Adjustment
47
+ </label>
48
+ </div>
49
+ <% end %>
50
+ <% if can? :item_adjust, Kaui::Invoice %>
51
+ <div class="controls">
52
+ <label class="radio">
53
+ <%= radio_button_tag :adjustment_type, 'invoiceItemAdjustment' %>
63
54
  Invoice Item Adjustment
55
+ </label>
56
+ </div>
57
+ <% end %>
58
+ </div>
59
+ <div id="invoiceItems" style="display:none">
60
+ <% @invoice.items.each_with_index do |ii, index| %>
61
+ <% if ii.amount > 0 %>
62
+ <div id=<%= "div_#{ii.invoice_item_id}" %> class="control-group">
63
+ <label class="control-label"></label>
64
+
65
+ <div class="controls">
66
+ <input type="checkbox" id=<%= "cb_adj_#{ii.invoice_item_id}" %>>
67
+ <%= "Item #{index + 1} : #{ii.description} " %>
68
+ <%= text_field_tag "adjustments[#{ii.invoice_item_id}]", index, :id => "tf_adj_#{ii.invoice_item_id}", :value => ii.amount, :class => 'input-small' %>
69
+ </div>
70
+ </div>
71
+ <% end %>
72
+ <% end %>
73
+ </div>
74
+ <div class="control-group">
75
+ <label class="control-label">Paid Amount</label>
76
+ <div class="controls">
77
+ <label class="checkbox">
78
+ <%= @payment.purchased_amount %> <%= @account.currency if @payment.purchased_amount.present? %>
64
79
  </label>
65
80
  </div>
66
- <% end %>
67
- </div>
68
- <div id="invoiceItems" style="display:none">
69
- <% @invoice.items.each_with_index do |ii, index | %>
70
- <% if ii.amount > 0 and ii.subscription_id.present? %>
71
- <div id=<%= "div_#{ii.invoice_item_id}" %> class="control-group">
72
- <label class="control-label"></label>
73
- <div class="controls">
74
- <input type="checkbox" id=<%= "cb_adj_#{ii.invoice_item_id}" %>>
75
- <%= "Item #{index + 1} : #{ii.description} " %>
76
- <%= text_field_tag "adjustments[#{ii.invoice_item_id}]", index, :id => "tf_adj_#{ii.invoice_item_id}" , :value => ii.amount, :class => 'input-small' %>
77
- </div>
78
- </div>
79
- <% end %>
80
- <% end %>
81
- </div>
82
- <div class="control-group">
83
- <label class="control-label">Paid Amount</label>
84
- <div class="controls">
85
- <label class="checkbox">
86
- <%= @payment.paid_amount %> <%= @account.currency if @payment.paid_amount.present? %>
87
- </label>
88
81
  </div>
89
- </div>
90
- <div id="div_refund_amount" class="control-group">
91
- <%= f.label :amount, "Refund amount", :class => "control-label" %>
92
- <div class="controls">
93
- <%= f.text_field :amount, :id => 'refund_amount', :value => @payment.paid_amount, :class => 'input-small' %>
94
- <p class="help-inline"><%= @account.currency %></p>
82
+ <div id="div_refund_amount" class="control-group">
83
+ <%= label_tag :amount, 'Refund amount', :class => 'control-label' %>
84
+ <div class="controls">
85
+ <%= text_field_tag :amount, @payment.purchased_amount, :id => 'refund_amount', :class => 'input-small' %>
86
+ <p class="help-inline"><%= @account.currency %></p>
87
+ </div>
95
88
  </div>
96
- </div>
97
- <div class="control-group">
98
- <%= label_tag :reason, "Reason", :class => "control-label" %>
99
- <div class="controls">
100
- <%= select_tag :reason, options_for_select(Kaui::Refund::SAMPLE_REASON_CODES) %>
89
+ <div class="control-group">
90
+ <%= label_tag :reason, "Reason", :class => "control-label" %>
91
+ <div class="controls">
92
+ <%= select_tag :reason, options_for_select(Kaui::Refund::SAMPLE_REASON_CODES) %>
93
+ </div>
94
+ </div>
95
+ <div class="control-group">
96
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
97
+ <div class="controls">
98
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
99
+ </div>
101
100
  </div>
102
- </div>
103
- <div class="control-group">
104
- <%= label_tag :comment, "Comment", :class => "control-label" %>
105
- <div class="controls">
106
- <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
101
+ <div class="form-actions">
102
+ <%= button_tag "Create refund", :id => "submit", :class => "btn btn-primary" %>
103
+ <%= link_to 'Back', :back, :class => 'btn' %>
107
104
  </div>
108
- </div>
109
- <div class="form-actions">
110
- <%= button_tag "Create refund", :id => "submit", :class =>"btn btn-primary" %>
111
- <%= link_to 'Back', :back, :class => 'btn' %>
112
- </div>
113
- </fieldset>
105
+ </fieldset>
114
106
  <% end %>
115
107
  <%= javascript_tag do %>
116
108
 
117
109
  var textToDivId = function(textId) {
118
110
  return "div_" + textId.split("tf_adj_")[1];
119
111
  };
120
-
112
+
121
113
  var textToCheckboxId = function(textId) {
122
114
  return "cb_adj_" + textId.split("tf_adj_")[1];
123
115
  };
@@ -125,7 +117,7 @@
125
117
  var checkboxToTextId = function(cbId) {
126
118
  return "tf_adj_" + cbId.split("cb_adj_")[1];
127
119
  };
128
-
120
+
129
121
  var setClassForElement = function(id, newClass) {
130
122
  var currentClasses = $(id).attr('class').split(' ');
131
123
  for (var i=0; i<currentClasses.length; i++) {
@@ -144,7 +136,7 @@
144
136
  };
145
137
 
146
138
  var validateRefundAmount = function() {
147
- if (Number($("#refund_amount").attr('value')) > <%= @payment.paid_amount %> ||
139
+ if (Number($("#refund_amount").attr('value')) > <%= @payment.purchased_amount %> ||
148
140
  Number($("#refund_amount").attr('value')) <= 0) {
149
141
  setClassForElement("#div_refund_amount", "control-group error");
150
142
  $("#submit").prop('disabled', true);
@@ -174,8 +166,8 @@
174
166
  * _ For Invoice adjustment or no adjustment, default to payment amount
175
167
  */
176
168
  var recomputeRefundAmountAndValidateAmount = function() {
177
- var computedRefundAmount = <%= @payment.paid_amount %>;
178
- if ($("#refund_adjustment_type_invoiceitemadjustment").is(':checked')) {
169
+ var computedRefundAmount = <%= @payment.purchased_amount %>;
170
+ if ($("#adjustment_type_invoiceItemAdjustment").is(':checked')) {
179
171
  var x = 0; $('input').filter(function() { return this.id.match(/tf_adj_/) }).each(function() {
180
172
  var id = textToCheckboxId(this.id);
181
173
  if ($("#" + id).is(':checked')) {
@@ -191,7 +183,7 @@
191
183
  }
192
184
  validateRefundAmount();
193
185
  };
194
-
186
+
195
187
  /*
196
188
  * When clicking checkbox for each item, disable amount and recompute total refund amount
197
189
  */
@@ -250,11 +242,11 @@
250
242
  /*
251
243
  * Adjustment type handlers
252
244
  */
253
- $("#refund_adjustment_type_noinvoiceadjustment")
245
+ $("#adjustment_type_noInvoiceAdjustment")
254
246
  .click(onClickWithInvoiceOrNoAdjustment);
255
- $("#refund_adjustment_type_invoiceadjustment")
247
+ $("#adjustment_type_invoiceAdjustment")
256
248
  .click(onClickWithInvoiceOrNoAdjustment);
257
- $("#refund_adjustment_type_invoiceitemadjustment")
249
+ $("#adjustment_type_invoiceItemAdjustment")
258
250
  .click(onClickWithInvoiceItemAdjustment);
259
251
 
260
252
  /*
@@ -0,0 +1,36 @@
1
+ <%= form_for(@subscription, :html => {:class => 'form-horizontal'}) do |f| %>
2
+ <fieldset>
3
+ <%= f.hidden_field :bundle_id %>
4
+ <%= f.hidden_field :account_id %>
5
+ <%= f.hidden_field :product_category %>
6
+ <% if @subscription.product_category == 'ADD_ON' %>
7
+ <%= hidden_field_tag :base_product_name, @base_product_name %>
8
+ <div class="control-group">
9
+ <%= label_tag :plan_name, 'Available Plans:', :class => 'control-label' %>
10
+ <div class="controls">
11
+ <%= select_tag :plan_name, options_for_select(@plans) %>
12
+ <p class="help-block">
13
+ Proration on customer's invoice will be done automatically.
14
+ </p>
15
+ </div>
16
+ </div>
17
+ <% else %>
18
+ <div class="control-group">
19
+ <%= f.label :external_key, 'Bundle External Key:', :class => 'control-label' %>
20
+ <div class="controls">
21
+ <%= f.text_field :external_key, :class => 'input-xlarge', :id => 'external_key' %>
22
+ </div>
23
+ </div>
24
+ <div class="control-group">
25
+ <%= label_tag :plan_name, 'Available Plans:', :class => 'control-label' %>
26
+ <div class="controls">
27
+ <%= select_tag :plan_name, options_for_select(@plans) %>
28
+ </div>
29
+ </div>
30
+ <% end %>
31
+ <div class="form-actions">
32
+ <%= f.submit 'Create Subscription', :class => 'btn btn-primary' %>
33
+ <%= link_to 'Back', :back, :class => 'btn' %>
34
+ </div>
35
+ </fieldset>
36
+ <% end %>
@@ -3,54 +3,49 @@
3
3
  </div>
4
4
  <table class="table table-condensed table-striped data-table">
5
5
  <thead>
6
- <tr>
7
- <th>Product category</th>
8
- <th>Product name</th>
9
- <th>Start date</th>
10
- <th>Charged through date</th>
11
- <th>Notes</th>
12
- <th>Actions</th>
13
- </tr>
6
+ <tr>
7
+ <th>Product category</th>
8
+ <th>Product name</th>
9
+ <th>Start date</th>
10
+ <th>Charged through date</th>
11
+ <th>Notes</th>
12
+ <th>Actions</th>
13
+ </tr>
14
14
  </thead>
15
15
  <tbody>
16
- <% if subscriptions.present? && !subscriptions.nil? %>
16
+ <% if subscriptions.present? && !subscriptions.nil? %>
17
17
  <% subscriptions.each do |sub| %>
18
- <tr>
19
- <td><%= sub.product_category.downcase.capitalize if sub.product_category.present? %></td>
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, 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
- <td>
24
- <% if sub.cancelled_date.present? && !sub.cancelled_date.nil? %>
25
- <% if Time.parse(sub.cancelled_date) > Time.now %> <%= "Pending cancellation on " %> <% else %> <%= "Canceled on " %> <% end %> <%= format_date(sub.cancelled_date, account.timezone).html_safe %>
26
- <% end %>
27
- </td>
28
- <td>
29
- <nobr>
30
- <% if sub.billing_end_date.present? && Time.parse(sub.billing_end_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.billing_end_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, :policy => 'END_OF_TERM'), :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
- <%= link_to "Add Addons", kaui_engine.new_subscription_path(:params => { :bundle_id => sub.bundle_id, :base_subscription => sub.product_name, :product_category => "ADD_ON" }), :class => "btn btn-mini" %>
48
- <% end %>
18
+ <tr>
19
+ <td><%= humanized_product_category(sub) %></td>
20
+ <td><%= humanized_full_product_name(sub) %></td>
21
+ <td><%= humanized_start_date(sub, account) %></td>
22
+ <td><%= humanized_charged_through_date(sub, account) %></td>
23
+ <td><%= humanized_cancelled_date(sub, account) %></td>
24
+ <td>
25
+ <%= link_to 'Details', kaui_engine.subscription_path(:id => sub.subscription_id), :class => 'btn btn-mini' %>
26
+ <% if is_future_cancelled?(sub) %>
27
+ <%= link_to 'Reinstate', kaui_engine.reinstate_subscription_path(:id => sub.subscription_id), :method => :put, :class => 'btn btn-mini' %>
28
+ <% elsif is_cancelled?(sub) %>
29
+ <%= link_to 'Change', kaui_engine.edit_subscription_path(sub.subscription_id), :class => 'btn btn-mini' %>
30
+ <div class="btn-group">
31
+ <a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
32
+ Cancel
33
+ <span class="caret"></span>
34
+ </a>
35
+ <ul class="dropdown-menu">
36
+ <li><%= link_to 'Cancel (default policy)', kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'END_OF_TERM'), :method => :delete %></li>
37
+ <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>
38
+ <li><%= link_to 'Cancel immediately (generate proration)', kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE'), :method => :delete %></li>
39
+ <li><%= link_to 'Cancel end of term', kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'END_OF_TERM'), :method => :delete %></li>
40
+ </ul>
41
+ </div>
42
+ <% if sub.product_category == 'BASE' %>
43
+ <%= link_to 'Add add-ons', kaui_engine.new_subscription_path(:params => {:bundle_id => sub.bundle_id, :base_product_name => sub.product_name, :product_category => 'ADD_ON'}), :class => 'btn btn-mini' %>
44
+ <% end %>
49
45
  <% end %>
50
- </nobr>
51
- </td>
52
- </tr>
46
+ </td>
47
+ </tr>
53
48
  <% end %>
54
- <% end %>
49
+ <% end %>
55
50
  </tbody>
56
51
  </table>
@@ -1,41 +1,30 @@
1
- <% @page_title = "Edit Subscription" %>
2
- <%= form_for(@subscription, :as => :subscription, :url => subscription_path(@subscription.subscription_id), :html => { :method => :put, :class => "form-horizontal" }) do |f| %>
3
- <%= f.hidden_field :subscription_id %>
4
- <%= f.hidden_field :price_list %>
5
- <div class="control-group">
6
- <label class="control-label">Account timezone</label>
7
- <div class="controls">
8
- <label class="checkbox">
9
- <%= @account.timezone %>
10
- </label>
1
+ <% @page_title = 'Edit Subscription' %>
2
+ <%= form_for(@subscription, :url => subscription_path(@subscription.subscription_id), :html => {:method => :put, :class => 'form-horizontal'}) do |f| %>
3
+ <div class="control-group">
4
+ <%= label_tag :current_plan, 'Current plan:', :class => 'control-label' %>
5
+ <div class="controls">
6
+ <%= text_field_tag :current_plan, @current_plan, :class => 'input-xlarge disabled', :disabled => 'disabled' %>
7
+ </div>
11
8
  </div>
12
- </div>
13
- <div class="control-group">
14
- <%= label_tag :current_plan, 'Current plan:', :class => "control-label" %>
15
- <div class="controls">
16
- <%= text_field_tag :current_plan, @current_plan, :class => 'input-xlarge disabled', :disabled => "disabled" %>
9
+ <div class="control-group">
10
+ <%= label_tag :plan_name, 'New plan:', :class => 'control-label' %>
11
+ <div class="controls">
12
+ <%= select_tag :plan_name, options_for_select(@plans) %>
13
+ </div>
17
14
  </div>
18
- </div>
19
- <div class="control-group">
20
- <%= label_tag :plan_name, "New plan:", :class => "control-label" %>
21
- <div class="controls">
22
- <%= select_tag :plan_name, options_for_select(@catalog.keys, @plan_name) %>
15
+ <div class="control-group">
16
+ <%= label_tag :requested_date, 'Change Date:', :class => 'control-label' %>
17
+ <div class="controls">
18
+ <%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'input-xlarge date-picker' %>
19
+ </div>
23
20
  </div>
24
- </div>
25
- <div class="control-group">
26
- <%= label_tag :requested_date, 'Change Date:', :class => "control-label" %>
27
- <div class="controls">
28
- <%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'input-xlarge date-picker' %>
21
+ <div class="control-group">
22
+ <%= label_tag :policy, 'Policy Override (leave blank for default; select an option to force plan change):', :class => 'control-label' %>
23
+ <div class="controls">
24
+ <%= select_tag :policy, options_for_select(['', 'IMMEDIATE', 'END_OF_TERM']) %>
25
+ </div>
29
26
  </div>
30
- </div>
31
- <div class="control-group">
32
- <%= label_tag :policy, "Policy Override (leave blank for default; select an option to force plan change):", :class => "control-label" %>
33
- <div class="controls">
34
- <%= select_tag :policy, options_for_select(['', 'IMMEDIATE', 'END_OF_TERM']) %>
27
+ <div class="form-actions">
28
+ <%= f.submit 'Change', :class => 'btn btn-primary' %>
35
29
  </div>
36
- </div>
37
- <div class="form-actions">
38
- <%= f.submit "Change", :class => 'btn btn-primary' %>
39
- <%= link_to 'Back', :back, :class => 'btn' %>
40
- </div>
41
30
  <% end %>
@@ -1,14 +1,15 @@
1
- <%= form_tag subscriptions_path, :class => "form-horizontal", :method => :get do %>
2
- <fieldset>
3
- <legend>Please enter subsciption id</legend>
4
- <div class="control-group">
5
- <label class="control-label" for="subscription_id">Subscription</label>
6
- <div class="controls">
7
- <%= text_field_tag 'subscription_id', nil, :class => "input-xlarge", :id => "subscription_id" %>
1
+ <%= form_tag subscriptions_path, :class => 'form-horizontal', :method => :get do %>
2
+ <fieldset>
3
+ <legend>Please enter subscription id</legend>
4
+ <div class="control-group">
5
+ <label class="control-label" for="subscription_id">Subscription</label>
6
+
7
+ <div class="controls">
8
+ <%= text_field_tag 'subscription_id', nil, :class => 'input-xlarge', :id => 'subscription_id' %>
9
+ </div>
8
10
  </div>
9
- </div>
10
- <div class="form-actions">
11
- <%= button_tag "Search", :class =>"btn btn-primary" %>
12
- </div>
13
- </fieldset>
11
+ <div class="form-actions">
12
+ <%= button_tag 'Search', :class => 'btn btn-primary' %>
13
+ </div>
14
+ </fieldset>
14
15
  <% end %>
@@ -1,49 +1,12 @@
1
1
  <div class="page-header">
2
- <% if @product_category == "ADD_ON" %>
3
- <h1>Add ADD_ON subscription
2
+ <% if @subscription.product_category == 'ADD_ON' %>
3
+ <h1>Add add-on subscription
4
4
  <% if @bundle.external_key %> to <%= Kaui.bundle_key_display_string.call(@bundle.external_key) %>
5
- <% end %></h1>
5
+ <% end %>
6
+ </h1>
6
7
  <% else %>
7
- <h1>Create new base subscription
8
- <% if @account_id %> to account <%= @account_id %>
9
- <% end %></h1>
8
+ <h1>Create new base subscription to account <%= @subscription.account_id %></h1>
10
9
  <% end %>
11
10
  </div>
12
- <%= form_for(@subscription, :url => {:action => :create}, :html => {:class => "form-horizontal"}) do |f| %>
13
- <fieldset>
14
- <% if @product_category == "ADD_ON" %>
15
- <%= f.hidden_field :bundle_id %>
16
- <%= f.hidden_field :product_category %>
17
- <%= hidden_field_tag :base_subscription, @base_subscription %>
18
- <div class="control-group">
19
- <%= label_tag :plan_name, "Available Plans:", :class => "control-label" %>
20
- <div class="controls">
21
- <%= select_tag :plan_name, options_for_select(@catalog.keys, @plan_name) %>
22
- <p class="help-block">
23
- Proration on customer's invoice will be done automatically.
24
- </p>
25
- </div>
26
- </div>
27
- <% else %>
28
- <%= f.hidden_field :account_id %>
29
- <%= f.hidden_field :product_category %>
30
- <div class="control-group">
31
- <%= label_tag :external_key, "Bundle External Key:", :class => "control-label" %>
32
- <div class="controls">
33
- <%= text_field_tag :external_key, params[:external_key], :class => 'input-xlarge', :id => "external_key" %>
34
- </div>
35
- </div>
36
- <div class="control-group">
37
- <%= label_tag :plan_name, "Available Plans:", :class => "control-label" %>
38
- <div class="controls">
39
- <%= select_tag :plan_name, options_for_select(@catalog.keys, @plan_name) %>
40
- </div>
41
- </div>
42
- <% end %>
43
- <div class="form-actions">
44
- <%= f.submit 'Create Subscription', :class => 'btn btn-primary' %>
45
- <%= link_to 'Back', :back, :class => 'btn' %>
46
- </div>
47
11
 
48
- </fieldset>
49
- <% end %>
12
+ <%= render 'form' %>
@@ -1,26 +1,33 @@
1
- <% if @subscription.present? %>
2
- <div class="page-header">
3
- <h2>Subscription <%= @subscription.subscription_id %></h2>
4
- </div>
5
- <dl class="dl-horizontal">
6
- <dt>Category</dt>
7
- <dd><%= @subscription.product_category.downcase.capitalize if @subscription.product_category.present? %></dd>
8
- <dt>Product</dt>
9
- <dd><%= @subscription.product_name.downcase.capitalize if @subscription.product_name.present? %></dd>
10
- <dt>Period</dt>
11
- <dd><%= @subscription.billing_period.downcase.capitalize if @subscription.billing_period.present? %></dd>
12
- <dt>Charged through</dt>
13
- <dd> <%= format_date(@subscription.charged_through_date, @account.timezone).html_safe if @subscription.charged_through_date.present? %>
14
- <dt>Price List</dt>
15
- <dd><%= @subscription.price_list %></dd>
16
- <dt>Start Date</dt>
17
- <dd> <%= format_date(@subscription.start_date, @account.timezone).html_safe if @subscription.start_date.present? %>
18
- </dl>
19
- <hr/>
20
- <%= link_to "Change", kaui_engine.edit_subscription_path(@subscription.subscription_id), :class => "btn btn-mini" %>
21
- <%= link_to "Cancel", kaui_engine.subscription_path(@subscription.subscription_id), :method => :delete, :confirm => "Are you sure?", :class => "btn btn-mini" %>
22
- <%= link_to "Add Addons", kaui_engine.new_subscription_path(:params => { :bundle_id => @subscription.bundle_id, :base_subscription => @subscription.product_name, :product_category => "ADD_ON" }), :class => "btn btn-mini" %>
23
- <% else %>
24
- <p>Subscription not found</p>
1
+ <div class="page-header">
2
+ <h2>Subscription <%= @subscription.subscription_id %></h2>
3
+ </div>
4
+ <dl class="dl-horizontal">
5
+ <dt>Category</dt>
6
+ <dd><%= humanized_product_category(@subscription) || '&nbsp;'.html_safe %></dd>
7
+ <dt>Product</dt>
8
+ <dd><%= humanized_product_name(@subscription) || '&nbsp;'.html_safe %></dd>
9
+ <dt>Period</dt>
10
+ <dd><%= humanized_billing_period(@subscription) || '&nbsp;'.html_safe %></dd>
11
+ <dt>Charged through</dt>
12
+ <dd><%= humanized_charged_through_date(@subscription, @account) || '&nbsp;'.html_safe %>
13
+ <dt>Price list</dt>
14
+ <dd><%= humanized_price_list(@subscription) || '&nbsp;'.html_safe %></dd>
15
+ <dt>Start date</dt>
16
+ <dd><%= humanized_start_date(@subscription, @account) || '&nbsp;'.html_safe %></dd>
17
+ <dt>Cancelled date</dt>
18
+ <dd><%= humanized_cancelled_date(@subscription, @account) || '&nbsp;'.html_safe %></dd>
19
+ <dt>Billing start date</dt>
20
+ <dd><%= humanized_billing_start_date(@subscription, @account) || '&nbsp;'.html_safe %></dd>
21
+ <dt>Billing end date</dt>
22
+ <dd><%= humanized_billing_end_date(@subscription, @account) || '&nbsp;'.html_safe %></dd>
23
+ </dl>
24
+ <hr/>
25
+ <% if is_future_cancelled?(@subscription) %>
26
+ <%= link_to 'Reinstate', kaui_engine.reinstate_subscription_path(:id => sub.subscription_id), :method => :put, :class => 'btn btn-mini' %>
27
+ <% elsif is_cancelled?(@subscription) %>
28
+ <%= link_to 'Change', kaui_engine.edit_subscription_path(@subscription.subscription_id), :class => 'btn btn-mini' %>
29
+ <%= link_to 'Cancel', kaui_engine.subscription_path(@subscription.subscription_id), :method => :delete, :confirm => 'Are you sure?', :class => 'btn btn-mini' %>
30
+ <%= link_to 'Add Addons', kaui_engine.new_subscription_path(:params => {:bundle_id => @subscription.bundle_id, :base_product_name => @subscription.product_name, :product_category => 'ADD_ON'}), :class => 'btn btn-mini' %>
25
31
  <% end %>
26
- <%= link_to 'Back', :back, :class => 'btn' %>
32
+ &nbsp;
33
+ <%= link_to 'Go to bundle', kaui_engine.bundle_path(@subscription.bundle_id), :class => 'btn btn-mini' %>