kaui 4.0.7 → 4.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 890fbf5edb1c2f67edab9875e0c07d68bbdd5dad5403c190b63c5c783fbaa7a0
4
- data.tar.gz: 994a37d01dc5bb7784730e960e7014b351f638a5b06fe2f22e96aff3e79a0738
3
+ metadata.gz: 68f193d330400858d2b943a2b2e4e356366ebd03fa1099d1279612c40c1f7666
4
+ data.tar.gz: 61d17f6e690ca34e6ef8972ba185cf589a0deca6c22159409c040147146d8955
5
5
  SHA512:
6
- metadata.gz: d1910b8162699e1d0171bdfefb3188c92df44867082b624f1e90ce33822dffdec283c2e562e6c853aaacdcd40a79ed8949d2b3da42e3de3aa099e961ab3670dd
7
- data.tar.gz: c0fbfd5a9541304d384afca229c3c53e22d749c887812a754adf464b49a570f92bc2f74c1a887485a2883735b274c943dbbbfd9030561a1431fccef6d417a8fe
6
+ metadata.gz: 040f78a63f17a79983d6382eb1547636cdc1274309f72f96ff8fa737a950427940121c7a711c05e2d3a96a752f1cf6bca720c6371625452d371e190aebeecc69
7
+ data.tar.gz: 0d54dce07e8dbed25c0e997018d3b9fef5184387003775d6f1b88f6891eec414837e6e0ac6848c2d66b4b3620a5d44b6c03dcf65fbdafa9eed36774a209978c3
@@ -157,8 +157,8 @@ module Kaui
157
157
  return {} if all_invoices.nil? || all_invoices.empty?
158
158
 
159
159
  # Convert into Kaui::Invoice to benefit from additional methods xxx_to_money
160
- @invoices_by_id = all_invoices.each_with_object({}) do |invoice, hsh|
161
- hsh[invoice.invoice_id] = Kaui::Invoice.build_from_raw_invoice(invoice)
160
+ @invoices_by_id = all_invoices.to_h do |invoice|
161
+ [invoice.invoice_id, Kaui::Invoice.build_from_raw_invoice(invoice)]
162
162
  end
163
163
  end
164
164
  end
@@ -173,6 +173,7 @@ module Kaui
173
173
  ops
174
174
  end
175
175
  fetch_available_tags = promise { Kaui::TagDefinition.all_for_account(cached_options_for_klient) }
176
+ fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
176
177
 
177
178
  @overdue_state = wait(fetch_overdue_state)
178
179
  @tags = wait(fetch_account_tags)
@@ -184,6 +185,7 @@ module Kaui
184
185
  @children = wait(fetch_children)
185
186
  @account_parent = @account.parent_account_id.nil? ? nil : wait(fetch_parent)
186
187
  @email_notification_configuration = is_email_notifications_plugin_available ? wait(fetch_email_notification_configuration) : []
188
+ @bundles = wait(fetch_bundles)
187
189
 
188
190
  @last_transaction_by_payment_method_id = {}
189
191
  wait(fetch_payments).each do |payment|
@@ -114,7 +114,7 @@ module Kaui
114
114
  end
115
115
 
116
116
  @latest_version = begin
117
- @catalog_versions[@catalog_versions.length - 1][:version_date]
117
+ @catalog_versions[-1][:version_date]
118
118
  rescue StandardError
119
119
  nil
120
120
  end
@@ -199,6 +199,7 @@ module Kaui
199
199
 
200
200
  is_plan_id_found = false
201
201
  plan_id = params[:plan_id]
202
+ product = nil
202
203
 
203
204
  options = tenant_options_for_client
204
205
  options[:api_key] = @tenant.api_key
@@ -207,9 +208,12 @@ module Kaui
207
208
  catalog = Kaui::Catalog.get_catalog_json(true, nil, nil, options)
208
209
 
209
210
  # seek if plan id exists
210
- catalog.products.each do |product|
211
- product.plans.each { |plan| is_plan_id_found |= plan.name == plan_id }
212
- break if is_plan_id_found
211
+ catalog.products.each do |p|
212
+ p.plans.each { |plan| is_plan_id_found |= plan.name == plan_id }
213
+ if is_plan_id_found
214
+ product = p
215
+ break
216
+ end
213
217
  end
214
218
 
215
219
  unless is_plan_id_found
@@ -219,6 +223,7 @@ module Kaui
219
223
 
220
224
  @simple_plan = Kaui::SimplePlan.new
221
225
  @simple_plan.plan_id = params[:plan_id]
226
+ @simple_plan.product_name = product.name if product
222
227
  end
223
228
 
224
229
  def create_simple_plan
@@ -472,7 +477,7 @@ module Kaui
472
477
  # convert result to a full hash since dynamic attributes of a class are ignored when converting to json
473
478
  result.each do |data|
474
479
  plans = data[:plans].map do |plan|
