2017-01-15 16:27:22 +01:00
|
|
|
% my $id = stash 'id';
|
|
|
|
% title $id ? "Change credit $id" : "Enter new credit";
|
|
|
|
|
|
|
|
<form method="post">
|
|
|
|
<h2>Essentials</h2>
|
|
|
|
|
|
|
|
% my %r;
|
|
|
|
% $r{date} = begin
|
|
|
|
<input id="date" name="date" value="<%= $credit->date %>"> (Format: YYYY-MM-DD)
|
|
|
|
% end
|
|
|
|
% $r{purpose} = begin
|
|
|
|
<input id="purpose" name="purpose" style="width:100%" value="<%= $credit->purpose %>">
|
|
|
|
% end
|
2017-01-29 15:57:34 +01:00
|
|
|
% $r{category} = begin
|
|
|
|
% my $category = $credit->category // '';
|
|
|
|
<select id="category" name="category">
|
|
|
|
<option value="">-- Please select --</option>
|
|
|
|
% while ( my $c = $categories->next ) {
|
|
|
|
<option value="<%= $c->ID %>" <%== $category == $c->ID ? 'selected="selected"' :'' %>>
|
|
|
|
<%= $c->label %>
|
|
|
|
</option>
|
|
|
|
% }
|
|
|
|
</select>
|
|
|
|
% end
|
2017-01-15 16:27:22 +01:00
|
|
|
% $r{value} = begin
|
|
|
|
<input id="value" name="value" value="<%= $credit->value %>"> Cent (declare target credit with "0")
|
|
|
|
% end
|
|
|
|
% $r{account} = begin
|
|
|
|
<input id="account" name="account" value="<%= $credit->account->ID %>">
|
|
|
|
% end
|
|
|
|
|
|
|
|
<dl class="upsert">
|
|
|
|
% for my $f ( $credit->result_source->columns ) {
|
|
|
|
% my $renderer = $r{$f} // do {
|
|
|
|
% my $value = $credit->$f // next;
|
|
|
|
% begin
|
|
|
|
<%= $value %>
|
|
|
|
% end
|
|
|
|
% };
|
|
|
|
<dt><label for="<%= $f %>"><%= $f %>:</label></dt>
|
|
|
|
<dd><%= $renderer->() %></dd>
|
|
|
|
% }
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
% if ( $credit->in_storage ) {
|
|
|
|
% my $o = $credit->outgoings;
|
|
|
|
% if ( $o->count() ) {
|
|
|
|
<h2>Outgoings</h2>
|
|
|
|
<p>If you want to <strong>revoke</strong> any outgoings, please check those.</p>
|
|
|
|
<table>
|
|
|
|
<tr><th>R</th><th>timestamp</th><th>paid</th><th>value</th><th>note</th></tr>
|
|
|
|
% while ( my $t = $o->next ) {
|
|
|
|
% my $d = $t->debit;
|
|
|
|
<tr><td><input type="checkbox" name="revoke" value="<%= $t->billId %>"></td>
|
|
|
|
<td><%= $t->timestamp %></td>
|
2017-01-15 22:03:06 +01:00
|
|
|
<td><%== nl2br $d->purpose %></td>
|
|
|
|
<td class="number"><%== money $t->amount %></td>
|
2017-01-15 16:27:22 +01:00
|
|
|
<td><%= $t->note %></td>
|
|
|
|
</tr>
|
|
|
|
% }
|
|
|
|
</table>
|
|
|
|
% }
|
|
|
|
% else {
|
|
|
|
<p>Credit not used, yet.</p>
|
|
|
|
% }
|
|
|
|
% }
|
|
|
|
|
|
|
|
% my $account = stash('account');
|
|
|
|
% if ( $account //= $credit->account ) {
|
|
|
|
<h2>Spend for arrears</h2>
|
|
|
|
% my $arrears = ( ref $account ? $account : app->db->resultset("Account")->find($account) )->current_arrears;
|
|
|
|
% if ( $arrears->count() ) {
|
|
|
|
<p>Check arrears you want to <strong>use this credit</strong> for.</p>
|
|
|
|
<table>
|
|
|
|
<tr><th>S</th><th>date</th><th>purpose</th><th>to pay</th></tr>
|
|
|
|
% while ( my $d = $arrears->next ) {
|
|
|
|
<tr><td><input type="checkbox" name="spendFor" value="<%= $d->billId %>"></td>
|
|
|
|
<td><%= $d->date %></td>
|
2017-01-15 22:03:06 +01:00
|
|
|
<td><%== nl2br $d->purpose %></td>
|
|
|
|
<td class="number"><%== money $d->difference %></td>
|
2017-01-15 16:27:22 +01:00
|
|
|
</tr>
|
|
|
|
% }
|
|
|
|
</table>
|
|
|
|
% }
|
|
|
|
% else {
|
|
|
|
<p>Currently no arrears to pay.</p>
|
|
|
|
% }
|
|
|
|
% }
|
|
|
|
|
|
|
|
<button type="submit">Submit</button>
|
|
|
|
|
|
|
|
</form>
|