Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
57 lines
2.2 KiB
Markdown
57 lines
2.2 KiB
Markdown
# 1. Goal
|
|
Calculate the overdue fine of a returned library item. The lending desk calls the
|
|
calculation before it prints the receipt. The result gives the days overdue, the
|
|
chargeable days, and the fine.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- Package $TMP contains no object for this task.
|
|
- The class is new. No other object is necessary.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}OVERDUE_FINE in package $TMP.
|
|
- The class is public and final. You can create it with NEW {{P}}OVERDUE_FINE( )
|
|
without parameters.
|
|
- The class has these public types:
|
|
- TY_MEDIA: character field, length 8.
|
|
- TY_AMOUNT: packed number, length 8, 2 decimal places.
|
|
- TY_RESULT: structure with the components DAYS_OVERDUE (type i),
|
|
CHARGEABLE_DAYS (type i), and FINE (type TY_AMOUNT).
|
|
- The class has one public method:
|
|
CALCULATE
|
|
IMPORTING iv_due_date TYPE d
|
|
iv_return_date TYPE d
|
|
iv_media TYPE ty_media
|
|
RETURNING VALUE(rs_result) TYPE ty_result.
|
|
- Do not add other public methods or public components.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence.
|
|
1. If iv_return_date is earlier than or equal to iv_due_date, return
|
|
DAYS_OVERDUE = 0, CHARGEABLE_DAYS = 0, and FINE = 0.00. Stop.
|
|
2. DAYS_OVERDUE is the number of calendar days from iv_due_date to iv_return_date.
|
|
3. The media code gives the daily rate and the grace days:
|
|
- BOOK: daily rate 0.30, grace 7 days
|
|
- DVD: daily rate 1.50, grace 2 days
|
|
- GAME: daily rate 2.50, grace 0 days
|
|
Compare the media code exactly. If the media code is not in this list, return
|
|
CHARGEABLE_DAYS = 0 and FINE = 0.00. Keep DAYS_OVERDUE from rule 2. Stop.
|
|
4. CHARGEABLE_DAYS is DAYS_OVERDUE minus the grace days. If this value is less
|
|
than 0, CHARGEABLE_DAYS is 0.
|
|
5. FINE is CHARGEABLE_DAYS multiplied by the daily rate.
|
|
6. If DAYS_OVERDUE is greater than 30, add a reminder fee of 5.00 to FINE.
|
|
7. If FINE is greater than 25.00, FINE is 25.00.
|
|
|
|
# 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: 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.
|