59 lines
2.5 KiB
Markdown
59 lines
2.5 KiB
Markdown
# 1. Goal
|
|
A pharmacy calculates the co-payment that a customer pays for a prescription.
|
|
A checkout program calls the calculation before it prints the receipt. The
|
|
program needs the co-payment amount and one reason code for each call.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_MED_COPAY exists in package $TMP. It is active.
|
|
- The interface has the types TY_TIER (character, length 1), TY_REASON
|
|
(character, length 10) and TY_AMOUNT (packed number, length 9, 2 decimals).
|
|
- The interface has the constant structure C_TIER with the values STANDARD,
|
|
CHRONIC and EXEMPT.
|
|
- The interface has the constant structure C_REASON with the values OK, PRICE,
|
|
QUANTITY and TIER.
|
|
- The interface has the structure TY_RESULT with the components COPAY (TY_AMOUNT)
|
|
and REASON (TY_REASON).
|
|
- The interface has one method:
|
|
CALCULATE
|
|
IMPORTING iv_price TYPE ty_amount
|
|
iv_quantity TYPE i
|
|
iv_tier TYPE ty_tier
|
|
RETURNING VALUE(rs_result) TYPE ty_result.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}MED_COPAY in package $TMP.
|
|
- The class is public, final and has a public constructor without parameters.
|
|
- The class implements {{P}}IF_MED_COPAY.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence. Return the reason of the first rule that fails.
|
|
1. If iv_price is zero or less, return the reason PRICE and the co-payment 0.
|
|
2. If iv_quantity is less than 1, return the reason QUANTITY and the co-payment 0.
|
|
3. If iv_tier is not STANDARD, CHRONIC or EXEMPT, return the reason TIER and the
|
|
co-payment 0.
|
|
4. The total price is iv_price multiplied by iv_quantity.
|
|
5. If iv_tier is EXEMPT, the co-payment is 0. Continue with rule 9.
|
|
6. If iv_tier is CHRONIC, the co-payment is 10 per cent of the total price.
|
|
7. If iv_tier is STANDARD, the co-payment is 30 per cent of the total price.
|
|
8. Round the co-payment to 2 decimals (commercial rounding, half away from zero).
|
|
Then apply the limits. For CHRONIC the minimum is 5.00 and the maximum is
|
|
10.00. For STANDARD the minimum is 5.00 and the maximum is 50.00.
|
|
9. If the co-payment is more than the total price, the co-payment is the total
|
|
price.
|
|
10. Return the reason OK.
|
|
|
|
# 6. Constraints
|
|
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
|
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
|
variables. No comment that restates the code.
|
|
- Out of scope: do not change {{P}}IF_MED_COPAY.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|