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,108 @@
CLASS {{p}}storage_pricer DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES ty_sqm TYPE i.
TYPES ty_months TYPE i.
TYPES:
BEGIN OF ty_booking,
size_sqm TYPE ty_sqm,
months TYPE ty_months,
climate TYPE abap_bool,
insurance TYPE abap_bool,
END OF ty_booking.
METHODS calculate_price
IMPORTING is_booking TYPE ty_booking
RETURNING VALUE(rv_price) TYPE ty_amount.
PRIVATE SECTION.
CONSTANTS:
c_rate_small TYPE ty_amount VALUE '14.00',
c_rate_medium TYPE ty_amount VALUE '11.50',
c_rate_large TYPE ty_amount VALUE '9.00',
c_climate_addon TYPE ty_amount VALUE '4.50',
c_insurance_rate TYPE ty_amount VALUE '0.90',
c_admin_fee TYPE ty_amount VALUE '19.00',
c_percent TYPE i VALUE 100,
c_size_small_max TYPE ty_sqm VALUE 5,
c_size_medium_max TYPE ty_sqm VALUE 15,
c_months_short TYPE ty_months VALUE 6,
c_months_medium TYPE ty_months VALUE 12,
c_months_long TYPE ty_months VALUE 24,
c_disc_short TYPE i VALUE 5,
c_disc_medium TYPE i VALUE 10,
c_disc_long TYPE i VALUE 15.
METHODS is_valid
IMPORTING is_booking TYPE ty_booking
RETURNING VALUE(rv_valid) TYPE abap_bool.
METHODS monthly_rate
IMPORTING is_booking TYPE ty_booking
RETURNING VALUE(rv_rate) TYPE ty_amount.
METHODS discount_percent
IMPORTING is_booking TYPE ty_booking
RETURNING VALUE(rv_percent) TYPE i.
METHODS insurance_fee
IMPORTING is_booking TYPE ty_booking
RETURNING VALUE(rv_fee) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}storage_pricer IMPLEMENTATION.
METHOD calculate_price.
IF is_valid( is_booking ) = abap_false.
RETURN.
ENDIF.
DATA lv_rent TYPE ty_amount.
DATA lv_discount TYPE ty_amount.
DATA lv_total TYPE ty_amount.
lv_rent = is_booking-size_sqm * is_booking-months * monthly_rate( is_booking ).
lv_discount = lv_rent * discount_percent( is_booking ) / c_percent.
lv_total = lv_rent - lv_discount + insurance_fee( is_booking ) + c_admin_fee.
rv_price = lv_total.
ENDMETHOD.
METHOD is_valid.
rv_valid = xsdbool( is_booking-size_sqm > 0 AND is_booking-months > 0 ).
ENDMETHOD.
METHOD monthly_rate.
IF is_booking-size_sqm <= c_size_small_max.
rv_rate = c_rate_small.
ELSEIF is_booking-size_sqm <= c_size_medium_max.
rv_rate = c_rate_medium.
ELSE.
rv_rate = c_rate_large.
ENDIF.
IF is_booking-climate = abap_true.
rv_rate = rv_rate + c_climate_addon.
ENDIF.
ENDMETHOD.
METHOD discount_percent.
IF is_booking-months >= c_months_long.
rv_percent = c_disc_long.
ELSEIF is_booking-months >= c_months_medium.
rv_percent = c_disc_medium.
ELSEIF is_booking-months >= c_months_short.
rv_percent = c_disc_short.
ENDIF.
ENDMETHOD.
METHOD insurance_fee.
IF is_booking-insurance = abap_true.
rv_fee = is_booking-size_sqm * is_booking-months * c_insurance_rate.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,92 @@
CLASS ltc_storage_pricer DEFINITION
FINAL
FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA mo_cut TYPE REF TO {{p}}storage_pricer.
METHODS setup.
METHODS assert_price
IMPORTING iv_size TYPE i
iv_months TYPE i
iv_climate TYPE abap_bool
iv_insurance TYPE abap_bool
iv_expected TYPE {{p}}storage_pricer=>ty_amount.
METHODS small_unit_no_extras FOR TESTING.
METHODS medium_unit_climate FOR TESTING.
METHODS large_unit_all_extras FOR TESTING.
METHODS long_term_discount FOR TESTING.
METHODS size_band_change FOR TESTING.
METHODS invalid_booking FOR TESTING.
ENDCLASS.
CLASS ltc_storage_pricer IMPLEMENTATION.
METHOD setup.
mo_cut = NEW {{p}}storage_pricer( ).
ENDMETHOD.
METHOD assert_price.
DATA(ls_booking) = VALUE {{p}}storage_pricer=>ty_booking(
size_sqm = iv_size
months = iv_months
climate = iv_climate
insurance = iv_insurance ).
cl_abap_unit_assert=>assert_equals(
exp = iv_expected
act = mo_cut->calculate_price( ls_booking ) ).
ENDMETHOD.
METHOD small_unit_no_extras.
assert_price( iv_size = 3
iv_months = 1
iv_climate = abap_false
iv_insurance = abap_false
iv_expected = '61.00' ).
ENDMETHOD.
METHOD medium_unit_climate.
assert_price( iv_size = 4
iv_months = 3
iv_climate = abap_true
iv_insurance = abap_false
iv_expected = '241.00' ).
ENDMETHOD.
METHOD large_unit_all_extras.
assert_price( iv_size = 16
iv_months = 12
iv_climate = abap_true
iv_insurance = abap_true
iv_expected = '2524.60' ).
ENDMETHOD.
METHOD long_term_discount.
assert_price( iv_size = 20
iv_months = 24
iv_climate = abap_false
iv_insurance = abap_false
iv_expected = '3691.00' ).
ENDMETHOD.
METHOD size_band_change.
assert_price( iv_size = 6
iv_months = 2
iv_climate = abap_false
iv_insurance = abap_false
iv_expected = '157.00' ).
ENDMETHOD.
METHOD invalid_booking.
assert_price( iv_size = 0
iv_months = 6
iv_climate = abap_false
iv_insurance = abap_false
iv_expected = '0.00' ).
ENDMETHOD.
ENDCLASS.