The first chapter of 'Refactoring' by Martin Fowler, 2nd Edition contains a worked example of this exercise, in javascript. That chapter is available to download for free. This repo contains the starting point for this exercise in several languages, with tests, so you can try it out for yourself.
Refactoring is usually driven by a need to make changes. In the book, Fowler adds code to print the statement as HTML in addition to the existing plain text version. He also mentions that the theatrical players want to add new kinds of plays to their repertoire, for example history and pastoral.
In his book Fowler mentions that the first step in refactoring is always the same - to ensure you have a solid set of tests for that section of code. As a start, you can look to add some tests by using the Approval testing approach.
Company Pedro is setting up their new digital invoice system but is having a hard time coping with the nerver ending changes. Your job as a consultant team is to refactor the code and take into account the following requirements given by the owner.
The new calculation rates are to be taken into account and an attempt has been done but it isn't correct.
- A customer asking for more than 10 plays needs to pay an extra 5% on each following performance
- The TVA in France (5.5%) is calculated but the TVA in Belgium (21%) and in Luxembourg (3%) is not.
- Every year, the credits number account for an extra income but the bonus % can change. a. the year 2020, the rate was 0.45 per credit b. the year 2021, it changed to 0.4 per credit until today
- Thanks to the cultural revitalisation program in Luxembourg, the comedy performances are not submitted to the TVA. It needs to be addressed.
A new line for TVA per performance would be nice in the invoice statement
The handling of the exception needs to be better by displaying error message with information
A better set of tests will go a long way to understand the application
==> You are the new team responsible of this roadmap.
Miro board used to run your exercice : https://miro.com/app/board/uXjVOuDqllU=/?moveToWidget=3458764555194008021&cot=14