Stage 2 summary at 50 accepted trajectories

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 18:02:52 +02:00
parent 332fb4601d
commit 5bcd1bf9cd
1230 changed files with 77563 additions and 33 deletions

View File

@@ -0,0 +1,51 @@
FUNCTION {{p}}tel_rate
IMPORTING
iv_ctype TYPE string
iv_zone TYPE string
iv_secs TYPE i
EXPORTING
ev_minutes TYPE i
ev_charge TYPE decfloat34
EXCEPTIONS
invalid_duration.
TYPES: BEGIN OF ty_price,
ctype TYPE string,
zone TYPE string,
price TYPE decfloat34,
END OF ty_price,
tt_price TYPE SORTED TABLE OF ty_price WITH UNIQUE KEY ctype zone.
DATA lt_prices TYPE tt_price.
DATA ls_price TYPE ty_price.
IF iv_secs < 0.
RAISE invalid_duration.
ENDIF.
IF iv_secs > 0.
ev_minutes = ( iv_secs + 59 ) DIV 60.
lt_prices = VALUE #(
( ctype = 'NT' zone = 'A' price = '0.09' )
( ctype = 'NT' zone = 'B' price = '0.19' )
( ctype = 'NT' zone = 'C' price = '0.29' )
( ctype = 'IT' zone = 'A' price = '0.19' )
( ctype = 'IT' zone = 'B' price = '0.39' )
( ctype = 'IT' zone = 'C' price = '0.59' )
( ctype = 'MO' zone = 'A' price = '0.29' )
( ctype = 'MO' zone = 'B' price = '0.49' )
( ctype = 'MO' zone = 'C' price = '0.69' )
( ctype = 'SP' zone = 'A' price = '0.39' )
( ctype = 'SP' zone = 'B' price = '0.59' )
( ctype = 'SP' zone = 'C' price = '0.79' ) ).
READ TABLE lt_prices INTO ls_price
WITH TABLE KEY ctype = iv_ctype zone = iv_zone.
IF sy-subrc = 0 AND ls_price-price > 0.
ev_charge = round( val = ev_minutes * ls_price-price + 0.025
dec = 2 mode = cl_abap_math=>round_half_up ).
ENDIF.
ENDIF.
ENDFUNCTION.

View File

@@ -0,0 +1,73 @@
CLASS {{p}}tel_test DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS rate
IMPORTING iv_ctype TYPE string
iv_zone TYPE string
iv_secs TYPE i
EXPORTING ev_minutes TYPE i
ev_charge TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS zero_duration FOR TESTING.
METHODS national_call FOR TESTING.
METHODS rounds_up FOR TESTING.
METHODS unknown_type FOR TESTING.
METHODS negative_secs FOR TESTING.
ENDCLASS.
CLASS {{p}}tel_test IMPLEMENTATION.
METHOD rate.
CALL FUNCTION '{{P}}TEL_RATE'
EXPORTING
iv_ctype = iv_ctype
iv_zone = iv_zone
iv_secs = iv_secs
IMPORTING
ev_minutes = ev_minutes
ev_charge = ev_charge
EXCEPTIONS
invalid_duration = 1
OTHERS = 2.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD zero_duration.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 0
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD national_call.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = 30
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.12' ) act = lv_charge ).
ENDMETHOD.
METHOD rounds_up.
rate( EXPORTING iv_ctype = 'IT' iv_zone = 'B' iv_secs = 61
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.81' ) act = lv_charge ).
ENDMETHOD.
METHOD unknown_type.
rate( EXPORTING iv_ctype = 'XX' iv_zone = 'A' iv_secs = 60
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_min ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( 0 ) act = lv_charge ).
ENDMETHOD.
METHOD negative_secs.
rate( EXPORTING iv_ctype = 'NT' iv_zone = 'A' iv_secs = -1
IMPORTING ev_minutes = DATA(lv_min) ev_charge = DATA(lv_charge) ev_subrc = DATA(lv_rc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
ENDCLASS.