Files
abap-llm/tasks_gen/train/G1039/spec.md

2.2 KiB

1. Goal

A tour operator wants a summary of the booking fees of one day. The booking program calls one class for each day of the month and shows the summary.

2. Open questions

None.

3. Context

  • The interface {{P}}IF_TOUR_SUMMARY exists in package $TMP. It is active.
  • The interface has the types TY_TOUR_TYPE, TY_STATUS, TY_BOOKING, TT_BOOKING and TY_RESULT, the constant structure C_STATUS, and one method: SUMMARIZE IMPORTING it_bookings TYPE tt_booking RETURNING VALUE(rs_result) TYPE ty_result.
  • The booking program passes the bookings of one day to the method.
  • A day can have no bookings.

4. Contract

  • Create the class {{P}}TOUR_SUMMARY in package $TMP.
  • The class is public, final, and has a public constructor without parameters.
  • The class implements {{P}}IF_TOUR_SUMMARY.
  • Do not add other public methods.

5. Business rules

  1. A tour type is 'C' (classic) or 'P' (premium).
  2. If one booking has a negative number of adults or a negative number of children, the summary is invalid. Return status 'N' and 0 in the fields total_fee, booking_count and average_fee.
  3. If one booking has a tour type that is not 'C' and not 'P', the summary is invalid. Return status 'T' and 0 in the fields total_fee, booking_count and average_fee.
  4. Check rule 2 before rule 3.
  5. The fee of one booking: an adult pays 20.00 for a classic tour and 30.00 for a premium tour. A child pays half of the adult fee of the tour.
  6. If the number of participants of one booking (adults plus children) is 10 or more, reduce the fee of this booking by 10 percent.
  7. Round the fee of each booking to 2 decimals. Round half up.
  8. total_fee is the sum of the fees of all bookings.
  9. booking_count is the number of bookings.
  10. average_fee is total_fee divided by booking_count. Round half up to 2 decimals.
  11. If the summary is valid, return status 'O'.

6. Constraints

  • Release target: 8.16.
  • 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_TOUR_SUMMARY.

7. Acceptance

  • The class is active and has no syntax error.
  • The class implements {{P}}IF_TOUR_SUMMARY.
  • Write your own ABAP Unit tests for the class.