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

(-)a/C4/Accounts.pm (-60 / +14 lines)
Lines 415-421 sub recordpayment_selectaccts { Link Here
415
        {
415
        {
416
            amount => $amount,
416
            amount => $amount,
417
            lines  => \@lines,
417
            lines  => \@lines,
418
            note   => $note
418
            note   => $note,
419
        }
419
        }
420
      );
420
      );
421
}
421
}
Lines 424-490 sub recordpayment_selectaccts { Link Here
424
# fills in
424
# fills in
425
sub makepartialpayment {
425
sub makepartialpayment {
426
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
426
    my ( $accountlines_id, $borrowernumber, $accountno, $amount, $user, $branch, $payment_note ) = @_;
427
    my $manager_id = 0;
428
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
429
    if (!$amount || $amount < 0) {
430
        return;
431
    }
432
    $payment_note //= "";
433
    my $dbh = C4::Context->dbh;
434
435
    my $nextaccntno = getnextacctno($borrowernumber);
436
    my $newamtos    = 0;
437
438
    my $data = $dbh->selectrow_hashref(
439
        'SELECT * FROM accountlines WHERE  accountlines_id=?',undef,$accountlines_id);
440
    my $new_outstanding = $data->{amountoutstanding} - $amount;
441
442
    my $update = 'UPDATE  accountlines SET amountoutstanding = ?  WHERE   accountlines_id = ? ';
443
    $dbh->do( $update, undef, $new_outstanding, $accountlines_id);
444
445
    if ( C4::Context->preference("FinesLog") ) {
446
        logaction("FINES", 'MODIFY', $borrowernumber, Dumper({
447
            action                => 'fee_payment',
448
            borrowernumber        => $borrowernumber,
449
            old_amountoutstanding => $data->{'amountoutstanding'},
450
            new_amountoutstanding => $new_outstanding,
451
            amount_paid           => $data->{'amountoutstanding'} - $new_outstanding,
452
            accountlines_id       => $data->{'accountlines_id'},
453
            accountno             => $data->{'accountno'},
454
            manager_id            => $manager_id,
455
        }));
456
    }
457
458
    # create new line
459
    my $insert = 'INSERT INTO accountlines (borrowernumber, accountno, date, amount, '
460
    .  'description, accounttype, amountoutstanding, itemnumber, manager_id, note) '
461
    . ' VALUES (?, ?, now(), ?, ?, ?, 0, ?, ?, ?)';
462
463
    $dbh->do(  $insert, undef, $borrowernumber, $nextaccntno, -$amount,
464
        '', 'Pay', $data->{'itemnumber'}, $manager_id, $payment_note);
465
427
466
    UpdateStats({
428
    my $line = Koha::Account::Lines->find( $accountlines_id );
467
        branch => $branch,
468
        type   => 'payment',
469
        amount => $amount,
470
        borrowernumber => $borrowernumber,
471
        accountno => $accountno
472
    });
473
429
474
    if ( C4::Context->preference("FinesLog") ) {
430
    return Koha::Account->new(
475
        logaction("FINES", 'CREATE',$borrowernumber,Dumper({
431
        {
476
            action            => 'create_payment',
432
            patron_id => $borrowernumber,
477
            borrowernumber    => $user,
433
        }
478
            accountno         => $nextaccntno,
434
      )->pay(
479
            amount            => 0 - $amount,
435
        {
480
            accounttype       => 'Pay',
436
            amount => $amount,
481
            itemnumber        => $data->{'itemnumber'},
437
            lines  => [ $line ],
482
            accountlines_paid => [ $data->{'accountlines_id'} ],
438
            note   => $payment_note,
483
            manager_id        => $manager_id,
439
            library_id => $branch,
484
        }));
440
        }
485
    }
441
      );
486
442
487
    return;
488
}
443
}
489
444
490
=head2 WriteOffFee
445
=head2 WriteOffFee
491
- 

Return to bug 15898