Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ group :development do
end

group :development, :test do
gem 'rubocop', require: false
gem 'rubocop', '~> 1.89.0', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
gem 'rubocop-rails', '~> 2.36.0', require: false
gem 'rubocop-rspec', '~> 3.10.2', require: false
gem 'rubocop-thread_safety', require: false
end

Expand Down
3 changes: 3 additions & 0 deletions app/assets/images/kaui/blocking-states/shield-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/images/kaui/timeline/block.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions app/assets/stylesheets/kaui/subscription.css
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,44 @@ table tr.expired td {
right: 0.5rem;
}

/* app/views/kaui/components/blocking_state_form/_about_panel.html.erb */

.blocking-state-about-panel {
flex: 0 0 20rem;
max-width: 20rem;
height: fit-content;
padding: 1.25rem;
background-color: #EFF6FF;
border: 0.0625rem solid #DBEAFE;
border-radius: 0.5rem;
}

.blocking-state-about-panel .icon-container {
display: inline-flex;
justify-content: center;
align-items: center;
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
background-color: #2563EB;
flex-shrink: 0;
}

.blocking-state-about-panel h6 {
font-weight: 600;
font-size: 1rem;
line-height: 1.5rem;
color: #1B1C1E;
}

.blocking-state-about-panel p {
font-size: 0.875rem;
font-weight: 400;
line-height: 1.25rem;
color: #414651;
margin-bottom: 0;
}

.kaui-subscription-new .form-group.d-flex.pb-3 .form-control {
height: 2.5rem;
border-radius: 0.375rem;
Expand Down
30 changes: 24 additions & 6 deletions app/controllers/kaui/account_timelines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def show
@invoices = timeline.invoices
@payments = timeline.payments
extract_invoices_by_id(@invoices)
@account_blocking_states = fetch_account_blocking_states(@account)

# Lookup all bundle names
@bundle_names = {}
Expand Down Expand Up @@ -51,6 +52,7 @@ def download
@invoices = timeline.invoices
@payments = timeline.payments
extract_invoices_by_id(@invoices)
@account_blocking_states = fetch_account_blocking_states(@account)

# Lookup all bundle names
@bundle_names = {}
Expand Down Expand Up @@ -117,20 +119,30 @@ def download
@bundles.each do |bundle|
bundle.subscriptions.each do |sub|
sub.events.each do |event|
# Skip SERVICE_STATE_CHANGE events
next if event.event_type == 'SERVICE_STATE_CHANGE'

effective_date = event.effective_date.present? ? Date.parse(event.effective_date).to_s : '[unknown]'
bundle_keys = @bundle_names[bundle.external_key]
event_type = event.event_type
phase = event.phase
audit_logs = event.audit_logs.present? ? event.audit_logs.map { |entry| Kaui::AuditLog.description(entry) }.join(', ') : ''
details = if event.event_type == 'SERVICE_STATE_CHANGE' || event.is_blocked_billing || event.is_blocked_entitlement
"#{event.service_name}/#{event.service_state_name} (billing=#{event.is_blocked_billing}, entitlement=#{event.is_blocked_entitlement})"
else
event.phase
end

csv << [effective_date, bundle_keys, event_type, phase, audit_logs] if filter_date?(effective_date, start_date, end_date)
csv << [effective_date, bundle_keys, event.event_type, details, audit_logs] if filter_date?(effective_date, start_date, end_date)
end
end
end
end

if %w[ENTITLEMENT ALL].include?(event_type)
@account_blocking_states.each do |blocking_state|
effective_date = blocking_state.effective_date.present? ? Date.parse(blocking_state.effective_date).to_s : '[unknown]'
audit_logs = blocking_state.audit_logs.present? ? blocking_state.audit_logs.map { |entry| Kaui::AuditLog.description(entry) }.join(', ') : ''
details = "#{blocking_state.service}/#{blocking_state.state_name} (billing=#{blocking_state.is_block_billing}, entitlement=#{blocking_state.is_block_entitlement}, change=#{blocking_state.is_block_change})"

csv << [effective_date, '', 'SERVICE_STATE_CHANGE', details, audit_logs] if filter_date?(effective_date, start_date, end_date)
end
end
end

send_data csv_string, filename: "account-timelines-#{Time.zone.today}.csv", type: 'text/csv'
Expand Down Expand Up @@ -161,5 +173,11 @@ def extract_invoices_by_id(all_invoices)
[invoice.invoice_id, Kaui::Invoice.build_from_raw_invoice(invoice)]
end
end

def fetch_account_blocking_states(account)
account.blocking_states(nil, nil, 'NONE', options_for_klient)
rescue StandardError
[]
end
end
end
15 changes: 15 additions & 0 deletions app/controllers/kaui/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,5 +391,20 @@ def export_account
data = KillBillClient::Model::Export.find_by_account_id(params[:account_id], current_user.kb_username, options_for_klient)
send_data data, filename: "account#{params[:account_id]}.txt", type: :txt
end

def block
@account = Kaui::Account.find_by_id(params.require(:account_id), false, false, options_for_klient)
end

def do_block
account_id = params.require(:account_id)
account = Kaui::Account.new(account_id:)
account.set_blocking_state(params.require(:state_name), params.require(:service),
params[:is_block_change] == '1', params[:is_block_entitlement] == '1',
params[:is_block_billing] == '1', params[:requested_date].presence,
current_user.kb_username, params[:reason], params[:comment], options_for_klient)

redirect_to account_path(account_id), notice: 'Blocking state was successfully created'
end
end
end
14 changes: 14 additions & 0 deletions app/controllers/kaui/bundles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def do_pause_resume
redirect_to kaui_engine.account_bundles_path(@account.account_id), notice: msg
end

def block
@bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
end

def do_block
bundle = Kaui::Bundle.new(bundle_id: params.require(:id))
bundle.set_blocking_state(params.require(:state_name), params.require(:service),
params[:is_block_change] == '1', params[:is_block_entitlement] == '1',
params[:is_block_billing] == '1', params[:requested_date].presence,
current_user.kb_username, params[:reason], params[:comment], options_for_klient)

redirect_to kaui_engine.account_bundles_path(params.require(:account_id)), notice: 'Blocking state was successfully created'
end

private

def search_bundles(query, search_by, options)
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/kaui/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,20 @@ def update_bcd
redirect_to kaui_engine.account_bundles_path(input_subscription['account_id']), notice: 'Subscription BCD was successfully changed'
end

def block
@subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
end

def do_block
subscription = Kaui::Subscription.new(subscription_id: params.require(:id))
subscription.set_blocking_state(params.require(:state_name), params.require(:service),
params[:is_block_change] == '1', params[:is_block_entitlement] == '1',
params[:is_block_billing] == '1', params[:requested_date].presence,
current_user.kb_username, params[:reason], params[:comment], options_for_klient)

redirect_to kaui_engine.account_bundles_path(params.require(:account_id)), notice: 'Blocking state was successfully created'
end

def edit_quantity
@subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
end
Expand Down
Loading
Loading