Pipeline controller: plan 2 (hard +, error +50 %), backlog throttle, 2 trajectory workers, stop rules, summaries every 50; budget reserve

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Kral
2026-10-05 13:35:54 +02:00
parent 1c4667a0fc
commit 13360292dd
781 changed files with 50211 additions and 22 deletions

View File

@@ -0,0 +1,94 @@
CLASS {{p}}garden_rent DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_plot_type TYPE c LENGTH 4.
TYPES ty_reason TYPE c LENGTH 10.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES:
BEGIN OF ty_result,
reason TYPE ty_reason,
rent TYPE ty_amount,
END OF ty_result.
CONSTANTS:
BEGIN OF c_reason,
ok TYPE ty_reason VALUE 'OK',
plot TYPE ty_reason VALUE 'PLOT',
area TYPE ty_reason VALUE 'AREA',
END OF c_reason.
METHODS calculate
IMPORTING iv_plot_type TYPE ty_plot_type
iv_area TYPE i
iv_water TYPE abap_bool
iv_member TYPE abap_bool
RETURNING VALUE(rs_result) TYPE ty_result.
PRIVATE SECTION.
CONSTANTS:
c_min_area TYPE i VALUE 10,
c_max_area TYPE i VALUE 500,
c_water_units TYPE i VALUE 120000,
c_member_percent TYPE i VALUE 85,
c_scale TYPE i VALUE 100,
c_half_cent TYPE i VALUE 50,
c_min_rent_cents TYPE i VALUE 1000,
c_cent_factor TYPE ty_amount VALUE '0.01'.
METHODS is_valid_plot_type
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS rate_units
IMPORTING iv_plot_type TYPE ty_plot_type
RETURNING VALUE(rv_units) TYPE i.
METHODS to_amount
IMPORTING iv_cents TYPE i
RETURNING VALUE(rv_rent) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}garden_rent IMPLEMENTATION.
METHOD calculate.
IF is_valid_plot_type( iv_plot_type ) = abap_false.
rs_result-reason = c_reason-plot.
RETURN.
ENDIF.
IF iv_area < c_min_area OR iv_area > c_max_area.
rs_result-reason = c_reason-area.
RETURN.
ENDIF.
DATA(lv_units) = iv_area * rate_units( iv_plot_type ).
IF iv_water = abap_true.
lv_units = lv_units + c_water_units.
ENDIF.
IF iv_member = abap_true.
lv_units = ( lv_units * c_member_percent ) DIV c_scale.
ENDIF.
DATA(lv_cents) = ( lv_units + c_half_cent ) DIV c_scale.
IF lv_cents < c_min_rent_cents.
lv_cents = c_min_rent_cents.
ENDIF.
rs_result-rent = to_amount( lv_cents ).
rs_result-reason = c_reason-ok.
ENDMETHOD.
METHOD is_valid_plot_type.
CASE to_upper( iv_plot_type ).
WHEN 'STD' OR 'PREM' OR 'BED'.
rv_valid = abap_true.
ENDCASE.
ENDMETHOD.
METHOD rate_units.
CASE to_upper( iv_plot_type ).
WHEN 'STD'.
rv_units = 3500.
WHEN 'PREM'.
rv_units = 6000.
WHEN 'BED'.
rv_units = 9000.
ENDCASE.
ENDMETHOD.
METHOD to_amount.
DATA(lv_cents) = CONV ty_amount( iv_cents ).
rv_rent = lv_cents * c_cent_factor.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,71 @@
CLASS ltc_garden_rent DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
DATA mo_cut TYPE REF TO {{p}}garden_rent.
METHODS setup.
METHODS standard_plot_rent FOR TESTING.
METHODS member_discount FOR TESTING.
METHODS water_connection_fee FOR TESTING.
METHODS minimum_rent FOR TESTING.
METHODS rounds_half_up FOR TESTING.
METHODS unknown_plot_type FOR TESTING.
METHODS area_out_of_range FOR TESTING.
ENDCLASS.
CLASS ltc_garden_rent IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}garden_rent( ).
ENDMETHOD.
METHOD standard_plot_rent.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '35.00' ) act = ls_result-rent ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-ok
act = ls_result-reason ).
ENDMETHOD.
METHOD member_discount.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 100
iv_water = abap_false iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '29.75' ) act = ls_result-rent ).
ENDMETHOD.
METHOD water_connection_fee.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'PREM' iv_area = 100
iv_water = abap_true iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '72.00' ) act = ls_result-rent ).
ENDMETHOD.
METHOD minimum_rent.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 10
iv_water = abap_false iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '10.00' ) act = ls_result-rent ).
ENDMETHOD.
METHOD rounds_half_up.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 42
iv_water = abap_true iv_member = abap_true ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '22.70' ) act = ls_result-rent ).
ENDMETHOD.
METHOD unknown_plot_type.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'X' iv_area = 100
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-plot
act = ls_result-reason ).
cl_abap_unit_assert=>assert_equals( exp = CONV ty_amount( '0.00' ) act = ls_result-rent ).
ENDMETHOD.
METHOD area_out_of_range.
DATA(ls_result) = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 9
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-area
act = ls_result-reason ).
ls_result = mo_cut->calculate( iv_plot_type = 'STD' iv_area = 501
iv_water = abap_false iv_member = abap_false ).
cl_abap_unit_assert=>assert_equals( exp = {{p}}garden_rent=>c_reason-area
act = ls_result-reason ).
ENDMETHOD.
ENDCLASS.