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,240 @@
1
+ <%= form_for @refund, :url => {:action => :create}, :html => {:class => 'form-horizontal'} do |f| %>
2
+ <%= hidden_field_tag :account_id, @invoice.account_id %>
3
+ <%= hidden_field_tag :payment_id, @payment.payment_id %>
4
+ <%= hidden_field_tag :invoice_id, @invoice.invoice_id %>
5
+
6
+ <div class="form-group">
7
+ <div class="col-sm-offset-2 col-sm-10">
8
+ <div class="checkbox">
9
+ <%= label_tag :adjustment_type do %>
10
+ <%= radio_button_tag :adjustment_type, 'noInvoiceAdjustment', :checked => true %>
11
+ No Invoice Adjustment
12
+ <% end %>
13
+ </div>
14
+ <% if can? :item_adjust, Kaui::Invoice %>
15
+ <div class="checkbox">
16
+ <%= label_tag :adjustment_type do %>
17
+ <%= radio_button_tag :adjustment_type, 'invoiceItemAdjustment' %>
18
+ Invoice Item Adjustment
19
+ <% end %>
20
+ </div>
21
+ <% end %>
22
+ </div>
23
+ </div>
24
+
25
+ <div id="invoiceItems" style="display:none">
26
+ <% @invoice.items.each_with_index do |ii, index| %>
27
+ <% if ii.amount > 0 %>
28
+ <div id=<%= "div_#{ii.invoice_item_id}" %> class="form-group">
29
+ <label class="col-sm-2 control-label"></label>
30
+
31
+ <div class="col-sm-10">
32
+ <input type="checkbox" id=<%= "cb_adj_#{ii.invoice_item_id}" %>>
33
+ <%= "Item #{index + 1} : #{ii.description} " %>
34
+ <%= text_field_tag "adjustments[#{ii.invoice_item_id}]", index, :id => "tf_adj_#{ii.invoice_item_id}", :value => ii.amount, :class => 'form-control' %>
35
+ </div>
36
+ </div>
37
+ <% end %>
38
+ <% end %>
39
+ </div>
40
+
41
+ <div id="div_refund_amount" class="form-group">
42
+ <%= label_tag :amount, 'Amount', :class => 'col-sm-2 control-label' %>
43
+ <div class="col-sm-10">
44
+ <%= text_field_tag :amount, @payment.purchased_amount, :id => 'refund_amount', :class => 'form-control' %>
45
+ <p class="help-block">Currency: <%= @invoice.currency %></p>
46
+ </div>
47
+ </div>
48
+ <div class="form-group">
49
+ <%= label_tag :reason, 'Reason', :class => 'col-sm-2 control-label' %>
50
+ <div class="col-sm-10">
51
+ <%= select_tag :reason, options_for_select(Kaui::Refund::SAMPLE_REASON_CODES), :class => 'form-control' %>
52
+ </div>
53
+ </div>
54
+ <div class="form-group">
55
+ <%= label_tag :comment, 'Comment', :class => 'col-sm-2 control-label' %>
56
+ <div class="col-sm-10">
57
+ <%= text_area_tag :comment, nil, :rows => 3, :class => 'form-control' %>
58
+ </div>
59
+ </div>
60
+ <div class="form-group">
61
+ <div class="col-sm-offset-2 col-sm-10">
62
+ <%= submit_tag 'Save', :class => 'btn btn-default' %>
63
+ </div>
64
+ </div>
65
+ <% end %>
66
+
67
+ <%= javascript_tag do %>
68
+ var textToDivId = function(textId) {
69
+ return "div_" + textId.split("tf_adj_")[1];
70
+ };
71
+
72
+ var textToCheckboxId = function(textId) {
73
+ return "cb_adj_" + textId.split("tf_adj_")[1];
74
+ };
75
+
76
+ var checkboxToTextId = function(cbId) {
77
+ return "tf_adj_" + cbId.split("cb_adj_")[1];
78
+ };
79
+
80
+ var setClassForElement = function(id, newClass) {
81
+ var currentClasses = $(id).attr('class').split(' ');
82
+ for (var i=0; i<currentClasses.length; i++) {
83
+ $(id).removeClass(currentClasses[i]);
84
+ }
85
+ $(id).addClass(newClass);
86
+ };
87
+
88
+ var validateInvoiceItemAmount = function(id) {
89
+ var divId = textToDivId(id);
90
+ if (Number($("#" + id).attr('value')) > Number($("#" + id).attr('originalValue'))) {
91
+ setClassForElement($("#" + divId), "form-group error");
92
+ } else {
93
+ setClassForElement($("#" + divId), "form-group");
94
+ }
95
+ };
96
+
97
+ var validateRefundAmount = function() {
98
+ if (Number($("#refund_amount").attr('value')) > <%= @payment.purchased_amount %> ||
99
+ Number($("#refund_amount").attr('value')) <= 0) {
100
+ setClassForElement("#div_refund_amount", "form-group error");
101
+ $("#submit").prop('disabled', true);
102
+ } else {
103
+ setClassForElement("#div_refund_amount", "form-group");
104
+ $("#submit").prop('disabled', false);
105
+ }
106
+ };
107
+
108
+ /*
109
+ * Disabled unwanted invoice item at the time we submit the form
110
+ */
111
+ var disableNonCheckedInvoiceItem = function() {
112
+ $('input').filter(function() {
113
+ return this.id.match(/cb_adj_/);
114
+ }).each(function() {
115
+ var id = checkboxToTextId(this.id);
116
+ if (! $(this).is(':checked')) {
117
+ $("#" + id).prop('disabled', true);
118
+ }
119
+ });
120
+ };
121
+
122
+ /*
123
+ * Recompute refund amount based on adjustment type:
124
+ * - For Invoice Item Adjustment, recompute price based on selection and invalidate text area to make it match exact selection
125
+ * _ For Invoice adjustment or no adjustment, default to payment amount
126
+ */
127
+ var recomputeRefundAmountAndValidateAmount = function() {
128
+ var computedRefundAmount = <%= @payment.purchased_amount %>;
129
+ if ($("#adjustment_type_invoiceItemAdjustment").is(':checked')) {
130
+ var x = 0; $('input').filter(function() { return this.id.match(/tf_adj_/) }).each(function() {
131
+ var id = textToCheckboxId(this.id);
132
+ if ($("#" + id).is(':checked')) {
133
+ x = x + Number(this.value);
134
+ }
135
+ });
136
+ computedRefundAmount = x.toFixed(2);
137
+ $("#refund_amount").attr('value', computedRefundAmount);
138
+ $("#refund_amount").prop('readonly', true);
139
+ } else {
140
+ $("#refund_amount").attr('value', computedRefundAmount);
141
+ $("#refund_amount").prop('readonly', false);
142
+ }
143
+ validateRefundAmount();
144
+ };
145
+
146
+ /*
147
+ * When clicking checkbox for each item, disable amount and recompute total refund amount
148
+ */
149
+ var onClickInvoiceItemAdjustment = function(event) {
150
+ var id = checkboxToTextId(this.id);
151
+ if ($(this).is(':checked')) {
152
+ $("#" + id).prop('readonly', true);
153
+ } else {
154
+ $("#" + id).prop('readonly', false);
155
+ $("#" + id).attr('value', $("#" + id).attr('originalValue'));
156
+ }
157
+ recomputeRefundAmountAndValidateAmount();
158
+ validateInvoiceItemAmount(id);
159
+ };
160
+
161
+ /*
162
+ * When selecting Invoice Adjustment or No Adjustment, hide invoice items and recompute refund Amount
163
+ */
164
+ var onClickWithInvoiceOrNoAdjustment = function(event) {
165
+ $("#invoiceItems").hide();
166
+ recomputeRefundAmountAndValidateAmount();
167
+ };
168
+
169
+ /*
170
+ * When selecting Invoice Item Adjustment, show items and recompute refund amount
171
+ */
172
+ var onClickWithInvoiceItemAdjustment = function(event) {
173
+ $("#invoiceItems").show();
174
+ recomputeRefundAmountAndValidateAmount();
175
+ };
176
+
177
+ /*
178
+ * Attach all handlers when page loads
179
+ */
180
+ $(document).ready(function() {
181
+
182
+ /*
183
+ * For refund amount text area, attach handler to disable 'ENTER' and also prevent bad values
184
+ */
185
+ $("#refund_amount").keydown(function(event) {
186
+ preventNonNumericValues(event);
187
+ }).bind('keypress', function(e) {
188
+ if ((e.keyCode || e.which) == 13) {
189
+ return false;
190
+ }
191
+ }).blur(function(e) {
192
+ validateRefundAmount();
193
+ });
194
+
195
+ /*
196
+ * If doing invoice Item adjustment, disable entries that were not selected, so the controllers does not
197
+ * get them
198
+ */
199
+ $("#submit").click(disableNonCheckedInvoiceItem);
200
+
201
+ /*
202
+ * Adjustment type handlers
203
+ */
204
+ $("#adjustment_type_noInvoiceAdjustment")
205
+ .click(onClickWithInvoiceOrNoAdjustment);
206
+ $("#adjustment_type_invoiceAdjustment")
207
+ .click(onClickWithInvoiceOrNoAdjustment);
208
+ $("#adjustment_type_invoiceItemAdjustment")
209
+ .click(onClickWithInvoiceItemAdjustment);
210
+
211
+ /*
212
+ * Attach handler onClickInvoiceItemAdjustment for all invoice item checkbox
213
+ */
214
+ $('input').filter(function() {
215
+ return this.id.match(/cb_adj_/);
216
+ }).click(onClickInvoiceItemAdjustment);
217
+
218
+ /*
219
+ * Attach handler for all invoice item text areas so that:
220
+ * - We disable posting form when pressing 'ENTER'
221
+ * - Automatically select the matching checkbox on 'ENTER' and disable checkbox
222
+ */
223
+ $('input').filter(function() {
224
+ return this.id.match(/tf_adj_/);
225
+ }).each( function() {
226
+ var originalValue = this.value;
227
+ $(this).attr('originalValue', originalValue);
228
+ $(this).bind('keypress', function(e) {
229
+ if ((e.keyCode || e.which) == 13) {
230
+ var id = textToCheckboxId(this.id);
231
+ $("#" + id).attr('checked', true);
232
+ $(this).prop('readonly', true);
233
+ recomputeRefundAmountAndValidateAmount();
234
+ validateInvoiceItemAmount(this.id);
235
+ return false;
236
+ }
237
+ });
238
+ });
239
+ });
240
+ <% end %>
@@ -1,282 +1,10 @@
1
- <div class="page-header">
2
- <h1>Refund Payment</h1>
3
- </div>
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
- </div>
17
- <div class="control-group">
18
- <label class="control-label">Invoice number</label>
19
- <div class="controls">
20
- <label class="checkbox">
21
- <%= @invoice.invoice_number %><br/>
22
- </label>
23
- </div>
24
- </div>
25
- <div class="control-group">
26
- <label class="control-label">Account name</label>
27
- <div class="controls">
28
- <label class="checkbox">
29
- <%= @account.name %><br/>
30
- <%= @account.email %>
31
- </label>
32
- </div>
33
- </div>
34
- <div class="control-group">
35
- <%= label_tag :adjustment_type, 'Adjustment Type', :class => 'control-label' %>
36
- <div class="controls">
37
- <label class="radio">
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' %>
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-sm' %>
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? %>
79
- </label>
80
- </div>
81
- </div>
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-sm' %>
86
- <p class="help-inline"><%= @account.currency %></p>
87
- </div>
88
- </div>
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>
100
- </div>
101
- <div class="form-actions">
102
- <%= button_tag "Create refund", :id => "submit", :class => "btn btn-primary" %>
103
- <%= link_to 'Back', :back, :class => 'btn' %>
104
- </div>
105
- </fieldset>
106
- <% end %>
107
- <%= javascript_tag do %>
108
-
109
- var textToDivId = function(textId) {
110
- return "div_" + textId.split("tf_adj_")[1];
111
- };
112
-
113
- var textToCheckboxId = function(textId) {
114
- return "cb_adj_" + textId.split("tf_adj_")[1];
115
- };
116
-
117
- var checkboxToTextId = function(cbId) {
118
- return "tf_adj_" + cbId.split("cb_adj_")[1];
119
- };
120
-
121
- var setClassForElement = function(id, newClass) {
122
- var currentClasses = $(id).attr('class').split(' ');
123
- for (var i=0; i<currentClasses.length; i++) {
124
- $(id).removeClass(currentClasses[i]);
125
- }
126
- $(id).addClass(newClass);
127
- };
128
-
129
- var validateInvoiceItemAmount = function(id) {
130
- var divId = textToDivId(id);
131
- if (Number($("#" + id).attr('value')) > Number($("#" + id).attr('originalValue'))) {
132
- setClassForElement($("#" + divId), "control-group error");
133
- } else {
134
- setClassForElement($("#" + divId), "control-group");
135
- }
136
- };
137
-
138
- var validateRefundAmount = function() {
139
- if (Number($("#refund_amount").attr('value')) > <%= @payment.purchased_amount %> ||
140
- Number($("#refund_amount").attr('value')) <= 0) {
141
- setClassForElement("#div_refund_amount", "control-group error");
142
- $("#submit").prop('disabled', true);
143
- } else {
144
- setClassForElement("#div_refund_amount", "control-group");
145
- $("#submit").prop('disabled', false);
146
- }
147
- };
148
-
149
- /*
150
- * Disabled unwanted invoice item at the time we submit the form
151
- */
152
- var disableNonCheckedInvoiceItem = function() {
153
- $('input').filter(function() {
154
- return this.id.match(/cb_adj_/);
155
- }).each(function() {
156
- var id = checkboxToTextId(this.id);
157
- if (! $(this).is(':checked')) {
158
- $("#" + id).prop('disabled', true);
159
- }
160
- });
161
- };
162
-
163
- /*
164
- * Recompute refund amount based on adjustment type:
165
- * - For Invoice Item Adjustment, recompute price based on selection and invalidate text area to make it match exact selection
166
- * _ For Invoice adjustment or no adjustment, default to payment amount
167
- */
168
- var recomputeRefundAmountAndValidateAmount = function() {
169
- var computedRefundAmount = <%= @payment.purchased_amount %>;
170
- if ($("#adjustment_type_invoiceItemAdjustment").is(':checked')) {
171
- var x = 0; $('input').filter(function() { return this.id.match(/tf_adj_/) }).each(function() {
172
- var id = textToCheckboxId(this.id);
173
- if ($("#" + id).is(':checked')) {
174
- x = x + Number(this.value);
175
- }
176
- });
177
- computedRefundAmount = x.toFixed(2);
178
- $("#refund_amount").attr('value', computedRefundAmount);
179
- $("#refund_amount").prop('readonly', true);
180
- } else {
181
- $("#refund_amount").attr('value', computedRefundAmount);
182
- $("#refund_amount").prop('readonly', false);
183
- }
184
- validateRefundAmount();
185
- };
1
+ <div class="register">
2
+ <div class="col-md-8 col-md-offset-2">
186
3
 
