Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
48 lines
1.5 KiB
ABAP
48 lines
1.5 KiB
ABAP
FUNCTION {{p}}bowl_fee_old
|
|
IMPORTING
|
|
iv_lanes TYPE i
|
|
iv_minutes TYPE i
|
|
iv_players TYPE i
|
|
iv_day TYPE string
|
|
iv_start TYPE t
|
|
iv_member TYPE abap_bool
|
|
EXPORTING
|
|
ev_fee TYPE decfloat34
|
|
EXCEPTIONS
|
|
invalid_input.
|
|
|
|
CONSTANTS c_half_hour_minutes TYPE i VALUE 30.
|
|
CONSTANTS c_lane_price TYPE decfloat34 VALUE '6.00'.
|
|
CONSTANTS c_shoe_price TYPE decfloat34 VALUE '2.50'.
|
|
CONSTANTS c_peak_start TYPE t VALUE '180000'.
|
|
CONSTANTS c_peak_end TYPE t VALUE '220000'.
|
|
CONSTANTS c_peak_factor TYPE decfloat34 VALUE '1.2'.
|
|
CONSTANTS c_weekend_factor TYPE decfloat34 VALUE '1.15'.
|
|
CONSTANTS c_member_factor TYPE decfloat34 VALUE '0.9'.
|
|
CONSTANTS c_member_min_fee TYPE decfloat34 VALUE '20.00'.
|
|
|
|
IF iv_lanes < 1 OR iv_minutes < 1 OR iv_players < 0.
|
|
RAISE invalid_input.
|
|
ENDIF.
|
|
|
|
DATA(lv_half_hours) = ( iv_minutes + c_half_hour_minutes - 1 ) DIV c_half_hour_minutes.
|
|
DATA(lv_lane_fee) = iv_lanes * lv_half_hours * c_lane_price.
|
|
|
|
IF iv_start >= c_peak_start AND iv_start < c_peak_end.
|
|
lv_lane_fee = lv_lane_fee * c_peak_factor.
|
|
ENDIF.
|
|
|
|
IF iv_day = 'SAT' AND iv_day = 'SUN'.
|
|
lv_lane_fee = lv_lane_fee * c_weekend_factor.
|
|
ENDIF.
|
|
|
|
DATA(lv_total) = lv_lane_fee + iv_players * c_shoe_price.
|
|
|
|
IF iv_member = abap_true AND lv_total >= c_member_min_fee.
|
|
lv_total = lv_total * c_member_factor.
|
|
ENDIF.
|
|
|
|
ev_fee = round( val = lv_total dec = 2 mode = cl_abap_math=>round_half_up ).
|
|
|
|
ENDFUNCTION.
|