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

(-)a/C4/Accounts.pm (-37 / +29 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
365
    unless ($existing_charge_hashref) {
374
    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
375
378
        if ( C4::Context->preference("FinesLog") ) {
376
        #add processing fee
379
            logaction("FINES", 'CREATE', $borrowernumber, Dumper({
377
        if ($processfee > 0){
380
                action            => 'create_fee',
378
            manualinvoice($borrowernumber, $itemnumber, $description, 'PF', $processfee, $processingfeenote, 1);
381
                borrowernumber    => $borrowernumber,
379
        }
382
                accountno         => $accountno,
380
        #add replace cost
383
                amount            => $amount,
381
        if ($replacementprice > 0){
384
                amountoutstanding => $amount,
382
            manualinvoice($borrowernumber, $itemnumber, $description, 'L', $replacementprice, undef, 1);
385
                description       => $description,
386
                accounttype       => 'L',
387
                itemnumber        => $itemnumber,
388
                manager_id        => $manager_id,
389
            }));
390
        }
383
        }
391
392
    }
384
    }
393
}
385
}
394
386
Lines 409-425 should be the empty string. Link Here
409
#'
401
#'
410
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function
402
# FIXME: In Koha 3.0 , the only account adjustment 'types' passed to this function
411
# are :  
403
# are :  
412
# 		'C' = CREDIT
404
# 		'C'   = CREDIT
413
# 		'FOR' = FORGIVEN  (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere)
405
# 		'FOR' = FORGIVEN  (Formerly 'F', but 'F' is taken to mean 'FINE' elsewhere)
414
# 		'N' = New Card fee
406
# 		'N'   = New Card fee
415
# 		'F' = Fine
407
# 		'F'   = Fine
416
# 		'A' = Account Management fee
408
# 		'A'   = Account Management fee
417
# 		'M' = Sundry
409
# 		'M'   = Sundry
418
# 		'L' = Lost Item
410
# 		'L'   = Lost Item
419
#
411
#
420
412
421
sub manualinvoice {
413
sub manualinvoice {
422
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note ) = @_;
414
    my ( $borrowernumber, $itemnum, $desc, $type, $amount, $note, $skip_notify ) = @_;
423
    my $manager_id = 0;
415
    my $manager_id = 0;
424
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
416
    $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv;
425
    my $dbh      = C4::Context->dbh;
417
    my $dbh      = C4::Context->dbh;
Lines 427-432 sub manualinvoice { Link Here
427
    my $insert;
419
    my $insert;
428
    my $accountno  = getnextacctno($borrowernumber);
420
    my $accountno  = getnextacctno($borrowernumber);
429
    my $amountleft = $amount;
421
    my $amountleft = $amount;
422
    $skip_notify //= 0;
430
423
431
    if (   ( $type eq 'L' )
424
    if (   ( $type eq 'L' )
432
        or ( $type eq 'F' )
425
        or ( $type eq 'F' )
Lines 434-440 sub manualinvoice { Link Here
434
        or ( $type eq 'N' )
427
        or ( $type eq 'N' )
435
        or ( $type eq 'M' ) )
428
        or ( $type eq 'M' ) )
436
    {
429
    {
437
        $notifyid = 1;
430
        $notifyid = 1 unless $skip_notify;
438
    }
431
    }
439
432
440
    if ( $itemnum ) {
433
    if ( $itemnum ) {
Lines 473-481 sub manualinvoice { Link Here
473
}
466
}
474
467
475
sub getcharges {
468
sub getcharges {
476
	my ( $borrowerno, $timestamp, $accountno ) = @_;
469
	my ( $borrowerno, $accountno ) = @_;
477
	my $dbh        = C4::Context->dbh;
470
	my $dbh        = C4::Context->dbh;
478
	my $timestamp2 = $timestamp - 1;
479
	my $query      = "";
471
	my $query      = "";
480
	my $sth = $dbh->prepare(
472
	my $sth = $dbh->prepare(
481
			"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
473
			"SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?"
(-)a/C4/Circulation.pm (-2 / +3 lines)
Lines 3604-3613 sub LostItem{ Link Here
3604
    my ($itemnumber, $mark_returned) = @_;
3604
    my ($itemnumber, $mark_returned) = @_;
3605
3605
3606
    my $dbh = C4::Context->dbh();
3606
    my $dbh = C4::Context->dbh();
3607
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title 
3607
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title,itemtypes.defaultreplacecost, itemtypes.processfee
3608
                           FROM issues 
3608
                           FROM issues 
3609
                           JOIN items USING (itemnumber) 
3609
                           JOIN items USING (itemnumber) 
3610
                           JOIN biblio USING (biblionumber)
3610
                           JOIN biblio USING (biblionumber)
3611
                           JOIN itemtypes on items.itype = itemtypes.itemtype
3611
                           WHERE issues.itemnumber=?");
3612
                           WHERE issues.itemnumber=?");
3612
    $sth->execute($itemnumber);
3613
    $sth->execute($itemnumber);
3613
    my $issues=$sth->fetchrow_hashref();
3614
    my $issues=$sth->fetchrow_hashref();
Lines 3621-3627 sub LostItem{ Link Here
3621
            defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!";  # zero is OK, check defined
3622
            defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!";  # zero is OK, check defined
3622
        }
3623
        }
3623
        if (C4::Context->preference('WhenLostChargeReplacementFee')){
3624
        if (C4::Context->preference('WhenLostChargeReplacementFee')){
3624
            C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}");
3625
            C4::Accounts::chargelostitem($issues, "Lost Item $issues->{'title'} $issues->{'barcode'}");
3625
            #FIXME : Should probably have a way to distinguish this from an item that really was returned.
3626
            #FIXME : Should probably have a way to distinguish this from an item that really was returned.
3626
            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
3627
            #warn " $issues->{'borrowernumber'}  /  $itemnumber ";
3627
        }
3628
        }
(-)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/kohastructure.sql (+2 lines)
Lines 1270-1275 CREATE TABLE `itemtypes` ( -- defines the item types Link Here
1270
  itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
1270
  itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
1271
  description mediumtext, -- a plain text explanation of the item type
1271
  description mediumtext, -- a plain text explanation of the item type
1272
  rentalcharge double(16,4) default NULL, -- the amount charged when this item is checked out/issued
1272
  rentalcharge double(16,4) default NULL, -- the amount charged when this item is checked out/issued
1273
  defaultreplacecost double(16,4) default NULL, -- default replacement cost
1274
  processfee double(16,4) default NULL, -- default text be recorded in the column note when the processing fee is applied
1273
  notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
1275
  notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan
1274
  imageurl varchar(200) default NULL, -- URL for the item type icon
1276
  imageurl varchar(200) default NULL, -- URL for the item type icon
1275
  summary text, -- information from the summary field, may include HTML
1277
  summary text, -- information from the summary field, may include HTML
(-)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 456-461 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
456
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
457
('UseControlNumber','0','','If ON, record control number (w subfields) and control number (001) are used for linking of bibliographic records.','YesNo'),
457
('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'),
458
('UseCourseReserves','0',NULL,'Enable the course reserves feature.','YesNo'),
458
('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'),
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
('useDefaultReplacementCost', '0', NULL, 'default replacement cost defined in item type', 'YesNo'),
459
('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'),
461
('UseICU','0','1','Tell Koha if ICU indexing is in use for Zebra or not.','YesNo'),
460
('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'),
462
('UseKohaPlugins','0','','Enable or disable the ability to use Koha Plugins.','YesNo'),
461
('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'),
463
('UseQueryParser','0',NULL,'If enabled, try to use QueryParser for queries.','YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+10 lines)
Lines 9793-9798 if(CheckVersion($DBversion)) { Link Here
9793
    SetVersion($DBversion);
9793
    SetVersion($DBversion);
9794
}
9794
}
9795
9795
9796
$DBversion = 'XXX';
9797
if ( CheckVersion($DBversion) ) {
9798
    $dbh->do("ALTER TABLE  `itemtypes` ADD  `defaultreplacecost` DOUBLE( 16, 4 ) NULL DEFAULT NULL AFTER  `rentalcharge`");
9799
    $dbh->do("ALTER TABLE  `itemtypes` ADD  `processfee` DOUBLE( 16, 4 ) NULL DEFAULT NULL AFTER  `defaultreplacecost`");
9800
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('useDefaultReplacementCost',0,'default replacement cost defined in item type','YesNo')");
9801
    $dbh->do("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')");
9802
    print "Upgrade to $DBversion done (Bug 12768 - Replacement cost and processing fee management)\n";
9803
    SetVersion($DBversion);
9804
}
9805
9796
=head1 FUNCTIONS
9806
=head1 FUNCTIONS
9797
9807
9798
=head2 TableExists($table)
9808
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+4 lines)
Lines 597-602 fieldset.rows fieldset { Link Here
597
	width: 9em;  
597
	width: 9em;  
598
}
598
}
599
599
600
.yui-b fieldset.rows ol.oladditemtype label, .yui-b fieldset.rows ol.oladditemtype span.label {
601
    width: 13em;
602
}
603
600
.yui-b fieldset.rows div.hint {
604
.yui-b fieldset.rows div.hint {
601
	margin-left : 10.5em;
605
	margin-left : 10.5em;
602
}
606
}
(-)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 632-637 Circulation: Link Here
632
                  yes: Charge
632
                  yes: Charge
633
                  no: "Don't Charge"
633
                  no: "Don't Charge"
634
            - the replacement price when a patron loses an item.
634
            - the replacement price when a patron loses an item.
635
        -
636
            - pref: useDefaultReplacementCost
637
              choices:
638
                  yes: use
639
                  no: "Don't use"
640
            - the default replacement cost defined in item type.
641
        -
642
            - "Set the text to be recorded in the column 'note', table 'accountlines' when the processing fee (defined in item type) is applied."
643
            - pref: ProcessingFeeNote
644
              type: textarea
645
              class: code
646
635
    Self Checkout:
647
    Self Checkout:
636
        -
648
        -
637
            - "Include the following JavaScript on all pages in the web-based self checkout:"
649
            - "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