kaui 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. data/README.rdoc +27 -1
  2. data/app/controllers/kaui/account_tags_controller.rb +24 -9
  3. data/app/controllers/kaui/account_timelines_controller.rb +1 -1
  4. data/app/controllers/kaui/accounts_controller.rb +7 -5
  5. data/app/controllers/kaui/bundles_controller.rb +2 -2
  6. data/app/controllers/kaui/chargebacks_controller.rb +3 -2
  7. data/app/controllers/kaui/charges_controller.rb +32 -0
  8. data/app/controllers/kaui/credits_controller.rb +3 -4
  9. data/app/controllers/kaui/external_payments_controller.rb +0 -2
  10. data/app/controllers/kaui/invoice_items_controller.rb +44 -0
  11. data/app/controllers/kaui/invoices_controller.rb +4 -3
  12. data/app/controllers/kaui/payments_controller.rb +10 -13
  13. data/app/controllers/kaui/refunds_controller.rb +19 -8
  14. data/app/controllers/kaui/subscriptions_controller.rb +5 -1
  15. data/app/controllers/kaui/tag_definitions_controller.rb +85 -0
  16. data/app/helpers/kaui/date_helper.rb +1 -1
  17. data/app/helpers/kaui/killbill_helper.rb +160 -59
  18. data/app/models/kaui/account.rb +7 -1
  19. data/app/models/kaui/account_timeline.rb +0 -4
  20. data/app/models/kaui/audit_log.rb +9 -7
  21. data/app/models/kaui/base.rb +80 -1
  22. data/app/models/kaui/charge.rb +14 -0
  23. data/app/models/kaui/chargeback.rb +2 -10
  24. data/app/models/kaui/event.rb +2 -13
  25. data/app/models/kaui/invoice.rb +6 -7
  26. data/app/models/kaui/invoice_item.rb +9 -17
  27. data/app/models/kaui/payment.rb +6 -21
  28. data/app/models/kaui/payment_method.rb +1 -8
  29. data/app/models/kaui/plugin_info.rb +1 -5
  30. data/app/models/kaui/plugin_info_property.rb +0 -6
  31. data/app/models/kaui/refund.rb +5 -13
  32. data/app/models/kaui/tag.rb +10 -3
  33. data/app/models/kaui/tag_definition.rb +46 -0
  34. data/app/views/kaui/account_tags/edit.html.erb +17 -17
  35. data/app/views/kaui/account_timelines/show.html.erb +61 -39
  36. data/app/views/kaui/accounts/index.html.erb +1 -1
  37. data/app/views/kaui/accounts/show.html.erb +16 -2
  38. data/app/views/kaui/bundles/show.html.erb +2 -1
  39. data/app/views/kaui/chargebacks/new.html.erb +18 -2
  40. data/app/views/kaui/charges/new.html.erb +87 -0
  41. data/app/views/kaui/credits/new.html.erb +1 -1
  42. data/app/views/kaui/invoice_items/edit.html.erb +92 -0
  43. data/app/views/kaui/invoice_items/index.html.erb +20 -0
  44. data/app/views/kaui/invoice_items/show.html.erb +31 -0
  45. data/app/views/kaui/invoices/index.html.erb +1 -1
  46. data/app/views/kaui/invoices/show.html.erb +42 -24
  47. data/app/views/kaui/payments/_payments_table.html.erb +7 -5
  48. data/app/views/kaui/payments/new.html.erb +32 -12
  49. data/app/views/kaui/refunds/index.html.erb +3 -3
  50. data/app/views/kaui/refunds/new.html.erb +3 -3
  51. data/app/views/kaui/refunds/show.html.erb +27 -13
  52. data/app/views/kaui/subscriptions/edit.html.erb +8 -0
  53. data/app/views/kaui/tag_definitions/_form.html.erb +45 -0
  54. data/app/views/kaui/tag_definitions/edit.html.erb +3 -0
  55. data/app/views/kaui/tag_definitions/index.html.erb +34 -0
  56. data/app/views/kaui/tag_definitions/new.html.erb +3 -0
  57. data/app/views/kaui/tag_definitions/show.html.erb +12 -0
  58. data/app/views/kaui/tags/_tags_table.html.erb +3 -3
  59. data/config/locales/en.yml +3 -0
  60. data/config/locales/fr.yml +3 -0
  61. data/config/routes.rb +11 -1
  62. data/lib/kaui/version.rb +1 -1
  63. data/test/dummy/app/controllers/application_controller.rb +10 -0
  64. data/test/dummy/app/views/layouts/application.html.erb +44 -11
  65. data/test/dummy/config/application.rb +1 -0
  66. data/test/dummy/config/database.yml +5 -4
  67. data/test/dummy/config/environments/development.rb +2 -0
  68. data/test/dummy/config/routes.rb +1 -2
  69. data/test/dummy/log/development.log +2419 -0
  70. data/test/dummy/log/test.log +3265 -131
  71. data/test/dummy/test/fixtures/accounts.yml +32 -0
  72. data/test/dummy/test/fixtures/bundles.yml +4 -0
  73. data/test/dummy/test/fixtures/invoice_items.yml +13 -0
  74. data/test/dummy/test/fixtures/invoices.yml +11 -0
  75. data/test/dummy/test/fixtures/payment_methods.yml +5 -0
  76. data/test/dummy/test/fixtures/plugin_info_properties.yml +59 -0
  77. data/test/dummy/test/fixtures/plugin_infos.yml +2 -0
  78. data/test/dummy/test/fixtures/refunds.yml +8 -0
  79. data/test/dummy/test/fixtures/tag_definitions.yml +9 -0
  80. data/test/dummy/tmp/cache/assets/C8D/6D0/sprockets%2F0ce756f49d61795508c543a702955fc2 +0 -0
  81. data/test/dummy/tmp/cache/assets/C94/4E0/sprockets%2Fea1476dc10a3348303f74d111f70441a +0 -0
  82. data/test/dummy/tmp/cache/assets/CD0/9D0/sprockets%2F5c9508c21501c73fbe00473a09b1f5f4 +0 -0
  83. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  84. data/test/dummy/tmp/cache/assets/CEA/300/sprockets%2Fdf2ad5c9d0990441c2bf59883383d652 +0 -0
  85. data/test/dummy/tmp/cache/assets/D0E/370/sprockets%2F27630db2080819f67c8a0ed5e491b7cb +0 -0
  86. data/test/dummy/tmp/cache/assets/D32/200/sprockets%2Ffa467106e01bda5d6246baea72159d64 +0 -0
  87. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  88. data/test/dummy/tmp/cache/assets/D39/5E0/sprockets%2F59fd338be48a81a17a2a785cbd1612b4 +0 -0
  89. data/test/dummy/tmp/cache/assets/D44/170/sprockets%2Fac15571bce3f926a498da7cd09322d97 +0 -0
  90. data/test/dummy/tmp/cache/assets/D4A/DD0/sprockets%2F0f813582283b7f56fd83fe3d52be7e2c +0 -0
  91. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  92. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  93. data/test/dummy/tmp/cache/assets/D6C/710/sprockets%2F1765773caead06c0a6a19ea9de2453f7 +0 -0
  94. data/test/dummy/tmp/cache/assets/D76/910/sprockets%2Ff99b4bdc434e11e8634e6af62fe805e0 +0 -0
  95. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  96. data/test/dummy/tmp/cache/assets/DF1/1A0/sprockets%2F7f6b7bfea83401d3106b7fadac81ea4b +0 -0
  97. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  98. data/test/dummy/tmp/cache/assets/E20/230/sprockets%2F7d3b1348fdf74cf1b6ba2107fbbac5af +0 -0
  99. data/test/dummy/vendor/assets/images/img/glyphicons-halflings-white.png +0 -0
  100. data/test/dummy/vendor/assets/images/img/glyphicons-halflings.png +0 -0
  101. data/test/dummy/vendor/assets/javascripts/bootstrap.v2.0.4.min.js +6 -0
  102. data/test/dummy/vendor/assets/javascripts/jquery.dataTables.v1.9.3.min.js +156 -0
  103. data/test/dummy/vendor/assets/stylesheets/bootstrap.v2.0.4.min.css +9 -0
  104. data/test/functional/kaui/accounts_controller_test.rb +63 -0
  105. data/test/functional/kaui/bundles_controller_test.rb +18 -6
  106. data/test/functional/kaui/invoice_items_controller_test.rb +18 -0
  107. data/test/functional/kaui/invoices_controller_test.rb +18 -6
  108. data/test/functional/kaui/tag_definitions_controller_test.rb +60 -0
  109. data/test/test_helper.rb +143 -0
  110. data/test/unit/helpers/kaui/plugin_infos_helper_test.rb +20 -0
  111. data/test/unit/kaui/account_test.rb +42 -0
  112. data/test/unit/kaui/base_test.rb +39 -0
  113. data/test/unit/kaui/date_helper_test.rb +13 -0
  114. data/test/unit/kaui/invoice_item_test.rb +23 -0
  115. data/test/unit/kaui/invoice_test.rb +20 -0
  116. data/test/unit/kaui/payment_method_test.rb +26 -0
  117. data/test/unit/kaui/plugin_info_property_test.rb +20 -0
  118. data/test/unit/kaui/plugin_info_test.rb +19 -0
  119. data/test/unit/kaui/refund_test.rb +19 -0
  120. data/test/unit/kaui/tag_definition_test.rb +23 -0
  121. data/test/unit/model_test.rb +23 -23
  122. metadata +330 -226
