set search_path TO bank;

call add_bank('Banque de l''Est');

call add_account(1,'EUR');
call add_account(1,'YEN');
call add_account(1,'USD');

update account set balance = 100000 where id = 1;
update account set balance = 50000 where id = 2;
update account set balance = 200000 where id = 3;

insert into exchange_rate values
('EUR', '1999-01-01', 1),
('USD', '2025-01-02', 1.0321),
('USD', '2025-02-03', 1.0274),
('USD', '2025-03-03', 1.0465);

call add_person('Albane','Trottier', '1987-01-01', array['USD']);
call add_person('Josef','Jakubowski', '1988-01-01',array['EUR', 'EUR']);
call add_person('Ali','Sahim', '1989-01-01', array['EUR']);
call add_person('Émilie','Jolie', '1992-01-01', array['EUR']);
call add_person('Soufiane','Mamoun', '1993-01-01',array['EUR', 'EUR']);
call add_person('Élodie','Bérengier', '1991-01-01',array['EUR', 'EUR']);
call add_person('Eugène','Makiadi', '1994-01-01', array['EUR']);
call add_person('Julie','Thomis', '1980-01-01',array['EUR', 'USD', 'EUR']);
call add_person('Marc','Aurèle', '1981-01-01',array['USD', 'EUR', 'EUR']);
call add_person('Albert','Unepierre', '1982-01-01', array['EUR']);
call add_person('Lucas','George', '1978-01-01', array['EUR']);
call add_person('Lyna','Mansour', '1983-01-01',array['EUR', 'USD']);
call add_person('Nour','Zermani', '1984-01-01', array['USD']);
call add_person('Théophile','M''Beko', '1985-01-01',array['EUR', 'USD']);
call add_person('Sébastien','Voltier', '1986-01-01', array['EUR']);
call add_person('Matteo','Giordano', '1985-01-01',array['EUR', 'USD']);
call add_person('Diego','Delavega', '1977-01-01',array['EUR', 'EUR', 'EUR']);
call add_person('Geoffrey','Lebowski', '1990-01-01',array['EUR', 'EUR', 'EUR']);
call add_person('Ælita','Dornburg', '1991-01-01',array['EUR', 'USD']);
call add_person('João','Costa', '1978-01-01',array['EUR']);
call add_person('Maëla','Le Roux', '1990-01-01',array['EUR']);
call add_person('Rose-Lynn','Noël', '1986-01-01',array['EUR']);
call add_person('Jean-Christophe','Prigent', '1990-01-01',array['EUR','USD']);
call add_person('Apolline','de Bazelaire de Lesseux', '1984-01-01',array['EUR']);
call add_person('Aylin','Özkan', '1985-01-01',array['EUR', 'EUR', 'EUR']);
call add_person('Yana','Zhdanova', '1993-02-28',array['EUR', 'EUR']);
call add_person('Nayiri','Zakarian', '1996-01-01',array['EUR', 'EUR']);
call add_person('François','du Bessey de Contenson', '1990-01-01', array['USD', 'EUR', 'EUR']);
call add_person('Martial','Mondésir', '1990-01-01', array['EUR', 'EUR', 'EUR']);
call add_person('Tom','Kishida', '1995-01-01',array['EUR', 'EUR']);
call add_person('Zainap','Bisliev', '1997-01-01',array['EUR']);
call add_person('Maï Ly','Pham Le', '1999-01-01',array['EUR', 'EUR']);
call add_person('Laurent','Ramasawmy', '1993-01-01',array['EUR']);
call add_person('Atika','Mroudjaé', '1994-01-01',array['EUR', 'EUR', 'EUR']);
call add_person('Alice','Inechains', '1987-07-07',array['EUR']);
call add_person('Laureline','Mézières', '1986-01-01',array['EUR', 'USD']);
call add_person('Valerian','Christin', '1987-01-01',array['EUR', 'EUR', 'USD']);
call add_person('Alice','Kingsleigh', '1981-01-01',array['EUR', 'USD', 'EUR']);
call add_person('Amélie','Pond', '1998-01-01',array['EUR', 'EUR', 'EUR']);
call add_person('Eyota','Olmsted', '1992-01-01',array['EUR', 'EUR']);
call add_person('Hapsatou','Sall','1982-01-01');
call add_person('Arthur','Koblenz','1984-01-01');
call add_person('Ellen Louise','Ripley','1979-01-01');

update account set balance = 2000 where id = 4;
update account set balance = 2100 where id = 6;
update account set balance = 1200 where id = 9;

update account set balance = 3400 where id = 13;
update account set balance = 200 where id = 15;
update account set balance = 3000 where id = 16;
update account set balance = 3000 where id = 19;

