$accountline->discard_changes->status('RETURNED');
$accountline->store;
- ModItem( { paidfor => '' }, undef, $itemnumber, { log_action => 0 } );
-
if ( defined $account and C4::Context->preference('AccountAutoReconcile') ) {
$account->reconcile_balance;
}
sub ReturnLostItem{
my ( $borrowernumber, $itemnum ) = @_;
-
MarkIssueReturned( $borrowernumber, $itemnum );
- my $patron = Koha::Patrons->find( $borrowernumber );
- my $item = Koha::Items->find($itemnum);
- my $old_note = ($item->paidfor && ($item->paidfor ne q{})) ? $item->paidfor.' / ' : q{};
- my @datearr = localtime(time);
- my $date = ( 1900 + $datearr[5] ) . "-" . ( $datearr[4] + 1 ) . "-" . $datearr[3];
- my $bor = $patron->firstname . ' ' . $patron->surname . ' ' . $patron->cardnumber;
- ModItem({ paidfor => $old_note."Paid for by $bor $date" }, undef, $itemnum);
}
materials => undef,
new_status => undef,
notforloan => 0,
- # paidfor => undef, # commented, see bug 12817
price => undef,
replacementprice => undef,
replacementpricedate => undef,
itemnotes = ?,
itemnotes_nonpublic = ?,
holdingbranch = ?,
- paidfor = ?,
location = ?,
permanent_location = ?,
onloan = ?,
$item->{'itemnotes'},
$item->{'itemnotes_nonpublic'},
$item->{'holdingbranch'},
- $item->{'paidfor'},
$item->{'location'},
$item->{'permanent_location'},
$item->{'onloan'},
=cut
+=head3 patron
+
+Return the patron linked to this account line
+
+=cut
+
+sub patron {
+ my ( $self ) = @_;
+ my $rs = $self->_result->borrowernumber;
+ return unless $rs;
+ return Koha::Patron->_new_from_dbic( $rs );
+}
+
=head3 item
Return the item linked to this account line if exists
-
columnname: holdingbranch
-
- columnname: paidfor
- -
columnname: timestamp
-
columnname: location
$item->{status_advisory} = 1;
}
+ # Add paidfor info
+ if ( $item->{itemlost} ) {
+ my $accountlines = Koha::Account::Lines->search(
+ {
+ itemnumber => $item->{itemnumber},
+ accounttype => 'LOST',
+ status => [ undef, { '<>' => 'RETURNED' } ],
+ amountoutstanding => 0
+ },
+ {
+ order_by => { '-desc' => 'date' },
+ rows => 1
+ }
+ );
+
+ if ( my $accountline = $accountlines->next ) {
+ my $payment_offsets = Koha::Account::Offsets->search(
+ {
+ debit_id => $accountline->id,
+ credit_id => { '!=' => undef }, # it is not the debit itself
+ type => { '!=' => [ 'Writeoff', 'Forgiven' ] },
+ amount => { '<' => 0 } # credits are negative on the DB
+ },
+ { order_by => { '-desc' => 'created_on' } }
+ );
+
+ if ($payment_offsets->count) {
+ my $patron = $accountline->patron;
+ my $payment_offset = $payment_offsets->next;
+ $item->{paidfor} =
+ $patron->firstname . " "
+ . $patron->surname . " "
+ . $patron->cardnumber . " "
+ . $payment_offset->created_on;
+ }
+ }
+ }
+
if (C4::Context->preference("IndependentBranches")) {
#verifying rights
my $userenv = C4::Context->userenv();
<field name="items.itemnotes">Public note</field>
<field name="items.itemnotes_nonpublic">Internal note</field>
<field name="items.holdingbranch">Current library</field>
-<field name="items.paidfor">Paid for (unused)</field>
<field name="items.timestamp">Timestamp</field>
<field name="items.location">Shelving location</field>
<field name="items.permanent_location">Permanent shelving location</field>