data/README.rdoc CHANGED
@@ -1,3 +1,29 @@
1
1
  = Kaui
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ This project rocks and uses MIT-LICENSE.
4
+
5
+ == Getting started
6
+
7
+ === Running Kaui
8
+
9
+ You can run Kaui locally using the dummy app in the test directory:
10
+
11
+ # Point to your killbill installation
12
+ export KILLBILL_URL="http://killbill.company.com:8080"
13
+ cd test/dummy && rails s
14
+
15
+ === Mounting Kaui into your own Rails app
16
+
17
+ Kaui expects the container app to define the <tt>current_user</tt> method, which returns the
18
+ name of the logged-in user. This is used by Killbill for auditing purposes.
19
+
20
+ === Running tests
21
+
22
+ Prepare a kaui_test database locally to be able to run the test suite:
23
+
24
+ create database kaui_test;
25
+ grant all privileges on kaui_test.* to 'root'@'localhost' identified by '';
26
+
27
+ You can run tests using rake:
28
+
29
+ rake test
@@ -12,22 +12,37 @@ class Kaui::AccountTagsController < Kaui::EngineController
12
12
 
13
13
  def edit
14
14
  @account_id = params[:account_id]
15
- @available_tags = Kaui::KillbillHelper::get_tag_definitions.sort {|tag_a, tag_b| tag_a.name.downcase <=> tag_b.name.downcase }
15
+ @available_tags = Kaui::KillbillHelper::get_tag_definitions.sort
16
16
 
