Replacing the paid button with the cancel/hide action block cut the old markup at the first <% end %>, which belonged to the button's inner if/else, leaving a stray </button></form><% end %> behind. show.erb no longer compiled and every admin invoice page returned 500; nothing rendered that page in tests. Remove the leftovers, render the page in every state (pending, paid, cancelled, hidden), and compile every view in a test so an unbalanced template fails CI even when no test visits that page. Assisted-by: Claude:opus-5
82 lines
4.2 KiB
Text
82 lines
4.2 KiB
Text
<div class="header">
|
|
<h1><%= @invoice.number %></h1>
|
|
<p class="tagline"><a href="/admin/invoices">← all invoices</a></p>
|
|
</div>
|
|
|
|
<section class="section">
|
|
<dl class="kv">
|
|
<dt>Client</dt><dd><%= @invoice.client_name %> <<%= @invoice.client_email %>></dd>
|
|
<dt>Issued</dt><dd class="mono"><%= @invoice.issued_on.strftime('%Y-%m-%d') %></dd>
|
|
<dt>Due</dt><dd class="mono"><%= @invoice.due_on.strftime('%Y-%m-%d') %></dd>
|
|
<dt>Total</dt><dd class="mono"><%= @invoice.currency %> <%= '%.2f' % @invoice.total %><% unless @invoice.currency == 'GEL' %> · GEL <%= '%.2f' % @invoice.total_gel %><% end %></dd>
|
|
<dt>Status</dt><dd><span class="badge badge-<%= @invoice.status %>"><%= @invoice.status %></span></dd>
|
|
<% if @invoice.cancelled? %>
|
|
<dt>Cancelled</dt><dd class="mono"><%= @invoice.cancelled_at.utc.strftime('%Y-%m-%d %H:%M UTC') %><%= " · #{@invoice.cancel_reason}" if @invoice.cancel_reason %></dd>
|
|
<% end %>
|
|
<% if @invoice.hidden %>
|
|
<dt>Visibility</dt><dd><span class="badge badge-hidden">hidden</span> <span class="optional">only superusers see it in the admin</span></dd>
|
|
<% end %>
|
|
<% if @invoice.paid_at %>
|
|
<dt>Paid at</dt><dd class="mono"><%= @invoice.paid_at.utc.strftime('%Y-%m-%d %H:%M UTC') %></dd>
|
|
<% end %>
|
|
<% if @invoice.crypto? %>
|
|
<dt><%= @invoice.crypto_coin %></dt>
|
|
<dd class="mono">
|
|
<% if (amt = @invoice.crypto_amount_due) %><%= fmt_crypto(amt) %> <%= @invoice.crypto_coin %><% if @invoice.crypto_rate %> @ <%= fmt_rate(@invoice.crypto_rate) %> <%= @invoice.currency %><% end %><br /><% end %>
|
|
<span style="word-break:break-all;"><%= @invoice.crypto_address %></span>
|
|
</dd>
|
|
<% end %>
|
|
</dl>
|
|
</section>
|
|
|
|
<section class="section">
|
|
<h2>Actions</h2>
|
|
<p>
|
|
<a href="/i/<%= @invoice.uuid %>" target="_blank">Public landing page</a>
|
|
·
|
|
<a href="/i/<%= @invoice.uuid %>/pdf" target="_blank">Download PDF</a>
|
|
</p>
|
|
<p>
|
|
Share this URL with the client:<br />
|
|
<code class="mono">https://asxp.io/i/<%= @invoice.uuid %></code>
|
|
</p>
|
|
<% if can?('invoices', 'write') %>
|
|
<div class="invoice-actions">
|
|
<% unless @invoice.cancelled? %>
|
|
<form method="post" action="/admin/invoices/<%= @invoice.uuid %>/paid">
|
|
<input type="hidden" name="authenticity_token" value="<%= csrf_token %>" />
|
|
<button type="submit" class="link-button"><%= @invoice.paid? ? 'Mark unpaid' : 'Mark paid' %></button>
|
|
</form>
|
|
<% end %>
|
|
<% if @invoice.cancelled? %>
|
|
<form method="post" action="/admin/invoices/<%= @invoice.uuid %>/reinstate">
|
|
<input type="hidden" name="authenticity_token" value="<%= csrf_token %>" />
|
|
<button type="submit" class="link-button">↺ Reinstate</button>
|
|
</form>
|
|
<% else %>
|
|
<form method="post" action="/admin/invoices/<%= @invoice.uuid %>/cancel" class="invoice-form cancel-form"
|
|
onsubmit="return confirm('Cancel this invoice? The client link and PDF will show it as CANCELLED.')">
|
|
<input type="hidden" name="authenticity_token" value="<%= csrf_token %>" />
|
|
<input type="text" name="reason" maxlength="500" placeholder="Reason (optional, printed on the PDF)" />
|
|
<button type="submit" class="link-button danger">Cancel invoice</button>
|
|
</form>
|
|
<% end %>
|
|
<% if current_user.superuser %>
|
|
<form method="post" action="/admin/invoices/<%= @invoice.uuid %>/hide">
|
|
<input type="hidden" name="authenticity_token" value="<%= csrf_token %>" />
|
|
<button type="submit" class="link-button"><%= @invoice.hidden ? 'Unhide' : 'Hide (superusers only)' %></button>
|
|
</form>
|
|
<% end %>
|
|
</div>
|
|
<% end %>
|
|
<p style="margin-top: 14px;">
|
|
<% if can?('invoices', 'write') %><a href="/admin/invoices/<%= @invoice.uuid %>/duplicate">Use as template for a new invoice →</a><% end %>
|
|
</p>
|
|
</section>
|
|
|
|
<% unless @invoice.notes.to_s.strip.empty? %>
|
|
<section class="section">
|
|
<h2>Notes</h2>
|
|
<p style="white-space: pre-wrap;"><%= @invoice.notes %></p>
|
|
</section>
|
|
<% end %>
|