1 $DBversion = 'XXX'; # will be replaced by the RM
2 if ( CheckVersion($DBversion) ) {
6 CREATE TABLE IF NOT EXISTS account_debit_types (
7 code varchar(64) NOT NULL,
8 description varchar(200) NULL,
9 can_be_added_manually tinyint(4) NOT NULL DEFAULT 1,
10 default_amount decimal(28, 6) NULL,
11 is_system tinyint(1) NOT NULL DEFAULT 0,
13 ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
19 CREATE TABLE IF NOT EXISTS ac_debit_types_branches (
20 debit_type_code VARCHAR(64),
21 branchcode VARCHAR(10),
22 FOREIGN KEY (debit_type_code) REFERENCES account_debit_types(code) ON DELETE CASCADE,
23 FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
24 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
30 INSERT IGNORE INTO account_debit_types (
33 can_be_added_manually,
38 ('ACCOUNT', 'Account creation fee', 0, NULL, 1),
39 ('ACCOUNT_RENEW', 'Account renewal fee', 0, NULL, 1),
40 ('HE', 'Hold waiting too long', 0, NULL, 1),
41 ('LOST', 'Lost item', 1, NULL, 1),
42 ('M', 'Manual fee', 1, NULL, 0),
43 ('N', 'New card fee', 1, NULL, 1),
44 ('OVERDUE', 'Overdue fine', 0, NULL, 1),
45 ('PF', 'Lost item processing fee', 0, NULL, 1),
46 ('RENT', 'Rental fee', 0, NULL, 1),
47 ('RENT_DAILY', 'Daily rental fee', 0, NULL, 1),
48 ('RENT_RENEW', 'Renewal of rental item', 0, NULL, 1),
49 ('RENT_DAILY_RENEW', 'Rewewal of daily rental item', 0, NULL, 1),
50 ('Res', 'Hold fee', 0, NULL, 1)
56 INSERT IGNORE INTO account_debit_types (
60 can_be_added_manually,
64 SUBSTR(authorised_value, 1, 64),
72 category = 'MANUAL_INV'
78 ALTER IGNORE TABLE accountlines
80 debit_type varchar(64) DEFAULT NULL
88 ALTER TABLE accountlines ADD CONSTRAINT `accountlines_ibfk_debit_type` FOREIGN KEY (`debit_type`) REFERENCES `account_debit_types` (`code`) ON DELETE SET NULL ON UPDATE CASCADE
94 UPDATE accountlines SET debit_type = accounttype, accounttype = NULL WHERE accounttype IN (SELECT code from account_debit_types)
101 DELETE FROM authorised_values WHERE category = 'MANUAL_INV'
106 DELETE FROM authorised_value_categories WHERE category_name = 'MANUAL_INV'
113 INSERT IGNORE INTO permissions (module_bit, code, description)
118 'Manage Account Debit and Credit Types'
123 SetVersion($DBversion);
124 print "Upgrade to $DBversion done (Bug 23049 - Add account debit_types)\n";