diff --git a/TrsrDB/HTTP.pm b/TrsrDB/HTTP.pm
index 155ce5b..556f871 100644
--- a/TrsrDB/HTTP.pm
+++ b/TrsrDB/HTTP.pm
@@ -32,6 +32,16 @@ sub startup {
user => undef,
);
+ $self->helper(money => sub {
+ my (undef, $cent) = @_;
+ return if !defined $cent;
+ my $c100 = $cent =~ s{ (\d{0,2}) \z }{}xms && sprintf("%02d", $1);
+ $cent ||= 0;
+ return qq{$cent.$c100};
+ });
+ $self->helper(nl2br => sub {
+ pop =~ s{\n}{
}grms;
+ });
if ( my $l = $ENV{LOG} ) {
use Mojo::Log;
@@ -53,6 +63,13 @@ sub startup {
$auth->get( '/logout' )->to("user#logout");
+ my $check = $auth->under(sub { shift->stash('grade') })->get('/');
+ $check->get('/bankStatement' => sub {
+ my $c = shift;
+ $c->stash( records => $c->app->db->resultset("ReconstructedBankStatement") );
+ $c->render('bankStatement');
+ });
+
my $admin = $auth->under(sub { shift->stash('grade') > 1 });
$admin->any('/admin')->to('admin#dash');
$admin->post('/:account/in')->to('credit#upsert');
@@ -68,13 +85,6 @@ sub startup {
$auth->get('/')->to('account#list')->name('home');
- my $check = $auth->under(sub { shift->stash('grade') })->get('/');
- $check->get('/bankStatement')->to(sub {
- my $c = shift;
- $c->stash( records => $c->app->db->resultset("ReconstructedBankStatement") );
- $c->render('bankStatement');
- });
-
my $account = $auth->get('/:account')->under(sub {
my $c = shift;
diff --git a/TrsrDB/HTTP/Account.pm b/TrsrDB/HTTP/Account.pm
index 5811f60..21b2f24 100644
--- a/TrsrDB/HTTP/Account.pm
+++ b/TrsrDB/HTTP/Account.pm
@@ -31,13 +31,15 @@ sub transfer {
my $db = $self->app->db;
my $account = $db->resultset("Account")->find( $self->stash("account") );
- if ( $self->req->method eq 'GET' ) {
- $self->stash(
- credits => $account->available_credits_rs,
- arrears => $account->current_arrears_rs,
- );
- return;
- }
+ my $credits = $account->available_credits;
+ my $arrears = $account->current_arrears;
+
+ return $self->redirect_to('home')
+ if !( $credits->count() && $arrears->count() );
+
+ $self->stash( credits => $credits, arrears => $arrears );
+
+ return if $self->req->method ne 'POST';
$db->make_transfers(
$self->every_param('credits')
@@ -47,5 +49,19 @@ sub transfer {
return;
}
+
+sub report {
+ my $self = shift;
+ my $account = $self->app->db
+ ->resultset("Account")
+ ->find( $self->stash("account") )
+ ;
+
+ $self->stash( report => $account->report->search_rs(
+ {}, { order_by => { -asc => [qw/date/] } }
+ ) );
+
+}
+
1;
diff --git a/site/style.css b/site/style.css
index b393a67..51d020c 100644
--- a/site/style.css
+++ b/site/style.css
@@ -42,6 +42,7 @@ a.transfer-btn {
font-weight: bold;
border: 2px outset rgb(224,32,0);
text-decoration: none;
+ border-radius: 3px;
}
table td.even_until {
diff --git a/t/schema.sh b/t/schema.sh
index 87397d9..e967d83 100644
--- a/t/schema.sh
+++ b/t/schema.sh
@@ -1,4 +1,7 @@
echo "My database file: $1"
if sqlite3 $1 < schema.sql; then
- diff t/schema.out <(sqlite3 $1 < t/schema.sql 2>&1)
+ diff t/schema.out <(sqlite3 $1 < t/schema.sql 2>&1) \
+ && rm $1 && sqlite3 $1 < t/schema.sql \
+ && TRSRDB_SQLITE_FILE=$1 perl t/schema.t \
+ && rm -i $1
fi
diff --git a/templates/account/history.html.ep b/templates/account/history.html.ep
index e686e65..15aeeee 100644
--- a/templates/account/history.html.ep
+++ b/templates/account/history.html.ep
@@ -7,10 +7,10 @@
% while ( my $hr = $history->next ) {
Date | Value | Purpose |
---|---|---|
<%= $record->date %> | <%== money $record->value %> | <%== nl2br $record->purpose %> |
Check at least one item of each table that belong together.
@@ -6,34 +6,33 @@Check credits you want to pay above debit(s) with.
+Check credits you want to spend for the arrear(s) below with.
S | date | purpose | to spend | ||
---|---|---|---|---|---|
? | date | purpose | to spend | ||
<%= $d->date %> | -<%= $d->purpose %> | -<%= $d->difference %> | +<%== nl2br $d->purpose %> | +<%== money $d->difference %> |
Check arrears you want to use this credit for.
+Check arrears you want to settle with credit(s) above.
S | date | purpose | to pay | ||
---|---|---|---|---|---|
? | date | purpose | to pay | ||
<%= $d->date %> | -<%= $d->purpose %> | -<%= $d->difference %> | +<%== nl2br $d->purpose %> | +<%== money $d->difference %> |
Date | Account | Purpose | Debit | Credit |
---|---|---|---|---|
Date | Purpose | Account | Debit | Credit |
<%= $record->date %> | <%= $record->account %> | <%= $record->purpose %> | <%= $record->debit %> | <%= $record->credit %> |
<%= $record->date %> | <%= $record->purpose %> | <%= $record->account %> | <%= $record->debit %> | <%= $record->credit %> |
Id | Date | Purpose | value | spent |
---|---|---|---|---|
<%= $credit->credId %> | <%= $credit->date %> | <%= $credit->purpose %> | <%= $credit->value %> | <%= $credit->spent %> |
<%= $credit->credId %> | <%= $credit->date %> | <%== nl2br $credit->purpose %> | <%== money $credit->value %> | <%== money $credit->spent %> |