update account set balance = 3420 where id = 20;
update account set balance = 2000 where id = 21;
update account set balance = 2500 where id = 22;
update account set balance = 2300 where id = 23;
update account set balance = 2000 where id = 28;
update account set balance = 3500 where id = 29;

update account set balance = 1600 where id = 31;
update account set balance = 1500 where id = 33;
update account set balance = 500 where id = 34;
update account set balance = 9140 where id = 35;
update account set balance = 1600 where id = 36;
update account set balance = 500 where id = 37;
update account set balance = 2400 where id = 38;

update account set balance = 2200 where id = 41;
update account set balance = 2500 where id = 44;
update account set balance = 3500 where id = 46;
update account set balance = 990 where id = 47;

update account set balance = 800 where id = 50;
update account set balance = 5200 where id = 51;
update account set balance = 3500 where id = 53;
update account set balance = 1000 where id = 54;
update account set balance = 1600 where id = 55;
update account set balance = 4000 where id = 57;

update account set balance = 500 where id = 63;
update account set balance = 3500 where id = 65;
update account set balance = 1600 where id = 66;
update account set balance = 2900 where id = 67;
update account set balance = 2000 where id = 68;
update account set balance = 500 where id = 69;

update account set balance = 1500 where id = 71;
update account set balance = 1800 where id = 77;
update account set balance = 1600 where id = 78;

update account set balance = 1500 where id = 62;
update account set balance = 1500 where id = 26;

with addholder as (
  insert into holder (type) values ('COMPANY') returning id
)
insert into company (id, name, registration_number, created_at)
select
  addholder.id,
  'Boulangerie de Valorgue', 'FR19803269968', '2014-08-19'
  from addholder;

