Files

69 lines
2.4 KiB
Markdown

# 1. Goal
A company pays a monthly commission to its sales agents. A payroll program
calls one calculation for each agent and each month. The calculation returns
the commission of one agent.
# 2. Open questions
None.
# 3. Context
- The interface {{P}}IF_COMMISSION exists in package $TMP. It is active.
- The interface contains the type TY_AMOUNT. TY_AMOUNT is a packed number
with length 15 and 2 decimal places.
- The interface contains one method:
CALCULATE
IMPORTING iv_sales TYPE ty_amount
iv_target TYPE ty_amount
iv_years TYPE i
RETURNING VALUE(rv_bonus) TYPE ty_amount
- iv_sales is the sales volume of the month.
- iv_target is the monthly target of the agent.
- iv_years is the number of completed years of service of the agent.
# 4. Contract
- Create the class {{P}}COMMISSION_CALC in package $TMP.
- The class is public and final. The class has a public constructor without
parameters.
- The class implements the interface {{P}}IF_COMMISSION.
- Do not add other public methods.
# 5. Business rules
Apply the rules in this sequence.
1. If iv_sales is zero or negative, or if iv_target is zero or negative,
return 0.
2. If two times iv_sales is less than iv_target, return 0.
3. Calculate the commission. Keep the full precision. Round only in rule 4.
a. Add 1 percent of the part of iv_sales that is at most iv_target.
b. If iv_sales is more than iv_target, add 3 percent of the part of
iv_sales that is more than iv_target. Use at most half of iv_target
for this part.
c. If iv_sales is more than 1.5 times iv_target, add 5 percent of the
part of iv_sales that is more than 1.5 times iv_target.
4. Round the commission to 2 decimal places. Use commercial rounding.
5. Add the loyalty bonus. Add 500 if iv_years is 10 or more. Add 200 if
iv_years is 5 or more. Add 0 in all other cases.
6. If the result is more than 5000, return 5000.
7. Return the result.
# 6. Constraints
- Release target: 7.40 SP05. Use only language elements that this release
supports. Do not use language elements of a later release.
- Coding standards: Clean ABAP. Method length below 40 statements. No global
variables. No comment that restates the code.
- Out of scope: do not change the interface {{P}}IF_COMMISSION.
# 7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.