Bug 24592: Reword LOST_RETURN to LOST_FOUND
[koha-equinox.git] / installer / data / mysql / atomicupdate / bug_24592.perl
1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3
4     # Add LOST_FOUND debit type
5     $dbh->do(qq{
6         INSERT IGNORE INTO
7           account_credit_types ( code, description, can_be_added_manually, is_system )
8         VALUES
9           ('LOST_FOUND', 'Lost item fee refund', 0, 1)
10     });
11
12     # Migrate LOST_RETURN to LOST_FOUND
13     $dbh->do(qq{
14         UPDATE
15           accountlines
16         SET
17           credit_type_code = 'LOST_FOUND'
18         WHERE
19           credit_type_code = 'LOST_RETURN'
20     });
21
22     # Migrate LOST + RETURNED to LOST + FOUND
23     $dbh->do(qq{
24         UPDATE
25           accountlines
26         SET
27           status = 'FOUND'
28         WHERE
29           debit_type_code = 'LOST'
30         AND
31           status = 'RETURNED'
32     });
33
34     # Drop LOST_RETURNED credit type
35     $dbh->do(qq{
36         DELETE FROM account_credit_types WHERE code = 'LOST_RETURN'
37     });
38
39     # Add Lost Item Found offset type
40     $dbh->do(qq{
41         INSERT IGNORE INTO
42           account_offset_types ( type )
43         VALUES
44           ( 'Lost Item Found' )
45     });
46
47     SetVersion( $DBversion );
48     print "Upgrade to $DBversion done (Bug 24592 - Update LOST_RETURN to LOST_FOUND)\n";
49 }