call transfer(45,66,239,'2025-01-05');
call transfer(50,43,128,'2025-03-02');
call transfer(34,76,185,'2025-01-21');
call transfer(66,12,1100,'2025-07-13');
call transfer(20,64,348,'2025-05-20');
call transfer(37,71,876,'2025-06-04');
call transfer(31,73,1504,'2025-07-12');
call transfer(29,43,1385,'2025-04-12');
call transfer(51,60,934,'2025-05-12');
call transfer(19,35,141,'2025-02-27');
call transfer(47,6,1144,'2025-05-30');
call transfer(33,79,24,'2025-02-26');
call transfer(13,11,148,'2025-02-28');
call transfer(8,46,1062,'2025-01-19');
call transfer(34,39,1004,'2025-06-20');
call transfer(31,73,1491,'2025-02-03');
call transfer(77,64,1616,'2025-03-03');
call transfer(64,56,203,'2025-02-18');
call transfer(16,59,877,'2025-03-31');
call transfer(56,63,120,'2025-07-05');
call transfer(16,11,1501,'2025-04-13');
call transfer(47,17,402,'2025-03-04');
call transfer(28,72,297,'2025-04-24');
call transfer(58,27,957,'2025-03-12');
call transfer(35,13,1664,'2025-04-23');
call transfer(74,16,1345,'2025-01-13');
call transfer(73,5,1907,'2025-01-24');
call transfer(34,25,1004,'2025-04-14');
call transfer(65,31,1858,'2025-04-12');
call transfer(11,25,14,'2025-04-07');
call transfer(53,37,1617,'2025-07-19');
call transfer(62,40,1436,'2025-04-18');
call transfer(75,66,398,'2025-02-09');
call transfer(41,31,1196,'2025-01-15');
call transfer(73,11,652,'2025-07-10');
call transfer(11,10,986,'2025-05-29');
call transfer(68,71,126,'2025-02-10');
call transfer(69,14,150,'2025-02-17');
call transfer(12,34,255,'2025-04-13');
call transfer(76,35,1227,'2025-05-28');
call transfer(9,14,1356,'2025-04-17');
call transfer(78,76,657,'2025-05-13');
call transfer(37,30,1476,'2025-06-20');
call transfer(44,34,820,'2025-03-08');
call transfer(20,42,657,'2025-04-27');
call transfer(13,5,1282,'2025-04-27');
call transfer(76,16,1111,'2025-01-19');
call transfer(31,68,281,'2025-03-08');
call transfer(48,12,766,'2025-03-03');
call transfer(40,24,1717,'2025-04-22');
call transfer(73,42,1662,'2025-06-05');
call transfer(71,5,1683,'2025-06-19');
call transfer(74,42,222,'2025-06-18');
call transfer(21,37,1832,'2025-01-30');
call transfer(17,74,567,'2025-02-09');
call transfer(40,30,712,'2025-07-02');
call transfer(30,37,1010,'2025-05-09');
call transfer(36,10,1309,'2025-01-24');
call transfer(58,39,17,'2025-01-12');
call transfer(46,20,546,'2025-06-12');
call transfer(24,60,1455,'2025-05-21');
call transfer(58,75,239,'2025-01-03');
call transfer(13,23,83,'2025-05-19');
call transfer(51,78,313,'2025-05-21');
call transfer(59,20,641,'2025-01-11');
call transfer(50,9,440,'2025-04-01');
call transfer(35,17,1607,'2025-03-31');
call transfer(75,56,1544,'2025-06-07');
call transfer(23,34,1648,'2025-02-11');
call transfer(26,56,377,'2025-01-07');
call transfer(46,56,1779,'2025-06-20');
call transfer(35,38,1622,'2025-02-10');
call transfer(17,52,1768,'2025-01-10');
call transfer(64,32,1682,'2025-02-21');
call transfer(62,48,1690,'2025-03-19');
call transfer(33,32,1361,'2025-01-07');
call transfer(28,55,580,'2025-03-25');
call transfer(12,39,1323,'2025-03-30');
call transfer(69,55,1737,'2025-06-22');
call transfer(72,46,246,'2025-01-08');
call transfer(37,26,1981,'2025-05-28');
call transfer(37,8,1231,'2025-01-28');
call transfer(59,48,1620,'2025-07-05');
call transfer(44,59,1057,'2025-06-04');
call transfer(18,53,399,'2025-05-27');
call transfer(36,9,903,'2025-06-30');
call transfer(4,70,1416,'2025-05-17');
call transfer(29,50,153,'2025-04-20');
call transfer(46,44,1746,'2025-06-18');
call transfer(19,42,643,'2025-05-09');
call transfer(56,45,1437,'2025-04-13');
call transfer(41,74,402,'2025-02-02');
call transfer(57,52,1542,'2025-06-22');
call transfer(26,76,841,'2025-03-18');
call transfer(74,4,597,'2025-03-18');
call transfer(30,59,1252,'2025-05-28');
call transfer(45,63,915,'2025-04-23');
call transfer(31,69,1635,'2025-05-01');
call transfer(25,14,1065,'2025-03-13');
call transfer(46,15,491,'2025-07-11');
call transfer(43,32,311,'2025-02-20');
call transfer(7,9,983,'2025-03-03');
call transfer(13,62,1824,'2025-04-16');
call transfer(77,28,1436,'2025-07-02');
call transfer(53,67,509,'2025-04-12');
call transfer(22,4,1772,'2025-07-11');
call transfer(17,58,370,'2025-02-26');
call transfer(70,63,1151,'2025-01-13');
call transfer(35,19,283,'2025-04-26');
call transfer(63,71,1229,'2025-05-23');
call transfer(44,60,1679,'2025-06-05');
call transfer(68,58,923,'2025-05-20');
call transfer(24,64,540,'2025-04-25');
call transfer(35,39,1602,'2025-07-15');
call transfer(70,66,499,'2025-06-09');
call transfer(39,60,1471,'2025-01-20');
call transfer(40,34,697,'2025-03-10');
call transfer(44,73,293,'2025-01-21');
call transfer(23,33,1431,'2025-04-08');
call transfer(23,31,859,'2025-01-17');
call transfer(56,46,964,'2025-05-18');
call transfer(57,11,1715,'2025-02-22');
call transfer(57,53,1206,'2025-07-16');
call transfer(6,77,986,'2025-04-07');
call transfer(4,49,1553,'2025-03-17');
call transfer(53,57,1540,'2025-05-17');
call transfer(73,32,459,'2025-05-04');
call transfer(38,59,69,'2025-05-04');
call transfer(53,47,1400,'2025-06-20');
call transfer(55,25,1893,'2025-04-29');
call transfer(20,72,1867,'2025-01-07');
call transfer(54,79,1367,'2025-05-24');
call transfer(7,14,887,'2025-06-13');
call transfer(21,63,112,'2025-02-16');
call transfer(37,52,443,'2025-03-24');
call transfer(62,45,1568,'2025-03-27');
call transfer(52,39,1958,'2025-07-11');
call transfer(57,36,973,'2025-01-21');
call transfer(6,73,1959,'2025-01-14');
call transfer(48,32,150,'2025-06-15');
call transfer(9,7,418,'2025-03-04');
call transfer(6,23,268,'2025-03-02');
call transfer(64,18,1951,'2025-05-24');
call transfer(31,63,534,'2025-06-28');
call transfer(51,25,1253,'2025-06-04');
call transfer(18,24,231,'2025-03-20');
call transfer(78,7,1189,'2025-03-20');
call transfer(52,54,416,'2025-07-02');
call transfer(13,79,1711,'2025-06-25');
call transfer(35,17,1592,'2025-06-27');
call transfer(42,19,1612,'2025-05-24');
call transfer(9,48,887,'2025-05-16');
call transfer(51,12,1336,'2025-05-09');
call transfer(47,5,1694,'2025-04-17');
call transfer(66,17,1977,'2025-04-20');
call transfer(50,62,323,'2025-06-30');
call transfer(59,26,1078,'2025-07-06');
call transfer(38,72,1000,'2025-07-17');
call transfer(63,59,1223,'2025-07-06');
call transfer(38,45,1711,'2025-03-03');
call transfer(15,39,509,'2025-04-25');
call transfer(63,76,1378,'2025-06-05');
call transfer(52,47,1022,'2025-01-08');
call transfer(45,27,444,'2025-05-04');
call transfer(49,37,582,'2025-03-28');
call transfer(39,75,1068,'2025-01-03');
call transfer(28,14,1484,'2025-03-02');
call transfer(56,66,1562,'2025-05-22');
call transfer(34,64,1467,'2025-06-14');
call transfer(66,61,200,'2025-01-05');
call transfer(41,32,1426,'2025-04-13');
call transfer(35,43,1201,'2025-06-18');
call transfer(51,64,1097,'2025-05-21');
call transfer(48,58,1137,'2025-07-09');
call transfer(46,49,939,'2025-06-28');
call transfer(38,43,482,'2025-03-05');
call transfer(19,28,254,'2025-03-21');
call transfer(72,27,453,'2025-02-19');
call transfer(65,39,1217,'2025-07-04');
call transfer(71,40,1715,'2025-01-26');
call transfer(28,41,749,'2025-02-28');
call transfer(26,42,1460,'2025-01-04');
call transfer(72,20,103,'2025-03-11');
call transfer(10,74,1438,'2025-03-15');
call transfer(20,66,1797,'2025-01-27');
call transfer(5,77,971,'2025-03-13');
call transfer(65,60,387,'2025-03-28');
call transfer(10,36,243,'2025-05-02');
call transfer(12,55,161,'2025-05-05');
call transfer(77,10,315,'2025-02-08');
call transfer(76,42,518,'2025-01-22');
call transfer(19,75,862,'2025-07-14');
call transfer(32,70,932,'2025-04-07');
call transfer(60,42,888,'2025-05-30');
call transfer(43,76,133,'2025-06-07');
call transfer(16,30,442,'2025-06-09');
call transfer(37,14,501,'2025-02-10');
call transfer(26,74,330,'2025-01-20');
call transfer(4,56,1421,'2025-04-25');
call transfer(64,41,484,'2025-01-09');
call transfer(40,62,1417,'2025-01-19');
call transfer(33,37,1217,'2025-06-09');
call transfer(29,58,1125,'2025-01-30');
call transfer(32,23,1702,'2025-03-09');
call transfer(22,13,349,'2025-01-16');
call transfer(43,76,909,'2025-03-14');
call transfer(19,63,632,'2025-06-25');
call transfer(55,38,1115,'2025-05-08');
call transfer(67,60,1234,'2025-01-21');
call transfer(9,59,670,'2025-07-07');
call transfer(36,7,478,'2025-01-24');
call transfer(77,79,1576,'2025-01-06');
call transfer(38,77,1572,'2025-01-11');
call transfer(26,64,1344,'2025-05-12');
call transfer(60,39,1208,'2025-02-16');
call transfer(59,66,972,'2025-01-24');
call transfer(48,56,667,'2025-03-26');
call transfer(17,24,853,'2025-03-25');
call transfer(67,40,1945,'2025-06-18');
call transfer(55,74,941,'2025-01-10');
call transfer(4,37,822,'2025-03-02');
call transfer(37,68,831,'2025-03-23');
call transfer(68,4,1493,'2025-03-05');
call transfer(26,68,913,'2025-05-28');
call transfer(68,17,1344,'2025-04-25');
call transfer(17,26,1173,'2025-02-20');
call transfer(42,68,973,'2025-04-29');
call transfer(68,29,555,'2025-04-12');
call transfer(29,42,1030,'2025-03-15');
call transfer(23,51,1137,'2025-04-06');
call transfer(51,24,1010,'2025-05-26');
call transfer(24,23,952,'2025-05-10');
call transfer(73,71,552,'2025-05-27');
call transfer(71,4,773,'2025-03-17');
call transfer(4,73,634,'2025-04-30');
