Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
63 lines
2.5 KiB
Markdown
63 lines
2.5 KiB
Markdown
# 1. Goal
|
|
A bank charges interest on the overdrawn part of a current account. The bank
|
|
needs one calculation that returns the interest of one account for one period.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- All objects are in package $TMP.
|
|
- The interface {{P}}IF_OVERDRAFT exists in package $TMP. It is active.
|
|
- The interface contains the types TY_AMOUNT (packed number, length 15, two
|
|
decimals) and TY_SEGMENT (character, length 1), the constants
|
|
C_SEGMENT_PRIVATE (value 'P'), C_SEGMENT_BUSINESS (value 'B') and
|
|
C_MIN_INTEREST (value 5.00), and one method:
|
|
CALCULATE
|
|
IMPORTING iv_amount TYPE ty_amount
|
|
iv_days TYPE i
|
|
iv_segment TYPE ty_segment
|
|
RETURNING VALUE(rv_interest) TYPE ty_amount.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}OVERDRAFT_CALC in package $TMP.
|
|
- The class is public and final. It implements {{P}}IF_OVERDRAFT.
|
|
- The class can be created without parameters.
|
|
- Do not add other public methods or attributes.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence.
|
|
1. If iv_amount is zero or negative, or if iv_days is zero or negative,
|
|
return 0.00.
|
|
2. The first three days of the period carry no interest. The chargeable days
|
|
are iv_days minus 3. If this value is negative, the chargeable days are 0.
|
|
3. The whole amount uses one annual interest rate. The rate depends on the
|
|
amount:
|
|
- amount up to and including 1,000.00: 12.00 per cent
|
|
- amount up to and including 5,000.00: 10.00 per cent
|
|
- amount up to and including 20,000.00: 8.00 per cent
|
|
- amount above 20,000.00: 6.50 per cent
|
|
4. If iv_segment is 'B', subtract 2.00 percentage points from the rate. The
|
|
rate never falls below 5.00 per cent. Every other value of iv_segment
|
|
leaves the rate unchanged.
|
|
5. The interest is the exact value of
|
|
amount * (rate / 100) * (chargeable days / 360).
|
|
Do not round intermediate results. Round only the final interest to 2
|
|
decimals. Round half away from zero.
|
|
6. If the rounded interest is greater than 0.00 and less than 5.00, the
|
|
interest is 5.00.
|
|
7. Return the interest.
|
|
|
|
# 6. Constraints
|
|
- Release target: 7.02. The code must pass the 7.02 syntax check. Do not use
|
|
language elements that are newer than release 7.02. Examples of forbidden
|
|
elements are inline declarations, constructor expressions and table
|
|
expressions.
|
|
- Coding standards: Clean ABAP. Methods below 40 statements. No global
|
|
variables.
|
|
- Out of scope: do not change {{P}}IF_OVERDRAFT.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|