Skip to content

KAUI 8.5 - #650

Open
tungleduyxyz wants to merge 8 commits into
masterfrom
kaui_8.5
Open

KAUI 8.5#650
tungleduyxyz wants to merge 8 commits into
masterfrom
kaui_8.5

Conversation

@tungleduyxyz

@tungleduyxyz tungleduyxyz commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Related issues:

@tungleduyxyz tungleduyxyz changed the title Improve invoice translation UI: toggle View/Hide Source button, locale dropdown KAUI 8.5 Aug 2, 2026
@tungleduyxyz
tungleduyxyz requested a review from Copilot August 2, 2026 04:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the invoice translation admin UI to improve usability and reduce locale entry mistakes when uploading invoice translation files.

Changes:

  • Updates the “View Source” button behavior so the label toggles between “View Source” and “Hide Source” based on visibility.
  • Replaces the free-text locale input with a locale dropdown built from the existing all_available_locales helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/views/kaui/admin_tenants/_form_invoice_translation.erb Outdated
Adds invoice_number link rendering in account_invoices_columns lambda,
matching the existing payment_number link behavior on the payments listing
page. The invoice number now links to the invoice detail page:
/accounts/{account_id}/invoices/{invoice_id}

Fixes #629

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (1)

lib/kaui.rb:137

  • invoice.invoice_number can be blank (e.g., dry-run invoices). In that case this renders an empty <a> tag, which is confusing and makes the row hard to interact with. Consider falling back to a short invoice id (or a placeholder) when invoice_number isn’t present, while still linking to the invoice details page.
      when 'invoice_number'
        view_context.link_to(invoice.invoice_number, view_context.url_for(controller: :invoices, action: :show, account_id: invoice.account_id, id: invoice.invoice_id))

- Detect whether a subscription's account uses an XML or Aviate catalog
  via the Aviate plugin's Catalog Info API (GET .../catalog/info)
- For Aviate catalogs, reuse the existing Record Usage form but submit
  through the Aviate Submit Usage Events API instead, swapping the
  'Unit Type' label/field for 'Billing Meter Code' (fetched from the
  plan's usage phases) and allowing decimal amounts
- trackingId is auto-generated (UUID) when left blank, since the Aviate
  API requires it unlike the standard Record Usage API
- Add Dependencies::Aviate::Metering, a self-contained wrapper around
  the Aviate plugin's Catalog/Metering REST APIs (not yet exposed by
  the killbill-client gem), authenticated via a JWT bearer token
  (jwt_token cookie, same convention as killbill-aviate-ui) in addition
  to the tenant api_key/api_secret

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Suppressed comments (4)

app/controllers/kaui/subscriptions_controller.rb:228

  • The Aviate metering API timestamp is being formatted without a timezone designator (e.g., missing trailing Z). This makes the value ambiguous and inconsistent with the XML-catalog path that uses iso8601. Use parsed_date.utc.iso8601 (or include Z) when submitting usage events.
          Dependencies::Aviate::Metering.submit_usage_event(@subscription.account_id, unit_type, subscription_id, tracking_id,
                                                            parsed_date.utc.strftime('%Y-%m-%dT%H:%M:%S'), amount.to_f, options_for_aviate_klient)

app/views/kaui/subscriptions/record_usage.erb:49

  • The Aviate amount field allows 0 client-side (min: 0), but the server-side validation rejects non-positive values (<= 0). Align the HTML constraint with the controller validation to avoid confusing submit failures.
                        <% if @is_aviate_catalog %>
                            <%= number_field_tag :amount, @amount, required: true, min: 0, step: 'any', class: 'form-control', placeholder: 'Positive number' %>
                        <% else %>
                            <%= number_field_tag :amount, @amount, required: true, min: 1, step: 1, class: 'form-control', placeholder: 'Positive integer' %>
                        <% end %>

app/views/kaui/subscriptions/record_usage.erb:40

  • The tooltip link uses href="#", which will change the URL fragment and can scroll the page to the top when clicked. Use a non-navigating href (or prevent default) so the link only triggers the tooltip.
                            <a href="#" data-toggle="tooltip" class="kb-tooltip" title="Kaui automatically detects the catalog type for this subscription's account and submits usage through the matching Kill Bill API: the Record Usage API (unit type) for standard catalogs, or the Aviate Submit Usage Events API (billing meter code) for Aviate catalogs.">(?)</a>

app/services/dependencies/aviate.rb:36

  • plan_name is interpolated directly into the URL path. If it contains spaces or other reserved characters, the request URL will be invalid (and can potentially lead to path confusion). URL-escape plan_name when constructing the Aviate catalog plan endpoint.
          response = KillBillClient::API.get("#{KILLBILL_AVIATE_PREFIX}/catalog/#{plan_name}/plan", catalog_params(account_id), request_options(options_for_klient))
          plan = JSON.parse(response.body)

Comment thread app/views/kaui/admin_tenants/_form_invoice_translation.erb Outdated
- Fix ArgumentError: options_for_select doesn't accept keyword args in
  Ruby 3; pass disabled options as an explicit hash positional argument
  in the invoice translation locale dropdown
- Wrap button label in a span (kaui-button-label) in the shared button
  component so the 'View Source'/'Hide Source' toggle only updates the
  label text, instead of clobbering the whole button contents (which
  would have removed icon/trailing_icon elements)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants