|
Line 0
Link Here
|
|
|
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
| 2 |
if ( CheckVersion($DBversion) ) { |
| 3 |
|
| 4 |
my $sth = $dbh->prepare( "SELECT accountlines_id, issue_id, borrowernumber, itemnumber, amount, manager_id FROM accountlines WHERE accounttype = 'LR' AND amount < 0" ); |
| 5 |
$sth->execute(); |
| 6 |
while ( my $row = $sth->fetchrow_hashref ) { |
| 7 |
$dbh->do( |
| 8 |
"INSERT INTO accountlines (accounttype, issue_id, borrowernumber, itemnumber, amount, manager_id) VALUES ( ?, ?, ?, ?, ?, ? );", |
| 9 |
{}, |
| 10 |
( |
| 11 |
'CR', $row->{issue_id}, |
| 12 |
$row->{borrowernumber}, $row->{itemnumber}, |
| 13 |
$row->{amount}, $row->{manager_id} |
| 14 |
) |
| 15 |
); |
| 16 |
my $credit_id = $dbh->last_insert_id(); |
| 17 |
my $amount = $row->{amount} * -1; |
| 18 |
$dbh->do("INSERT INTO account_offsets (credit_id, debit_id, type, amount) VALUES (?,?,?,?);",{},($credit_id, $row->{accountlines_id}, 'Lost Item', $amount)); |
| 19 |
$dbh->do("UPDATE accountlines SET amount = '$amount' WHERE accountlines_id = '$row->{accountlines_id}';"); |
| 20 |
} |
| 21 |
|
| 22 |
$dbh->do(qq{ |
| 23 |
UPDATE |
| 24 |
accountlines |
| 25 |
SET |
| 26 |
accounttype = 'LOST', |
| 27 |
status = 'RETURNED' |
| 28 |
WHERE |
| 29 |
accounttype = 'LR'; |
| 30 |
}); |
| 31 |
|
| 32 |
SetVersion($DBversion); |
| 33 |
print "Upgrade to $DBversion done (Bug 22518 - Fix accounttypes for 'L' and 'LR')\n"; |
| 34 |
} |