<commit_before><div class="page-header">
  <h3>Account <%= @account.name %></h3>
  <%= link_to @account.email, Kaui.account_home_path.call(@account.external_key) %>
</div>
<form class="form-horizontal">
  <div class="control-group">
    <label for="bundles" class="control-label">Filter by bundle name</label>

    <div class="controls">
      <%= select_tag 'bundles', options_for_select([''] + @bundle_names.values.sort, @selected_bundle || 'all') %>
    </div>

    <label for="events" class="control-label">Filter by event type</label>

    <div class="controls">
      <%= select_tag 'event_types', options_for_select('<option value="all">ALL</option><option value="invoice">INVOICE</option><option value="payment">PAYMENT</option><option value="entitlement">ENTITLEMENTS</option>'.html_safe) %>
    </div>

    <dl class="dl-horizontal">
      <dt>Billing timezone:</dt>
      <dd><%= @account.time_zone %></dd>
    </dl>
  </div>
</form>
<hr/>
<table id="timeline-table" class="table table-condensed">
<thead>
<tr>
  <th>Requested Date</th>
  <th>Effective Date</th>
  <th>Bundle Name</th>
  <th>Event Type</th>
  <th>Details</th>
  <th>Reason Code / Comments</th>
  <th>Actions</th>
</tr>
</thead>
<tbody>
<% if @account.present? && @timeline.present? %>
    <% @timeline.invoices.each do |invoice_stub| %>
        <% if invoice_stub.bundle_keys.present? %>
            <% bundles = invoice_stub.bundle_keys.split(',').map { |bundle_key| @bundle_names[bundle_key] }.join(',') %>
        <% end %>
        <% if invoice_stub.invoice_id.present? && @invoices_by_id.has_key?(invoice_stub.invoice_id) %>
            <% invoice = @invoices_by_id[invoice_stub.invoice_id] %>
        <% else %>
            <% invoice = invoice_stub %>
        <% end %>
        <tr title="<%= bundles %>" data-event_type="INVOICE">
          <td>
            <% if invoice.invoice_date.present? %>
                <%= invoice.invoice_date %>
            <% else %>
                [unknown]
            <% end %>
          </td>
          <td>
            <% if invoice.target_date.present? %>
                <%= invoice.target_date %>
            <% else %>
                [unknown]
            <% end %>
          </td>
          <td>
            <% if invoice_stub.bundle_keys.present? %>
                <% invoice_stub.bundle_keys.split(',').each do |bundle_key| %>
                    <%= link_to @bundle_names[bundle_key], kaui_engine.account_bundles_path(invoice.account_id) %>
                    <br/>
                <% end %>
            <% end %>
          </td>
          <td><%= 'INVOICE' %></td>
          <td><span class="hide" title="<%= invoice.invoice_number %>"></span>
            <%= 'Amount:' %> <%= humanized_money_with_symbol invoice.amount_to_money %>
            (<%= @account.currency %>)<br/>
            <%= 'Balance:' %> <%= humanized_money_with_symbol invoice.balance_to_money %>
            (<%= @account.currency %>)<br/>
            <% if invoice.credit_adj.present? && invoice.credit_adj > 0 %>
                <%= 'Credit adjustment:' %> <%= humanized_money_with_symbol invoice.credit_adjustment_to_money %>
                (<%= @account.currency %>)<br/>
            <% end %>
            <% if invoice.credits.present? && invoice.credits > 0 %>
                <%= 'Credit balance adjustment:' %> <%= humanized_money_with_symbol invoice.credits_to_money %>
                (<%= @account.currency %>)<br/>
            <% end %>
            <% if invoice.refund_adj.present? && invoice.refund_adj < 0 %>
                <%= 'Refund adjustment:' %> <%= humanized_money_with_symbol invoice.refund_adjustment_to_money %>
                (<%= @account.currency %>)<br/>
            <% end %>
            <%= 'Invoice #' %>
            <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
          </td>
          <td>
            <% if invoice_stub.audit_logs.present? %>
                <% invoice_stub.audit_logs.each do |entry| %>
                    <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'Transition' %>
                    <br/>
                <% end %>
            <% end %>
          </td>
          <td>
            <nobr>
              <%= link_to 'Payment',
                          kaui_engine.new_account_payment_path(:account_id => invoice.account_id, :invoice_id => invoice.invoice_id),
                          :class => "btn btn-xs #{'disabled' unless invoice.balance > 0}" %>
            </nobr>
            <% if can? :credit, Kaui::Invoice %>
                <nobr>
                  <%= link_to 'Credit',
                              kaui_engine.new_account_credit_path(invoice.account_id, :invoice_id => invoice.invoice_id),
                              :class => 'btn btn-xs' %>
                </nobr>
            <% end %>
            <% if can? :charge, Kaui::Invoice %>
                <nobr>
                  <%= link_to 'Charge',
                              kaui_engine.new_account_charge_path(invoice.account_id, :invoice_id => invoice.invoice_id),
                              :class => 'btn btn-xs' %>
                </nobr>
            <% end %>
          </td>
        </tr>
    <% end %>
    <% @timeline.payments.each do |payment| %>
        <% if payment.target_invoice_id.present? %>
            <% bundles = @bundle_names_by_invoice_id[payment.target_invoice_id].to_a.join(',') %>
            <% invoice = @invoices_by_id[payment.target_invoice_id] %>
        <% else %>
            <% bundles = nil %>
            <% invoice = nil %>
        <% end %>
        <% payment.transactions.each do |transaction| %>
            <tr title="<%= bundles %>" data-event_type="PAYMENT">
              <td>
                <% if transaction.effective_date.present? %>
                    <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
                <% else %>
                    [unknown]
                <% end %>
              </td>
              <td>
                <% if transaction.effective_date.present? %>
                    <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
                <% else %>
                    [unknown]
                <% end %>
              </td>
              <td>
                <% (@bundle_keys_by_invoice_id[payment.target_invoice_id] || []).each do |bundle_key| %>
                    <%= link_to @bundle_names[bundle_key], kaui_engine.account_bundles_path(payment.account_id) %>
                    <br/>
                <% end %>
              </td>
              <td><%= transaction.transaction_type %></td>
              <td>
                <span class="hide" title="<%= invoice.invoice_number unless invoice.nil? %>"></span>
                <%= 'Transaction id:' %> <%= truncate_uuid(transaction.transaction_id) %>
                <br/>
                <%= 'Amount:' %> <%= humanized_money_with_symbol Kaui::Transaction.amount_to_money(transaction) %>
                (<%= transaction.currency %>)<br/>
            <span
            <% if transaction.status == 'FAILED' %>class="alert-error"
            <% elsif transaction.status == 'SUCCESS' %>class="alert-success" <% end %>>
              <%= transaction.status %>
            </span>
                <br/>
                <%= 'Payment #' %> <%= link_to payment.payment_number, payment_path(:id => payment.payment_id) %>
                <% unless invoice.nil? %>
                    <br/><%= 'Invoice #' %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
                <% end %>
              </td>
              <td>
                <% if transaction.audit_logs.present? %>
                    <% transaction.audit_logs.each do |entry| %>
                        <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'PaymentRequestProcessor' %>
                        <br/>
                    <% end %>
                <% end %>
              </td>
              <td>
                <% if invoice.present? and %w(CAPTURE PURCHASE).include?(transaction.transaction_type) %>
                    <% if can? :refund, Kaui::Payment %>
                        <nobr>
                          <%= link_to 'Refund', kaui_engine.new_account_refund_path(@account.account_id, :params => {:payment_id => payment.payment_id,
                                                                                                                     :invoice_id => payment.target_invoice_id}),
                                      :class => "btn btn-xs #{'disabled' unless payment.paym
                                      ent_id.present? and transaction.status == 'SUCCESS' }" %>
                        </nobr>
                    <% end %>
                    <% if can? :chargeback, Kaui::Payment %><commit_msg>account_timelines: fix typo in view<commit_after><div class="page-header">
  <h3>Account <%= @account.name %></h3>
  <%= link_to @account.email, Kaui.account_home_path.call(@account.external_key) %>
