-- Fresh initialization of error_messages table
TRUNCATE TABLE error_messages;

-- Baseline data for YSP (Provider 4)
INSERT INTO error_messages (error_code, provider, error_message) VALUES
('00', 4, 'APPROVED'),
('01', 4, 'REFER TO CARD ISSUER'),
('02', 4, 'REFER TO CARD ISSUER'),
('03', 4, 'INVALID MERCHANT'),
('04', 4, 'PICK UP CARD'),
('05', 4, 'DO NOT HONOR'),
('06', 4, 'ERROR'),
('07', 4, 'PICK UP CARD'),
('10', 4, 'PARTIAL APPROVED'),
('11', 4, 'APPROVED VIP'),
('12', 4, 'INVALID TRANSACTION'),
('13', 4, 'INVALID AMOUNT'),
('14', 4, 'INVALID ACCOUNT NUMBER'),
('15', 4, 'NO SUCH ISSUER'),
('19', 4, 'RE-ENTER TRANSACTIONS'),
('25', 4, 'UNABLE TO LOCATE RECORD IN FILE'),
('30', 4, 'FORMAT ERROR'),
('39', 4, 'NO CREDIT ACCOUNT'),
('41', 4, 'LOST CARD, PICK UP'),
('43', 4, 'STOLEN CARD, PICK UP'),
('51', 4, 'INSUFFICIENT FUNDS'),
('52', 4, 'NOT CHECKING ACCOUNT'),
('53', 4, 'NO SAVINGS ACCOUNT'),
('54', 4, 'EXPIRED CARD'),
('55', 4, 'INCORRECT PIN'),
('57', 4, 'TRANSACTION NOT PERMITTED TO CARDHOLDER'),
('58', 4, 'TRANSACTION NOT ALLOWED AT TERMINAL'),
('61', 4, 'TXN DECLINED, USE CONTACT'),
('62', 4, 'RESTRICTED CARD'),
('63', 4, 'SECURITY VIOLATION'),
('64', 4, 'INVALID ACCOUNT'),
('65', 4, 'EXCEEDS WITHDRAWAL FREQUENCY LIMIT'),
('68', 4, 'HOST TIMEOUT'),
('75', 4, 'PIN TRY LIMIT EXCEEDED'),
('76', 4, 'UNSOLICITED REVERSAL'),
('79', 4, 'ALREADY REVERSED'),
('80', 4, 'INVALID DATE'),
('81', 4, 'SECURITY VIOLATION'),
('82', 4, 'INCORRECT CVV'),
('83', 4, 'UNABLE/CANNOT VERIFY PIN'),
('85', 4, 'DATABASE ERROR'),
('86', 4, 'UNABLE/CANNOT VERIFY PIN'),
('91', 4, 'ISSUER SWITCH INOPERATIVE'),
('92', 4, 'NETWORK ROUTING ERROR'),
('94', 4, 'DUPLICATE TRANSMISSION'),
('95', 4, 'SYSTEM MALFUNCTION'),
('96', 4, 'SYSTEM MALFUNCTION');

-- Internal jPOS Codes (Provider 0) with (INT) suffix
INSERT INTO error_messages (error_code, provider, error_message) VALUES
('00', 0, 'APPROVED (INT)'),
('06', 0, 'ERROR (INT)'),
('12', 0, 'INVALID TRANSACTION (INT)'),
('68', 0, 'HOST TIMEOUT (INT)'),
('76', 0, 'INVALID POS MAPPING/TERMINAL (INT)'),
('77', 0, 'INVALID ACQUIRER CONFIG (INT)'),
('78', 0, 'MIDDLEWARE SYSTEM ERROR (INT)'),
('82', 0, 'DATABASE ERROR (INT)'),
('83', 0, 'ACQUIRER HOST TIMEOUT (INT)'),
('96', 0, 'SYSTEM MALFUNCTION (INT)');

-- Force all messages to UPPERCASE as a final safety step
UPDATE error_messages SET error_message = UPPER(error_message);
