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

141 lines
5.3 KiB
ABAP

CLASS {{p}}t14_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS call_fee
IMPORTING iv_pair TYPE string
iv_words TYPE i
iv_express TYPE abap_bool DEFAULT abap_false
iv_cert TYPE abap_bool DEFAULT abap_false
EXPORTING ev_fee TYPE decfloat34
ev_subrc TYPE sysubrc.
METHODS pricer_fee
IMPORTING iv_pair TYPE string
iv_words TYPE i
RETURNING VALUE(rv_fee) TYPE decfloat34.
METHODS minimum_charge FOR TESTING.
METHODS rare_rate FOR TESTING.
METHODS tier_one_discount FOR TESTING.
METHODS tier_two_discount FOR TESTING.
METHODS no_discount_below_tier FOR TESTING.
METHODS certified_fee FOR TESTING.
METHODS express_multiplier FOR TESTING.
METHODS discount_rounding FOR TESTING.
METHODS express_rounding FOR TESTING.
METHODS invalid_pair_first FOR TESTING.
METHODS invalid_word_count FOR TESTING.
METHODS pricer_class_fee FOR TESTING.
ENDCLASS.
CLASS {{p}}t14_hidden IMPLEMENTATION.
METHOD call_fee.
ev_fee = 0.
CALL FUNCTION '{{P}}TRANS_FEE'
EXPORTING
iv_lang_pair = iv_pair
iv_word_count = iv_words
iv_express = iv_express
iv_certified = iv_cert
IMPORTING
ev_fee = ev_fee
EXCEPTIONS
invalid_lang_pair = 1
invalid_word_count = 2
OTHERS = 3.
ev_subrc = sy-subrc.
ENDMETHOD.
METHOD pricer_fee.
DATA(lo_pricer) = NEW {{p}}trans_pricer( ).
rv_fee = lo_pricer->calculate_fee(
iv_lang_pair = iv_pair
iv_word_count = iv_words
iv_express = abap_false
iv_certified = abap_false ).
ENDMETHOD.
METHOD minimum_charge.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 100
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '35.00' ) act = lv_fee ).
ENDMETHOD.
METHOD rare_rate.
call_fee( EXPORTING iv_pair = 'RARE' iv_words = 200
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '38.00' ) act = lv_fee ).
ENDMETHOD.
METHOD tier_one_discount.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 1000
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '108.00' ) act = lv_fee ).
ENDMETHOD.
METHOD tier_two_discount.
call_fee( EXPORTING iv_pair = 'RARE' iv_words = 5000
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '807.50' ) act = lv_fee ).
ENDMETHOD.
METHOD no_discount_below_tier.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 999
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '119.88' ) act = lv_fee ).
ENDMETHOD.
METHOD certified_fee.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 300 iv_cert = abap_true
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '58.00' ) act = lv_fee ).
ENDMETHOD.
METHOD express_multiplier.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 300 iv_cert = abap_true iv_express = abap_true
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '87.00' ) act = lv_fee ).
ENDMETHOD.
METHOD discount_rounding.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 1001
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '108.11' ) act = lv_fee ).
ENDMETHOD.
METHOD express_rounding.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 1001 iv_express = abap_true
IMPORTING ev_fee = DATA(lv_fee) ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
cl_abap_unit_assert=>assert_equals( exp = CONV decfloat34( '162.17' ) act = lv_fee ).
ENDMETHOD.
METHOD invalid_pair_first.
call_fee( EXPORTING iv_pair = 'XX' iv_words = 0
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
ENDMETHOD.
METHOD invalid_word_count.
call_fee( EXPORTING iv_pair = 'STD' iv_words = 0
IMPORTING ev_subrc = DATA(lv_subrc) ).
cl_abap_unit_assert=>assert_equals( exp = 2 act = lv_subrc ).
ENDMETHOD.
METHOD pricer_class_fee.
cl_abap_unit_assert=>assert_equals(
exp = CONV decfloat34( '807.50' )
act = pricer_fee( iv_pair = 'RARE' iv_words = 5000 ) ).
ENDMETHOD.
ENDCLASS.