You are given two files: 1. LineItemTest.php 2. LineItem.php
Complete the 'LineItem.php' class using 'LineItemTest.php' as a reference, ensuring that all tests pass.
No test cases should be removed, but additional tests may be added if necessary.
Please refer to the link below to obtain the formulas necessary to complete this exercise.
https://support.avaza.com/what-difference-does-the-tax-inclusive-tax-exclusive-setting-make/
Methods to implement:
1. `__construct`
pass in the input and other information necessary, see all the test cases
2. `subTotal`
which which equals unit price * qty
3. `netPrice`
also known as "Amount Before Tax," see the link for formulas for both tax inclusive and exclusive
4. `discountAmount`
refer to the link for the formula; simply return 'discount value' if the 'discount type' is not percent.
5. `taxAmount`
see the link to find the formula
6. `totalAmount
see the link to find the formula
Notes:
1. Discounts are offered in two ways.
- percent
- value (amount)
2. Taxes are classified into two categories: inclusive and exclusive.
3. By default the "line item" is tax exclusive (test cases 1 and 2)
Ensure that you handle all the cases.
Tips:
1. To obtain accurate results, netPrice and taxAmount are rounded to two decimal places (verify yourself)
- (Discount %) = ($discount_value / 100)
- (Tax %) = ($tax_percent / 100)
- Include brackets wherever necessary to obtain the correct calculation.
Finally, submit 'LineItem.php' privately (Make sure your answer is not public)