Fixed Transfer note handling in debit and credit upsert forms.
Plus, explanation in the case that debit is settled / credit is spent so that checking further items is pointless.
This commit is contained in:
parent
e91405b041
commit
6c43accd5f
@ -71,6 +71,14 @@ sub upsert {
|
|||||||
$db->make_transfers( $self->param("billId") => $to_spend_for);
|
$db->make_transfers( $self->param("billId") => $to_spend_for);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for my $param ( grep { /^note\[/ } @{ $self->req->params->names } ) {
|
||||||
|
my $note = $self->param($param) || next;
|
||||||
|
s{^note\[}{} && s{\]$}{} for $param;
|
||||||
|
$credit->search_related(
|
||||||
|
outgoings => { billId => $param }
|
||||||
|
)->update({ note => $note });
|
||||||
|
}
|
||||||
|
|
||||||
$self->redirect_to('home');
|
$self->redirect_to('home');
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,15 +105,16 @@ sub upsert {
|
|||||||
if ( @$to_pay_with ) {
|
if ( @$to_pay_with ) {
|
||||||
my $billId = $self->param("billId");
|
my $billId = $self->param("billId");
|
||||||
$db->make_transfers( $to_pay_with => $billId );
|
$db->make_transfers( $to_pay_with => $billId );
|
||||||
for my $param ( grep { /^note\[/ } @{ $self->req->params->names } ) {
|
|
||||||
my $note = $self->param($param) || next;
|
|
||||||
s{^note\[}{} && s{\]$}{} for $param;
|
|
||||||
$db->resultset("Transfer")->find({
|
|
||||||
billId => $self->param("billId"), credId => $param
|
|
||||||
})->update({ note => $note });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for my $param ( grep { /^note\[/ } @{ $self->req->params->names } ) {
|
||||||
|
my $note = $self->param($param) || next;
|
||||||
|
s{^note\[}{} && s{\]$}{} for $param;
|
||||||
|
$debit->search_related(
|
||||||
|
incomings => { credId => $param }
|
||||||
|
)->update({ note => $note });
|
||||||
|
}
|
||||||
|
|
||||||
$self->redirect_to('home');
|
$self->redirect_to('home');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
|
||||||
|
% my %paid_debits;
|
||||||
% if ( $credit->in_storage ) {
|
% if ( $credit->in_storage ) {
|
||||||
% my $o = $credit->outgoings;
|
% my $o = $credit->outgoings;
|
||||||
% if ( $o->count() ) {
|
% if ( $o->count() ) {
|
||||||
@ -52,11 +53,12 @@
|
|||||||
<tr><th>R</th><th>timestamp</th><th>paid</th><th>value</th><th>note</th></tr>
|
<tr><th>R</th><th>timestamp</th><th>paid</th><th>value</th><th>note</th></tr>
|
||||||
% while ( my $t = $o->next ) {
|
% while ( my $t = $o->next ) {
|
||||||
% my $d = $t->debit;
|
% my $d = $t->debit;
|
||||||
|
% $paid_debits{ $t->billId } = 1;
|
||||||
<tr><td><input type="checkbox" name="revoke" value="<%= $t->billId %>"></td>
|
<tr><td><input type="checkbox" name="revoke" value="<%= $t->billId %>"></td>
|
||||||
<td><%= $t->timestamp %></td>
|
<td><%= $t->timestamp %></td>
|
||||||
<td><%== nl2br $d->purpose %></td>
|
<td><%== nl2br $d->purpose %></td>
|
||||||
<td class="number"><%== money $t->amount %></td>
|
<td class="number"><%== money $t->amount %></td>
|
||||||
<td><%= $t->note %></td>
|
<td><input type="text" name="note[<%= $t->billId %>]" value="<%= $t->note %>"></td>
|
||||||
</tr>
|
</tr>
|
||||||
% }
|
% }
|
||||||
</table>
|
</table>
|
||||||
@ -70,15 +72,18 @@
|
|||||||
% if ( $account //= $credit->account ) {
|
% if ( $account //= $credit->account ) {
|
||||||
<h2>Spend for arrears</h2>
|
<h2>Spend for arrears</h2>
|
||||||
% my $arrears = ( ref $account ? $account : app->db->resultset("Account")->find($account) )->current_arrears;
|
% my $arrears = ( ref $account ? $account : app->db->resultset("Account")->find($account) )->current_arrears;
|
||||||
% if ( $arrears->count() ) {
|
% if ( $arrears->first() ) {
|
||||||
|
<p><%= $credit->value == $credit->spent ? "The credit is already spent. Unless you revoke any outgoings above, there is no point in checking" : "Check" %> <%= %paid_debits ? "other" : "" %> debits you want to <strong>spend this credit</strong> for:</p>
|
||||||
<p>Check arrears you want to <strong>use this credit</strong> for.</p>
|
<p>Check arrears you want to <strong>use this credit</strong> for.</p>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>S</th><th>date</th><th>purpose</th><th>to pay</th></tr>
|
<tr><th>S</th><th>date</th><th>purpose</th><th>to pay</th></tr>
|
||||||
% while ( my $d = $arrears->next ) {
|
% while ( my $d = $arrears->next ) {
|
||||||
|
% next if $paid_debits{ $d->billId };
|
||||||
<tr><td><input type="checkbox" name="spendFor" value="<%= $d->billId %>"></td>
|
<tr><td><input type="checkbox" name="spendFor" value="<%= $d->billId %>"></td>
|
||||||
<td><%= $d->date %></td>
|
<td><%= $d->date %></td>
|
||||||
<td><%== nl2br $d->purpose %></td>
|
<td><%== nl2br $d->purpose %></td>
|
||||||
<td class="number"><%== money $d->difference %></td>
|
<td class="number"><%== money $d->difference %></td>
|
||||||
|
<td><input type="text" name="note[<%= $d->billId %>]"></td>
|
||||||
</tr>
|
</tr>
|
||||||
% }
|
% }
|
||||||
</table>
|
</table>
|
||||||
|
@ -73,6 +73,7 @@ oops
|
|||||||
% }
|
% }
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
% my %used_credits;
|
||||||
% if ( $debit->in_storage ) {
|
% if ( $debit->in_storage ) {
|
||||||
% my $i = $debit->incomings;
|
% my $i = $debit->incomings;
|
||||||
% if ( $i->count() ) {
|
% if ( $i->count() ) {
|
||||||
@ -82,11 +83,12 @@ oops
|
|||||||
<tr><th>R</th><th>timestamp</th><th>paid</th><th>value</th><th>note</th></tr>
|
<tr><th>R</th><th>timestamp</th><th>paid</th><th>value</th><th>note</th></tr>
|
||||||
% while ( my $t = $i->next ) {
|
% while ( my $t = $i->next ) {
|
||||||
% my $c = $t->credit;
|
% my $c = $t->credit;
|
||||||
|
% $used_credits{ $t->credId } = 1;
|
||||||
<tr><td><input type="checkbox" name="revoke" value="<%= $t->credId %>"></td>
|
<tr><td><input type="checkbox" name="revoke" value="<%= $t->credId %>"></td>
|
||||||
<td><%= $t->timestamp %></td>
|
<td><%= $t->timestamp %></td>
|
||||||
<td><%== nl2br $c->purpose %></td>
|
<td><%== nl2br $c->purpose %></td>
|
||||||
<td><%== money $t->amount %></td>
|
<td class="number"><%== money $t->amount %></td>
|
||||||
<td><%= $t->note %></td>
|
<td><input type="text" name="note[<%= $t->credId %>]" value="<%= $t->note %>"></td>
|
||||||
</tr>
|
</tr>
|
||||||
% }
|
% }
|
||||||
</table>
|
</table>
|
||||||
@ -100,16 +102,17 @@ oops
|
|||||||
% if ( $account ||= $debit->debtor ) {
|
% if ( $account ||= $debit->debtor ) {
|
||||||
<h2>Pay with credits</h2>
|
<h2>Pay with credits</h2>
|
||||||
% my $credits = app->db->resultset("Account")->find($account)->available_credits;
|
% my $credits = app->db->resultset("Account")->find($account)->available_credits;
|
||||||
% if ( $credits->count() ) {
|
% if ( $credits->first() ) {
|
||||||
<p>Check credits you want to <strong>pay this debit</strong> with.</p>
|
<p><%= $debit->value == $debit->value ? "The debt is already settled. Unless you revoke any incomings above, there is no point in checking" : "Check" %> <%= %used_credits ? "other" : "" %> credits you want to <strong>pay this debit</strong> with:</p>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>S</th><th>date</th><th>purpose</th><th>to spend</th><th>note</th></tr>
|
<tr><th>S</th><th>date</th><th>purpose</th><th>to spend</th><th>note</th></tr>
|
||||||
% while ( my $d = $credits->next ) {
|
% while ( my $c = $credits->next ) {
|
||||||
<tr><td><input type="checkbox" name="payWith" value="<%= $d->credId %>"></td>
|
% next if $used_credits{ $c->credId };
|
||||||
<td><%= $d->date %></td>
|
<tr><td><input type="checkbox" name="payWith" value="<%= $c->credId %>"></td>
|
||||||
<td><%== nl2br $d->purpose %></td>
|
<td><%= $c->date %></td>
|
||||||
<td><%== money $d->difference %></td>
|
<td><%== nl2br $c->purpose %></td>
|
||||||
<td><input type="text" name="note[<%= $d->credId %>]"></td>
|
<td><%== money $c->difference %></td>
|
||||||
|
<td><input type="text" name="note[<%= $c->credId %>]"></td>
|
||||||
</tr>
|
</tr>
|
||||||
% }
|
% }
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user