</div>
<form class="form-horizontal">
  <div class="control-group">
    <label for="bundles" class="control-label">Filter by bundle name</label>

    <div class="controls">
      <%= select_tag 'bundles', options_for_select([''] + @bundle_names.values.sort, @selected_bundle || 'all') %>
    </div>

    <label for="events" class="control-label">Filter by event type</label>

    <div class="controls">
      <%= select_tag 'event_types', options_for_select('<option value="all">ALL</option><option value="invoice">INVOICE</option><option value="payment">PAYMENT</option><option value="entitlement">ENTITLEMENTS</option>'.html_safe) %>
    </div>

    <dl class="dl-horizontal">
      <dt>Billing timezone:</dt>
      <dd><%= @account.time_zone %></dd>
    </dl>
  </div>
</form>
<hr/>
<table id="timeline-table" class="table table-condensed">
<thead>
<tr>
  <th>Requested Date</th>
  <th>Effective Date</th>
  <th>Bundle Name</th>
  <th>Event Type</th>
  <th>Details</th>
  <th>Reason Code / Comments</th>
  <th>Actions</th>
</tr>
</thead>
<tbody>
<% if @account.present? && @timeline.present? %>
    <% @timeline.invoices.each do |invoice_stub| %>
        <% if invoice_stub.bundle_keys.present? %>
            <% bundles = invoice_stub.bundle_keys.split(',').map { |bundle_key| @bundle_names[bundle_key] }.join(',') %>
        <% end %>
        <% if invoice_stub.invoice_id.present? && @invoices_by_id.has_key?(invoice_stub.invoice_id) %>
            <% invoice = @invoices_by_id[invoice_stub.invoice_id] %>
        <% else %>
            <% invoice = invoice_stub %>
        <% end %>
        <tr title="<%= bundles %>" data-event_type="INVOICE">
          <td>
            <% if invoice.invoice_date.present? %>
                <%= invoice.invoice_date %>
            <% else %>
                [unknown]
            <% end %>
          </td>
          <td>
            <% if invoice.target_date.present? %>
                <%= invoice.target_date %>
            <% else %>
                [unknown]
            <% end %>
          </td>
          <td>
            <% if invoice_stub.bundle_keys.present? %>
                <% invoice_stub.bundle_keys.split(',').each do |bundle_key| %>
                    <%= link_to @bundle_names[bundle_key], kaui_engine.account_bundles_path(invoice.account_id) %>
                    <br/>
                <% end %>
            <% end %>
          </td>
          <td><%= 'INVOICE' %></td>
          <td><span class="hide" title="<%= invoice.invoice_number %>"></span>
            <%= 'Amount:' %> <%= humanized_money_with_symbol invoice.amount_to_money %>
            (<%= @account.currency %>)<br/>
            <%= 'Balance:' %> <%= humanized_money_with_symbol invoice.balance_to_money %>
            (<%= @account.currency %>)<br/>
            <% if invoice.credit_adj.present? && invoice.credit_adj > 0 %>
                <%= 'Credit adjustment:' %> <%= humanized_money_with_symbol invoice.credit_adjustment_to_money %>
                (<%= @account.currency %>)<br/>
            <% end %>
            <% if invoice.credits.present? && invoice.credits > 0 %>
                <%= 'Credit balance adjustment:' %> <%= humanized_money_with_symbol invoice.credits_to_money %>
                (<%= @account.currency %>)<br/>
            <% end %>
            <% if invoice.refund_adj.present? && invoice.refund_adj < 0 %>
                <%= 'Refund adjustment:' %> <%= humanized_money_with_symbol invoice.refund_adjustment_to_money %>
                (<%= @account.currency %>)<br/>
            <% end %>
            <%= 'Invoice #' %>
            <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
          </td>
          <td>
            <% if invoice_stub.audit_logs.present? %>
                <% invoice_stub.audit_logs.each do |entry| %>
                    <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'Transition' %>
                    <br/>
                <% end %>
            <% end %>
          </td>
          <td>
            <nobr>
              <%= link_to 'Payment',
                          kaui_engine.new_account_payment_path(:account_id => invoice.account_id, :invoice_id => invoice.invoice_id),
                          :class => "btn btn-xs #{'disabled' unless invoice.balance > 0}" %>
            </nobr>
            <% if can? :credit, Kaui::Invoice %>
                <nobr>
                  <%= link_to 'Credit',
                              kaui_engine.new_account_credit_path(invoice.account_id, :invoice_id => invoice.invoice_id),
                              :class => 'btn btn-xs' %>
                </nobr>
            <% end %>
            <% if can? :charge, Kaui::Invoice %>
                <nobr>
                  <%= link_to 'Charge',
                              kaui_engine.new_account_charge_path(invoice.account_id, :invoice_id => invoice.invoice_id),
                              :class => 'btn btn-xs' %>
                </nobr>
            <% end %>
          </td>
        </tr>
    <% end %>
    <% @timeline.payments.each do |payment| %>
        <% if payment.target_invoice_id.present? %>
            <% bundles = @bundle_names_by_invoice_id[payment.target_invoice_id].to_a.join(',') %>
            <% invoice = @invoices_by_id[payment.target_invoice_id] %>
        <% else %>
            <% bundles = nil %>
            <% invoice = nil %>
        <% end %>
        <% payment.transactions.each do |transaction| %>
            <tr title="<%= bundles %>" data-event_type="PAYMENT">
              <td>
                <% if transaction.effective_date.present? %>
                    <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
                <% else %>
                    [unknown]
                <% end %>
              </td>
              <td>
                <% if transaction.effective_date.present? %>
                    <%= format_date(transaction.effective_date, @account.time_zone).html_safe %>
                <% else %>
                    [unknown]
                <% end %>
              </td>
              <td>
                <% (@bundle_keys_by_invoice_id[payment.target_invoice_id] || []).each do |bundle_key| %>
                    <%= link_to @bundle_names[bundle_key], kaui_engine.account_bundles_path(payment.account_id) %>
                    <br/>
                <% end %>
              </td>
              <td><%= transaction.transaction_type %></td>
              <td>
                <span class="hide" title="<%= invoice.invoice_number unless invoice.nil? %>"></span>
                <%= 'Transaction id:' %> <%= truncate_uuid(transaction.transaction_id) %>
                <br/>
                <%= 'Amount:' %> <%= humanized_money_with_symbol Kaui::Transaction.amount_to_money(transaction) %>
                (<%= transaction.currency %>)<br/>
            <span
            <% if transaction.status == 'FAILED' %>class="alert-error"
            <% elsif transaction.status == 'SUCCESS' %>class="alert-success" <% end %>>
              <%= transaction.status %>
            </span>
                <br/>
                <%= 'Payment #' %> <%= link_to payment.payment_number, payment_path(:id => payment.payment_id) %>
                <% unless invoice.nil? %>
                    <br/><%= 'Invoice #' %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
                <% end %>
              </td>
              <td>
                <% if transaction.audit_logs.present? %>
                    <% transaction.audit_logs.each do |entry| %>
                        <%= Kaui::AuditLog.description(entry) unless entry.changed_by == 'PaymentRequestProcessor' %>
                        <br/>
                    <% end %>
                <% end %>
              </td>
              <td>
                <% if invoice.present? and %w(CAPTURE PURCHASE).include?(transaction.transaction_type) %>
                    <% if can? :refund, Kaui::Payment %>
                        <nobr>
                          <%= link_to 'Refund', kaui_engine.new_account_refund_path(@account.account_id, :params => {:payment_id => payment.payment_id,
                                                                                                                     :invoice_id => payment.target_invoice_id}),
                                      :class => "btn btn-xs #{'disabled' unless payment.payment_id.present? and transaction.status == 'SUCCESS' }" %>
                        </nobr>
                    <% end %>
                    <% if can? :chargeback, Kaui::Payment %>
{'fraction_non_alphanumeric': 0.1576022231044065, 'fraction_numerical': 0.0006805421652583225, 'mean_word_length': 1.6881097560975609, 'pattern_counts': {'":': 0, '<': 451, '<?xml version=': 0, '>': 483, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6532068', 'n_tokens_mistral': 5705, 'n_tokens_neox': 4972, 'n_words': 807}