17
17
  @account = Kaui::KillbillHelper::get_account(@account_id)
18
- @tags = Kaui::KillbillHelper::get_tags_for_account(@account.account_id)
18
+ @tag_names = Kaui::KillbillHelper::get_tags_for_account(@account.account_id).map { |tag| tag.tag_definition_name }
19
19
  end
20
20
 
21
21
  def update
22
- account = Kaui::KillbillHelper::get_account(params[:account_id])
23
- tags = params[:tags]
22
+ current_tags = Kaui::KillbillHelper::get_tags_for_account(params[:account_id]).map { |tag| tag.tag_definition_id }
23
+ new_tags = []
24
+ params.each do |tag, tag_name|
25
+ tag_info = tag.split('_')
26
+ next if tag_info.size != 2 or tag_info[0] != 'tag'
27
+ new_tags << tag_info[1]
28
+ end
24
29
 
25
- if account.account_id.present?
26
- Kaui::KillbillHelper::set_tags_for_account(account.account_id, tags)
27
- redirect_to Kaui.account_home_path.call(account.external_key)
28
- else
29
- flash[:error] = "No account id given"
30
+ # Find tags to remove
31
+ tags_to_remove = []
32
+ current_tags.each do |current_tag_definition_id|
33
+ tags_to_remove << current_tag_definition_id unless new_tags.include?(current_tag_definition_id)
30
34
  end
