View | Details | Raw Unified | Return to bug 17894
Collapse All | Expand All

(-)a/C4/Accounts.pm (-44 / +13 lines)
Lines 33-52 use Data::Dumper qw(Dumper); Link Here
33
use vars qw(@ISA @EXPORT);
33
use vars qw(@ISA @EXPORT);
34
34
35
BEGIN {
35
BEGIN {
36
	require Exporter;
36
    require Exporter;
37
	@ISA    = qw(Exporter);
37
    @ISA    = qw(Exporter);
38
	@EXPORT = qw(
38
    @EXPORT = qw(
39
		&manualinvoice
39
      &manualinvoice
40
		&getnextacctno
40
      &getnextacctno
41
		&getcharges
41
      &getcharges
42
		&ModNote
42
      &ModNote
43
		&getcredits
43
      &getcredits
44
		&getrefunds
44
      &getrefunds
45
		&chargelostitem
45
      &chargelostitem
46
		&ReversePayment
46
      &ReversePayment
47
        &WriteOffFee
47
      &purge_zero_balance_fees
48
        &purge_zero_balance_fees
48
    );
49
	);
50
}
49
}
51
50
52
=head1 NAME
51
=head1 NAME
Lines 350-385 sub ReversePayment { Link Here
350
349
351
}
350
}
352
351
353
=head2 WriteOffFee
354
355
  WriteOffFee( $borrowernumber, $accountline_id, $itemnum, $accounttype, $amount, $branch, $payment_note );
356
357
Write off a fine for a patron.
358
C<$borrowernumber> is the patron's borrower number.
359
C<$accountline_id> is the accountline_id of the fee to write off.
360
C<$itemnum> is the itemnumber of of item whose fine is being written off.
361
C<$accounttype> is the account type of the fine being written off.
362
C<$amount> is a floating-point number, giving the amount that is being written off.
363
C<$branch> is the branchcode of the library where the writeoff occurred.
364
C<$payment_note> is the note to attach to this payment
365
366
=cut
367
368
sub WriteOffFee {
369
    my ( $borrowernumber, $accountlines_id, $itemnum, $accounttype, $amount, $branch, $payment_note ) = @_;
370
371
    my $line = Koha::Account::Lines->find($accountlines_id);
372
    return Koha::Account->new( { patron_id => $borrowernumber } )->pay(
373
        {
374
            amount     => $amount,
375
            lines      => [$line],
376
            type       => 'writeoff',
377
            note       => $payment_note,
378
            library_id => $branch,
379
        }
380
    );
381
}
382
383
=head2 purge_zero_balance_fees
352
=head2 purge_zero_balance_fees
384
353
385
  purge_zero_balance_fees( $days );
354
  purge_zero_balance_fees( $days );
(-)a/members/pay.pl (-17 / +29 lines)
Lines 88-98 if ($writeoff_all) { Link Here
88
    writeoff_all(@names);
88
    writeoff_all(@names);
89
} elsif ($writeoff_item) {
89
} elsif ($writeoff_item) {
90
    my $accountlines_id = $input->param('accountlines_id');
90
    my $accountlines_id = $input->param('accountlines_id');
91
    my $itemno       = $input->param('itemnumber');
92
    my $account_type = $input->param('accounttype');
93
    my $amount       = $input->param('amountoutstanding');
91
    my $amount       = $input->param('amountoutstanding');
94
    my $payment_note = $input->param("payment_note");
92
    my $payment_note = $input->param("payment_note");
95
    WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $account_type, $amount, $branch, $payment_note );
93
94
    Koha::Account->new( { patron_id => $borrowernumber } )->pay(
95
        {
96
            amount     => $amount,
97
            lines      => [Koha::Account::Lines->find($accountlines_id)],
98
            type       => 'writeoff',
99
            note       => $payment_note,
100
            library_id => $branch,
101
        }
102
    );
