ATTENTION: The tests will only be added after the exam. Currently, it is only tested whether your code compiles.
The state bond issue in the summer of 2023 was a huge success. In total, 22.3 billion euros were subscribed to the state bond. Subscribing for the state bond could be done both through one’s own bank and through a secure government website. The following assignment contains a number of backend functions necessary to make this site work.
Define a function subscribe_to_state_bond with parameters an amount, a national registration number, and the account number on which the amount + interest should be repaid. The function will register the subscription in the register variable if:
ERROR: [amount] must be higher than 0.
ERROR: [amount] is not a multiple of 100.
ERROR: a subscription has already been made using the national registration number
If all conditions are met, the subscription is registered in the register, and the function returns True.
Define a function queried_amount with as parameter a national registration number. The function returns the amount for which was subscribed by the given national registration number. If no subscription is found, the method returns 0.
After a subscription, a payment invitation is sent via email. The text of this email is composed by the function payment_invitation. This method has as a parameter a national registration number and returns the following text:
The amount must be on our account by 01/09/2023 at the latest. IBAN: [IBAN_overheid] (BIC: [BIC_overheid]) in the name of the Department of the Ledgers, Kunstlaan 30, 1040 Brussels. Amount: [amount] EUR with the communication: Purchase of State Bond [national registration number]
You can assume for this function that a subscription for the given national registration number has been added.
Define the function total_subscribed. This function returns the total amount that has been subscribed to date.
Define a method register_to_csv with parameters a filename and a delimiter with the default value “;”. This method will write the Dictionary linked to the register variable to a CSV file:
national registration number;amount;timestamp;account number 78.06.28-111.64;1000000;2023-09-05 10:14:29.056256;BE98 1111 1111 1111 55.04.23-456.64;20000;2023-09-05 10:14:29.056535;BE77 2222 2222 2222 07.05.12-678.11;2000;2023-09-05 10:14:29.056537;BE78 3333 3333 3333
Add a main method that tests the various functions. Ensure that a minimum of three subscriptions have been added, the payment invitation of one of the subscriptions is displayed in the console, and the total of the subscriptions is displayed.