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

(-)a/C4/Circulation.pm (-3 / +17 lines)
Lines 1406-1412 sub AddIssue { Link Here
1406
           # If it costs to borrow this book, charge it to the patron's account.
1406
           # If it costs to borrow this book, charge it to the patron's account.
1407
            my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} );
1407
            my ( $charge, $itemtype ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} );
1408
            if ( $charge > 0 ) {
1408
            if ( $charge > 0 ) {
1409
                AddIssuingCharge( $item->{'itemnumber'}, $borrower->{'borrowernumber'}, $issue->id, $charge );
1409
                AddIssuingCharge({
1410
                    itemnumber     => $item->{'itemnumber'},
1411
                    borrowernumber => $borrower->{'borrowernumber'},
1412
                    issue_id       => $issue->id,
1413
                    charge         => $charge,
1414
                });
1410
                $item->{'charge'} = $charge;
1415
                $item->{'charge'} = $charge;
1411
            }
1416
            }
1412
1417
Lines 3165-3176 sub _get_discount_from_rule { Link Here
3165
3170
3166
=head2 AddIssuingCharge
3171
=head2 AddIssuingCharge
3167
3172
3168
  &AddIssuingCharge( $itemno, $borrowernumber, $issue_id, $charge )
3173
  &AddIssuingCharge({
3174
      itemnumber     => $itemno,
3175
      borrowernumber => $borrowernumber,
3176
      issue_id       => $issue_id,
3177
      charge         => $charge,
3178
  })
3169
3179
3170
=cut
3180
=cut
3171
3181
3172
sub AddIssuingCharge {
3182
sub AddIssuingCharge {
3173
    my ( $itemnumber, $borrowernumber, $issue_id, $charge ) = @_;
3183
    my ( $parameters ) = @_;
3184
    my $itemnumber     = $parameters->{itemnumber};
3185
    my $borrowernumber = $parameters->{borrowernumber};
3186
    my $issue_id       = $parameters->{issue_id};
3187
    my $charge         = $parameters->{charge};
3174
3188
3175
    my $nextaccntno = getnextacctno($borrowernumber);
3189
    my $nextaccntno = getnextacctno($borrowernumber);
3176
3190
(-)a/t/db_dependent/Circulation/issue.t (-3 / +13 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 32;
20
use Test::More tests => 35;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 53-58 can_ok( Link Here
53
      )
53
      )
54
);
54
);
55
55
56
use constant PI => 3.141592;
57
56
#Start transaction
58
#Start transaction
57
my $schema = Koha::Database->schema;
59
my $schema = Koha::Database->schema;
58
$schema->storage->txn_begin;
60
$schema->storage->txn_begin;
Lines 207-216 $sth = $dbh->prepare($query); Link Here
207
$sth->execute;
209
$sth->execute;
208
my $countaccount = $sth -> fetchrow_array;
210
my $countaccount = $sth -> fetchrow_array;
209
is ($countaccount,0,"0 accountline exists");
211
is ($countaccount,0,"0 accountline exists");
210
my $offset = C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, $issue_id1, 10 );
212
my $offset = C4::Circulation::AddIssuingCharge({
213
    itemnumber     => $item_id1,
214
    borrowernumber => $borrower_id1,
215
    issue_id       => $issue_id1,
216
    charge         => PI,
217
});
211
is( ref( $offset ), 'Koha::Account::Offset', "An issuing charge has been added" );
218
is( ref( $offset ), 'Koha::Account::Offset', "An issuing charge has been added" );
212
my $charge = Koha::Account::Lines->find( $offset->debit_id );
219
my $charge = Koha::Account::Lines->find( $offset->debit_id );
220
is( $charge->itemnumber, $item_id1, 'Item number is set correctly for issuing charge' );
221
is( $charge->borrowernumber, $borrower_id1, 'Borrower number is set correctly for issuing charge' );
213
is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' );
222
is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' );
223
# force typecast to keep agnostic of decimal 28,6 definition
224
is( $charge->amount+0, PI, 'Charge amount is set correctly for issuing charge' );
214
my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef );
225
my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef );
215
$sth->execute;
226
$sth->execute;
216
$countaccount = $sth -> fetchrow_array;
227
$countaccount = $sth -> fetchrow_array;
217
- 

Return to bug 20572