35
+
36
+ # Find tags to add
37
+ tags_to_add = []
38
+ new_tags.each do |new_tag_definition_id|
39
+ tags_to_add << new_tag_definition_id unless current_tags.include?(new_tag_definition_id)
40
+ end
41
+
42
+ Kaui::KillbillHelper::remove_tags_for_account(params[:account_id], tags_to_remove)
43
+ Kaui::KillbillHelper::add_tags_for_account(params[:account_id], tags_to_add)
44
+
45
+ redirect_to Kaui.account_home_path.call(params[:account_id])
31
46
  end
32
47
 
33
48
  end
@@ -12,7 +12,7 @@ class Kaui::AccountTimelinesController < Kaui::EngineController
12
12
 
13
13
  if @account.present?
14
14
  @timeline = Kaui::KillbillHelper::get_account_timeline(@account_id)
15
- # @payment_attempts_by_payment_id = {}
15
+
16
16
  @invoices_by_id = {}
17
17
  @bundle_names = {}
18
18
  unless @timeline.nil?
@@ -13,12 +13,13 @@ class Kaui::AccountsController < Kaui::EngineController
13
13
  if key.present?
14
14
  # support id (UUID) and external key search
15
15
  if key =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/
16
- @account = Kaui::KillbillHelper::get_account(key)
16
+ @account = Kaui::KillbillHelper::get_account(key, true)
17
17
  else
18
- @account = Kaui::KillbillHelper::get_account_by_external_key(key)
18
+ @account = Kaui::KillbillHelper::get_account_by_external_key(key, true)
19
19
  end
20
20
 
21
- if @account.present?
21
+ if @account.present? and @account.is_a? Kaui::Account
22
+ @tags = Kaui::KillbillHelper::get_tags_for_account(@account.account_id).sort
22
23
  @payment_methods = Kaui::KillbillHelper::get_payment_methods(@account.account_id)
23
24
  @bundles = Kaui::KillbillHelper::get_bundles(@account.account_id)
24
25
  @subscriptions_by_bundle_id = {}
@@ -30,8 +31,8 @@ class Kaui::AccountsController < Kaui::EngineController
30
31
  end
31
32
  end
32
33
  else
33
- flash[:error] = "Account #{@account_id} not found"
34
- redirect_to :action => :index
34
+ flash[:error] = "Account #{@account_id} not found: #{@account}"
35
+ render :action => :index
35
36
  end
36
37
  else
37
38
  flash[:error] = "No id given"
@@ -125,4 +126,5 @@ class Kaui::AccountsController < Kaui::EngineController
125
126
  end
126
127
  redirect_to :back
127
128
  end
129
+
128
130
  end
@@ -13,7 +13,7 @@ class Kaui::BundlesController < Kaui::EngineController
13
13
  if key =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/
14
14
  @bundle = Kaui::KillbillHelper.get_bundle(key)
15
15
  else
16
- @bundle = Kaui::KillbillHelper.get_bundle_by_external_key(key)
16
+ @bundle = Kaui::KillbillHelper.get_bundle_by_external_key(key, params[:account_id])
17
17
  end
18
18
 
19
19
  if @bundle.present?
@@ -21,7 +21,7 @@ class Kaui::BundlesController < Kaui::EngineController
21
21
  @subscriptions = Kaui::KillbillHelper.get_subscriptions_for_bundle(@bundle.bundle_id)
22
22
  else
23
23
  flash[:error] = "Bundle #{key} not found"
24
- redirect_to :action => :index
24
+ render :action => :index
25
25
  end
26
26
  else
27
27
  flash[:error] = "No id given"
@@ -21,9 +21,10 @@ class Kaui::ChargebacksController < Kaui::EngineController
21
21
 
22
22
  # @payment_attempt = Kaui::KillbillHelper::get_payment_attempt(@external_key, @invoice_id, @payment_id)
23
23
  @account = Kaui::KillbillHelper::get_account(@account_id)
24
- # TODO: get payment by payment id (no api at the moment)
25
- @payment = Kaui::KillbillHelper::get_payment(@invoice_id, @payment_id)
24
+ @payment = Kaui::KillbillHelper::get_payment(@payment_id)
26
25
  @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
26
+ @payment_method = Kaui::KillbillHelper::get_payment_method(@payment.payment_method_id)
27
+
27
28
  @chargeback = Kaui::Chargeback.new("payment_id" => @payment_id,
28
29
  "chargeback_amount" => @payment.amount)
29
30
  end
