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,87 @@
CLASS {{p}}water_bill DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
METHODS constructor.
METHODS calculate
IMPORTING iv_consumption TYPE i
iv_days TYPE i
RETURNING VALUE(rv_amount) TYPE ty_amount.
PRIVATE SECTION.
DATA mo_tariff TYPE REF TO {{p}}water_tariff.
METHODS consumption_charge
IMPORTING iv_consumption TYPE i
RETURNING VALUE(rv_charge) TYPE ty_amount.
METHODS sewage_charge
IMPORTING iv_consumption_charge TYPE ty_amount
RETURNING VALUE(rv_charge) TYPE ty_amount.
METHODS standing_charge
IMPORTING iv_days TYPE i
RETURNING VALUE(rv_charge) TYPE ty_amount.
METHODS tier_charge
IMPORTING iv_from TYPE i
iv_to TYPE i
iv_price TYPE {{p}}water_tariff=>ty_price
RETURNING VALUE(rv_charge) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}water_bill IMPLEMENTATION.
METHOD constructor.
mo_tariff = NEW {{p}}water_tariff( ).
ENDMETHOD.
METHOD calculate.
DATA(lv_consumption_charge) = consumption_charge( iv_consumption ).
DATA lv_net TYPE ty_amount.
lv_net = lv_consumption_charge
+ sewage_charge( lv_consumption_charge )
+ standing_charge( iv_days ).
DATA(lv_minimum) = mo_tariff->get_minimum_charge( ).
IF lv_net < lv_minimum.
rv_amount = lv_minimum.
ELSE.
rv_amount = lv_net.
ENDIF.
ENDMETHOD.
METHOD consumption_charge.
DATA(lt_tiers) = mo_tariff->get_tiers( ).
DATA lv_from TYPE i.
LOOP AT lt_tiers INTO DATA(ls_tier).
DATA(lv_to) = COND i( WHEN ls_tier-limit_cbm = 0 OR ls_tier-limit_cbm > iv_consumption
THEN iv_consumption
ELSE ls_tier-limit_cbm ).
rv_charge = rv_charge + tier_charge( iv_from = lv_from
iv_to = lv_to
iv_price = ls_tier-price_cbm ).
lv_from = lv_to.
IF lv_from >= iv_consumption.
EXIT.
ENDIF.
ENDLOOP.
ENDMETHOD.
METHOD sewage_charge.
DATA lv_product TYPE p LENGTH 16 DECIMALS 4.
lv_product = iv_consumption_charge * mo_tariff->get_sewage_percent( ).
rv_charge = lv_product / 100.
ENDMETHOD.
METHOD standing_charge.
rv_charge = iv_days / mo_tariff->get_standing_charge( ).
ENDMETHOD.
METHOD tier_charge.
DATA(lv_units) = iv_to - iv_from.
IF lv_units > 0.
rv_charge = lv_units * iv_price.
ENDIF.
ENDMETHOD.
ENDCLASS.