use vars qw(@ISA @EXPORT);
BEGIN {
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT = qw(
- &manualinvoice
- &getnextacctno
- &getcharges
- &ModNote
- &getcredits
- &getrefunds
- &chargelostitem
- &ReversePayment
- &WriteOffFee
- &purge_zero_balance_fees
- );
+ require Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(
+ &manualinvoice
+ &getnextacctno
+ &getcharges
+ &ModNote
+ &getcredits
+ &getrefunds
+ &chargelostitem
+ &ReversePayment
+ &purge_zero_balance_fees
+ );
}
=head1 NAME
}
-=head2 WriteOffFee
-
- WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
-
-Write off a fine for a patron.
-C<$borrowernumber> is the patron's borrower number.
-C<$accountline_id> is the accountline_id of the fee to write off.
-C<$itemnum> is the itemnumber of of item whose fine is being written off.
-C<$accounttype> is the account type of the fine being written off.
-C<$amount> is a floating-point number, giving the amount that is being written off.
-C<$branch> is the branchcode of the library where the writeoff occurred.
-C<$payment_note> is the note to attach to this payment
-
-=cut
-
-sub WriteOffFee {
- my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_;
-
- my $line = Koha::Account::Lines->find($accountlines_id);
- return Koha::Account->new( { patron_id => $borrowernumber } )->pay(
- {
- amount => $amount,
- lines => [$line],
- type => 'writeoff',
- note => $payment_note,
- library_id => $branch,
- }
- );
-}
-
=head2 purge_zero_balance_fees
purge_zero_balance_fees( $days );
writeoff_all(@names);
} elsif ($writeoff_item) {
my $accountlines_id = $input->param('accountlines_id');
- my $itemno = $input->param('itemnumber');
- my $account_type = $input->param('accounttype');
my $amount = $input->param('amountoutstanding');
my $payment_note = $input->param("payment_note");
- WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch, $payment_note );
+
+ Koha::Account->new( { patron_id => $borrowernumber } )->pay(
+ {
+ amount => $amount,
+ lines => [Koha::Account::Lines->find($accountlines_id)],
+ type => 'writeoff',
+ note => $payment_note,
+ library_id => $branch,
+ }
+ );
}
for (@names) {
sub get_for_redirect {
my ( $name, $name_in, $money ) = @_;
my $s = q{&} . $name . q{=};
- my $value = $input->param($name_in);
+ my $value = uri_escape_utf8( $input->param($name_in) );
if ( !defined $value ) {
$value = ( $money == 1 ) ? 0 : q{};
}
$redirect .= get_for_redirect( 'amount', "amount$line_no", 1 );
$redirect .=
get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
- $redirect .= uri_escape_utf8( get_for_redirect( 'description', "description$line_no", 0 ) );
- $redirect .= uri_escape_utf8( get_for_redirect( 'title', "title$line_no", 0 ) );
+ $redirect .= get_for_redirect( 'description', "description$line_no", 0 );
+ $redirect .= get_for_redirect( 'title', "title$line_no", 0 );
$redirect .= get_for_redirect( 'itemnumber', "itemnumber$line_no", 0 );
$redirect .= get_for_redirect( 'notify_id', "notify_id$line_no", 0 );
$redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
sub writeoff_all {
my @params = @_;
my @wo_lines = grep { /^accountlines_id\d+$/ } @params;
+
+ my $borrowernumber = $input->param('borrowernumber');
+
for (@wo_lines) {
if (/(\d+)/) {
- my $value = $1;
- my $accounttype = $input->param("accounttype$value");
-
- # my $borrowernum = $input->param("borrowernumber$value");
- my $itemno = $input->param("itemnumber$value");
- my $amount = $input->param("amountoutstanding$value");
+ my $value = $1;
+ my $amount = $input->param("amountoutstanding$value");
my $accountlines_id = $input->param("accountlines_id$value");
- my $payment_note = $input->param("payment_note_$value");
- WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch, $payment_note );
+ my $payment_note = $input->param("payment_note_$value");
+ Koha::Account->new( { patron_id => $borrowernumber } )->pay(
+ {
+ amount => $amount,
+ lines => [ Koha::Account::Lines->find($accountlines_id) ],
+ type => 'writeoff',
+ note => $payment_note,
+ library_id => $branch,
+ }
+ );
}
}
- $borrowernumber = $input->param('borrowernumber');
- print $input->redirect(
- "/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
+ print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
return;
}