From: senator Date: Thu, 12 May 2011 14:15:41 +0000 (-0400) Subject: remove in-template fine-totaling: mod_perl code was already doing the same X-Git-Url: http://git.equinoxoli.org/?p=evergreen-equinox.git;a=commitdiff_plain;h=b109023db4f4bce464bad03b683dc0e55c8ecbfd remove in-template fine-totaling: mod_perl code was already doing the same also: make that fine-totaling not use floating point math. don't provide payment form for <= 0 totals (we're not issuing refunds) last copyright date in footer always current year, not hardcoded --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index a4fa51f..e9da422 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -560,9 +560,20 @@ sub load_myopac_hold_history { sub load_myopac_payment_form { my $self = shift; - my $r = $self->load_fines(undef, undef, [$self->cgi->param('xact')]); - return $r if $r; - return $self->load_extended_user_info || Apache2::Const::OK; + my $r; + + $r = $self->load_fines(undef, undef, [$self->cgi->param('xact')]) and return $r; + + # total selected fines + foreach ( + @{$self->ctx->{"fines"}->{"circulation"}}, + @{$self->ctx->{"fines"}->{"grocery"}} + ) { + } + + $r = $self->load_extended_user_info and return $r; + + return Apache2::Const::OK; } # TODO: add other filter options as params/configs/etc. @@ -631,6 +642,9 @@ sub load_fines { } ); + my @total_keys = qw/total_paid total_owed balance_owed/; + $self->ctx->{"fines"}->{@total_keys} = (0, 0, 0); + while(my $resp = $req->recv) { my $mobts = $resp->content; my $circ = $mobts->circulation; @@ -641,10 +655,10 @@ sub load_fines { $last_billing = pop(@billings); } - # XXX TODO switch to some money-safe non-fp library for math - $self->ctx->{"fines"}->{$_} += $mobts->$_ for ( - qw/total_paid total_owed balance_owed/ - ); + # XXX TODO confirm that the following, and the later division by 100.0 + # to get a floating point representation once again, is sufficiently + # "money-safe" math. + $self->ctx->{"fines"}->{$_} += int($mobts->$_ * 100) for (@total_keys); my $marc_xml = undef; if ($mobts->xact_type eq 'reservation' and @@ -669,7 +683,8 @@ sub load_fines { ); } - return; + $self->ctx->{"fines"}->{$_} /= 100.0 for (@total_keys); + return; } sub load_myopac_main { diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css index c0a9004..0ce3c8e 100644 --- a/Open-ILS/web/css/skin/default/opac/style.css +++ b/Open-ILS/web/css/skin/default/opac/style.css @@ -806,6 +806,8 @@ div.select-wrapper:hover { height: 166px; } +#myopac_sum_fines_placehold { float: right; width: 177px; height: 166px; } + .acct_holds_temp td { text-align: left; } diff --git a/Open-ILS/web/templates/default/opac/myopac/main_payment_form.tt2 b/Open-ILS/web/templates/default/opac/myopac/main_payment_form.tt2 index a70b684..b054f46 100644 --- a/Open-ILS/web/templates/default/opac/myopac/main_payment_form.tt2 +++ b/Open-ILS/web/templates/default/opac/myopac/main_payment_form.tt2 @@ -4,8 +4,15 @@ myopac_page = "main"; myopac_main_page = "payment_form"; %] +[% IF ctx.fines.balance_owed <= 0 %] +
+ [% l("You either have no fines to pay or you have selected fines whose " _ + "total is non-positive. We cannot process non-positive amounts.") %] +
+[% ELSE %]
-
+ [% FOR xact IN CGI.param('xact') %] [% END %] @@ -24,7 +31,6 @@ [% - pay_total = 0.0; FOR f IN ctx.fines.circulation; NEXT IF CGI.param('xact').size && !CGI.param('xact').grep(f.xact.id).size; @@ -33,9 +39,7 @@ PROCESS get_marc_attrs args=attrs; ELSIF f.xact.reservation; attrs.title = f.xact.reservation.target_resource_type.name; - END; - # XXX use fixed point math - pay_total = pay_total + f.xact.balance_owed; %] + END %] [% attrs.title %] [% money(f.xact.balance_owed) %] @@ -44,9 +48,7 @@ END; FOR f IN ctx.fines.grocery; NEXT IF CGI.param('xact').size && - !CGI.param('xact').grep(f.xact.id).size; - # XXX use fixed point math - pay_total = pay_total + f.xact.balance_owed; %] + !CGI.param('xact').grep(f.xact.id).size %] [% f.xact.last_billing_type %] [% money(f.xact.balance_owed) %] @@ -57,10 +59,7 @@
[% l('Total amount to pay:') %] - [%# XXX TODO: calculate pay_total not here in the - template but rather in the mod_perl, and only - proceed when that number is positive %] - [% money(pay_total) %] + [% money(ctx.fines.balance_owed) %]

[% | l('', '') %]Click [_1]Cancel[_2] to go back and (un)select other fines.[% END %] @@ -167,3 +166,4 @@
[% END %] +[% END %] diff --git a/Open-ILS/web/templates/default/opac/parts/footer.tt2 b/Open-ILS/web/templates/default/opac/parts/footer.tt2 index 70379c4..eb6db18 100644 --- a/Open-ILS/web/templates/default/opac/parts/footer.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/footer.tt2 @@ -6,7 +6,7 @@ [% l('Bottom Link 5') %] + [% IF myopac_main_page == "payment_form" %] +
+ [% ELSE %]
@@ -43,6 +46,7 @@ src="[% ctx.media_prefix %]/images/pay-fines-btn.png" class="pos-rel-top-5" />
+ [% END %]