From 7e814fc5c668e271bd0f4d0906e5aee53187ad24 Mon Sep 17 00:00:00 2001 From: David Bourgault Date: Wed, 27 Sep 2017 10:15:57 -0400 Subject: [PATCH] Bug 5620 - Capture mode of payment in accounttype Means of payment are now captured into accountlines.accounttype. Staff users can select the mode in a dropdown menu in paycollect.tt. OPAC Paypal payment have been changed from 'note=Paypal" to mode=08 To reuse SIP logic, payment modes are represented as two digits codes, appended to the 'Pay' string. Codes are mapped as follows 00 : cash via SIP2 01 : credit card via SIP2 02 : visa via SIP2 03 : cash 04 : credit card 05 : debit 06 : check 07 : cryptocurrency 08 : paypal 00 - 02 are already in master, this patches only adds 03 - 08. Payments with no specified mode default to 'Pay', which is displayed as "Payment, thanks". Test plan: 0) Apply patch 1) Visit a test patron's profile in the staff interface 2) Add an invoice if patron has no fines 3) In the pay fines tab, pay off either all, selected or individual (they should all work) 4) Select a payment mode in the dropdown menu when asked 5) Check that payment mode is correctly displayed in staff interface and OPAC user's profile ('your fines') This obsoletes previous patches because the solution is completly different. --- C4/SIP/ILS/Transaction/FeePayment.pm | 4 ++-- Koha/Account.pm | 6 +++--- .../prog/en/modules/members/boraccount.tt | 6 ++++++ .../prog/en/modules/members/paycollect.tt | 22 ++++++++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-account.tt | 6 ++++++ members/paycollect.pl | 14 +++++++++++--- opac/opac-account-pay-paypal-return.pl | 2 +- 7 files changed, 51 insertions(+), 9 deletions(-) diff --git a/C4/SIP/ILS/Transaction/FeePayment.pm b/C4/SIP/ILS/Transaction/FeePayment.pm index fe49197..96ce291 100644 --- a/C4/SIP/ILS/Transaction/FeePayment.pm +++ b/C4/SIP/ILS/Transaction/FeePayment.pm @@ -61,7 +61,7 @@ sub pay { $account->pay( { amount => $amt, - sip => $sip_type, + mode => $sip_type, type => $type, lines => [$fee], } @@ -76,7 +76,7 @@ sub pay { $account->pay( { amount => $amt, - sip => $sip_type, + mode => $sip_type, type => $type, } ); diff --git a/Koha/Account.pm b/Koha/Account.pm index 9ec1c1b..33d0220 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -50,7 +50,7 @@ This method allows payments to be made against fees/fines Koha::Account->new( { patron_id => $borrowernumber } )->pay( { amount => $amount, - sip => $sipmode, + mode => $mode, note => $note, library_id => $branchcode, lines => $lines, # Arrayref of Koha::Account::Line objects to pay @@ -63,7 +63,7 @@ sub pay { my ( $self, $params ) = @_; my $amount = $params->{amount}; - my $sip = $params->{sip}; + my $mode = $params->{mode}; my $note = $params->{note} || q{}; my $library_id = $params->{library_id}; my $lines = $params->{lines}; @@ -176,7 +176,7 @@ sub pay { my $account_type = $type eq 'writeoff' ? 'W' - : defined($sip) ? "Pay$sip" + : defined($mode) ? "Pay$mode" : 'Pay'; my $description = $type eq 'writeoff' ? 'Writeoff' : q{}; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt index ec79237..227d763 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/boraccount.tt @@ -89,6 +89,12 @@ $(document).ready(function() { [% CASE 'Pay00' %]Payment, thanks (cash via SIP2) [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2) [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2) + [% CASE 'Pay03' %]Payment, thanks (cash) + [% CASE 'Pay04' %]Payment, thanks (credit card) + [% CASE 'Pay05' %]Payment, thanks (debit) + [% CASE 'Pay06' %]Payment, thanks (check) + [% CASE 'Pay07' %]Payment, thanks (cryptocurrency) + [% CASE 'Pay08' %]Payment, thanks (PayPal) [% CASE 'N' %]New card [% CASE 'F' %]Fine [% CASE 'A' %]Account management fee diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt index a1458b5..827c151 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/paycollect.tt @@ -147,6 +147,17 @@ function moneyFormat(textObj) { +
  • + + +
  • @@ -215,6 +226,17 @@ function moneyFormat(textObj) { +
  • + + +
  • diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt index a868d0f..8a5a4d9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-account.tt @@ -109,6 +109,12 @@ [% CASE 'Pay00' %]Payment, thanks (cash via SIP2) [% CASE 'Pay01' %]Payment, thanks (VISA via SIP2) [% CASE 'Pay02' %]Payment, thanks (credit card via SIP2) + [% CASE 'Pay03' %]Payment, thanks (cash) + [% CASE 'Pay04' %]Payment, thanks (credit card) + [% CASE 'Pay05' %]Payment, thanks (debit) + [% CASE 'Pay06' %]Payment, thanks (check) + [% CASE 'Pay07' %]Payment, thanks (cryptocurrency) + [% CASE 'Pay08' %]Payment, thanks (PayPal) [% CASE 'N' %]New card [% CASE 'F' %]Fine [% CASE 'A' %]Account management fee diff --git a/members/paycollect.pl b/members/paycollect.pl index f880f57..5d95a62 100755 --- a/members/paycollect.pl +++ b/members/paycollect.pl @@ -69,6 +69,7 @@ my $individual = $input->param('pay_individual'); my $writeoff = $input->param('writeoff_individual'); my $select_lines = $input->param('selected'); my $select = $input->param('selected_accts'); +my $paymode = $input->param('paymode') || undef; my $payment_note = uri_unescape scalar $input->param('payment_note'); my $accountlines_id; @@ -123,7 +124,8 @@ if ( $total_paid and $total_paid ne '0.00' ) { lines => [$line], amount => $total_paid, library_id => $branch, - note => $payment_note + note => $payment_note, + mode => $paymode, } ); print $input->redirect( @@ -154,13 +156,19 @@ if ( $total_paid and $total_paid ne '0.00' ) { amount => $total_paid, lines => \@lines, note => $note, + mode => $paymode, } ); } else { my $note = $input->param('selected_accts_notes'); - Koha::Account->new( { patron_id => $borrowernumber } ) - ->pay( { amount => $total_paid, note => $note } ); + Koha::Account->new( { patron_id => $borrowernumber } )->pay( + { + amount => $total_paid, + note => $note, + mode => $paymode, + } + ); } print $input->redirect( diff --git a/opac/opac-account-pay-paypal-return.pl b/opac/opac-account-pay-paypal-return.pl index 64292d4..b5c6ebf 100755 --- a/opac/opac-account-pay-paypal-return.pl +++ b/opac/opac-account-pay-paypal-return.pl @@ -104,7 +104,7 @@ if ( $response->is_success ) { { amount => $amount, lines => \@lines, - note => 'PayPal' + mode => '08'; } ); } -- 2.7.4