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

(-)a/C4/Accounts.pm (-39 / +33 lines)
Lines 353-394 sub chargelostitem{ Link Here
353
# a charge has been added
353
# a charge has been added
354
# FIXME : if no replacement price, borrower just doesn't get charged?
354
# FIXME : if no replacement price, borrower just doesn't get charged?
355
    my $dbh = C4::Context->dbh();
355
    my $dbh = C4::Context->dbh();
356
    my ($borrowernumber, $itemnumber, $amount, $description) = @_;
356
    my ($issues, $description) = @_;
357
357
    my $borrowernumber = $issues->{'borrowernumber'};
358
    my $itemnumber = $issues->{'itemnumber'};
359
    my $replacementprice = $issues->{'replacementprice'};
360
    my $defaultreplacecost = $issues->{'defaultreplacecost'};
361
    my $processfee = $issues->{'processfee'};
362
    my $usedefaultreplacementcost = C4::Context->preference("useDefaultReplacementCost");
363
    my $processingfeenote = C4::Context->preference("ProcessingFeeNote");
364
365
    if ($usedefaultreplacementcost && $replacementprice == 0){
366
        $replacementprice = $defaultreplacecost;
367
    }
358
    # first make sure the borrower hasn't already been charged for this item
368
    # first make sure the borrower hasn't already been charged for this item
359
    my $sth1=$dbh->prepare("SELECT * from accountlines
369
    my $sth1=$dbh->prepare("SELECT * from accountlines
360
    WHERE borrowernumber=? AND itemnumber=? and accounttype='L'");
370
    WHERE borrowernumber=? AND itemnumber=? and accounttype='L'");
361
    $sth1->execute($borrowernumber,$itemnumber);
371
    $sth1->execute($borrowernumber,$itemnumber);
362
    my $existing_charge_hashref=$sth1->fetchrow_hashref();
372
    my $existing_charge_hashref=$sth1->fetchrow_hashref();
363
364
    # OK, they haven't
373
    # OK, they haven't
374
    my $accountline;
365
    unless ($existing_charge_hashref) {
375
    unless ($existing_charge_hashref) {
366
        my $manager_id = 0;
367
        $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
368
        # This item is on issue ... add replacement cost to the borrower's record and mark it returned
369
        #  Note that we add this to the account even if there's no replacement price, allowing some other
370
        #  process (or person) to update it, since we don't handle any defaults for replacement prices.
371
        my $accountno = getnextacctno($borrowernumber);
372
        my $sth2=$dbh->prepare("INSERT INTO accountlines
373
        (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber,manager_id)
374
        VALUES (?,?,now(),?,?,'L',?,?,?)");
375
        $sth2->execute($borrowernumber,$accountno,$amount,
376
        $description,$amount,$itemnumber,$manager_id);
377
376
378
        if ( C4::Context->preference("FinesLog") ) {
377
        #add processing fee
379
            logaction("FINES", 'CREATE', $borrowernumber, Dumper({
378
        if ($processfee > 0){
380
                action            => 'create_fee',
379
            manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1);
381
                borrowernumber    => $borrowernumber,
380
        }
382
                accountno         => $accountno,
381
        #add replace cost
383
                amount            => $amount,
382
        if ($replacementprice > 0){
384
                amountoutstanding => $amount,
383
            manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1);
385
                description       => $description,
386
                accounttype       => 'L',
387
                itemnumber        => $itemnumber,
388
                manager_id        => $manager_id,
389
            }));
390
        }
384
        }
391
392
    }
385
    }
393
}
386
}
394
387
Lines 408-425 should be the empty string. Link Here
408
401
409
#'
402
#'
410
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function
403
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function
411
# are :  
404
# are :
412
# 		'C' = CREDIT
405
#       'C'   = CREDIT
413
# 		'FOR' = FORGIVEN  (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere)
406
#       'FOR' = FORGIVEN  (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere)
414
# 		'N' = New Card fee
407
#       'N'   = New Card fee
415
# 		'F' = Fine
408
#       'F'   = Fine
416
# 		'A' = Account Management fee
409
#       'A'   = Account Management fee
417
# 		'M' = Sundry
410
#       'PF'  = Processing fee
418
# 		'L' = Lost Item
411
#       'M'   = Sundry
412
#       'L'   = Lost Item
419
#
413
#
420
414
421
sub manualinvoice {
415
sub manualinvoice {
422
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
416
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $skip_notify ) = @_;
423
    my $manager_id = 0;
417
    my $manager_id = 0;
424
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
418
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
425
    my $dbh      = C4::Context->dbh;
419
    my $dbh      = C4::Context->dbh;
Lines 427-432 sub manualinvoice { Link Here
427
    my $insert;
421
    my $insert;
428
    my $accountno  = getnextacctno($borrowernumber);
422
    my $accountno  = getnextacctno($borrowernumber);
429
    my $amountleft = $amount;
423
    my $amountleft = $amount;
424
    $skip_notify //= 0;
430
425
431
    if (   ( $type eq 'L' )
426
    if (   ( $type eq 'L' )
432
        or ( $type eq 'F' )
427
        or ( $type eq 'F' )
Lines 434-440 sub manualinvoice { Link Here
434
        or ( $type eq 'N' )
429
        or ( $type eq 'N' )
435
        or ( $type eq 'M' ) )
430
        or ( $type eq 'M' ) )
436
    {
431
    {
437
        $notifyid = 1;
432
        $notifyid = 1 unless $skip_notify;
438
    }
433
    }
439
434
440
    if ( $itemnum ) {
435
    if ( $itemnum ) {
Lines 473-481 sub manualinvoice { Link Here
473
}
468
}
474
469
475
sub getcharges {
470
sub getcharges {
476
	my ( $borrowerno, $timestamp, $accountno ) = @_;
471
	my ( $borrowerno, $accountno ) = @_;
477
	my $dbh        = C4::Context->dbh;
472
	my $dbh        = C4::Context->dbh;
478
	my $timestamp2 = $timestamp - 1;
479
	my $query      = "";
473
	my $query      = "";
480
	my $sth = $dbh->prepare(
474
	my $sth = $dbh->prepare(
481
			"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
475
			"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 3620-3629 sub LostItem{ Link Here
3620
    my ($itemnumber, $mark_returned) = @_;
3620
    my ($itemnumber, $mark_returned) = @_;
3621
3621
3622
    my $dbh = C4::Context->dbh();
3622
    my $dbh = C4::Context->dbh();
3623
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title 
3623
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title,itemtypes.defaultreplacecost, itemtypes.processfee
3624
                           FROM issues 
3624
                           FROM issues 
3625
                           JOIN items USING (itemnumber) 
3625
                           JOIN items USING (itemnumber) 
3626
                           JOIN biblio USING (biblionumber)
3626
                           JOIN biblio USING (biblionumber)
3627
                           JOIN itemtypes on items.itype = itemtypes.itemtype
3627
                           WHERE issues.itemnumber=?");
3628
                           WHERE issues.itemnumber=?");
3628
    $sth->execute($itemnumber);
3629
    $sth->execute($itemnumber);
3629
    my $issues=$sth->fetchrow_hashref();
3630
    my $issues=$sth->fetchrow_hashref();
Lines 3637-3643 sub LostItem{ Link Here
3637
            defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!";  # zero is OK, check defined
3638
            defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!";  # zero is OK, check defined
3638
        }
3639
        }
3639
        if (C4::Context->preference('WhenLostChargeReplacementFee')){
3640
        if (C4::Context->preference('WhenLostChargeReplacementFee')){
3640
            C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}");
3641
            C4::Accounts::chargelostitem($issues, "Lost Item $issues->{'title'} $issues->{'barcode'}");
3641
            #FIXME : Should probably have a way to distinguish this from an item that really was returned.
3642
            #FIXME : Should probably have a way to distinguish this from an item that really was returned.
3642
            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
3643
            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
3643
        }
3644
        }
(-)a/admin/itemtypes.pl (-3 / +13 lines)
Lines 116-121 if ( $op eq 'add_form' ) { Link Here
116
        itemtype        => $itemtype,
116
        itemtype        => $itemtype,
117
        description     => $data->{'description'},
117
        description     => $data->{'description'},
118
        rentalcharge    => sprintf( "%.2f", $data->{'rentalcharge'} ),
118
        rentalcharge    => sprintf( "%.2f", $data->{'rentalcharge'} ),
119
        defaultreplacecost     => sprintf( "%.2f", $data->{'defaultreplacecost'} ),
120
        processfee     => sprintf( "%.2f", $data->{'processfee'} ),
119
        notforloan      => $data->{'notforloan'},
121
        notforloan      => $data->{'notforloan'},
120
        imageurl        => $data->{'imageurl'},
122
        imageurl        => $data->{'imageurl'},
121
        template        => C4::Context->preference('template'),
123
        template        => C4::Context->preference('template'),
Lines 144-149 elsif ( $op eq 'add_validate' ) { Link Here
144
            UPDATE itemtypes
146
            UPDATE itemtypes
145
            SET    description = ?
147
            SET    description = ?
146
                 , rentalcharge = ?
148
                 , rentalcharge = ?
149
                 , defaultreplacecost = ?
150
                 , processfee = ?
147
                 , notforloan = ?
151
                 , notforloan = ?
148
                 , imageurl = ?
152
                 , imageurl = ?
149
                 , summary = ?
153
                 , summary = ?
Lines 156-161 elsif ( $op eq 'add_validate' ) { Link Here
156
        $sth->execute(
160
        $sth->execute(
157
            $input->param('description'),
161
            $input->param('description'),
158
            $input->param('rentalcharge'),
162
            $input->param('rentalcharge'),
163
            $input->param('defaultreplacecost'),
164
            $input->param('processfee'),
159
            ( $input->param('notforloan') ? 1 : 0 ),
165
            ( $input->param('notforloan') ? 1 : 0 ),
160
            (
166
            (
161
                $input->param('image') eq 'removeImage' ? '' : (
167
                $input->param('image') eq 'removeImage' ? '' : (
Lines 168-182 elsif ( $op eq 'add_validate' ) { Link Here
168
            $input->param('checkinmsg'),
174
            $input->param('checkinmsg'),
169
            $input->param('checkinmsgtype'),
175
            $input->param('checkinmsgtype'),
170
            $sip_media_type,
176
            $sip_media_type,
171
            $input->param('itemtype')
177
            $input->param('itemtype'),
172
        );
178
        );
173
    }
179
    }
174
    else {    # add a new itemtype & not modif an old
180
    else {    # add a new itemtype & not modif an old
175
        my $query = "
181
        my $query = "
176
            INSERT INTO itemtypes
182
            INSERT INTO itemtypes
177
                (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type)
183
                (itemtype,description, rentalcharge, defaultreplacecost, processfee, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type)
178
            VALUES
184
            VALUES
179
                (?,?,?,?,?,?,?,?,?);
185
                (?,?,?,?,?,?,?,?,?,?,?);
180
            ";
186
            ";
181
        my $sth = $dbh->prepare($query);
187
        my $sth = $dbh->prepare($query);
182
		my $image = $input->param('image');
188
		my $image = $input->param('image');
Lines 184-189 elsif ( $op eq 'add_validate' ) { Link Here
184
            $input->param('itemtype'),
190
            $input->param('itemtype'),
185
            $input->param('description'),
191
            $input->param('description'),
186
            $input->param('rentalcharge'),
192
            $input->param('rentalcharge'),
193
            $input->param('defaultreplacecost'),
194
            $input->param('processfee'),
187
            $input->param('notforloan') ? 1 : 0,
195
            $input->param('notforloan') ? 1 : 0,
188
            $image eq 'removeImage' ?           ''                 :
196
            $image eq 'removeImage' ?           ''                 :
189
            $image eq 'remoteImage' ? $input->param('remoteImage') :
197
            $image eq 'remoteImage' ? $input->param('remoteImage') :
Lines 250-255 else { # DEFAULT Link Here
250
    foreach my $itemtype ( @{$results} ) {
258
    foreach my $itemtype ( @{$results} ) {
251
        $itemtype->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtype->{imageurl} );
259
        $itemtype->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtype->{imageurl} );
252
        $itemtype->{rentalcharge} = sprintf( '%.2f', $itemtype->{rentalcharge} );
260
        $itemtype->{rentalcharge} = sprintf( '%.2f', $itemtype->{rentalcharge} );
261
        $itemtype->{defaultreplacecost} = sprintf( '%.2f', $itemtype->{defaultreplacecost} );
262
        $itemtype->{processfee} = sprintf( '%.2f', $itemtype->{processfee} );
253
        push( @loop, $itemtype );
263
        push( @loop, $itemtype );
254
    }
264
    }
255
265
(-)a/installer/data/mysql/atomicupdate/bug_12768-replacement_cost_processing_fee_management.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences (variable,value,explanation,type) VALUES ('useDefaultReplacementCost',0,'default replacement cost defined in item type','YesNo');
2
INSERT INTO systempreferences (variable,value,explanation,type) VALUES ('ProcessingFeeNote','','Set the text to be recorded in the column note, table accountlines when the processing fee (defined in item type) is applied','textarea');
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 340-345 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
340
('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'),
340
('previousIssuesDefaultSortOrder','asc','asc|desc','Specify the sort order of Previous Issues on the circulation page','Choice'),
341
('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'),
341
('printcirculationslips','1','','If ON, enable printing circulation receipts','YesNo'),
342
('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'),
342
('PrintNoticesMaxLines','0','','If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.','Integer'),
343
('ProcessingFeeNote', '', NULL, 'Set the text to be recorded in the column note, table accountlines when the processing fee (defined in item type) is applied', 'textarea'),
343
('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'),
344
('QueryAutoTruncate','1',NULL,'If ON, query truncation is enabled by default','YesNo'),
344
('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'),
345
('QueryFuzzy','1',NULL,'If ON, enables fuzzy option for searches','YesNo'),
345
('QueryStemming','1',NULL,'If ON, enables query stemming','YesNo'),
346
('QueryStemming','1',NULL,'If ON, enables query stemming','YesNo'),
Lines 457-462 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
457
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
458
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
458
('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'),
459
('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'),
459
('useDaysMode','Calendar','Calendar|Days|Datedue','Choose the method for calculating due date: select Calendar to use the holidays module, and Days to ignore the holidays module','Choice'),
460
('useDaysMode','Calendar','Calendar|Days|Datedue','Choose the method for calculating due date: select Calendar to use the holidays module, and Days to ignore the holidays module','Choice'),
461
('useDefaultReplacementCost', '0', NULL, 'default replacement cost defined in item type', 'YesNo'),
460
('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'),
462
('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'),
461
('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'),
463
('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'),
462
('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'),
464
('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+4 lines)
Lines 604-609 fieldset.rows fieldset { Link Here
604
	width: 9em;  
604
	width: 9em;  
605
}
605
}
606
606
607
.yui-b fieldset.rows ol.oladditemtype label, .yui-b fieldset.rows ol.oladditemtype span.label {
608
    width: 13em;
609
}
610
607
.yui-b fieldset.rows div.hint {
611
.yui-b fieldset.rows div.hint {
608
	margin-left : 10.5em;
612
	margin-left : 10.5em;
609
}
613
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-2 / +14 lines)
Lines 162-168 Item types administration Link Here
162
</div>
162
</div>
163
</div>
163
</div>
164
[% END %]
164
[% END %]
165
<ol>
165
<ol class="oladditemtype">
166
      <li>
166
      <li>
167
          <label for="notforloan">Not for loan: </label>   [% IF ( notforloan ) %]
167
          <label for="notforloan">Not for loan: </label>   [% IF ( notforloan ) %]
168
                <input type="checkbox" id="notforloan" name="notforloan" checked="checked" value="1" />
168
                <input type="checkbox" id="notforloan" name="notforloan" checked="checked" value="1" />
Lines 175-181 Item types administration Link Here
175
      <li>
175
      <li>
176
          <label for="rentalcharge">Rental charge: </label>
176
          <label for="rentalcharge">Rental charge: </label>
177
		  <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" />
177
		  <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" />
178
         </li>
178
      </li>
179
      <li>
180
          <label for="defaultreplacecost">Default replacement cost: </label>
181
          <input type="text" id="defaultreplacecost" name="defaultreplacecost" size="10" value="[% defaultreplacecost %]" />
182
      </li>
183
      <li>
184
          <label for="processfee">Processing fee (when lost): </label>
185
          <input type="text" id="processfee" name="processfee" size="10" value="[% processfee %]" />
186
      </li>
179
      <li>
187
      <li>
180
          <label for="checkinmsg">Checkin message: </label>
188
          <label for="checkinmsg">Checkin message: </label>
181
          <textarea id="checkinmsg" name="checkinmsg" cols="55" rows="5">[% checkinmsg %]</textarea>
189
          <textarea id="checkinmsg" name="checkinmsg" cols="55" rows="5">[% checkinmsg %]</textarea>
Lines 262-267 Item types administration Link Here
262
    <th>Description</th>
270
    <th>Description</th>
263
    <th>Not for loan</th>
271
    <th>Not for loan</th>
264
    <th>Charge</th>
272
    <th>Charge</th>
273
    <th>Default replacement cost</th>
274
    <th>Processing fee (when lost)</th>
265
    <th>Checkin message</th>
275
    <th>Checkin message</th>
266
    <th>Actions</th>
276
    <th>Actions</th>
267
  </thead>
277
  </thead>
Lines 280-285 Item types administration Link Here
280
      [% loo.rentalcharge %]
290
      [% loo.rentalcharge %]
281
    [% END %]
291
    [% END %]
282
    </td>
292
    </td>
293
    <td>[% loo.defaultreplacecost %]</td>
294
    <td>[% loo.processfee %]</td>
283
    <td>[% loo.checkinmsg | html_line_break %]</td>
295
    <td>[% loo.checkinmsg | html_line_break %]</td>
284
    <td>
296
    <td>
285
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
297
      <a href="[% loo.script_name %]?op=add_form&amp;itemtype=[% loo.itemtype |html %]">Edit</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+12 lines)
Lines 626-631 Circulation: Link Here
626
                  yes: Charge
626
                  yes: Charge
627
                  no: "Don't Charge"
627
                  no: "Don't Charge"
628
            - the replacement price when a patron loses an item.
628
            - the replacement price when a patron loses an item.
629
        -
630
            - pref: useDefaultReplacementCost
631
              choices:
632
                  yes: use
633
                  no: "Don't use"
634
            - the default replacement cost defined in item type.
635
        -
636
            - "Set the text to be recorded in the column 'note', table 'accountlines' when the processing fee (defined in item type) is applied."
637
            - pref: ProcessingFeeNote
638
              type: textarea
639
              class: code
640
629
    Self Checkout:
641
    Self Checkout:
630
        -
642
        -
631
            - "Include the following JavaScript on all pages in the web-based self checkout:"
643
            - "Include the following JavaScript on all pages in the web-based self checkout:"
(-)a/t/db_dependent/Circulation/Chargelostitem.t (-1 / +89 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
use Modern::Perl;
9
10
use Test::MockModule;
11
use C4::Biblio;
12
use C4::Items;
13
use C4::Members;
14
use C4::Branch;
15
use C4::Category;
16
use C4::Circulation;
17
use MARC::Record;
18
use Test::More tests => 7;
19
20
BEGIN {
21
    use_ok('C4::Accounts');
22
}
23
24
my $dbh = C4::Context->dbh;
25
$dbh->{AutoCommit} = 0;
26
$dbh->{RaiseError} = 1;
27
$dbh->do(q|DELETE FROM accountlines|);
28
29
my $branchcode;
30
my $branch_created;
31
my @branches = keys %{ GetBranches() };
32
if (@branches) {
33
    $branchcode = $branches[0];
34
} else {
35
    $branchcode = 'B';
36
    ModBranch({ add => 1, branchcode => $branchcode, branchname => 'Branch' });
37
    $branch_created = 1;
38
}
39
40
my %item_branch_infos = (
41
    homebranch => $branchcode,
42
    holdingbranch => $branchcode,
43
);
44
45
my ($biblionumber1) = AddBiblio(MARC::Record->new, '');
46
my $itemnumber1 = AddItem({ barcode => '0101', %item_branch_infos }, $biblionumber1);
47
my $itemnumber2 = AddItem({ barcode => '0102', %item_branch_infos }, $biblionumber1);
48
49
my ($biblionumber2) = AddBiblio(MARC::Record->new, '');
50
my $itemnumber3 = AddItem({ barcode => '0203', %item_branch_infos }, $biblionumber2);
51
52
my $categorycode;
53
my $category_created;
54
my @categories = C4::Category->all;
55
if (@categories) {
56
    $categorycode = $categories[0]->{categorycode}
57
} else {
58
    $categorycode = 'C';
59
    C4::Context->dbh->do(
60
        "INSERT INTO categories(categorycode) VALUES(?)", undef, $categorycode);
61
    $category_created = 1;
62
}
63
64
my $borrowernumber = AddMember(categorycode => $categorycode, branchcode => $branchcode);
65
my $borrower = GetMember(borrowernumber => $borrowernumber);
66
67
# Need to mock userenv for AddIssue
68
my $module = new Test::MockModule('C4::Context');
69
$module->mock('userenv', sub { { branch => $branchcode } });
70
AddIssue($borrower, '0101');
71
AddIssue($borrower, '0203');
72
73
# Begin tests...
74
my $processfee = 10;
75
my $issues;
76
$issues = C4::Circulation::GetIssues({biblionumber => $biblionumber1});
77
my $issue=$issues->[0];
78
$issue->{'processfee'} = $processfee;
79
my $accountlineId = C4::Accounts::chargelostitem($issue, 'test');
80
81
my @accountline = C4::Accounts::getcharges($borrowernumber, $accountlineId);
82
83
is( scalar(@accountline), 1, 'accountline should have 1 row' );
84
is( int($accountline[0]->{amount}), $processfee, "The accountline amount should be precessfee value " );
85
is( $accountline[0]->{accounttype}, 'PF', "The accountline accounttype should be PF " );
86
is( $accountline[0]->{borrowernumber}, $borrowernumber, "The accountline borrowernumber should be the exemple borrownumber" );
87
my $itemnumber = C4::Items::GetItemnumberFromBarcode('0101');
88
is( $accountline[0]->{itemnumber}, $itemnumber, "The accountline itemnumber should the linked with barcode '0101'" );
89
is( $accountline[0]->{description}, 'test', "The accountline description should be 'test'" );

Return to bug 12768