Fixes to avoid a warning when IBAN is null, in look and redirection

This commit is contained in:
Florian "flowdy" Heß 2017-02-06 08:12:56 +01:00
parent bb05b06cf3
commit 1a05fd4d54
13 changed files with 85 additions and 34 deletions

View File

@ -88,7 +88,7 @@ sub startup {
$check->get('/bankStatement' => sub { $check->get('/bankStatement' => sub {
my $c = shift; my $c = shift;
my $records = $c->app->db->resultset("ReconstructedBankStatement") my $records = $c->app->db->resultset("ReconstructedBankStatement")
->search( process_table_filter_widget($c) ); ->search( process_table_filter_widget($c, {}, { order => 'date' }) );
$c->stash( records => $records ); $c->stash( records => $records );
$c->render('bankStatement'); $c->render('bankStatement');
}); });
@ -339,7 +339,7 @@ sub process_table_filter_widget {
sub _get_trace_placeholder { \<<'EOF' sub _get_trace_placeholder { \<<'EOF'
In this area, the server can trace SQL commands executed to fulfill your request. If the admin wants that, they can run the server with environment variable DBIC_TRACE=1. In this area, the server can trace SQL commands executed to fulfill your request. If the admin wants that, they can run the server with environment variable DBIC_TRACE=1.
All substantial logic of Treasure DB is done in the scope of the database itself. In consequence, you could do without this HTTP interface and input all SQL commands shown here directly in a general-purpose SQLite3 user interface. Thus you will get roughly the same results. All substantial logic of Treasure DB is realized as triggers and views right in the database file. In consequence, you could do without this HTTP interface and input all SQL commands directly in a general-purpose SQLite3 user interface. Thus you would get essentially the same results, except they do not look as nice.
EOF EOF
} }
1; 1;

View File

@ -43,7 +43,7 @@ sub upsert {
if ( $self->req->method eq 'POST' ) { if ( $self->req->method eq 'POST' ) {
my $p = $self->req->params->to_hash; my $p = $self->req->params->to_hash;
if ( $p->{IBAN} eq q{*} ) { if ( ($p->{IBAN}//q{}) eq q{*} ) {
$p->{IBAN} = q{}; $p->{IBAN} = q{};
} }
elsif ( !$iban ) { elsif ( !$iban ) {

View File

@ -15,10 +15,17 @@ h1 {
table { table {
border-collapse: collapse; border-collapse: collapse;
width:100%;
} }
table td, table th { table td, table th {
border: 1px solid darkgrey; border: 1px solid darkgrey;
vertical-align: top;
}
table.accounts tr.group-heading th {
border:none;
vertical-align:middle;
} }
table tr:nth-child(even) { table tr:nth-child(even) {
@ -44,12 +51,22 @@ table td.number {
text-align: right; text-align: right;
font-family: monospace, monospace; /* Hack to prevent browser default size reduction of monospace font */ font-family: monospace, monospace; /* Hack to prevent browser default size reduction of monospace font */
font-size:1em; font-size:1em;
vertical-align: bottom;
} }
table td.mark { table td.mark {
background-color:rgba(255,0,0,0.1); background-color:rgba(255,0,0,0.1);
} }
table td input {
width:100%;
box-sizing: border-box;
}
form {
margin: 1em 0;
}
a.transfer-btn { a.transfer-btn {
background-color:rgba(224,32,0,0.4); background-color:rgba(224,32,0,0.4);
font-weight: bold; font-weight: bold;
@ -73,6 +90,9 @@ input, textarea {
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 2px; padding: 2px;
} }
input[type=checkbox], input[type=radio] {
border: none;
}
dl dt { dl dt {
float: left; float: left;
@ -117,3 +137,17 @@ img.icon {
color: darkgrey; color: darkgrey;
text-align: center; text-align: center;
} }
a.add-item-btn:link,
a.add-item-btn:visited {
display: block;
float: right;
font-variant: small-caps;
background-color: #eee;
border: 2px outset grey;
padding: 3px;
border-radius: 3px;
text-decoration: none;
color: inherit;
font-weight:normal;
}

View File

@ -9,12 +9,15 @@
% my $that = $hr->that_credit; % my $that = $hr->that_credit;
% my $this = $hr->this_credit; % my $this = $hr->this_credit;
% my $credit_ref = begin % my $credit_ref = begin
%== sprintf q{<strong>%s</strong><a href="/credit/%2$d">%d</a>}, shift() ? ($that->account->ID.q{.}, $that->credId) : (q{}, $this->credId) % my $that_acc = $that && $that->account;
% my $that_account_id = $that ? $that_acc->ID : q{(out)};
% my $that_credit_id = $that ? $that->credId : "";
%== sprintf q{<strong>%s</strong><a href="/credit/%2$d">%d</a>}, shift() ? ($that_account_id.q{:}, $that_credit_id) : (q{}, $this->credId)
% end % end
<p><strong><a href="/debit/<%= $hr->billId %>"><%= $hr->billId %></a>:</strong> <%= $hr->purpose %> &rarr; <%== $credit_ref->($hr->debit) %></p> <p><strong><a href="/debit/<%= $hr->billId %>"><%= $hr->billId %></a>:</strong> <%== nl2br $hr->purpose %> &rarr; <%== $credit_ref->($hr->debit) %></p>
<p class="linked-credit">from <%= $credit_ref->($hr->credit) %>, <%= $hr->credit ? $that->purpose : $this->purpose %> <p class="linked-credit">&uarr; <%= $credit_ref->($hr->credit) =%>, <%= $hr->credit ? $that->purpose : $this->purpose %>
% if ( $hr->note ) { % if ( $hr->note ) {
<br>Note: <%= $hr->note %> <br><em>Note: <%= $hr->note %></em>
% } % }
</p> </p>
</td><td class="number"><%== money $hr->debit %></td><td class="number"><%== money $hr->credit %></td></tr> </td><td class="number"><%== money $hr->debit %></td><td class="number"><%== money $hr->credit %></td></tr>

View File

@ -6,8 +6,8 @@
% my ($type) = q{}; % my ($type) = q{};
% my $inter_header = begin % my $inter_header = begin
% my $group = shift; % my $group = shift;
<tr><th colspan="11"><%= $group || 'Club management accounts' %></th> <tr class="group-heading"><th colspan="11"><%= $group || 'Club management accounts' %></th>
<th colspan="2"><a href="/debit?group=<%= $group %>"><img class="icon" src="/add-debit.svg" alt="Charge"> all at once</a></th></tr> <th colspan="2"><a class="add-item-btn" href="/debit?group=<%= $group %>"><img class="icon" src="/add-debit.svg" alt="Charge"> all at once</a></th></tr>
% end % end
% while ( my $account = $accounts->next ) { % while ( my $account = $accounts->next ) {
% my $bal = $account->balance; % my $bal = $account->balance;
@ -22,36 +22,35 @@
<td class="centered"> <td class="centered">
% my $which = ($bal->arrears && 1) + ($bal->available && 1); % my $which = ($bal->arrears && 1) + ($bal->available && 1);
% if ( $which == 2 ) { % if ( $which == 2 ) {
<a href="<%= $u %>/transfer"><img class="icon" src="/transfer.svg"></a> <a href="<%= $u %>/transfer"><img class="icon" src="/transfer.svg" alt="ready"></a>
% } % }
% elsif ( $which ) { % elsif ( $which ) {
<%== $bal->arrears ? q{} : q{&nbsp;} %> <%== $bal->arrears ? q{} : q{&nbsp;} %>
<img class="icon" src="/wait.svg" style="cursor:not-allowed;"> <img class="icon" src="/wait.svg" style="cursor:not-allowed;" alt="wait">
<%== $bal->available ? q{} : q{&nbsp;} %> <%== $bal->available ? q{} : q{&nbsp;} %>
% } % }
% else { % else {
<img class="icon" src="/even.svg" style="cursor:not-allowed;"> <img class="icon" src="/even.svg" style="cursor:not-allowed;" alt="even">
% } % }
</td><td class="number"><%== money $bal->available %></td><td><a href="<%= $u %>/credits"><img class="icon" alt="List" src="/list.svg" alt="List"></a></td><td><a title="Add a credit" href="<%= $u %>/in"><img class="icon" src="/add-credit.svg" alt="Credit"></a></td><td class="number"><%== money $bal->earned %></td><td class="number"><%== money $bal->promised %></td><td><a href="<%= $u %>/history">History</a></td><td><a href="<%= $u %>/report">Report</a></td></tr> </td><td class="number"><%== money $bal->available %></td><td><a href="<%= $u %>/credits"><img class="icon" alt="List" src="/list.svg" alt="List"></a></td><td><a title="Add a credit" href="<%= $u %>/in"><img class="icon" src="/add-credit.svg" alt="Credit"></a></td><td class="number"><%== money $bal->earned %></td><td class="number"><%== money $bal->promised %></td><td><a href="<%= $u %>/history">History</a></td><td><a href="<%= $u %>/report">Report</a></td></tr>
% } # while % } # while
</table> </table>
% stash links => [ '/account' => "Create account", '/bankStatement' => "Reconstructed bank statement" ]; % stash links => [ '/account' => "Create account", '/bankStatement' => "Reconstructed bank statement" ];
% my $help = begin % stash help => $_ for begin
<h2>Column explanation</h2> <h2>Column explanation</h2>
<dl> <dl>
<dt>Even till:</dt> <dt>Even until</dt>
<dd><p>Date of debt up to and including which all is settled.</p></dd> <dd>Date of the debt/bill up to and including which all is settled. Within each group (i.e. account type), accounts are ordered by this ascending date.</dd>
<dt>Arrears:</dt> <dt>Arrears</dt>
<dd><p>Unpaid debits</p></dd> <dd>Debits or partial amounts of which are still outstanding</dd>
<dt>Transfer:</dt> <dt>Transfer</dt>
<dd><p>Link to a view where you can match credit and debit and have the software transfer money in between automatically. Yellow "N/A" means there is no money to transfer as either credit or debit is 0. Green "N/A" means there is no money to transfer because the account is even.</p></dd> <dd>View of credit and debit for you to match and have the software transfer money in between automatically. <img class="icon" src="/transfer.svg" alt="ready"> means you need to take action. <img class="icon" src="/wait.svg" style="cursor:not-allowed;" alt="wait"> means there is no money to transfer as either credit or debit is 0, or <img class="icon" src="/even.svg" style="cursor:not-allowed;" alt="even"> if the account is even.</dd>
<dt>Available:</dt> <dt>Available</dt>
<dd><p>Credits that have not been used or not to full extent, yet</p></dd> <dd>Credits that have not been used or not to full extent, yet</dd>
<dt>Earned:</dt> <dt>Earned</dt>
<dd><p>Paid debits targetting credits of that account.</p></dd> <dd>Paid debits targetting credits of that account.</dd>
<dt>Promised:</dt> <dt>Promised</dt>
<dd><p>Unpaid or not fully paid debits targetting credits of that account.</p></dd> <dd>Unpaid or not fully paid debits targetting credits of that account.</dd>
</dl> </dl>
% end % end
% stash help => $help;

View File

@ -7,5 +7,5 @@
% $total += $record->value; % $total += $record->value;
<tr><td><%= $record->date %></td><td class="number"><%== money $record->value %></td><td><%== nl2br $record->purpose %></td></tr> <tr><td><%= $record->date %></td><td class="number"><%== money $record->value %></td><td><%== nl2br $record->purpose %></td></tr>
% } % }
<tr><td style="text-align:right;">In total:</td><td class="number"><%== money $total %></td></tr> <tr style="border-top: 2px solid black"><td style="text-align:right;">In total:</td><td class="number"><%== money $total %></td></tr>
</table> </table>

View File

@ -17,7 +17,7 @@
<input id="IBAN" name="IBAN" value="<%= $account->IBAN %>"> (may also be empty or '*' s. help) <input id="IBAN" name="IBAN" value="<%= $account->IBAN %>"> (may also be empty or '*' s. help)
% end % end
<form method="post"> <form action="<%= url_for %>" method="post">
<dl class="upsert"> <dl class="upsert">
% for my $f ( $account->result_source->columns ) { % for my $f ( $account->result_source->columns ) {

View File

@ -6,9 +6,17 @@
% while ( my $record = $records->next ) { % while ( my $record = $records->next ) {
% $total_credit += $record->credit; % $total_credit += $record->credit;
% $total_debit += $record->debit; % $total_debit += $record->debit;
<tr><td><%= $record->date %></td><td><%= $record->purpose %></td><td><%= $record->account %></td><td class="number"><%== money $record->debit %></td><td class="number"><%== money $record->credit %></td></tr> % $total_credit -= $total_debit;
% if ( $total_credit > 0 ) {
% $total_debit = 0;
% }
% if ( $total_credit < 0 ) {
% $total_debit = abs $total_credit;
% $total_credit = 0;
% }
<tr><td><%= $record->date %></td><td><%== nl2br $record->purpose %></td><td><%= $record->account %></td><td class="number"><%== money $record->debit %></td><td class="number"><%== money $record->credit %></td></tr>
% } % }
<tr><td colspan="3" style="text-align:right;">Current balance:</td><td class="number"><%== $total_debit ? money $total_debit : '' %></td><td class="number"><%== $total_credit ? money $total_credit : '' %></td> <tr style="border-top:2px solid black;"><td colspan="3" style="text-align:right;">Current balance:</td><td class="number" style="color:red;"><%== $total_debit ? money $total_debit : '' %></td><td class="number"><%== $total_credit ? money $total_credit : '' %></td>
</table> </table>
%= include 'filter-widget' %= include 'filter-widget'

View File

@ -1,5 +1,6 @@
% title 'Income of ' . $account; % title 'Income of ' . $account;
<a class="add-item-btn" href="/<%= $account %>/in"><img src="/add-credit.svg" class="icon" alt=""> Add credit</a>
<p>Listed in reverse order:</p> <p>Listed in reverse order:</p>
<table class="income"> <table class="income">

View File

@ -1,7 +1,7 @@
% my $id = stash 'id'; % my $id = stash 'id';
% title $id ? "Change credit $id" : "Enter new credit"; % title $id ? "Change credit $id" : "Enter new credit";
<form method="post"> <form class="<%= url_for %>" method="post">
<h2>Essentials</h2> <h2>Essentials</h2>
% my %r; % my %r;
@ -23,7 +23,7 @@
</select> </select>
% end % end
% $r{value} = begin % $r{value} = begin
<input id="value" name="value" value="<%= $credit->value %>"> Cent (declare target credit with "0") <input id="value" name="value" value="<%= $credit->value %>"> Cent (target credit? See <a href="#help">help</a>)
% end % end
% $r{account} = begin % $r{account} = begin
<%= $credit->account->ID %> <%= $credit->account->ID %>
@ -95,3 +95,8 @@
<p><button type="submit">Submit</button></p> <p><button type="submit">Submit</button></p>
</form> </form>
% stash help => $_ for begin
<h2>How to declare a target credit?</h2>
<p>A target credit can be declared by assigning it an initial value of 0 (zero).</p>
% end

View File

@ -1,5 +1,6 @@
% title 'Outcome of ' . $account; % title 'Outcome of ' . $account;
<a class="add-item-btn" href="/<%= $account %>/out"><img src="/add-debit.svg" class="icon" alt=""> Add debit</a>
<p>Listed in reverse order:</p> <p>Listed in reverse order:</p>
<table class="income"> <table class="income">

View File

@ -1,7 +1,7 @@
% my $id = stash 'id'; % my $id = stash 'id';
% title $id ? "Change debit $id" : "Enter new debit"; % title $id ? "Change debit $id" : "Enter new debit";
<form method="post"> <form action="<%= url_for %>" method="post">
<h2>Essentials</h2> <h2>Essentials</h2>
% my %r; % my %r;

View File

@ -39,7 +39,7 @@
% } % }
% if ( defined $sql ) { % if ( defined $sql ) {
<div class="targettable" id="sql"> <div class="targettable" id="sql">
<p>Please note that, to run the SQL commands directly in another tool, you might need to resolve the prepared statements manually. Just replace all question marks by the values listed after the colon in each line.</p> <p>Please note that if you want to run the SQL commands directly in another tool, you might need to resolve the prepared statements manually. Just replace all question marks by the values listed after the colon in each line.</p>
<textarea rows="5" style="width:100%;border:1px inset lightgrey;" readonly="readonly"> <textarea rows="5" style="width:100%;border:1px inset lightgrey;" readonly="readonly">
%== $$sql %== $$sql
</textarea></div> </textarea></div>