From: senator Date: Wed, 11 May 2011 20:02:12 +0000 (-0400) Subject: Payment for mostly done. Still needs: X-Git-Url: http://git.equinoxoli.org/?p=evergreen-equinox.git;a=commitdiff_plain;h=ab4a93c35dafb410162df844e1473c99e440a8a2 Payment for mostly done. Still needs: 1) to be able to handle the upper "Pay Fines" button that will mean "all my fines" 2) to use fixed point fine totaling math and bail on total <= 0 3) ... anything else? --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 18ed515..8a8bc70 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -121,6 +121,7 @@ sub load { return $self->load_place_hold if $path =~ m|opac/place_hold|; return $self->load_myopac_holds if $path =~ m|opac/myopac/holds|; return $self->load_myopac_circs if $path =~ m|opac/myopac/circs|; + return $self->load_myopac_payment_form if $path =~ m|opac/myopac/main_payment_form|; return $self->load_myopac_payments if $path =~ m|opac/myopac/main_payments|; return $self->load_myopac_main if $path =~ m|opac/myopac/main|; return $self->load_myopac_update_email if $path =~ m|opac/myopac/update_email|; 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 f8622b5..171fa39 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -8,10 +8,7 @@ use OpenILS::Application::AppUtils; use OpenSRF::Utils::JSON; my $U = 'OpenILS::Application::AppUtils'; - -# context additions: -# user : au object, fleshed -sub load_myopac_prefs { +sub load_extended_user_info { my $self = shift; $self->ctx->{user} = $self->editor->retrieve_actor_user([ @@ -19,13 +16,20 @@ sub load_myopac_prefs { { flesh => 1, flesh_fields => { - au => [qw/card home_ou addresses ident_type/] + au => [qw/card home_ou addresses ident_type billing_address/] # ... } } - ]); + ]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; - return Apache2::Const::OK; + return; +} + +# context additions: +# user : au object, fleshed +sub load_myopac_prefs { + my $self = shift; + return $self->load_extended_user_info || Apache2::Const::OK; } sub load_myopac_prefs_notify { @@ -102,22 +106,9 @@ sub update_optin_prefs { sub load_myopac_prefs_settings { my $self = shift; - - $self->ctx->{user} = $self->editor->retrieve_actor_user([ - $self->ctx->{user}->id, - { - flesh => 1, - flesh_fields => { - au => [qw/card home_ou addresses ident_type/] - # ... - } - } - ]); - - return Apache2::Const::OK; + return $self->load_extended_user_info || Apache2::Const::OK; } - sub fetch_user_holds { my $self = shift; my $hold_ids = shift; @@ -567,6 +558,13 @@ sub load_myopac_hold_history { return Apache2::Const::OK; } +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; +} + # TODO: add other filter options as params/configs/etc. sub load_myopac_payments { my $self = shift; @@ -589,16 +587,12 @@ sub load_myopac_payments { return Apache2::Const::OK; } +sub load_fines { + my ($self, $limit, $offset, $id_list) = @_; + # XXX TODO: check for failure after various network calls -sub load_myopac_main { - my $self = shift; - my $limit = $self->cgi->param('limit') || 0; - my $offset = $self->cgi->param('offset') || 0; - my $e = $self->editor; - my $ctx = $self->ctx; - - $ctx->{"fines"} = { + $self->ctx->{"fines"} = { "circulation" => [], "grocery" => [], "total_paid" => 0, @@ -606,7 +600,6 @@ sub load_myopac_main { "balance_owed" => 0 }; - my $cstore = OpenSRF::AppSession->create('open-ils.cstore'); # TODO: This should really be a ML call, but the existing calls @@ -617,8 +610,9 @@ sub load_myopac_main { my $req = $cstore->request( 'open-ils.cstore.direct.money.open_billable_transaction_summary.search', { - usr => $e->requestor->id, - balance_owed => {'!=' => 0} + usr => $self->editor->requestor->id, + balance_owed => {'!=' => 0}, + (ref $id_list eq 'ARRAY' ? ("id" => $id_list) : ()), }, { flesh => 4, @@ -648,7 +642,7 @@ sub load_myopac_main { } # XXX TODO switch to some money-safe non-fp library for math - $ctx->{"fines"}->{$_} += $mobts->$_ for ( + $self->ctx->{"fines"}->{$_} += $mobts->$_ for ( qw/total_paid total_owed balance_owed/ ); @@ -666,7 +660,7 @@ sub load_myopac_main { } push( - @{$ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}}, + @{$self->ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}}, { xact => $mobts, last_grocery_billing => $last_billing, @@ -675,8 +669,16 @@ sub load_myopac_main { ); } - return Apache2::Const::OK; -} + return; +} + +sub load_myopac_main { + my $self = shift; + my $limit = $self->cgi->param('limit') || 0; + my $offset = $self->cgi->param('offset') || 0; + + return $self->load_fines($limit, $offset) || Apache2::Const::OK; +} sub load_myopac_update_email { my $self = shift; diff --git a/Open-ILS/web/templates/default/opac/myopac/main.tt2 b/Open-ILS/web/templates/default/opac/myopac/main.tt2 index b187f0d..3a4bc04 100644 --- a/Open-ILS/web/templates/default/opac/myopac/main.tt2 +++ b/Open-ILS/web/templates/default/opac/myopac/main.tt2 @@ -4,7 +4,7 @@ myopac_page = "main"; myopac_main_page = "main"; %] -
+ [% IF ctx.fines.circulation.size > 0 %]
@@ -77,7 +77,8 @@ [% END %] @@ -141,7 +142,8 @@ [% END %] diff --git a/Open-ILS/web/templates/default/opac/myopac/main_pay.tt2 b/Open-ILS/web/templates/default/opac/myopac/main_pay.tt2 deleted file mode 100644 index ff9b512..0000000 --- a/Open-ILS/web/templates/default/opac/myopac/main_pay.tt2 +++ /dev/null @@ -1,158 +0,0 @@ -[% PROCESS "default/opac/parts/header.tt2"; - PROCESS "default/opac/parts/misc_util.tt2"; - WRAPPER "default/opac/parts/myopac/main_base.tt2"; - myopac_page = "main"; - myopac_main_page = "pay"; - - # XXX When we get no parameters, we're in "pay everything" mode. - # When we get paramters, they refer to the fines that we'll be paying -%] -
-
- +
[% f.xact.last_billing_type %] - +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [% INCLUDE "default/opac/myopac/main_refund_policy.tt2" %] - -
Billing Information - Selected fines you are paying for: - - - - - - - - - -
- Name - - Amount -
-
-
- Total amount to pay: - $ -
-
- Click Cancel to go back and (un)select - other fines. -
First Name
Last Name
Street Address
City
State or Province
ZIP or Postal Code
Credit Card Information
Credit Card #
-
-
- -
-
- Security Code -
- -
Exipration Month - -
Expiration Year - -
Edit Billing Address - -
- - -
-
-[% END %] 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 new file mode 100644 index 0000000..587c01b --- /dev/null +++ b/Open-ILS/web/templates/default/opac/myopac/main_payment_form.tt2 @@ -0,0 +1,167 @@ +[% PROCESS "default/opac/parts/header.tt2"; + PROCESS "default/opac/parts/misc_util.tt2"; + WRAPPER "default/opac/parts/myopac/main_base.tt2"; + myopac_page = "main"; + myopac_main_page = "payment_form"; +%] +
+ + [% FOR xact IN CGI.param('xact') %] + + [% END %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [% INCLUDE "default/opac/myopac/main_refund_policy.tt2" %] + +
[% l('Billing Information') %] + [% l('Selected fines you are paying for:') %] + + + + + + + + + [% + pay_total = 0.0; + FOR f IN ctx.fines.circulation; + NEXT UNLESS CGI.param('xact').grep(f.xact.id).size; + attrs = {marc_xml => f.marc_xml}; + IF f.marc_xml; + 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; + FOR f IN ctx.fines.grocery; + NEXT UNLESS CGI.param('xact').grep(f.xact.id).size; + # XXX use fixed point math + pay_total = pay_total + f.xact.balance_owed; %] + + + + + [% END %] + +
[% l('Name') %][% l('Amount') %]
[% attrs.title %][% money(f.xact.balance_owed) %]
[% f.xact.last_billing_type %][% money(f.xact.balance_owed) %]
+
+
+ [% 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) %] +
+
+ [% | l('', '') %]Click [_1]Cancel[_2] to go back and (un)select other fines.[% END %] +
[% l('First Name') %]
[% l('Last Name') %]
[% l('Street Address') %]
[% l('City' )%]
[% l('State or Province') %]
[% l('ZIP or Postal Code') %]
[% l('Credit Card Information') %]
[% l('Credit Card #') %]
+
+
+ +
+
+ [% l('Security Code') %] +
+ +
[% l('Exipration Month') %] + +
[% l('Expiration Year') %] + +
+ + +
+ +
+[% END %] diff --git a/Open-ILS/web/templates/default/opac/parts/myopac/main_base.tt2 b/Open-ILS/web/templates/default/opac/parts/myopac/main_base.tt2 index da0a088..2115655 100644 --- a/Open-ILS/web/templates/default/opac/parts/myopac/main_base.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/myopac/main_base.tt2 @@ -36,7 +36,7 @@ [% money(ctx.user_stats.fines.balance_owed) %]
-