<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>
    <dl class="dl-horizontal">
      <dt>Billing timezone:</dt>
      <dd><%= @account.timezone %></dd>
    </dl>
  </div>
</form>
<hr/>
<table id="timeline-table" class="table table-condensed data-table">
  <thead>
    <tr>
      <th class="sort-title-string">Requested Date</th>
      <th class="data-table-sort-desc sort-title-string">Effective Date</th>
      <th>Bundle Name</th>
      <th class="data-table-sort-desc">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 %>">
          <td>
            <% if invoice.invoice_date.present? %>
              <span class="hide" title="<%= invoice.invoice_date %>"></span>
              <%= invoice.invoice_date %>
            <% else %>
              [unknown]
            <% end %>
          <td>
            <% if invoice.target_date.present? %>
              <span class="hide" title="<%= invoice.target_date %>"></span>
              <%= 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.bundle_home_path.call(bundle_key) %><br/>
              <% end %>
            <% end %>
          </td>
          <td><%= "INVOICE" %></td>
          <td><%= "Amount:" %> <%= invoice.amount %>  <%= @account.currency %><br/>
              <%= "Balance:" %> <%= invoice.balance %> <%= @account.currency %><br/>
              <% if invoice.credit_adjustment.present? &&  invoice.credit_adjustment > 0  %>
                <%= "Credit adjustment:" %> <%= invoice.credit_adjustment %> <%= @account.currency %> <br/>
              <% end %>
              <% if invoice.credit_balance_adjustment.present? &&  invoice.credit_balance_adjustment > 0  %>
                <%= "Credit balance adjustment:" %> <%= invoice.credit_balance_adjustment %>  <%= @account.currency %> <br/>
              <% end %>
              <% if invoice.refund_adjustment.present? &&  invoice.refund_adjustment < 0  %>
                <%= "Refund adjustment:" %> <%= invoice.refund_adjustment %>  <%= @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| %>
                <%= entry.description unless entry.changed_by == 'Transition' %><br/>
              <% end %>
            <% end %>
          </td>
          <td>
            <% if invoice.balance > 0 %>
              <nobr>
                <%= link_to "Credit",
                            kaui_engine.new_credit_path(:params => { :account_id => invoice.account_id,
                                                                     :invoice_id => invoice.invoice_id }),
                            :class => "btn btn-mini" %>
              </nobr>
              <nobr>
                <%= link_to "External Payment",
                            kaui_engine.new_payment_path(:params => { :account_id => invoice.account_id,
                                                                      :invoice_id => invoice.invoice_id,
                                                                      :external => "true" }),
                            :class => "btn btn-mini" %>
              </nobr>
              <nobr>
                <%= link_to "Payment",
                            kaui_engine.new_payment_path(:params => { :account_id => invoice.account_id,
                                                                      :invoice_id => invoice.invoice_id,
                                                                      :external => "false" }),
                            :class => "btn btn-mini" %>
              </nobr>
            <% end %>
            <nobr>
              <%= link_to "Charge",
                          kaui_engine.new_charge_path(:params => { :account_id => invoice.account_id,
                                                                   :invoice_id => invoice.invoice_id }),
                          :class => "btn btn-mini" %>
            </nobr>
          </td>
        </tr>
      <% end %>
      <% @timeline.payments.each do |payment| %>
        <% payment.refunds.each do |refund| %>
          <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
          <tr title="<%= bundles %>">
            <td>
              <% if refund.requested_date.present? %>
                <span class="hide" title="<%= refund.requested_dt %>"></span>
                <%= format_date(refund.requested_date).html_safe %>
              <% else %>
                [unknown]
              <% end %>
            </td>
            <td>
              <% if refund.effective_date.present? %>
                <span class="hide" title="<%= refund.effective_date %>"></span>
                <%= format_date(refund.effective_date).html_safe %>
              <% else %>
                [unknown]
              <% end %>
            </td>
            <td>
              <% payment.bundle_keys.split(",").each do |bundle_key| %>
                <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
              <% end %>
            </td>
            <td><%= "REFUND" %></td>
            <td>
              <%= "Adjusted:" %> <% if refund.adjusted %>yes<% else %>no<% end %><br/>
              <%= "Payment id:" %> <%= refund.payment_id %><br/>
              <%= "Refund Amount:" %> <%= refund.refund_amount %><br/>
            </td>
            <td><commit_msg>timeline: fix typo in show 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>
    <dl class="dl-horizontal">
      <dt>Billing timezone:</dt>
      <dd><%= @account.timezone %></dd>
    </dl>
  </div>
