Question: Assignment (1) final part. 1) Write a ruby function payslip_monthly to compute a monthly payslip of an individual based on his/her annual salary with 2
Assignment (1) final part.
1) Write a ruby function payslip_monthly to compute a monthly payslip of an individual based on his/her annual salary with 2 decimal places with unit tests.
for example: When we give an argument of "tomy" with "60000"
payslip_monthly "tomy" 60000
Then it will return an output in console:
Monthly Payslip for: "tomy"
Gross Monthly Income: $5000.00
Monthly Income Tax: $500.00
Net Monthly Income: $4500.00
As follows is Tax Bracket:
| Salary Bracket | Rate |
|---|---|
| first 0 - 20000 | 0% |
| next 20001-40000 | 10% |
| next 40001-80000 | 20% |
| next 80001-180000 | 30% |
| 180001 and above | 40% |
2) Create a POST REST API request to expose payslip_monthly. Request parameters should include employee_name and annual_salary. The response body should return JSON format. Add unit tests where you think its relevant.
{ "employee_name": string, "gross_monthly_income": string, "monthly_income_tax": string, "net_monthly_income": string, } 3) When compute monthly salary POST API is invoked, Then write the following information in a database of your choice, can use any local or cloud database
- Timestamp
- Employee Name
- Annual Salary
- Monthly Income Tax
4) Create a GET API to list out all information from Requirement 3 on JSON Format:
- unit tests where you think its relevant
{ salary_computations: [ { "time_stamp": string, "employee_name": string "annual_salary": string "monthly_income_tax": string } ] } 5) Create Feature related to the APIs
- Build a Simple UI Form to enter transactions
- Generate a CSV
Prefer use unit test framework: Rspec and Minitest
* Please provide with your answer explanation algorithm that used for payslip computation, design pattern used, unit tests wrote, post/ get api / postman, database used and if you used any extra requirement you invented.
End of question.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
