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,109 @@
CLASS {{p}}glasses_pricer DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_amount TYPE p LENGTH 9 DECIMALS 2.
TYPES ty_lens TYPE c LENGTH 1.
TYPES ty_coat TYPE c LENGTH 1.
METHODS price
IMPORTING iv_frame TYPE ty_amount
iv_lens TYPE ty_lens
iv_coat TYPE ty_coat
iv_qty TYPE i
RETURNING VALUE(rv_price) TYPE ty_amount.
PRIVATE SECTION.
CONSTANTS:
c_max_qty TYPE i VALUE 100,
c_discount_qty TYPE i VALUE 3,
c_discount_percent TYPE i VALUE 10,
c_lens_standard TYPE ty_amount VALUE '40.00',
c_lens_bifocal TYPE ty_amount VALUE '90.00',
c_lens_progressive TYPE ty_amount VALUE '150.00',
c_coat_simple TYPE ty_amount VALUE '25.00',
c_coat_premium TYPE ty_amount VALUE '35.00',
c_coat_none TYPE ty_amount VALUE '0.00'.
METHODS capped_qty
IMPORTING iv_qty TYPE i
RETURNING VALUE(rv_qty) TYPE i.
METHODS lens_surcharge
IMPORTING iv_lens TYPE ty_lens
RETURNING VALUE(rv_amount) TYPE ty_amount.
METHODS coat_surcharge
IMPORTING iv_coat TYPE ty_coat
RETURNING VALUE(rv_amount) TYPE ty_amount.
METHODS total_price
IMPORTING iv_frame TYPE ty_amount
iv_lens TYPE ty_amount
iv_coat TYPE ty_amount
iv_qty TYPE i
RETURNING VALUE(rv_total) TYPE ty_amount.
METHODS with_discount
IMPORTING iv_total TYPE ty_amount
iv_qty TYPE i
RETURNING VALUE(rv_price) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}glasses_pricer IMPLEMENTATION.
METHOD price.
DATA(lv_qty) = capped_qty( iv_qty ).
IF lv_qty < 1.
RETURN.
ENDIF.
DATA(lv_total) = total_price( iv_frame = iv_frame
iv_lens = lens_surcharge( iv_lens )
iv_coat = coat_surcharge( iv_coat )
iv_qty = lv_qty ).
rv_price = with_discount( iv_total = lv_total
iv_qty = lv_qty ).
ENDMETHOD.
METHOD capped_qty.
rv_qty = iv_qty.
IF rv_qty > c_max_qty.
rv_qty = c_max_qty.
ENDIF.
ENDMETHOD.
METHOD lens_surcharge.
CASE iv_lens.
WHEN 'B'.
rv_amount = c_lens_bifocal.
WHEN 'P'.
rv_amount = c_lens_progressive.
WHEN OTHERS.
rv_amount = c_lens_standard.
ENDCASE.
ENDMETHOD.
METHOD coat_surcharge.
CASE iv_coat.
WHEN 'A'.
rv_amount = c_coat_simple.
WHEN 'B'.
rv_amount = c_coat_premium.
WHEN OTHERS.
rv_amount = c_coat_none.
ENDCASE.
ENDMETHOD.
METHOD total_price.
rv_total = iv_frame * iv_qty.
rv_total = rv_total + iv_lens * iv_qty.
rv_total = rv_total + iv_coat * iv_qty.
ENDMETHOD.
METHOD with_discount.
rv_price = iv_total.
IF iv_qty >= c_discount_qty.
rv_price = iv_total - iv_total * c_discount_percent / 100.
ENDIF.
ENDMETHOD.
ENDCLASS.

View File

@@ -0,0 +1,83 @@
CLASS ltc_glasses_pricer DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
CONSTANTS c_frame TYPE {{p}}glasses_pricer=>ty_amount VALUE '100.00'.
DATA mo_cut TYPE REF TO {{p}}glasses_pricer.
METHODS setup.
METHODS single_vision FOR TESTING.
METHODS bifocal_with_coating FOR TESTING.
METHODS progressive_with_blue FOR TESTING.
METHODS unknown_lens_defaults FOR TESTING.
METHODS unknown_coat_is_free FOR TESTING.
METHODS discount_from_three FOR TESTING.
METHODS no_discount_for_two FOR TESTING.
METHODS zero_qty_is_free FOR TESTING.
METHODS qty_capped_at_hundred FOR TESTING.
ENDCLASS.
CLASS ltc_glasses_pricer IMPLEMENTATION.
METHOD setup.
mo_cut = NEW #( ).
ENDMETHOD.
METHOD single_vision.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '140.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'N' iv_qty = 1 ) ).
ENDMETHOD.
METHOD bifocal_with_coating.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '430.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'B' iv_coat = 'A' iv_qty = 2 ) ).
ENDMETHOD.
METHOD progressive_with_blue.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '235.00' )
act = mo_cut->price( iv_frame = CONV {{p}}glasses_pricer=>ty_amount( '50.00' )
iv_lens = 'P' iv_coat = 'B' iv_qty = 1 ) ).
ENDMETHOD.
METHOD unknown_lens_defaults.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '140.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'Z' iv_coat = 'N' iv_qty = 1 ) ).
ENDMETHOD.
METHOD unknown_coat_is_free.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '140.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'X' iv_qty = 1 ) ).
ENDMETHOD.
METHOD discount_from_three.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '378.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'N' iv_qty = 3 ) ).
ENDMETHOD.
METHOD no_discount_for_two.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '280.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'N' iv_qty = 2 ) ).
ENDMETHOD.
METHOD zero_qty_is_free.
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '0.00' )
act = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'A' iv_qty = 0 ) ).
ENDMETHOD.
METHOD qty_capped_at_hundred.
DATA(lv_capped) = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'N' iv_qty = 100 ).
cl_abap_unit_assert=>assert_equals(
exp = CONV {{p}}glasses_pricer=>ty_amount( '12600.00' )
act = lv_capped ).
cl_abap_unit_assert=>assert_equals(
exp = lv_capped
act = mo_cut->price( iv_frame = c_frame iv_lens = 'S' iv_coat = 'N' iv_qty = 150 ) ).
ENDMETHOD.
ENDCLASS.