Files
abap-llm/tasks_gen/eval/G0105/spec.md

87 lines
2.7 KiB
Markdown

# 1. Goal
A toll operator charges a fee for each truck trip on its road network. The trip
log program calls one function module for each trip. The call happens before
the program stores the trip. The fee depends only on the trip data that the
caller passes.
# 2. Open questions
None.
# 3. Context
- Function group {{P}}FG_TOLL exists in package $TMP.
- All objects of this task are in package $TMP.
- The trip log program is not part of this task.
# 4. Contract
## 4.1 Function module {{P}}TOLL_FEE
Create the function module {{P}}TOLL_FEE in function group {{P}}FG_TOLL.
The interface is exactly:
IMPORTING
iv_distance_km TYPE decfloat34
iv_weight_class TYPE i
iv_axles TYPE i
EXPORTING
ev_fee TYPE decfloat34
EXCEPTIONS
invalid_input
## 4.2 Class {{P}}TOLL_CALC
Create the global class {{P}}TOLL_CALC in package $TMP. The class is public and
final. The class has a public instance constructor without parameters.
The class has this public method:
METHODS calculate
IMPORTING iv_distance_km TYPE decfloat34
iv_weight_class TYPE i
iv_axles TYPE i
RETURNING VALUE(rv_fee) TYPE decfloat34
RAISING cx_abap_invalid_value.
# 5. Business rules
1. The distance is the length of the trip in kilometres. A distance below 0
is invalid input.
2. The weight class is 1, 2, 3, or 4. Every other value is invalid input.
3. The number of axles is 2, 3, 4, or 5. Every other value is invalid input.
4. Invalid input raises the exception INVALID_INPUT in {{P}}TOLL_FEE and the
exception CX_ABAP_INVALID_VALUE in {{P}}TOLL_CALC. {{P}}TOLL_FEE does not
set the fee in this case.
5. The base rate per kilometre depends on the weight class:
- Weight class 1: 0.10
- Weight class 2: 0.14
- Weight class 3: 0.18
- Weight class 4: 0.22
6. The number of axles adds a surcharge to the base amount:
- 2 axles: 0 %
- 3 axles: 5 %
- 4 axles: 10 %
- 5 axles: 15 %
7. The base amount is the distance multiplied by the base rate. The fee is the
base amount increased by the surcharge percentage. Round the fee half up to
2 decimals.
8. The minimum fee is 1.00. If the fee from rule 7 is below 1.00, the fee is
1.00.
9. {{P}}TOLL_FEE returns the fee that {{P}}TOLL_CALC calculates.
# 6. Constraints
- Release target: 7.58.
- The calculation is pure logic. It reads no database table and no other
external data.
- Out of scope: the trip log program and every object that is not in the
contract.
# 7. Acceptance
- {{P}}TOLL_FEE and {{P}}TOLL_CALC are active and have no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests. Put local test classes in {{P}}TOLL_CALC. Write a
global test class for {{P}}TOLL_FEE.