Various fixes and completing the HTTP interface
This commit is contained in:
@@ -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{<strong>$cent</strong>.$c100};
|
||||
});
|
||||
$self->helper(nl2br => sub {
|
||||
pop =~ s{\n}{<br>}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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user