Lines 1-6
Link Here
|
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
2 |
if ( CheckVersion($DBversion) ) { |
2 |
if ( CheckVersion($DBversion) ) { |
3 |
|
3 |
|
|
|
4 |
# Find and correct pathological cases of LR |
4 |
my $sth = $dbh->prepare( "SELECT accountlines_id, issue_id, borrowernumber, itemnumber, amount, manager_id FROM accountlines WHERE accounttype = 'LR' AND amount < 0" ); |
5 |
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 |
$sth->execute(); |
6 |
while ( my $row = $sth->fetchrow_hashref ) { |
7 |
while ( my $row = $sth->fetchrow_hashref ) { |
Lines 29-34
if ( CheckVersion($DBversion) ) {
Link Here
|
29 |
accounttype = 'LR'; |
30 |
accounttype = 'LR'; |
30 |
}); |
31 |
}); |
31 |
|
32 |
|
|
|
33 |
# Find and correct pathalogical cases of L having been converted to W |
34 |
$sth = $dbh->prepare( "SELECT accountlines_id, issue_id, borrowernumber, itemnumber, amount, manager_id FROM accountlines WHERE accounttype = 'W' AND itemnumber IS NOT NULL" ); |
35 |
$sth->execute(); |
36 |
while ( my $row = $sth->fetchrow_hashref ) { |
37 |
my $amount = $row->{amount} * -1; |
38 |
$dbh->do( |
39 |
"INSERT INTO accountlines (accounttype, status, issue_id, borrowernumber, itemnumber, amount, manager_id) VALUES ( ?, ?, ?, ?, ?, ? );", |
40 |
{}, |
41 |
( |
42 |
'LOST', 'WAIVERED', $row->{issue_id}, $row->{borrowernumber}, |
43 |
$row->{itemnumber}, $amount, $row->{manager_id} |
44 |
) |
45 |
); |
46 |
my $debit_id = $dbh->last_insert_id(); |
47 |
$dbh->do("INSERT INTO account_offsets (credit_id, debit_id, type, amount) VALUES (?,?,?,?);",{},($row->{accountlines_id}, $debit_id, 'Lost Item Returned', $amount)); |
48 |
} |
49 |
|
50 |
$dbh->do(qq{ |
51 |
UPDATE |
52 |
accountlines |
53 |
SET |
54 |
accounttype = 'LOST', |
55 |
status = 'UNRETURNED' |
56 |
WHERE |
57 |
accounttype = 'L' |
58 |
AND |
59 |
amountoutstanding > 0; |
60 |
}); |
61 |
|
62 |
$dbh->do(qq{ |
63 |
UPDATE |
64 |
accountlines |
65 |
SET |
66 |
accounttype = 'LOST', |
67 |
status = 'PAID' |
68 |
WHERE |
69 |
accounttype = 'L' |
70 |
AND |
71 |
amountoutstanding = 0; |
72 |
}); |
73 |
|
32 |
SetVersion($DBversion); |
74 |
SetVersion($DBversion); |
33 |
print "Upgrade to $DBversion done (Bug 22518 - Fix accounttypes for 'L' and 'LR')\n"; |
75 |
print "Upgrade to $DBversion done (Bug 22563 - Fix accounttypes for 'L' and 'LR')\n"; |
34 |
} |
76 |
} |
35 |
- |
|
|