187
- /*
188
- * When clicking checkbox for each item, disable amount and recompute total refund amount
189
- */
190
- var onClickInvoiceItemAdjustment = function(event) {
191
- var id = checkboxToTextId(this.id);
192
- if ($(this).is(':checked')) {
193
- $("#" + id).prop('readonly', true);
194
- } else {
195
- $("#" + id).prop('readonly', false);
196
- $("#" + id).attr('value', $("#" + id).attr('originalValue'));
197
- }
198
- recomputeRefundAmountAndValidateAmount();
199
- validateInvoiceItemAmount(id);
200
- };
4
+ <div class="column-block">
5
+ <h1>Process refund</h1>
6
+ <%= render 'form' %>
7
+ </div>
201
8
 
202
- /*
203
- * When selecting Invoice Adjustment or No Adjustment, hide invoice items and recompute refund Amount
204
- */
205
- var onClickWithInvoiceOrNoAdjustment = function(event) {
206
- $("#invoiceItems").hide();
207
- recomputeRefundAmountAndValidateAmount();
208
- };
209
-
210
- /*
211
- * When selecting Invoice Item Adjustment, show items and recompute refund amount
212
- */
213
- var onClickWithInvoiceItemAdjustment = function(event) {
214
- $("#invoiceItems").show();
215
- recomputeRefundAmountAndValidateAmount();
216
- };
217
-
218
- /*
219
- * Attach all handlers when page loads
220
- */
221
- $(document).ready(function() {
222
-
223
- /*
224
- * For refund amount text area, attach handler to disable 'ENTER' and also prevent bad values
225
- */
226
- $("#refund_amount").keydown(function(event) {
227
- preventNonNumericValues(event);
228
- }).bind('keypress', function(e) {
229
- if ((e.keyCode || e.which) == 13) {
230
- return false;
231
- }
232
- }).blur(function(e) {
233
- validateRefundAmount();
234
- });
235
-
236
- /*
237
- * If doing invoice Item adjustment, disable entries that were not selected, so the controllers does not
238
- * get them
239
- */
240
- $("#submit").click(disableNonCheckedInvoiceItem);
241
-
242
- /*
243
- * Adjustment type handlers
244
- */
245
- $("#adjustment_type_noInvoiceAdjustment")
246
- .click(onClickWithInvoiceOrNoAdjustment);
247
- $("#adjustment_type_invoiceAdjustment")
248
- .click(onClickWithInvoiceOrNoAdjustment);
249
- $("#adjustment_type_invoiceItemAdjustment")
250
- .click(onClickWithInvoiceItemAdjustment);
251
-
252
- /*
253
- * Attach handler onClickInvoiceItemAdjustment for all invoice item checkbox
254
- */
255
- $('input').filter(function() {
256
- return this.id.match(/cb_adj_/);
257
- }).click(onClickInvoiceItemAdjustment);
258
-
259
- /*
260
- * Attach handler for all invoice item text areas so that:
261
- * - We disable posting form when pressing 'ENTER'
262
- * - Automatically select the matching checkbox on 'ENTER' and disable checkbox
263
- */
264
- $('input').filter(function() {
265
- return this.id.match(/tf_adj_/);
266
- }).each( function() {
267
- var originalValue = this.value;
268
- $(this).attr('originalValue', originalValue);
269
- $(this).bind('keypress', function(e) {
270
- if ((e.keyCode || e.which) == 13) {
271
- var id = textToCheckboxId(this.id);
272
- $("#" + id).attr('checked', true);
273
- $(this).prop('readonly', true);
274
- recomputeRefundAmountAndValidateAmount();
275
- validateInvoiceItemAmount(this.id);
276
- return false;
277
- }
278
- });
279
- });
280
- });
281
-
282
- <% end %>
9
+ </div>
10
+ </div>
@@ -0,0 +1,19 @@
1
+ <%= form_for resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-horizontal'} do |f| %>
2
+ <div class="form-group">
3
+ <%= f.label :kb_username, 'Username', :class => 'col-sm-2 control-label' %>
4
+ <div class="col-sm-10">
5
+ <%= f.text_field :kb_username, :class => 'form-control', :autofocus => true %>
6
+ </div>
7
+ </div>
8
+ <div class="form-group">
9
+ <%= f.label :password, :class => 'col-sm-2 control-label' %>
10
+ <div class="col-sm-10">
11
+ <%= f.password_field :password, :class => 'form-control' %>
12
+ </div>
13
+ </div>
14
+ <div class="form-group">
15
+ <div class="col-sm-offset-2 col-sm-10">
16
+ <%= f.submit 'Sign up', :class => 'btn btn-default' %>
17
+ </div>
18
+ </div>
19
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <div class="register">
2
+ <div class="col-md-8 col-md-offset-2">
3
+
4
+ <div class="column-block">
5
+ <h1>Sign up</h1>
6
+ <%= render 'form' %>
7
+ </div>
8
+
9
+ </div>
10
+ </div>
@@ -0,0 +1,19 @@
1
+ <%= form_for resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-horizontal'} do |f| %>
2
+ <div class="form-group">
3
+ <%= f.label :kb_username, 'Username', :class => 'col-sm-2 control-label' %>
4
+ <div class="col-sm-10">
5
+ <%= f.text_field :kb_username, :class => 'form-control', :autofocus => true %>
6
+ </div>
7
+ </div>
8
+ <div class="form-group">
9
+ <%= f.label :password, :class => 'col-sm-2 control-label' %>
10
+ <div class="col-sm-10">
11
+ <%= f.password_field :password, :class => 'form-control' %>
12
+ </div>
13
+ </div>
14
+ <div class="form-group">
15
+ <div class="col-sm-offset-2 col-sm-10">
16
+ <%= f.submit 'Sign in', :class => 'btn btn-default' %>
17
+ </div>
18
+ </div>
19
+ <% end %>
@@ -1,21 +1,10 @@
1
- <h2>Sign in</h2>
1
+ <div class="register">
2
+ <div class="col-md-8 col-md-offset-2">
2
3
 
