Line 0
Link Here
|
|
|
1 |
$DBversion = 'XXX'; # will be replaced by the RM |
2 |
if ( CheckVersion($DBversion) ) { |
3 |
|
4 |
$dbh->do( |
5 |
qq{ |
6 |
CREATE TABLE IF NOT EXISTS account_debit_types ( |
7 |
type_code varchar(5) NOT NULL, |
8 |
description varchar(200) NULL, |
9 |
can_be_deleted tinyint NOT NULL DEFAULT '1', |
10 |
can_be_added_manually tinyint(4) NOT NULL DEFAULT '1', |
11 |
default_amount decimal(28, 6) NULL, |
12 |
PRIMARY KEY (type_code) |
13 |
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci |
14 |
} |
15 |
); |
16 |
|
17 |
$dbh->do( |
18 |
qq{ |
19 |
CREATE TABLE IF NOT EXISTS account_credit_types ( |
20 |
type_code varchar(5) NOT NULL, |
21 |
description varchar(200) NULL, |
22 |
can_be_deleted tinyint NOT NULL DEFAULT '1', |
23 |
can_be_added_manually tinyint(4) NOT NULL DEFAULT '1', |
24 |
PRIMARY KEY (type_code) |
25 |
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci |
26 |
} |
27 |
); |
28 |
|
29 |
$dbh->do( |
30 |
qq{ |
31 |
INSERT IGNORE INTO account_debit_types ( |
32 |
type_code, |
33 |
default_amount, |
34 |
description, |
35 |
can_be_deleted, |
36 |
can_be_added_manually |
37 |
) |
38 |
VALUES |
39 |
('A', NULL, 'Account management fee', 0, 1), |
40 |
('F', NULL, 'Overdue fine', 0, 1), |
41 |
('FU', NULL, 'Accruing overdue fine', 0, 0), |
42 |
('L', NULL, 'Lost item', 0, 1), |
43 |
('LR', NULL, 'Lost and returned', 0, 0), |
44 |
('M', NULL, 'Sundry', 0, 1), |
45 |
('N', NULL, 'New card', 0, 1), |
46 |
('O', NULL, 'Overdue fine', 0, 0), |
47 |
('Rent', NULL, 'Rental fee', 0, 1), |
48 |
('Rep', NULL, 'Replacement', 0, 0), |
49 |
('Res', NULL, 'Reserve charge', 0, 1) |
50 |
} |
51 |
); |
52 |
|
53 |
$dbh->do( |
54 |
qq{ |
55 |
INSERT IGNORE INTO account_debit_types ( |
56 |
type_code, |
57 |
default_amount, |
58 |
description, |
59 |
can_be_deleted, |
60 |
can_be_added_manually |
61 |
) |
62 |
SELECT |
63 |
SUBSTR(authorised_value, 1, 5), |
64 |
lib, |
65 |
authorised_value, |
66 |
1, |
67 |
1 |
68 |
FROM |
69 |
authorised_values |
70 |
WHERE |
71 |
category = 'MANUAL_INV' |
72 |
} |
73 |
); |
74 |
|
75 |
$dbh->do( |
76 |
qq{ |
77 |
INSERT IGNORE INTO account_credit_types ( |
78 |
type_code, |
79 |
description, |
80 |
can_be_deleted, |
81 |
can_be_added_manually |
82 |
) |
83 |
VALUES |
84 |
('C', 'Credit', 0, 1), |
85 |
('CC', 'Credit card', 0, 0), |
86 |
('CR', 'Refunded found lost item', 0, 0), |
87 |
('FFOR', 'Forgiven overdue fine', 0, 0), |
88 |
('FOR', 'Forgiven', 0, 1), |
89 |
('OL', 'Other online payment service', 0, 0), |
90 |
('Pay', 'Cash', 0, 0), |
91 |
('Pay00', 'Cash via SIP2', 0, 0), |
92 |
('Pay01', 'VISA via SIP2', 0, 0), |
93 |
('Pay02', 'Credit card via SIP2', 0, 0), |
94 |
('PayPa', 'PayPal', 0, 0), |
95 |
('W', 'Write Off', 0, 0) |
96 |
} |
97 |
); |
98 |
|
99 |
$dbh->do( |
100 |
qq{ |
101 |
ALTER IGNORE TABLE accountlines |
102 |
ADD |
103 |
credit_type varchar(5) COLLATE utf8mb4_unicode_ci NULL |
104 |
AFTER |
105 |
accounttype |
106 |
} |
107 |
); |
108 |
|
109 |
# Add new permission |
110 |
$dbh->do( |
111 |
q{ |
112 |
INSERT IGNORE INTO permissions (module_bit, code, description) |
113 |
VALUES |
114 |
( |
115 |
3, |
116 |
'manage_accounts', |
117 |
'Manage Account Debit and Credit Types' |
118 |
) |
119 |
} |
120 |
); |
121 |
|
122 |
SetVersion($DBversion); |
123 |
print "Upgrade to $DBversion done (Bug XXXXX - description)\n"; |
124 |
} |