Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aUaQeLnwbb1zTpN7kHeat
161 lines
5.7 KiB
ABAP
161 lines
5.7 KiB
ABAP
CLASS {{p}}t21_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
|
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
|
PRIVATE SECTION.
|
|
METHODS fee_of
|
|
IMPORTING
|
|
iv_type TYPE string
|
|
iv_hours TYPE decfloat34
|
|
iv_parts TYPE decfloat34
|
|
iv_member TYPE abap_bool DEFAULT abap_false
|
|
EXPORTING
|
|
ev_labour TYPE decfloat34
|
|
ev_total TYPE decfloat34
|
|
ev_subrc TYPE sysubrc.
|
|
METHODS brake_rate FOR TESTING.
|
|
METHODS gear_rate FOR TESTING.
|
|
METHODS wheel_rate FOR TESTING.
|
|
METHODS other_rate FOR TESTING.
|
|
METHODS labour_rounding FOR TESTING.
|
|
METHODS minimum_total FOR TESTING.
|
|
METHODS member_discount FOR TESTING.
|
|
METHODS member_minimum FOR TESTING.
|
|
METHODS negative_hours FOR TESTING.
|
|
METHODS zero_hours FOR TESTING.
|
|
ENDCLASS.
|
|
|
|
|
|
CLASS {{p}}t21_hidden IMPLEMENTATION.
|
|
METHOD fee_of.
|
|
ev_labour = 0.
|
|
ev_total = 0.
|
|
CALL FUNCTION '{{P}}REPAIR_FEE'
|
|
EXPORTING
|
|
iv_repair_type = iv_type
|
|
iv_hours = iv_hours
|
|
iv_parts_cost = iv_parts
|
|
iv_member = iv_member
|
|
IMPORTING
|
|
ev_labour_fee = ev_labour
|
|
ev_total_fee = ev_total
|
|
EXCEPTIONS
|
|
invalid_hours = 1
|
|
OTHERS = 2.
|
|
ev_subrc = sy-subrc.
|
|
ENDMETHOD.
|
|
|
|
METHOD brake_rate.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'BR' iv_hours = '1.5' iv_parts = '20'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '90.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '110.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD gear_rate.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'GE' iv_hours = '2' iv_parts = '0'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '90.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD wheel_rate.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'WH' iv_hours = '1' iv_parts = '5'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '30.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '35.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD other_rate.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'XX' iv_hours = '1' iv_parts = '0'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '40.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD labour_rounding.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'GE' iv_hours = '0.333' iv_parts = '20'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '14.99'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '34.99'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD minimum_total.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'WH' iv_hours = '0.5' iv_parts = '1'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '15.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '25.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD member_discount.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'BR' iv_hours = '1.5' iv_parts = '20' iv_member = abap_true
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '81.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '101.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD member_minimum.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'WH' iv_hours = '0.5' iv_parts = '0' iv_member = abap_true
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ).
|
|
lv_exp = '13.50'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '25.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
|
|
METHOD negative_hours.
|
|
DATA lv_subrc TYPE sysubrc.
|
|
fee_of( EXPORTING iv_type = 'BR' iv_hours = '-1' iv_parts = '0'
|
|
IMPORTING ev_subrc = lv_subrc ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 1 act = lv_subrc ).
|
|
ENDMETHOD.
|
|
|
|
METHOD zero_hours.
|
|
DATA lv_labour TYPE decfloat34.
|
|
DATA lv_total TYPE decfloat34.
|
|
DATA lv_subrc TYPE sysubrc.
|
|
DATA lv_exp TYPE decfloat34.
|
|
fee_of( EXPORTING iv_type = 'BR' iv_hours = '0' iv_parts = '30'
|
|
IMPORTING ev_labour = lv_labour ev_total = lv_total ev_subrc = lv_subrc ).
|
|
cl_abap_unit_assert=>assert_equals( exp = 0 act = lv_subrc ).
|
|
lv_exp = '0.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_labour ).
|
|
lv_exp = '30.00'.
|
|
cl_abap_unit_assert=>assert_equals( exp = lv_exp act = lv_total ).
|
|
ENDMETHOD.
|
|
ENDCLASS.
|