</form>
<hr/>
<table id="timeline-table" class="table table-condensed data-table">
  <thead>
    <tr>
      <th class="sort-title-string">Requested Date</th>
      <th class="data-table-sort-desc sort-title-string">Effective Date</th>
      <th>Bundle Name</th>
      <th class="data-table-sort-desc">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 %>">
          <td>
            <% if invoice.invoice_date.present? %>
              <span class="hide" title="<%= invoice.invoice_date %>"></span>
              <%= invoice.invoice_date %>
            <% else %>
              [unknown]
            <% end %>
          <td>
            <% if invoice.target_date.present? %>
              <span class="hide" title="<%= invoice.target_date %>"></span>
              <%= 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.bundle_home_path.call(bundle_key) %><br/>
              <% end %>
            <% end %>
          </td>
          <td><%= "INVOICE" %></td>
          <td><%= "Amount:" %> <%= invoice.amount %>  <%= @account.currency %><br/>
              <%= "Balance:" %> <%= invoice.balance %> <%= @account.currency %><br/>
              <% if invoice.credit_adjustment.present? &&  invoice.credit_adjustment > 0  %>
                <%= "Credit adjustment:" %> <%= invoice.credit_adjustment %> <%= @account.currency %> <br/>
              <% end %>
              <% if invoice.credit_balance_adjustment.present? &&  invoice.credit_balance_adjustment > 0  %>
                <%= "Credit balance adjustment:" %> <%= invoice.credit_balance_adjustment %>  <%= @account.currency %> <br/>
              <% end %>
              <% if invoice.refund_adjustment.present? &&  invoice.refund_adjustment < 0  %>
                <%= "Refund adjustment:" %> <%= invoice.refund_adjustment %>  <%= @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| %>
                <%= entry.description unless entry.changed_by == 'Transition' %><br/>
              <% end %>
            <% end %>
          </td>
          <td>
            <% if invoice.balance > 0 %>
              <nobr>
                <%= link_to "Credit",
                            kaui_engine.new_credit_path(:params => { :account_id => invoice.account_id,
                                                                     :invoice_id => invoice.invoice_id }),
                            :class => "btn btn-mini" %>
              </nobr>
              <nobr>
                <%= link_to "External Payment",
                            kaui_engine.new_payment_path(:params => { :account_id => invoice.account_id,
                                                                      :invoice_id => invoice.invoice_id,
                                                                      :external => "true" }),
                            :class => "btn btn-mini" %>
              </nobr>
              <nobr>
                <%= link_to "Payment",
                            kaui_engine.new_payment_path(:params => { :account_id => invoice.account_id,
                                                                      :invoice_id => invoice.invoice_id,
                                                                      :external => "false" }),
                            :class => "btn btn-mini" %>
              </nobr>
            <% end %>
            <nobr>
              <%= link_to "Charge",
                          kaui_engine.new_charge_path(:params => { :account_id => invoice.account_id,
                                                                   :invoice_id => invoice.invoice_id }),
                          :class => "btn btn-mini" %>
            </nobr>
          </td>
        </tr>
      <% end %>
      <% @timeline.payments.each do |payment| %>
        <% payment.refunds.each do |refund| %>
          <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
          <tr title="<%= bundles %>">
            <td>
              <% if refund.requested_date.present? %>
                <span class="hide" title="<%= refund.requested_date %>"></span>
                <%= format_date(refund.requested_date).html_safe %>
              <% else %>
                [unknown]
              <% end %>
            </td>
            <td>
              <% if refund.effective_date.present? %>
                <span class="hide" title="<%= refund.effective_date %>"></span>
                <%= format_date(refund.effective_date).html_safe %>
              <% else %>
                [unknown]
              <% end %>
            </td>
            <td>
              <% payment.bundle_keys.split(",").each do |bundle_key| %>
                <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
              <% end %>
            </td>
            <td><%= "REFUND" %></td>
            <td>
              <%= "Adjusted:" %> <% if refund.adjusted %>yes<% else %>no<% end %><br/>
              <%= "Payment id:" %> <%= refund.payment_id %><br/>
              <%= "Refund Amount:" %> <%= refund.refund_amount %><br/>
            </td>
            <td>
{'fraction_non_alphanumeric': 0.16562771817918237, 'fraction_numerical': 0.0008698173383589446, 'mean_word_length': 1.5039927404718694, 'pattern_counts': {'":': 0, '<': 375, '<?xml version=': 0, '>': 417, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5992318', 'n_tokens_mistral': 4368, 'n_tokens_neox': 3895, 'n_words': 656}