@@ -0,0 +1,32 @@
1
+ class Kaui::ChargesController < Kaui::EngineController
2
+
3
+ def new
4
+ @account_id = params[:account_id]
5
+ @invoice_id = params[:invoice_id]
6
+
7
+ @account = Kaui::KillbillHelper::get_account(@account_id)
8
+
9
+ if @invoice_id.present?
10
+ @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
11
+ @charge = Kaui::Charge.new("accountId" => @account_id, "invoiceId" => @invoice_id)
12
+ else
13
+ @charge = Kaui::Charge.new("accountId" => @account_id)
14
+ end
15
+
16
+ end
17
+
18
+ def create
19
+ charge = Kaui::Charge.new(params[:charge])
20
+
21
+ if charge.present?
22
+ success = Kaui::KillbillHelper::create_charge(charge, params[:requested_date], current_user, nil, params[:comment])
23
+ if success
24
+ flash[:info] = "Charge created"
25
+ end
26
+ else
27
+ flash[:error] = "No charge to process"
28
+ end
29
+ redirect_to account_timeline_path(:id => charge.account_id)
30
+ end
31
+
32
+ end
@@ -19,11 +19,10 @@ class Kaui::CreditsController < Kaui::EngineController
19
19
  def new
20
20
  @account_id = params[:account_id]
21
21
  @invoice_id = params[:invoice_id]
22
-
23
- @credit = Kaui::Credit.new("accountId" => @account_id, "invoiceId" => @invoice_id)
24
-
25
22
  @account = Kaui::KillbillHelper::get_account(@account_id)
26
- @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
23
+ @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id) unless @invoice_id.nil?
24
+
25
+ @credit = Kaui::Credit.new("accountId" => @account_id, "invoiceId" => @invoice_id, "creditAmount" => @invoice.balance)
27
26
  end
28
27
 
29
28
  def create
@@ -15,8 +15,6 @@ class Kaui::ExternalPaymentsController < Kaui::EngineController
15
15
  success = Kaui::KillbillHelper::create_external_payment(external_payment, current_user, params[:reason], params[:comment])
16
16
  if success
17
17
  flash[:info] = "External Payment created"
18
- # else
19
- # flash[:error] = "Error while creating external payment"
20
18
  end
21
19
  redirect_to account_timeline_path(external_payment.account_id)
22
20
  end
@@ -0,0 +1,44 @@
1
+ class Kaui::InvoiceItemsController < Kaui::EngineController
2
+ def index
3
+ if params[:invoice_item_id].present? and params[:invoice_id].present?
4
+ redirect_to invoice_item_path(params[:invoice_item_id], :invoice_id => params[:invoice_id])
5
+ end
6
+ end
7
+
8
+ def show
9
+ find_invoice_item
10
+ end
11
+
12
+ def edit
13
+ find_invoice_item
14
+ end
15
+
16
+ def update
17
+ @invoice_item = Kaui::InvoiceItem.new(params[:invoice_item])
18
+ success = Kaui::KillbillHelper.adjust_invoice(@invoice_item, current_user, params[:reason], params[:comment])
19
+ if success
20
+ flash[:notice] = "Adjustment item created"
21
+ redirect_to invoice_path(@invoice_item.invoice_id)
22
+ else
23
+ flash[:error] = "Unable to create adjustment item"
24
+ render :action => "edit"
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def find_invoice_item
31
+ invoice_item_id = params[:id]
32
+ invoice_id = params[:invoice_id]
33
+ if invoice_item_id.present? and invoice_id.present?
34
+ @invoice_item = Kaui::KillbillHelper.get_invoice_item(invoice_id, invoice_item_id)
35
+ unless @invoice_item.present?
36
+ flash[:error] = "Invoice for id #{invoice_id} and invoice item id #{invoice_item_id} not found"
37
+ render :action => :index
38
+ end
39
+ else
40
+ flash[:error] = "Both invoice item and invoice ids should be specified"
41
+ render :action => :index
42
+ end
43
+ end
44
+ end
@@ -1,7 +1,7 @@
1
1
  class Kaui::InvoicesController < Kaui::EngineController
2
2
  def index
3
- if params[:id].present?
4
- redirect_to invoice_path(params[:id])
3
+ if params[:invoice_id].present?
4
+ redirect_to invoice_path(params[:invoice_id])
5
5
  end