475
- plan.instance_variables.each_with_object({}) { |var, hash_plan| hash_plan[var.to_s.delete('@')] = plan.instance_variable_get(var) }
480
+ plan.instance_variables.to_h { |var| [var.to_s.delete('@'), plan.instance_variable_get(var)] }
476
481
  end
477
482
 
478
483
  catalog << { version_date: data[:version_date],
@@ -46,9 +46,8 @@ module Kaui
46
46
  @available_tags = wait(fetch_available_tags)
47
47
  @available_subscription_tags = wait(fetch_available_subscription_tags)
48
48
 
49
- # TODO: This doesn't take into account catalog versions
50
- catalogs = Kaui::Catalog.get_account_catalog_json(@account.account_id, nil, cached_options_for_klient) || []
51
- @catalog = catalogs[-1]
49
+ # Don't load the full catalog to avoid memory issues
50
+ @catalog = nil
52
51
 
53
52
  @subscription = {}
54
53
  @bundles.each do |bundle|
@@ -237,7 +237,7 @@ module Kaui
237
237
  return [] if catalog.blank?
238
238
 
239
239
  plans = []
240
- catalog[catalog.size - 1].products.each do |product|
240
+ catalog[-1].products.each do |product|
241
241
  next if product.type == 'ADD_ON' || (!product_category.nil? && product.type != product_category)
242
242
 
243
243
  product.plans.each do |plan|
@@ -69,5 +69,27 @@ module Kaui
69
69
  style = "style='#{style}'" unless style.empty?
70
70
  style
71
71
  end
72
+
73
+ # Get the effective BCD for an account
74
+ # If there's an active subscription with its own BCD, return that
75
+ # Otherwise return the account-level BCD
76
+ def effective_bcd(account, bundles = nil)
77
+ # If bundles are provided, check for subscription BCD
78
+ if bundles.present?
79
+ bundles.each do |bundle|
80
+ next unless bundle.subscriptions.present?
81
+
82
+ bundle.subscriptions.each do |subscription|
83
+ # Skip cancelled subscriptions
84
+ next if subscription.state == 'CANCELLED'
85
+ # If subscription has a BCD set, return it (subscription BCD takes precedence)
86
+ return subscription.bill_cycle_day_local if subscription.bill_cycle_day_local.present? && subscription.bill_cycle_day_local.positive?
87
+ end
88
+ end
89
+ end
90
+
91
+ # Fall back to account BCD
92
+ account.bill_cycle_day_local
93
+ end
72
94
  end
73
95
  end
@@ -37,7 +37,7 @@ module Kaui
37
37
 
38
38
  def get_catalog_json(latest, requested_date, account_id, options)
39
39
  catalogs = get_tenant_catalog_json(requested_date, account_id, options)
40
- return catalogs.length.positive? ? catalogs[catalogs.length - 1] : nil if latest
40
+ return catalogs.length.positive? ? catalogs[-1] : nil if latest
41
41
 
42
42
  # Order by latest
43
43
  result = []
@@ -106,8 +106,8 @@ module Kaui
106
106
  class << simple_plan
107
107
  attr_accessor :prices, :final_phase_duration
108
108
  end
109
- simple_plan.prices = plan.phases[-1].prices.each_with_object({}) do |e, r|
110
- r[e.currency] = e.value
109
+ simple_plan.prices = plan.phases[-1].prices.to_h do |e|
110
+ [e.currency, e.value]
111
111
  end
112
112
 
113
113
  simple_plan.plan_id = plan.name
@@ -3,6 +3,7 @@
3
3
  require 'killbill_client'
4
4
 
5
5
  # Hack for Zeitwerk
6
+ # rubocop:disable Style/OneClassPerFile
6
7
  module Kaui
7
8
  module KillbillAuthenticatable; end
8
9
  end
@@ -41,3 +42,4 @@ module Devise
41
42
  end
42
43
  end
43
44
  end
45
+ # rubocop:enable Style/OneClassPerFile
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Hack for Zeitwerk
4
+ # rubocop:disable Style/OneClassPerFile
4
5
  module Kaui
5
6
  module KillbillRegisterable; end
6
7
  end
@@ -12,3 +13,4 @@ module Devise
12
13
  end
13
14
  end
14
15
  end
16
+ # rubocop:enable Style/OneClassPerFile
@@ -110,8 +110,9 @@
110
110
  <div class="col-md-4">
111
111
  <div class="info-item">
112
112
  <b>Bill cycle day</b>
113
- <% if @account.bill_cycle_day_local > 0 %>
114
- <p><%= @account.bill_cycle_day_local %> (user timezone)</p>
113
+ <% effective_bcd_value = effective_bcd(@account, @bundles) %>
114
+ <% if effective_bcd_value.present? && effective_bcd_value > 0 %>
115
+ <p><%= effective_bcd_value %> (user timezone)</p>
115
116
  <% else %>
116
117
  <p>N/A</p>
117
118
  <% end %>
@@ -78,8 +78,9 @@
78
78
  <tr>
79
79
  <th>Bill cycle day</th>
80
80
  <td>
81
- <% if @account.bill_cycle_day_local > 0 %>
82
- <span class='label'><%= @account.bill_cycle_day_local %> (user timezone)</span>
81
+ <% effective_bcd_value = effective_bcd(@account, @bundles) %>
82
+ <% if effective_bcd_value.present? && effective_bcd_value > 0 %>
83
+ <span class='label'><%= effective_bcd_value %> (user timezone)</span>
83
84
  <% else %>
84
85
  <span class='label'>N/A</span>
85
86
  <% end %>
@@ -21,7 +21,7 @@
21
21
  <div class="form-group d-flex pb-3">
22
22
  <%= f.label :amount, 'Amount', :class => 'col-sm-3 control-label' %>
23
23
  <div class="col-sm-9 d-flex currency-select">
24
- <%= f.text_field :amount, :class => 'form-control w-100 amount-input' %>
24
+ <%= f.text_field :amount, :class => 'form-control w-100 amount-input', :required => true %>
25
25
  <%= f.select :currency, currencies, {:selected => 'USD'}, :class => 'form-control' %>
26
26
  </div>
27
27
  </div>
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
  <span>
36
36
  <%= render "kaui/components/button/button", {
37
- label: "Create User",
37
+ label: "Allow Tenant Access",
38
38
  icon: "kaui/plus.svg",
39
39
  variant: "outline-secondary d-inline-flex align-items-center gap-1",
40
40
  type: "button",
@@ -6,6 +6,8 @@
6
6
  # Try to determine root path dynamically
7
7
  if request.path.start_with?('/kaui')
8
8
  dynamic_root = '/kaui'
9
+ elsif request.path.start_with?('/aviate')
10
+ dynamic_root = '/aviate'
9
11
  else
10
12
  dynamic_root = '/'
11
13
  end
@@ -90,11 +92,12 @@
90
92
  <% end %>
91
93
  <% end %>
92
94
 
93
- <%# Process remaining segments (excluding root "kaui" segment) %>
95
+ <%# Process remaining segments (excluding root segments like "kaui" or "aviate") %>
94
96
  <% sanitized_segments = segments.map { |segment| CGI.escapeHTML(segment) } %>
95
97
  <%
96
- # Skip the first segment if it's "kaui" since we already handled home
97
- display_segments = sanitized_segments.first == "kaui" ? sanitized_segments[1..-1] : sanitized_segments
98
+ # Skip the first segment if it's a root mount point since we already handled home
99
+ root_segments = %w[kaui aviate]
100
+ display_segments = root_segments.include?(sanitized_segments.first) ? sanitized_segments[1..-1] : sanitized_segments
98
101
  %>
99
102
 
100
103
  <% display_segments.each_with_index do |segment, index| %>
@@ -48,7 +48,7 @@
48
48
 
49
49
  <div class="fw-semibold text-muted mb-2">Other search queries</div>
50
50
  <div class="d-flex flex-wrap gap-2">
51
- <% %w[custom\ field: subscription: tag:].each do |term| %>
51
+ <% %w[bundle: custom\ field: subscription: tag:].each do |term| %>
52
52
  <span class="badge text-dark border border-secondary rounded-3 px-3 py-2 custom-hover"><%= term %></span>
53
53
  <% end %>
54
54
  </div>
@@ -59,7 +59,7 @@
59
59
  <div class="form-group d-flex pb-3">
60
60
  <%= label_tag :amount, 'Amount', :class => 'col-sm-3 control-label' %>
61
61
  <div class="col-sm-9 d-flex currency-group">
62
- <%= number_field_tag :amount, @payment.purchased_amount, :id => 'refund_amount', :class => 'form-control' %>
62
+ <%= number_field_tag :amount, @payment.purchased_amount, :id => 'refund_amount', :class => 'form-control', :step => 'any' %>
63
63
  <div class="currency"><%= @invoice.currency %></div>
64
64
  </div>
65
65
  </div>
@@ -142,7 +142,7 @@
142
142
  } %>
143
143
  <% end %>
144
144
 
145
- <% if can?(:create, Kaui::Subscription) && @subscription[bundle.bundle_id].present? %>
145
+ <% if can?(:create, Kaui::Subscription) && @subscription[bundle.bundle_id].present? && sub.product_category != 'ADD_ON' %>
146
146
  <% menu_items << {
147
147
  label: @subscription[bundle.bundle_id].product_category == 'BASE' ? 'Add add-on' : 'Add standalone subscription',
148
148
  path: kaui_engine.new_subscription_path(
data/lib/kaui/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kaui
4
- VERSION = '4.0.7'
4
+ VERSION = '4.0.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-26 00:00:00.000000000 Z
11
+ date: 2026-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack