66 lines
2.5 KiB
Markdown
66 lines
2.5 KiB
Markdown
# 1. Goal
|
|
Calculate the monthly fee for a child at a day care centre. The billing program
|
|
calls the calculation for each child before it creates the invoice. The program
|
|
needs the fee and one reason code for each child.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}CHILDCARE_PRICER does not exist yet. Create it in package $TMP.
|
|
- The billing program is not part of this task. It calls the calculation for
|
|
each child and reads the reason and the fee.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}CHILDCARE_PRICER in package $TMP.
|
|
- The class is public, final, and has a public constructor without parameters.
|
|
- Define these public types:
|
|
TY_AGE_BAND TYPE c LENGTH 4
|
|
TY_REASON TYPE c LENGTH 6
|
|
TY_AMOUNT TYPE p LENGTH 8 DECIMALS 2
|
|
TY_RESULT a structure with the components REASON (TY_REASON) and
|
|
FEE (TY_AMOUNT)
|
|
- Define the public constant structure C_REASON with the components OK, AGE and
|
|
DAYS. Each component has the type TY_REASON.
|
|
- Add one public method:
|
|
CALCULATE
|
|
IMPORTING iv_age_months TYPE i
|
|
iv_days TYPE i
|
|
iv_full_day TYPE abap_bool
|
|
iv_sibling TYPE abap_bool
|
|
RETURNING VALUE(rs_result) TYPE ty_result
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence.
|
|
1. If iv_age_months is less than 3 or more than 60, return the reason AGE and
|
|
the fee 0.
|
|
2. If iv_days is less than 1 or more than 5, return the reason DAYS and the fee
|
|
0.
|
|
3. Find the age band of the child:
|
|
3 to 11 months: BABY
|
|
12 to 35 months: TODD
|
|
36 to 60 months: PRE
|
|
4. Find the daily rate of the age band:
|
|
BABY: 62.00 for a full day, 38.00 for a half day
|
|
TODD: 54.00 for a full day, 33.00 for a half day
|
|
PRE: 46.00 for a full day, 28.00 for a half day
|
|
iv_full_day = abap_true means a full day. All other values mean a half day.
|
|
5. The monthly fee is the daily rate multiplied by iv_days and by 4.348. Round
|
|
the result to 2 decimal places.
|
|
6. If iv_sibling = abap_true, multiply the monthly fee by 0.9 and round the
|
|
result to 2 decimal places.
|
|
7. If the monthly fee is more than 1050.00, set it to 1050.00.
|
|
8. Return the reason OK and the monthly fee.
|
|
|
|
# 6. Constraints
|
|
- Release target: 8.16.
|
|
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
|
variables. No comment that restates the code.
|
|
- Out of scope: no other object.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|