63 lines
2.7 KiB
Markdown
63 lines
2.7 KiB
Markdown
# 1. Goal
|
|
A water utility bills a household for one quarter. The billing program calls the
|
|
class {{P}}WATER_BILL for each meter reading. The class calculates the amount of
|
|
the bill in euro.
|
|
|
|
# 2. Open questions
|
|
None.
|
|
|
|
# 3. Context
|
|
- The class {{P}}WATER_TARIFF exists in package $TMP. It is active. It gives the
|
|
tariff data of the utility. Read its definition before you start.
|
|
- The tariff data contains a list of price tiers, the standing charge for one
|
|
day, the sewage percentage, and the minimum charge.
|
|
- All objects are in package $TMP.
|
|
|
|
# 4. Contract
|
|
- Create the class {{P}}WATER_BILL in package $TMP.
|
|
- The class is public and final. It has a public constructor without parameters.
|
|
- The class has the public type TY_AMOUNT. TY_AMOUNT is a packed number with
|
|
two decimal places.
|
|
- The class has this public method and no other public method:
|
|
calculate
|
|
IMPORTING iv_consumption TYPE i
|
|
iv_days TYPE i
|
|
RETURNING VALUE(rv_amount) TYPE ty_amount.
|
|
- iv_consumption is the consumption of the household in cubic metres.
|
|
- iv_days is the number of days of the billing period.
|
|
|
|
# 5. Business rules
|
|
Use the values of the tariff in {{P}}WATER_TARIFF.
|
|
1. Consumption charge:
|
|
- The tariff gives the price tiers in ascending order.
|
|
- The tiers are cumulative. The upper limit of a tier is a total consumption,
|
|
not the width of the tier.
|
|
- A tier covers the consumption up to its upper limit.
|
|
- The tier with the upper limit 0 is the last tier. It covers all the
|
|
consumption above the upper limit of the previous tier.
|
|
- Multiply the consumption of each tier by the price of that tier.
|
|
- The consumption charge is the sum of these products.
|
|
2. Sewage charge: it is the sewage percentage of the consumption charge. The
|
|
sewage percentage is a number of percent (50 means 50 percent). Round the
|
|
sewage charge to two decimal places.
|
|
3. Standing charge: it is the number of days multiplied by the standing charge
|
|
of the tariff for one day.
|
|
4. The net amount is the consumption charge plus the sewage charge plus the
|
|
standing charge.
|
|
5. If the net amount is below the minimum charge of the tariff, the amount of
|
|
the bill is the minimum charge.
|
|
6. Else the amount of the bill is the net amount.
|
|
7. The amount of the bill has two decimal places.
|
|
|
|
# 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. Pass large parameters by
|
|
reference.
|
|
- Out of scope: do not change {{P}}WATER_TARIFF.
|
|
|
|
# 7. Acceptance
|
|
- The class is active and has no syntax error.
|
|
- The hidden tests pass.
|
|
- Write your own ABAP Unit tests for the class.
|