{"id":17973199,"url":"https://github.com/andrewprofile/recuitment-task","last_synced_at":"2025-04-03T23:20:22.788Z","repository":{"id":260059899,"uuid":"876243870","full_name":"andrewprofile/recuitment-task","owner":"andrewprofile","description":"Fee Calculation","archived":false,"fork":false,"pushed_at":"2024-10-29T11:14:28.000Z","size":31,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T11:13:53.092Z","etag":null,"topics":["clean-code","oop","php","solid"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrewprofile.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-21T16:31:42.000Z","updated_at":"2024-10-29T11:12:50.000Z","dependencies_parsed_at":"2024-10-29T10:20:43.923Z","dependency_job_id":null,"html_url":"https://github.com/andrewprofile/recuitment-task","commit_stats":null,"previous_names":["andrewprofile/recuitment-task"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewprofile%2Frecuitment-task","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewprofile%2Frecuitment-task/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewprofile%2Frecuitment-task/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewprofile%2Frecuitment-task/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewprofile","download_url":"https://codeload.github.com/andrewprofile/recuitment-task/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247093030,"owners_count":20882334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean-code","oop","php","solid"],"created_at":"2024-10-29T16:27:54.744Z","updated_at":"2025-04-03T23:20:22.766Z","avatar_url":"https://github.com/andrewprofile.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PragmaGO.TECH Interview Test - Fee Calculation\n=====\n\n## Background\n\nThis test is designed to evaluate your problem solving approach and your engineering ability. Design your solution in a way that shows your knowledge of OOP concepts, SOLID principles, design patterns, clean and extensible architecture.\n\nProvide a test suite verifying your solution, use any testing framework you feel comfortable with. Use any libraries (or none) you feel add value to your solution. Treat the packaged project as a template; if you feel that your solution can be improved with modifications to it then please go ahead.\n\n## The test\n\nThe requirement is to build a fee calculator that - given a monetary **amount** and a **term** (the contractual duration of the loan, expressed as a number of months) - will produce an appropriate fee for a loan, based on a fee structure and a set of rules described below. A general contract for this functionality is defined in the interface `FeeCalculator`.\n\nImplement your solution such that it fulfils the requirements.\n\n- The fee structure does not follow a formula.\n- Values in between the breakpoints should be interpolated linearly between the lower bound and upper bound that they fall between.\n- The number of breakpoints, their values, or storage might change.\n- The term can be either 12 or 24 (number of months), you can also assume values will always be within this set.\n- The fee should be rounded up such that fee + loan amount is an exact multiple of 5.\n- The minimum amount for a loan is 1,000 PLN, and the maximum is 20,000 PLN.\n- You can assume values will always be within this range but they may be any value up to 2 decimal places.\n\nExample inputs/outputs:\n|Loan amount  |Term       |Fee     |\n|-------------|-----------|--------|\n|11,500 PLN   |24 months  |460 PLN |\n|19,250 PLN   |12 months  |385 PLN |\n\n# Installation\nA database or any other external dependency is not required for this test.\n\n```bash\ncomposer install\n```\n\n# Example\n\n```php\n\u003c?php\n\nuse PragmaGoTech\\Interview\\Fee\\AccurateFeeCalculator;\nuse PragmaGoTech\\Interview\\Fee\\CsvFileLoader;\nuse PragmaGoTech\\Interview\\Fee\\FeeCalculatorFacade;\nuse PragmaGoTech\\Interview\\Fee\\LinearInterpolatedFeeCalculator;\nuse PragmaGoTech\\Interview\\Fee\\Model\\BreakpointsCollection;\n\n$resourcesDir = __DIR__ . DIRECTORY_SEPARATOR . 'resources';\n$breakpointsCollection = new BreakpointsCollection();\n$breakpointsCollection-\u003eloadFromCsv(\n    12,\n    (new CsvFileLoader($resourcesDir . DIRECTORY_SEPARATOR . '12.csv'))\n);\n$breakpointsCollection-\u003eloadFromCsv(\n    24,\n    (new CsvFileLoader($resourcesDir . DIRECTORY_SEPARATOR . '24.csv'))\n);\n$accurateFeeCalculator = new AccurateFeeCalculator($breakpointsCollection);\n$linearInterpolatedFeeCalculator = new LinearInterpolatedFeeCalculator($breakpointsCollection);\n$facade = new FeeCalculatorFacade(\n    $accurateFeeCalculator,\n    $linearInterpolatedFeeCalculator,\n);\n$fee = $facade-\u003ecalculate(24, 2750);\n// $fee = (float) 115.0\n```\n\n# Fee Structure\nThe fee structure doesn't follow particular algorithm and it is possible that same fee will be applicable for different amounts.\n\n### Term 12\n```\n1000 PLN: 50 PLN\n2000 PLN: 90 PLN\n3000 PLN: 90 PLN\n4000 PLN: 115 PLN\n5000 PLN: 100 PLN\n6000 PLN: 120 PLN\n7000 PLN: 140 PLN\n8000 PLN: 160 PLN\n9000 PLN: 180 PLN\n10000 PLN: 200 PLN\n11000 PLN: 220 PLN\n12000 PLN: 240 PLN\n13000 PLN: 260 PLN\n14000 PLN: 280 PLN\n15000 PLN: 300 PLN\n16000 PLN: 320 PLN\n17000 PLN: 340 PLN\n18000 PLN: 360 PLN\n19000 PLN: 380 PLN\n20000 PLN: 400 PLN\n```\n\n### Term 24\n\n```\n1000 PLN: 70 PLN\n2000 PLN: 100 PLN\n3000 PLN: 120 PLN\n4000 PLN: 160 PLN\n5000 PLN: 200 PLN\n6000 PLN: 240 PLN\n7000 PLN: 280 PLN\n8000 PLN: 320 PLN\n9000 PLN: 360 PLN\n10000 PLN: 400 PLN\n11000 PLN: 440 PLN\n12000 PLN: 480 PLN\n13000 PLN: 520 PLN\n14000 PLN: 560 PLN\n15000 PLN: 600 PLN\n16000 PLN: 640 PLN\n17000 PLN: 680 PLN\n18000 PLN: 720 PLN\n19000 PLN: 760 PLN\n20000 PLN: 800 PLN\n```\n\n# In Production\n\nWorking with financial data is a serious matter, and small rounding mistakes in an application may lead to serious consequences in real life. That's why floating-point arithmetic is not suited for monetary calculations. \nHowever, for the purpose of this example I do not use external libraries, because as I understood it is to show the general concepts of programming and not how I am able to use libraries, so in a production environment it would be advisable to use for example the library `moneyphp/money`. See [#2](https://github.com/andrewprofile/recuitment-task/pull/2).\n\n# Useful commands\n\nRun the following command to run the test suite. \n\n```bash\ncomposer test\n```\n\nRun the following command to run the coverage code.\n\n```bash\ncomposer code-coverage\n```\n\nRun the following command to run the static analysis code.\n\n```bash\ncomposer static-analyze\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewprofile%2Frecuitment-task","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewprofile%2Frecuitment-task","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewprofile%2Frecuitment-task/lists"}