3
- <%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => { :class => "form-horizontal" }) do |f| %>
4
- <div class="control-group">
5
- <%= f.label :kb_username, 'Username', :class => "control-label" %>
6
- <div class="controls">
7
- <%= f.text_field :kb_username, :autofocus => true %>
8
- </div>
9
- </div>
10
- <div class="control-group">
11
- <%= f.label :password, :class => "control-label" %>
12
- <div class="controls">
13
- <%= f.password_field :password %>
14
- </div>
15
- </div>
16
- <div class="control-group">
17
- <div class="controls">
18
- <%= f.submit "Sign in", :class => 'btn' %>
4
+ <div class="column-block">
5
+ <h1>Login</h1>
6
+ <%= render 'form' %>
19
7
  </div>
8
+
20
9
  </div>
21
- <% end %>
10
+ </div>
@@ -0,0 +1,26 @@
1
+ <%= form_for @subscription, :url => subscription_path(@subscription.subscription_id), :html => {:method => :put, :class => 'form-horizontal'} do |f| %>
2
+ <div class="form-group">
3
+ <%= label_tag :plan_name, 'New plan', :class => 'col-sm-2 control-label' %>
4
+ <div class="col-sm-10">
5
+ <%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
6
+ </div>
7
+ </div>
8
+ <div class="form-group">
9
+ <%= label_tag :requested_date, 'Change Date', :class => 'col-sm-2 control-label' %>
10
+ <div class="col-sm-10">
11
+ <%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'form-control date-picker' %>
12
+ </div>
13
+ </div>
14
+ <div class="form-group">
15
+ <%= label_tag :policy, 'Policy', :class => 'col-sm-2 control-label' %>
16
+ <div class="col-sm-10">
17
+ <%= select_tag :policy, options_for_select(['', 'IMMEDIATE', 'END_OF_TERM']), :class => 'form-control' %>
18
+ <p class="help-block">Leave blank for default</p>
19
+ </div>
20
+ </div>
21
+ <div class="form-group">
22
+ <div class="col-sm-offset-2 col-sm-10">
23
+ <%= submit_tag 'Save', :class => 'btn btn-default' %>
24
+ </div>
25
+ </div>
26
+ <% end %>