Files
abap-llm/tasks_gen/train/G1125/hidden/prt_hidden.clas.abap
2026-10-05 18:02:52 +02:00

122 lines
4.2 KiB
ABAP

CLASS {{p}}prt_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS call
IMPORTING iv_type TYPE string
iv_quantity TYPE i
iv_express TYPE abap_bool DEFAULT abap_false
iv_price TYPE decfloat34 DEFAULT 0
EXPORTING ev_skip TYPE abap_bool
ev_note TYPE string
ev_price TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS flyers_price FOR TESTING.
METHODS flyers_minimum FOR TESTING.
METHODS cards_price FOR TESTING.
METHODS cards_minimum FOR TESTING.
METHODS posters_discount FOR TESTING.
METHODS posters_no_discount FOR TESTING.
METHODS express_surcharge FOR TESTING.
METHODS manual_quote FOR TESTING.
METHODS invalid_quantity FOR TESTING.
METHODS skip_false_for_flyers FOR TESTING.
ENDCLASS.
CLASS {{p}}prt_hidden IMPLEMENTATION.
METHOD call.
ev_price = iv_price.
ev_note = ''.
CALL FUNCTION '{{P}}PRT_PRICE'
EXPORTING
iv_job_type = iv_type
iv_quantity = iv_quantity
iv_express = iv_express
IMPORTING
ev_skip = ev_skip
ev_note = ev_note
CHANGING
cv_price = ev_price
EXCEPTIONS
invalid_quantity = 1
OTHERS = 2.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD flyers_price.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `FL` iv_quantity = 400
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '20.00' ) act = lv_price ).
ENDMETHOD.
METHOD flyers_minimum.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `FL` iv_quantity = 10
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '10.00' ) act = lv_price ).
ENDMETHOD.
METHOD cards_price.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `BC` iv_quantity = 100
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '8.00' ) act = lv_price ).
ENDMETHOD.
METHOD cards_minimum.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `BC` iv_quantity = 10
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '5.00' ) act = lv_price ).
ENDMETHOD.
METHOD posters_discount.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `PO` iv_quantity = 101
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '104.54' ) act = lv_price ).
ENDMETHOD.
METHOD posters_no_discount.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `PO` iv_quantity = 100
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '115.00' ) act = lv_price ).
ENDMETHOD.
METHOD express_surcharge.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `FL` iv_quantity = 202 iv_express = abap_true
IMPORTING ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '12.63' ) act = lv_price ).
ENDMETHOD.
METHOD manual_quote.
DATA lv_skip TYPE abap_bool.
DATA lv_note TYPE string.
DATA lv_price TYPE decfloat34.
call( EXPORTING iv_type = `XX` iv_quantity = 50
IMPORTING ev_skip = lv_skip ev_note = lv_note ev_price = lv_price ).
cl_abap_unit_assert=>assert_equals( exp = abap_true act = lv_skip ).
cl_abap_unit_assert=>assert_equals( exp = `MANUAL QUOTE` act = lv_note ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '0.00' ) act = lv_price ).
ENDMETHOD.
METHOD invalid_quantity.
DATA lv_rc TYPE sysubrc.
call( EXPORTING iv_type = `FL` iv_quantity = 0
IMPORTING ev_subrc = lv_rc ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_rc ).
ENDMETHOD.
METHOD skip_false_for_flyers.
DATA lv_skip TYPE abap_bool.
DATA lv_note TYPE string.
call( EXPORTING iv_type = `FL` iv_quantity = 400
IMPORTING ev_skip = lv_skip ev_note = lv_note ).
cl_abap_unit_assert=>assert_equals( exp = abap_false act = lv_skip ).
cl_abap_unit_assert=>assert_initial( lv_note ).
ENDMETHOD.
ENDCLASS.