6
6
  end
7
7
 
@@ -12,6 +12,7 @@ class Kaui::InvoicesController < Kaui::EngineController
12
12
  if @invoice.present?
13
13
  @account = Kaui::KillbillHelper.get_account(@invoice.account_id)
14
14
  @payments = Kaui::KillbillHelper.get_payments(@invoice_id)
15
+
15
16
  @subscriptions = {}
16
17
  @bundles = {}
17
18
  if @invoice.items.present?
@@ -28,7 +29,7 @@ class Kaui::InvoicesController < Kaui::EngineController
28
29
  end
29
30
  else
30
31
  flash[:error] = "Invoice #{@invoice_id} not found"
31
- redirect_to :action => :index
32
+ render :action => :index
32
33
  end
33
34
  else
34
35
  flash[:error] = "No id given"
@@ -1,29 +1,26 @@
1
1
  class Kaui::PaymentsController < Kaui::EngineController
2
2
 
3
3
  def new
4
- @invoice_id = params[:invoice_id]
5
4
  @account_id = params[:account_id]
6
-
7
- @payment = Kaui::Payment.new("invoiceId" => @invoice_id)
8
-
9
- @account = Kaui::KillbillHelper::get_account(@account_id)
5
+ @invoice_id = params[:invoice_id]
10
6
  @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
7
+ @account = Kaui::KillbillHelper::get_account(@account_id)
8
+
9
+ @payment = Kaui::Payment.new("accountId" => @account_id, "invoiceId" => @invoice_id, "amount" => @invoice.balance)
11
10
  end
12
11
 
13
12
  def create
14
- external_payment = Kaui::Payment.new(params[:external_payment])
13
+ payment = Kaui::Payment.new(params[:payment])
15
14
 
16
- if external_payment.present?
17
- success = Kaui::KillbillHelper::create_external_payment(payment, current_user, params[:reason], params[:comment])
15
+ if payment.present?
16
+ success = Kaui::KillbillHelper::create_payment(payment, params[:external], current_user, params[:reason], params[:comment])
18
17
  if success
19
- flash[:info] = "External Payment created"
20
- # else
21
- # flash[:error] = "Error while creating external payment"
18
+ flash[:info] = "Payment created"
22
19
  end
23
20
  else
24
- flash[:error] = "No external payment to process"
21
+ flash[:error] = "No payment to process"
25
22
  end
26
- redirect_to account_timeline_path(:id => params[:account_id])
23
+ redirect_to account_timeline_path(:id => payment.account_id)
27
24
  end
28
25
 
29
26
  end
@@ -1,15 +1,25 @@
1
1
  class Kaui::RefundsController < Kaui::EngineController
2
- def show
3
- @payment_id = params[:id]
4
- if @payment_id.present?
5
- data = Kaui::KillbillHelper::get_refunds_for_payment(@payment_id)
2
+ def index
3
+ if params[:refund_id].present?
4
+ redirect_to refund_path(params[:refund_id])
5
+ end
6
+ end
7
+
8
+ def show
9
+ if params[:id].present?
10
+ data = Kaui::KillbillHelper::get_refund(params[:id])
6
11
  if data.present?
7
- @refund = Kaui::Refund.new(data)
12
+ @refunds = [data]
8
13
  else
9
- Rails.logger.warn("Did not get back refunds for the payment id #{response_body}")
14
+ @refunds = Kaui::KillbillHelper::get_refunds_for_payment(params[:id])
15
+ unless @refunds.present?
16
+ flash[:error] = "Refund for id or payment id #{params[:id]} couldn't be found"
17
+ render :action => :index
18
+ end
10
19
  end
11
20
  else
12
- flash[:notice] = "No payment id given"
21
+ flash[:error] = "A refund or payment id should be specifed"
22
+ render :action => :index
13
23
  end
14
24
  end
15
25
 
@@ -21,8 +31,9 @@ class Kaui::RefundsController < Kaui::EngineController
21
31
  @refund = Kaui::Refund.new('adjusted' => true)
22
32
 
23
33
  @account = Kaui::KillbillHelper::get_account(@account_id)
24
- @payment = Kaui::KillbillHelper::get_payment(@invoice_id, @payment_id)
34
+ @payment = Kaui::KillbillHelper::get_payment(@payment_id)
25
35
  @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
