67 lines
2.9 KiB
Markdown
67 lines
2.9 KiB
Markdown
# 1. Goal
|
|
A freight forwarder prices air freight shipments. The sales desk calls one class
|
|
for each shipment. The class returns the chargeable weight, the freight, the
|
|
surcharges and the total charge of the shipment.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The interface {{P}}IF_AIR_FREIGHT exists in package $TMP. It is active.
|
|
- The interface defines the input types, the result structure, the goods
|
|
categories, the reason codes and one method. Read the interface before you
|
|
start.
|
|
- The method receives the actual weight in kilograms, the volume in cubic
|
|
centimetres, the goods category and a flag that marks a dangerous goods
|
|
shipment.
|
|
- The result structure has one field for the chargeable weight, one field for
|
|
each amount and one field for the reason.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}AIR_FREIGHT_PRICER in package $TMP.
|
|
- The class is public, final and has a public constructor without parameters.
|
|
- The class implements {{P}}IF_AIR_FREIGHT.
|
|
- Do not add other public methods.
|
|
|
|
# 5. Business rules
|
|
Apply the rules in this sequence.
|
|
1. If the actual weight is not positive, return BAD_WEIGHT.
|
|
2. If the volume is not positive, return BAD_VOLUME.
|
|
3. If the category is not one of the categories of the interface, return
|
|
BAD_CATEGORY.
|
|
4. The volumetric weight is the volume divided by 6000. The chargeable weight
|
|
is the larger of the actual weight and the volumetric weight, rounded up to
|
|
the next whole kilogram. A value that is already a whole number does not
|
|
change.
|
|
5. If the chargeable weight is more than 3000 kg, return TOO_HEAVY.
|
|
6. The base rate per kilogram depends on the chargeable weight:
|
|
- up to 45 kg: 9.00
|
|
- more than 45 kg and up to 100 kg: 7.20
|
|
- more than 100 kg and up to 500 kg: 5.60
|
|
- more than 500 kg: 4.30
|
|
7. The category factor is 1.00 for the general category, 1.25 for the
|
|
perishable category and 1.50 for the valuable category.
|
|
8. The freight is the chargeable weight multiplied by the base rate and by the
|
|
category factor.
|
|
9. If the shipment is dangerous, the dangerous goods surcharge is 40 per cent
|
|
of the freight. Otherwise the dangerous goods surcharge is zero.
|
|
10. The fuel surcharge is 12 per cent of the freight plus the dangerous goods
|
|
surcharge.
|
|
11. The security fee is 15.00.
|
|
12. The total is the freight plus the dangerous goods surcharge plus the fuel
|
|
surcharge plus the security fee.
|
|
13. Round each amount to two decimal places before you use it in the next step.
|
|
14. If one of the rules 1 to 5 fails, return the reason and set every numeric
|
|
field of the result to zero. If no rule fails, return 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_AIR_FREIGHT.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|