KAUI 8.5 - #650
Open
tungleduyxyz wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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_localeshelper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Contributor
There was a problem hiding this comment.
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_numbercan 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) wheninvoice_numberisn’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
Contributor
There was a problem hiding this comment.
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 usesiso8601. Useparsed_date.utc.iso8601(or includeZ) 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
0client-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_nameis 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-escapeplan_namewhen 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)
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues:
Error while uploading invoice translation #624
Toggle 'View Source' button label to 'Hide Source' when source is displayed, and back when hidden
Replace free-text locale input with a dropdown using the existing
all_available_localeshelper, reducing locale entry errorsMake invoice id clickable similar to payment number on payments screen #629
Make invoice number clickable on invoices listing, linking to the invoice detail page
Unable to use Advance filters/Sort on Invoices #633
Fix the table footer overlap
Change record usage UI to take into consideration aviate based usage plans #647
Detect whether a subscription's account uses an XML or Aviate catalog (via the Aviate plugin's Catalog Info API) and record usage through the matching Kill Bill API
For Aviate catalogs, reuse the existing Record Usage form (label swaps to "Billing Meter Code", decimal amounts allowed, trackingId auto-generated) instead of building a separate form