Files
2026-10-05 18:02:52 +02:00

61 lines
2.6 KiB
Markdown

# 1. Goal
A school canteen bills the parents for the meals of one week. The billing
program calls one function module for each week. The function module reads the
meal bookings of the week and returns the number of charged meals, the number
of pupils, the total amount, and the total discount.
# 2. Open questions
None.
# 3. Context
- The function group {{P}}FG_MEAL exists in package $TMP.
- The database table {{P}}MEALBK exists in package $TMP. It contains the meal
bookings. Its fields are:
- mandt: the client
- week_key: the week of the booking, for example '2024-15'
- pupil: the pupil who booked the meal
- meal_no: the number of the booking inside the week
- meal: the kind of meal, for example 'LUNCH'
- price: the price of the meal
- cancelled: 'X' when the booking was cancelled, otherwise initial
- The class {{P}}MEAL_DATA fills the table with sample bookings.
# 4. Contract
- Create the function module {{P}}MEAL_BILL in function group {{P}}FG_MEAL.
- Interface of {{P}}MEAL_BILL:
- IMPORTING iv_week TYPE string
- EXPORTING ev_meals TYPE decfloat34
- EXPORTING ev_pupils TYPE decfloat34
- EXPORTING ev_amount TYPE decfloat34
- EXPORTING ev_discount TYPE decfloat34
- EXCEPTIONS invalid_price
# 5. Business rules
1. The function module reads the bookings of the given week. A booking belongs
to the week that is in its field week_key.
2. A booking is charged when cancelled is not 'X' and price is greater than 0.
3. If a booking of the week has a price less than 0, raise the exception
INVALID_PRICE.
4. Each charged booking counts as one meal of its pupil.
5. The gross amount of a pupil is the sum of the prices of the charged bookings
of the pupil.
6. If a pupil has 5 or more charged meals, the amount of the pupil is 90 % of
the gross amount, rounded half up to 2 decimals. If a pupil has fewer than 5
charged meals, the amount of the pupil is the gross amount.
7. ev_meals is the total number of charged meals of the week.
8. ev_pupils is the number of pupils with at least one charged booking.
9. ev_amount is the sum of the amounts of all pupils.
10. ev_discount is the sum of the differences between the gross amount and the
amount of each pupil.
11. If the week has no charged booking, all output parameters are 0.
# 6. Constraints
- Release target: 7.58.
- Coding standards: Clean ABAP. Keep every method below 40 statements.
- Out of scope: do not change {{P}}MEALBK and {{P}}MEAL_DATA.
# 7. Acceptance
- The function module {{P}}MEAL_BILL is active and has no syntax error.
- The hidden tests pass.
- Write ABAP Unit tests for the function module in a global test class.