36
+ @payment_method = Kaui::KillbillHelper::get_payment_method(@payment.payment_method_id)
26
37
  end
27
38
 
28
39
  def create
@@ -76,10 +76,14 @@ class Kaui::SubscriptionsController < Kaui::EngineController
76
76
 
77
77
  def edit
78
78
  @subscription = Kaui::KillbillHelper.get_subscription(params[:id])
79
+
79
80
  if @subscription.present?
80
81
  @bundle = Kaui::KillbillHelper::get_bundle(@subscription.bundle_id)
82
+ @account = Kaui::KillbillHelper::get_account(@bundle.account_id)
81
83
  @catalog = Kaui::KillbillHelper::get_available_base_plans
84
+
82
85
  @current_plan = "#{@subscription.product_name} #{@subscription.billing_period}".humanize
86
+
83
87
  if @subscription.price_list != "DEFAULT"
84
88
  @current_plan += " (price list #{@subscription.price_list})"
85
89
  end
@@ -106,7 +110,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
106
110
  # TODO: need to use entered start_date (or current date if none entered)
107
111
 
108
112
  Kaui::KillbillHelper::update_subscription(subscription, requested_date, current_user)
109
- redirect_to Kaui.bundle_home_path.call(bundle.external_key)
113
+ redirect_to Kaui.bundle_home_path.call(bundle.bundle_id)
110
114
  else
111
115
  flash[:error] = "No subscription given"
112
116
  redirect_to :back
@@ -0,0 +1,85 @@
1
+ module Kaui
2
+ class TagDefinitionsController < ApplicationController
3
+ # GET /tag_definitions
4
+ # GET /tag_definitions.json
5
+ def index
6
+ @tag_definitions = TagDefinition.all
7
+
8
+ respond_to do |format|
9
+ format.html # index.html.erb
10
+ format.json { render json: @tag_definitions }
11
+ end
12
+ end
13
+
14
+ # GET /tag_definitions/1
15
+ # GET /tag_definitions/1.json
16
+ def show
17
+ @tag_definition = TagDefinition.find(params[:id])
18
+
19
+ respond_to do |format|
20
+ format.html # show.html.erb
21
+ format.json { render json: @tag_definition }
22
+ end
23
+ end
24
+
25
+ # GET /tag_definitions/new
26
+ # GET /tag_definitions/new.json
27
+ def new
28
+ @tag_definition = TagDefinition.new
29
+
30
+ respond_to do |format|
31
+ format.html # new.html.erb
32
+ format.json { render json: @tag_definition }
33
+ end
34
+ end
35
+
36
+ # GET /tag_definitions/1/edit
37
+ def edit
38
+ @tag_definition = TagDefinition.find(params[:id])
39
+ end
40
+
41
+ # POST /tag_definitions
42
+ # POST /tag_definitions.json
43
+ def create
44
+ @tag_definition = TagDefinition.new(params[:tag_definition])
45
+
46
+ respond_to do |format|
47
+ if @tag_definition.save
48
+ format.html { redirect_to @tag_definition, notice: 'Tag definition was successfully created.' }
49
+ format.json { render json: @tag_definition, status: :created, location: @tag_definition }
50
+ else
51
+ format.html { render action: "new" }
52
+ format.json { render json: @tag_definition.errors, status: :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /tag_definitions/1
58
+ # PUT /tag_definitions/1.json
59
+ def update
60
+ @tag_definition = TagDefinition.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @tag_definition.update_attributes(params[:tag_definition])
64
+ format.html { redirect_to @tag_definition, notice: 'Tag definition was successfully updated.' }
65
+ format.json { head :no_content }
66
+ else
67
+ format.html { render action: "edit" }
68
+ format.json { render json: @tag_definition.errors, status: :unprocessable_entity }
69
+ end
70
+ end
71
+ end
72
+
73
+ # DELETE /tag_definitions/1
74
+ # DELETE /tag_definitions/1.json
75
+ def destroy
76
+ @tag_definition = TagDefinition.find(params[:id])
77
+ @tag_definition.destroy
78
+
79
+ respond_to do |format|
80
+ format.html { redirect_to tag_definitions_url }
81
+ format.json { head :no_content }
82
+ end
83
+ end
84
+ end
85
+ end