96
}
103
}
97
104
98
for (@names) {
105
for (@names) {
Lines 153-159 sub add_accounts_to_template { Link Here
153
sub get_for_redirect {
160
sub get_for_redirect {
154
    my ( $name, $name_in, $money ) = @_;
161
    my ( $name, $name_in, $money ) = @_;
155
    my $s     = q{&} . $name . q{=};
162
    my $s     = q{&} . $name . q{=};
156
    my $value = $input->param($name_in);
163
    my $value = uri_escape_utf8( $input->param($name_in) );
157
    if ( !defined $value ) {
164
    if ( !defined $value ) {
158
        $value = ( $money == 1 ) ? 0 : q{};
165
        $value = ( $money == 1 ) ? 0 : q{};
159
    }
166
    }
Lines 175-182 sub redirect_to_paycollect { Link Here
175
    $redirect .= get_for_redirect( 'amount', "amount$line_no", 1 );
182
    $redirect .= get_for_redirect( 'amount', "amount$line_no", 1 );
176
    $redirect .=
183
    $redirect .=
177
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
184
      get_for_redirect( 'amountoutstanding', "amountoutstanding$line_no", 1 );
178
    $redirect .= uri_escape_utf8( get_for_redirect( 'description', "description$line_no", 0 ) );
185
    $redirect .= get_for_redirect( 'description', "description$line_no", 0 );
179
    $redirect .= uri_escape_utf8( get_for_redirect( 'title', "title$line_no", 0 ) );
186
    $redirect .= get_for_redirect( 'title', "title$line_no", 0 );
180
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
187
    $redirect .= get_for_redirect( 'itemnumber',   "itemnumber$line_no",   0 );
181
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
188
    $redirect .= get_for_redirect( 'notify_id',    "notify_id$line_no",    0 );
182
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
189
    $redirect .= get_for_redirect( 'notify_level', "notify_level$line_no", 0 );
Lines 190-212 sub redirect_to_paycollect { Link Here
190
sub writeoff_all {
197
sub writeoff_all {
191
    my @params = @_;
198
    my @params = @_;
192
    my @wo_lines = grep { /^accountlines_id\d+$/ } @params;
199
    my @wo_lines = grep { /^accountlines_id\d+$/ } @params;
200
201
    my $borrowernumber = $input->param('borrowernumber');
202
193
    for (@wo_lines) {
203
    for (@wo_lines) {
194
        if (/(\d+)/) {
204
        if (/(\d+)/) {
195
            my $value       = $1;
205
            my $value           = $1;
196
            my $accounttype = $input->param("accounttype$value");
206
            my $amount          = $input->param("amountoutstanding$value");
197
198
            #    my $borrowernum    = $input->param("borrowernumber$value");
199
            my $itemno    = $input->param("itemnumber$value");
200
            my $amount    = $input->param("amountoutstanding$value");
201
            my $accountlines_id = $input->param("accountlines_id$value");
207
            my $accountlines_id = $input->param("accountlines_id$value");
202
            my $payment_note = $input->param("payment_note_$value");
208
            my $payment_note    = $input->param("payment_note_$value");
203
            WriteOffFee( $borrowernumber, $accountlines_id, $itemno, $accounttype, $amount, $branch, $payment_note );
209
            Koha::Account->new( { patron_id => $borrowernumber } )->pay(
210
                {
211
                    amount => $amount,
212
                    lines  => [ Koha::Account::Lines->find($accountlines_id) ],
213
                    type   => 'writeoff',
214
                    note   => $payment_note,
215
                    library_id => $branch,
216
                }
217
            );
204
        }
218
        }
205
    }
219
    }
206
220
207
    $borrowernumber = $input->param('borrowernumber');
221
    print $input->redirect("/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
208
    print $input->redirect(
209
        "/cgi-bin/koha/members/boraccount.pl?borrowernumber=$borrowernumber");
210
    return;
222
    return;
211
}
223
}
212
224
(-)a/t/db_dependent/Accounts.t (-2 lines)
Lines 45-51 can_ok( 'C4::Accounts', Link Here
45
        getcredits
45
        getcredits
46
        getrefunds
46
        getrefunds
47
        ReversePayment
47
        ReversePayment
48
        WriteOffFee
49
        purge_zero_balance_fees )
48
        purge_zero_balance_fees )
50
);
49
);
51
50
52
- 

Return to bug 17894