Stage 2 summary at 50 accepted trajectories
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
110
tasks_gen/train/G1057/faulty/m0_air_freight_pricer.clas.abap
Normal file
110
tasks_gen/train/G1057/faulty/m0_air_freight_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}air_freight_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_air_freight.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_volume_divisor TYPE i VALUE 6000,
|
||||
c_max_weight TYPE {{p}}if_air_freight=>ty_weight VALUE '3000',
|
||||
c_dangerous_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.4000',
|
||||
c_fuel_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.1200',
|
||||
c_security_fee TYPE {{p}}if_air_freight=>ty_amount VALUE '15.00'.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_air_freight=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
METHODS base_rate
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
|
||||
METHODS category_factor
|
||||
IMPORTING iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_factor) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_freight_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_air_freight~price.
|
||||
rs_result-reason = check_input( iv_weight = iv_weight
|
||||
iv_volume = iv_volume
|
||||
iv_category = iv_category ).
|
||||
IF rs_result-reason <> {{p}}if_air_freight=>c_reason-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-chargeable_weight = chargeable_weight( iv_weight = iv_weight
|
||||
iv_volume = iv_volume ).
|
||||
IF rs_result-chargeable_weight > c_max_weight.
|
||||
CLEAR rs_result.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-too_heavy.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-freight = rs_result-chargeable_weight * base_rate( rs_result-chargeable_weight )
|
||||
* category_factor( iv_category ).
|
||||
IF iv_dangerous <> abap_true.
|
||||
rs_result-dangerous_fee = rs_result-freight * c_dangerous_rate.
|
||||
ENDIF.
|
||||
rs_result-fuel_fee = ( rs_result-freight + rs_result-dangerous_fee ) * c_fuel_rate.
|
||||
rs_result-security_fee = c_security_fee.
|
||||
rs_result-total_amount = rs_result-freight + rs_result-dangerous_fee
|
||||
+ rs_result-fuel_fee + rs_result-security_fee.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_weight.
|
||||
ELSEIF iv_volume <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_volume.
|
||||
ELSEIF iv_category <> {{p}}if_air_freight=>c_category-general
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-perishable
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_category.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE {{p}}if_air_freight=>ty_weight.
|
||||
DATA lv_gross TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
lv_volumetric = iv_volume / c_volume_divisor.
|
||||
lv_gross = nmax( val1 = iv_weight val2 = lv_volumetric ).
|
||||
rv_weight = ceil( lv_gross ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_rate.
|
||||
IF iv_weight <= 45.
|
||||
rv_rate = '9.00'.
|
||||
ELSEIF iv_weight <= 100.
|
||||
rv_rate = '7.20'.
|
||||
ELSEIF iv_weight <= 500.
|
||||
rv_rate = '5.60'.
|
||||
ELSE.
|
||||
rv_rate = '4.30'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD category_factor.
|
||||
CASE iv_category.
|
||||
WHEN {{p}}if_air_freight=>c_category-perishable.
|
||||
rv_factor = '1.25'.
|
||||
WHEN {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_factor = '1.50'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = '1.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1057/faulty/m1_air_freight_pricer.clas.abap
Normal file
110
tasks_gen/train/G1057/faulty/m1_air_freight_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}air_freight_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_air_freight.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_volume_divisor TYPE i VALUE 6000,
|
||||
c_max_weight TYPE {{p}}if_air_freight=>ty_weight VALUE '3000',
|
||||
c_dangerous_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.4000',
|
||||
c_fuel_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.1200',
|
||||
c_security_fee TYPE {{p}}if_air_freight=>ty_amount VALUE '15.00'.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_air_freight=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
METHODS base_rate
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
|
||||
METHODS category_factor
|
||||
IMPORTING iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_factor) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_freight_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_air_freight~price.
|
||||
rs_result-reason = check_input( iv_weight = iv_weight
|
||||
iv_volume = iv_volume
|
||||
iv_category = iv_category ).
|
||||
IF rs_result-reason <> {{p}}if_air_freight=>c_reason-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-chargeable_weight = chargeable_weight( iv_weight = iv_weight
|
||||
iv_volume = iv_volume ).
|
||||
IF rs_result-chargeable_weight > c_max_weight.
|
||||
CLEAR rs_result.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-too_heavy.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-freight = rs_result-chargeable_weight * base_rate( rs_result-chargeable_weight )
|
||||
* category_factor( iv_category ).
|
||||
IF iv_dangerous = abap_true.
|
||||
rs_result-dangerous_fee = rs_result-freight * c_dangerous_rate.
|
||||
ENDIF.
|
||||
rs_result-fuel_fee = ( rs_result-freight + rs_result-dangerous_fee ) * c_fuel_rate.
|
||||
rs_result-security_fee = c_security_fee.
|
||||
rs_result-total_amount = rs_result-freight + rs_result-dangerous_fee
|
||||
+ rs_result-fuel_fee - rs_result-security_fee.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_weight.
|
||||
ELSEIF iv_volume <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_volume.
|
||||
ELSEIF iv_category <> {{p}}if_air_freight=>c_category-general
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-perishable
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_category.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE {{p}}if_air_freight=>ty_weight.
|
||||
DATA lv_gross TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
lv_volumetric = iv_volume / c_volume_divisor.
|
||||
lv_gross = nmax( val1 = iv_weight val2 = lv_volumetric ).
|
||||
rv_weight = ceil( lv_gross ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_rate.
|
||||
IF iv_weight <= 45.
|
||||
rv_rate = '9.00'.
|
||||
ELSEIF iv_weight <= 100.
|
||||
rv_rate = '7.20'.
|
||||
ELSEIF iv_weight <= 500.
|
||||
rv_rate = '5.60'.
|
||||
ELSE.
|
||||
rv_rate = '4.30'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD category_factor.
|
||||
CASE iv_category.
|
||||
WHEN {{p}}if_air_freight=>c_category-perishable.
|
||||
rv_factor = '1.25'.
|
||||
WHEN {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_factor = '1.50'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = '1.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1057/faulty/m2_air_freight_pricer.clas.abap
Normal file
110
tasks_gen/train/G1057/faulty/m2_air_freight_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}air_freight_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_air_freight.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_volume_divisor TYPE i VALUE 6000,
|
||||
c_max_weight TYPE {{p}}if_air_freight=>ty_weight VALUE '3000',
|
||||
c_dangerous_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.4000',
|
||||
c_fuel_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.1200',
|
||||
c_security_fee TYPE {{p}}if_air_freight=>ty_amount VALUE '15.00'.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_air_freight=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
METHODS base_rate
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
|
||||
METHODS category_factor
|
||||
IMPORTING iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_factor) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_freight_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_air_freight~price.
|
||||
rs_result-reason = check_input( iv_weight = iv_weight
|
||||
iv_volume = iv_volume
|
||||
iv_category = iv_category ).
|
||||
IF rs_result-reason <> {{p}}if_air_freight=>c_reason-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-chargeable_weight = chargeable_weight( iv_weight = iv_weight
|
||||
iv_volume = iv_volume ).
|
||||
IF rs_result-chargeable_weight > c_max_weight.
|
||||
CLEAR rs_result.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-too_heavy.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-freight = rs_result-chargeable_weight * base_rate( rs_result-chargeable_weight )
|
||||
* category_factor( iv_category ).
|
||||
IF iv_dangerous = abap_true.
|
||||
rs_result-dangerous_fee = rs_result-freight * c_dangerous_rate.
|
||||
ENDIF.
|
||||
rs_result-fuel_fee = ( rs_result-freight + rs_result-dangerous_fee ) * c_fuel_rate.
|
||||
rs_result-security_fee = c_security_fee.
|
||||
rs_result-total_amount = rs_result-freight + rs_result-dangerous_fee
|
||||
+ rs_result-fuel_fee + rs_result-security_fee.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_weight.
|
||||
ELSEIF iv_volume <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_volume.
|
||||
ELSEIF iv_category = {{p}}if_air_freight=>c_category-general
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-perishable
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_category.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE {{p}}if_air_freight=>ty_weight.
|
||||
DATA lv_gross TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
lv_volumetric = iv_volume / c_volume_divisor.
|
||||
lv_gross = nmax( val1 = iv_weight val2 = lv_volumetric ).
|
||||
rv_weight = ceil( lv_gross ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_rate.
|
||||
IF iv_weight <= 45.
|
||||
rv_rate = '9.00'.
|
||||
ELSEIF iv_weight <= 100.
|
||||
rv_rate = '7.20'.
|
||||
ELSEIF iv_weight <= 500.
|
||||
rv_rate = '5.60'.
|
||||
ELSE.
|
||||
rv_rate = '4.30'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD category_factor.
|
||||
CASE iv_category.
|
||||
WHEN {{p}}if_air_freight=>c_category-perishable.
|
||||
rv_factor = '1.25'.
|
||||
WHEN {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_factor = '1.50'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = '1.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1057/faulty/m3_air_freight_pricer.clas.abap
Normal file
110
tasks_gen/train/G1057/faulty/m3_air_freight_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}air_freight_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_air_freight.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_volume_divisor TYPE i VALUE 6000,
|
||||
c_max_weight TYPE {{p}}if_air_freight=>ty_weight VALUE '3000',
|
||||
c_dangerous_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.4000',
|
||||
c_fuel_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.1200',
|
||||
c_security_fee TYPE {{p}}if_air_freight=>ty_amount VALUE '15.00'.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_air_freight=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
METHODS base_rate
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
|
||||
METHODS category_factor
|
||||
IMPORTING iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_factor) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_freight_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_air_freight~price.
|
||||
rs_result-reason = check_input( iv_weight = iv_weight
|
||||
iv_volume = iv_volume
|
||||
iv_category = iv_category ).
|
||||
IF rs_result-reason <> {{p}}if_air_freight=>c_reason-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-chargeable_weight = chargeable_weight( iv_weight = iv_weight
|
||||
iv_volume = iv_volume ).
|
||||
IF rs_result-chargeable_weight > c_max_weight.
|
||||
CLEAR rs_result.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-too_heavy.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-freight = rs_result-chargeable_weight * base_rate( rs_result-chargeable_weight )
|
||||
* category_factor( iv_category ).
|
||||
IF iv_dangerous = abap_true.
|
||||
rs_result-dangerous_fee = rs_result-freight * c_dangerous_rate.
|
||||
ENDIF.
|
||||
rs_result-fuel_fee = ( rs_result-freight + rs_result-dangerous_fee ) * c_fuel_rate.
|
||||
rs_result-security_fee = c_security_fee.
|
||||
rs_result-total_amount = rs_result-freight + rs_result-dangerous_fee
|
||||
+ rs_result-fuel_fee + rs_result-security_fee.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_weight.
|
||||
ELSEIF iv_volume <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_volume.
|
||||
ELSEIF iv_category <> {{p}}if_air_freight=>c_category-general
|
||||
OR iv_category <> {{p}}if_air_freight=>c_category-perishable
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_category.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE {{p}}if_air_freight=>ty_weight.
|
||||
DATA lv_gross TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
lv_volumetric = iv_volume / c_volume_divisor.
|
||||
lv_gross = nmax( val1 = iv_weight val2 = lv_volumetric ).
|
||||
rv_weight = ceil( lv_gross ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_rate.
|
||||
IF iv_weight <= 45.
|
||||
rv_rate = '9.00'.
|
||||
ELSEIF iv_weight <= 100.
|
||||
rv_rate = '7.20'.
|
||||
ELSEIF iv_weight <= 500.
|
||||
rv_rate = '5.60'.
|
||||
ELSE.
|
||||
rv_rate = '4.30'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD category_factor.
|
||||
CASE iv_category.
|
||||
WHEN {{p}}if_air_freight=>c_category-perishable.
|
||||
rv_factor = '1.25'.
|
||||
WHEN {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_factor = '1.50'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = '1.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
110
tasks_gen/train/G1057/faulty/m4_air_freight_pricer.clas.abap
Normal file
110
tasks_gen/train/G1057/faulty/m4_air_freight_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}air_freight_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_air_freight.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_volume_divisor TYPE i VALUE 6000,
|
||||
c_max_weight TYPE {{p}}if_air_freight=>ty_weight VALUE '3000',
|
||||
c_dangerous_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.4000',
|
||||
c_fuel_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.1200',
|
||||
c_security_fee TYPE {{p}}if_air_freight=>ty_amount VALUE '15.00'.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_air_freight=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
METHODS base_rate
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
|
||||
METHODS category_factor
|
||||
IMPORTING iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_factor) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_freight_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_air_freight~price.
|
||||
rs_result-reason = check_input( iv_weight = iv_weight
|
||||
iv_volume = iv_volume
|
||||
iv_category = iv_category ).
|
||||
IF rs_result-reason <> {{p}}if_air_freight=>c_reason-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-chargeable_weight = chargeable_weight( iv_weight = iv_weight
|
||||
iv_volume = iv_volume ).
|
||||
IF rs_result-chargeable_weight > c_max_weight.
|
||||
CLEAR rs_result.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-too_heavy.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-freight = rs_result-chargeable_weight * base_rate( rs_result-chargeable_weight )
|
||||
* category_factor( iv_category ).
|
||||
IF iv_dangerous = abap_true.
|
||||
rs_result-dangerous_fee = rs_result-freight * c_dangerous_rate.
|
||||
ENDIF.
|
||||
rs_result-fuel_fee = ( rs_result-freight + rs_result-dangerous_fee ) * c_fuel_rate.
|
||||
rs_result-security_fee = c_security_fee.
|
||||
rs_result-total_amount = rs_result-freight + rs_result-dangerous_fee
|
||||
+ rs_result-fuel_fee + rs_result-security_fee.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_weight.
|
||||
ELSEIF iv_volume <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_volume.
|
||||
ELSEIF iv_category <> {{p}}if_air_freight=>c_category-general
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-perishable
|
||||
AND iv_category = {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_category.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE {{p}}if_air_freight=>ty_weight.
|
||||
DATA lv_gross TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
lv_volumetric = iv_volume / c_volume_divisor.
|
||||
lv_gross = nmax( val1 = iv_weight val2 = lv_volumetric ).
|
||||
rv_weight = ceil( lv_gross ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_rate.
|
||||
IF iv_weight <= 45.
|
||||
rv_rate = '9.00'.
|
||||
ELSEIF iv_weight <= 100.
|
||||
rv_rate = '7.20'.
|
||||
ELSEIF iv_weight <= 500.
|
||||
rv_rate = '5.60'.
|
||||
ELSE.
|
||||
rv_rate = '4.30'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD category_factor.
|
||||
CASE iv_category.
|
||||
WHEN {{p}}if_air_freight=>c_category-perishable.
|
||||
rv_factor = '1.25'.
|
||||
WHEN {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_factor = '1.50'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = '1.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
34
tasks_gen/train/G1057/generation.json
Normal file
34
tasks_gen/train/G1057/generation.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"id": "G1057",
|
||||
"pool": "train",
|
||||
"object_type": "CLAS",
|
||||
"category": "F",
|
||||
"attempts": [
|
||||
{
|
||||
"stage": "bundle",
|
||||
"errors": [
|
||||
"hidden/air_frt_hidden.clas.abap line 8: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"METHODS\"",
|
||||
"reference/air_freight_pricer.testclasses.abap line 8: syntax error for release v758 (abaplint): Statement does not exist in the configured ABAP version(or a parser error), \"METHODS\""
|
||||
],
|
||||
"by_check": {
|
||||
"abaplint": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 0,
|
||||
"null": 0
|
||||
},
|
||||
{
|
||||
"stage": "validate",
|
||||
"oracle": 100.0,
|
||||
"null": 0,
|
||||
"mutation": {
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"ok": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"accepted": true
|
||||
}
|
||||
179
tasks_gen/train/G1057/hidden/air_frt_hidden.clas.abap
Normal file
179
tasks_gen/train/G1057/hidden/air_frt_hidden.clas.abap
Normal file
@@ -0,0 +1,179 @@
|
||||
CLASS {{p}}air_frt_hidden DEFINITION PUBLIC FINAL CREATE PUBLIC
|
||||
FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_expected TYPE c LENGTH 20.
|
||||
|
||||
DATA mo_cut TYPE REF TO {{p}}if_air_freight.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_expected TYPE ty_expected
|
||||
iv_actual TYPE {{p}}if_air_freight=>ty_weight.
|
||||
METHODS assert_amount
|
||||
IMPORTING iv_expected TYPE ty_expected
|
||||
iv_actual TYPE {{p}}if_air_freight=>ty_amount.
|
||||
|
||||
METHODS general_shipment FOR TESTING.
|
||||
METHODS volumetric_weight FOR TESTING.
|
||||
METHODS rounds_up_to_kg FOR TESTING.
|
||||
METHODS rate_break_100 FOR TESTING.
|
||||
METHODS rate_break_101 FOR TESTING.
|
||||
METHODS rate_break_501 FOR TESTING.
|
||||
METHODS perishable_goods FOR TESTING.
|
||||
METHODS valuable_dangerous FOR TESTING.
|
||||
METHODS rejects_zero_weight FOR TESTING.
|
||||
METHODS rejects_zero_volume FOR TESTING.
|
||||
METHODS rejects_bad_category FOR TESTING.
|
||||
METHODS rejects_too_heavy FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_frt_hidden IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}air_freight_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
DATA lv_expected TYPE {{p}}if_air_freight=>ty_weight.
|
||||
lv_expected = iv_expected.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_amount.
|
||||
DATA lv_expected TYPE {{p}}if_air_freight=>ty_amount.
|
||||
lv_expected = iv_expected.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD general_shipment.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '12.000'
|
||||
iv_volume = '48000.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
assert_weight( iv_expected = '12.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '108.00' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-dangerous_fee ).
|
||||
assert_amount( iv_expected = '12.96' iv_actual = ls_result-fuel_fee ).
|
||||
assert_amount( iv_expected = '15.00' iv_actual = ls_result-security_fee ).
|
||||
assert_amount( iv_expected = '135.96' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volumetric_weight.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '5.000'
|
||||
iv_volume = '120000.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
assert_weight( iv_expected = '20.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '180.00' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '21.60' iv_actual = ls_result-fuel_fee ).
|
||||
assert_amount( iv_expected = '216.60' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rounds_up_to_kg.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '12.400'
|
||||
iv_volume = '900.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
assert_weight( iv_expected = '13.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '117.00' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '146.04' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_break_100.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '100.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
assert_weight( iv_expected = '100.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '720.00' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '821.40' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_break_101.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '100.500'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
assert_weight( iv_expected = '101.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '565.60' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '648.47' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rate_break_501.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '500.400'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
assert_weight( iv_expected = '501.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '2154.30' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '2427.82' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD perishable_goods.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '10.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-perishable
|
||||
iv_dangerous = abap_false ).
|
||||
assert_amount( iv_expected = '112.50' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-dangerous_fee ).
|
||||
assert_amount( iv_expected = '141.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD valuable_dangerous.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '10.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-valuable
|
||||
iv_dangerous = abap_true ).
|
||||
assert_amount( iv_expected = '135.00' iv_actual = ls_result-freight ).
|
||||
assert_amount( iv_expected = '54.00' iv_actual = ls_result-dangerous_fee ).
|
||||
assert_amount( iv_expected = '22.68' iv_actual = ls_result-fuel_fee ).
|
||||
assert_amount( iv_expected = '226.68' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_zero_weight.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '0.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_weight
|
||||
act = ls_result-reason ).
|
||||
assert_weight( iv_expected = '0.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_zero_volume.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '10.000'
|
||||
iv_volume = '0.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_volume
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_bad_category.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '10.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = 'EXPRESS'
|
||||
iv_dangerous = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_category
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD rejects_too_heavy.
|
||||
DATA(ls_result) = mo_cut->price( iv_weight = '3000.500'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-too_heavy
|
||||
act = ls_result-reason ).
|
||||
assert_weight( iv_expected = '0.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
84
tasks_gen/train/G1057/mutation.json
Normal file
84
tasks_gen/train/G1057/mutation.json
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"task": "G1057",
|
||||
"mutants": [
|
||||
{
|
||||
"object": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"mutant": "line 55: = -> <> (eq)",
|
||||
"status": "killed",
|
||||
"hidden": "4/12",
|
||||
"failed_tests": [
|
||||
"GENERAL_SHIPMENT",
|
||||
"PERISHABLE_GOODS",
|
||||
"RATE_BREAK_100",
|
||||
"RATE_BREAK_101",
|
||||
"RATE_BREAK_501",
|
||||
"ROUNDS_UP_TO_KG",
|
||||
"VALUABLE_DANGEROUS",
|
||||
"VOLUMETRIC_WEIGHT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"mutant": "line 61: + -> - (arith)",
|
||||
"status": "killed",
|
||||
"hidden": "4/12",
|
||||
"failed_tests": [
|
||||
"GENERAL_SHIPMENT",
|
||||
"PERISHABLE_GOODS",
|
||||
"RATE_BREAK_100",
|
||||
"RATE_BREAK_101",
|
||||
"RATE_BREAK_501",
|
||||
"ROUNDS_UP_TO_KG",
|
||||
"VALUABLE_DANGEROUS",
|
||||
"VOLUMETRIC_WEIGHT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"mutant": "line 70: <> -> = (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "4/12",
|
||||
"failed_tests": [
|
||||
"GENERAL_SHIPMENT",
|
||||
"RATE_BREAK_100",
|
||||
"RATE_BREAK_101",
|
||||
"RATE_BREAK_501",
|
||||
"REJECTS_BAD_CATEGORY",
|
||||
"REJECTS_TOO_HEAVY",
|
||||
"ROUNDS_UP_TO_KG",
|
||||
"VOLUMETRIC_WEIGHT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"mutant": "line 71: AND -> OR (logic)",
|
||||
"status": "killed",
|
||||
"hidden": "3/12",
|
||||
"failed_tests": [
|
||||
"GENERAL_SHIPMENT",
|
||||
"PERISHABLE_GOODS",
|
||||
"RATE_BREAK_100",
|
||||
"RATE_BREAK_101",
|
||||
"RATE_BREAK_501",
|
||||
"REJECTS_TOO_HEAVY",
|
||||
"ROUNDS_UP_TO_KG",
|
||||
"VALUABLE_DANGEROUS",
|
||||
"VOLUMETRIC_WEIGHT"
|
||||
]
|
||||
},
|
||||
{
|
||||
"object": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"mutant": "line 72: <> -> = (rel)",
|
||||
"status": "killed",
|
||||
"hidden": "10/12",
|
||||
"failed_tests": [
|
||||
"REJECTS_BAD_CATEGORY",
|
||||
"VALUABLE_DANGEROUS"
|
||||
]
|
||||
}
|
||||
],
|
||||
"valid": 5,
|
||||
"killed": 5,
|
||||
"kill_rate": 1.0,
|
||||
"ok": true
|
||||
}
|
||||
110
tasks_gen/train/G1057/reference/air_freight_pricer.clas.abap
Normal file
110
tasks_gen/train/G1057/reference/air_freight_pricer.clas.abap
Normal file
@@ -0,0 +1,110 @@
|
||||
CLASS {{p}}air_freight_pricer DEFINITION PUBLIC FINAL CREATE PUBLIC.
|
||||
PUBLIC SECTION.
|
||||
INTERFACES {{p}}if_air_freight.
|
||||
|
||||
PRIVATE SECTION.
|
||||
CONSTANTS:
|
||||
c_volume_divisor TYPE i VALUE 6000,
|
||||
c_max_weight TYPE {{p}}if_air_freight=>ty_weight VALUE '3000',
|
||||
c_dangerous_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.4000',
|
||||
c_fuel_rate TYPE p LENGTH 5 DECIMALS 4 VALUE '0.1200',
|
||||
c_security_fee TYPE {{p}}if_air_freight=>ty_amount VALUE '15.00'.
|
||||
|
||||
TYPES ty_rate TYPE p LENGTH 7 DECIMALS 2.
|
||||
|
||||
METHODS check_input
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_reason) TYPE {{p}}if_air_freight=>ty_reason.
|
||||
|
||||
METHODS chargeable_weight
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
iv_volume TYPE {{p}}if_air_freight=>ty_volume
|
||||
RETURNING VALUE(rv_weight) TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
METHODS base_rate
|
||||
IMPORTING iv_weight TYPE {{p}}if_air_freight=>ty_weight
|
||||
RETURNING VALUE(rv_rate) TYPE ty_rate.
|
||||
|
||||
METHODS category_factor
|
||||
IMPORTING iv_category TYPE {{p}}if_air_freight=>ty_category
|
||||
RETURNING VALUE(rv_factor) TYPE ty_rate.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS {{p}}air_freight_pricer IMPLEMENTATION.
|
||||
METHOD {{p}}if_air_freight~price.
|
||||
rs_result-reason = check_input( iv_weight = iv_weight
|
||||
iv_volume = iv_volume
|
||||
iv_category = iv_category ).
|
||||
IF rs_result-reason <> {{p}}if_air_freight=>c_reason-ok.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-chargeable_weight = chargeable_weight( iv_weight = iv_weight
|
||||
iv_volume = iv_volume ).
|
||||
IF rs_result-chargeable_weight > c_max_weight.
|
||||
CLEAR rs_result.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-too_heavy.
|
||||
RETURN.
|
||||
ENDIF.
|
||||
|
||||
rs_result-freight = rs_result-chargeable_weight * base_rate( rs_result-chargeable_weight )
|
||||
* category_factor( iv_category ).
|
||||
IF iv_dangerous = abap_true.
|
||||
rs_result-dangerous_fee = rs_result-freight * c_dangerous_rate.
|
||||
ENDIF.
|
||||
rs_result-fuel_fee = ( rs_result-freight + rs_result-dangerous_fee ) * c_fuel_rate.
|
||||
rs_result-security_fee = c_security_fee.
|
||||
rs_result-total_amount = rs_result-freight + rs_result-dangerous_fee
|
||||
+ rs_result-fuel_fee + rs_result-security_fee.
|
||||
rs_result-reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD check_input.
|
||||
IF iv_weight <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_weight.
|
||||
ELSEIF iv_volume <= 0.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_volume.
|
||||
ELSEIF iv_category <> {{p}}if_air_freight=>c_category-general
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-perishable
|
||||
AND iv_category <> {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-bad_category.
|
||||
ELSE.
|
||||
rv_reason = {{p}}if_air_freight=>c_reason-ok.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD chargeable_weight.
|
||||
DATA lv_volumetric TYPE {{p}}if_air_freight=>ty_weight.
|
||||
DATA lv_gross TYPE {{p}}if_air_freight=>ty_weight.
|
||||
|
||||
lv_volumetric = iv_volume / c_volume_divisor.
|
||||
lv_gross = nmax( val1 = iv_weight val2 = lv_volumetric ).
|
||||
rv_weight = ceil( lv_gross ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD base_rate.
|
||||
IF iv_weight <= 45.
|
||||
rv_rate = '9.00'.
|
||||
ELSEIF iv_weight <= 100.
|
||||
rv_rate = '7.20'.
|
||||
ELSEIF iv_weight <= 500.
|
||||
rv_rate = '5.60'.
|
||||
ELSE.
|
||||
rv_rate = '4.30'.
|
||||
ENDIF.
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD category_factor.
|
||||
CASE iv_category.
|
||||
WHEN {{p}}if_air_freight=>c_category-perishable.
|
||||
rv_factor = '1.25'.
|
||||
WHEN {{p}}if_air_freight=>c_category-valuable.
|
||||
rv_factor = '1.50'.
|
||||
WHEN OTHERS.
|
||||
rv_factor = '1.00'.
|
||||
ENDCASE.
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
@@ -0,0 +1,118 @@
|
||||
CLASS ltc_air_freight_pricer DEFINITION FINAL FOR TESTING
|
||||
DURATION SHORT RISK LEVEL HARMLESS.
|
||||
|
||||
PRIVATE SECTION.
|
||||
TYPES ty_expected TYPE c LENGTH 20.
|
||||
|
||||
DATA mo_cut TYPE REF TO {{p}}if_air_freight.
|
||||
|
||||
METHODS setup.
|
||||
METHODS assert_weight
|
||||
IMPORTING iv_expected TYPE ty_expected
|
||||
iv_actual TYPE {{p}}if_air_freight=>ty_weight.
|
||||
METHODS assert_amount
|
||||
IMPORTING iv_expected TYPE ty_expected
|
||||
iv_actual TYPE {{p}}if_air_freight=>ty_amount.
|
||||
|
||||
METHODS general_shipment_is_priced FOR TESTING.
|
||||
METHODS volumetric_weight_wins FOR TESTING.
|
||||
METHODS dangerous_goods_surcharge FOR TESTING.
|
||||
METHODS zero_weight_is_rejected FOR TESTING.
|
||||
METHODS bad_category_is_rejected FOR TESTING.
|
||||
METHODS too_heavy_is_rejected FOR TESTING.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
CLASS ltc_air_freight_pricer IMPLEMENTATION.
|
||||
METHOD setup.
|
||||
mo_cut = NEW {{p}}air_freight_pricer( ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_weight.
|
||||
DATA lv_expected TYPE {{p}}if_air_freight=>ty_weight.
|
||||
lv_expected = iv_expected.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD assert_amount.
|
||||
DATA lv_expected TYPE {{p}}if_air_freight=>ty_amount.
|
||||
lv_expected = iv_expected.
|
||||
cl_abap_unit_assert=>assert_equals( exp = lv_expected act = iv_actual ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD general_shipment_is_priced.
|
||||
DATA ls_result TYPE {{p}}if_air_freight=>ty_result.
|
||||
|
||||
ls_result = mo_cut->price( iv_weight = '12.000'
|
||||
iv_volume = '48000.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-ok
|
||||
act = ls_result-reason ).
|
||||
assert_weight( iv_expected = '12.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '135.96' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD volumetric_weight_wins.
|
||||
DATA ls_result TYPE {{p}}if_air_freight=>ty_result.
|
||||
|
||||
ls_result = mo_cut->price( iv_weight = '5.000'
|
||||
iv_volume = '120000.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
|
||||
assert_weight( iv_expected = '20.000' iv_actual = ls_result-chargeable_weight ).
|
||||
assert_amount( iv_expected = '216.60' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD dangerous_goods_surcharge.
|
||||
DATA ls_result TYPE {{p}}if_air_freight=>ty_result.
|
||||
|
||||
ls_result = mo_cut->price( iv_weight = '10.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-valuable
|
||||
iv_dangerous = abap_true ).
|
||||
|
||||
assert_amount( iv_expected = '54.00' iv_actual = ls_result-dangerous_fee ).
|
||||
assert_amount( iv_expected = '226.68' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD zero_weight_is_rejected.
|
||||
DATA ls_result TYPE {{p}}if_air_freight=>ty_result.
|
||||
|
||||
ls_result = mo_cut->price( iv_weight = '0.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_weight
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD bad_category_is_rejected.
|
||||
DATA ls_result TYPE {{p}}if_air_freight=>ty_result.
|
||||
|
||||
ls_result = mo_cut->price( iv_weight = '10.000'
|
||||
iv_volume = '600.000'
|
||||
iv_category = 'EXPRESS'
|
||||
iv_dangerous = abap_false ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-bad_category
|
||||
act = ls_result-reason ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD too_heavy_is_rejected.
|
||||
DATA ls_result TYPE {{p}}if_air_freight=>ty_result.
|
||||
|
||||
ls_result = mo_cut->price( iv_weight = '3000.500'
|
||||
iv_volume = '600.000'
|
||||
iv_category = {{p}}if_air_freight=>c_category-general
|
||||
iv_dangerous = abap_false ).
|
||||
|
||||
cl_abap_unit_assert=>assert_equals( exp = {{p}}if_air_freight=>c_reason-too_heavy
|
||||
act = ls_result-reason ).
|
||||
assert_amount( iv_expected = '0.00' iv_actual = ls_result-total_amount ).
|
||||
ENDMETHOD.
|
||||
ENDCLASS.
|
||||
42
tasks_gen/train/G1057/seed/if_air_freight.intf.abap
Normal file
42
tasks_gen/train/G1057/seed/if_air_freight.intf.abap
Normal file
@@ -0,0 +1,42 @@
|
||||
INTERFACE {{p}}if_air_freight PUBLIC.
|
||||
TYPES:
|
||||
ty_weight TYPE p LENGTH 9 DECIMALS 3,
|
||||
ty_volume TYPE p LENGTH 11 DECIMALS 3,
|
||||
ty_amount TYPE p LENGTH 13 DECIMALS 2,
|
||||
ty_category TYPE c LENGTH 10,
|
||||
ty_reason TYPE c LENGTH 12.
|
||||
|
||||
TYPES:
|
||||
BEGIN OF ty_result,
|
||||
chargeable_weight TYPE ty_weight,
|
||||
freight TYPE ty_amount,
|
||||
dangerous_fee TYPE ty_amount,
|
||||
fuel_fee TYPE ty_amount,
|
||||
security_fee TYPE ty_amount,
|
||||
total_amount TYPE ty_amount,
|
||||
reason TYPE ty_reason,
|
||||
END OF ty_result.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_category,
|
||||
general TYPE ty_category VALUE 'GENERAL',
|
||||
perishable TYPE ty_category VALUE 'PERISHABLE',
|
||||
valuable TYPE ty_category VALUE 'VALUABLE',
|
||||
END OF c_category.
|
||||
|
||||
CONSTANTS:
|
||||
BEGIN OF c_reason,
|
||||
ok TYPE ty_reason VALUE 'OK',
|
||||
bad_weight TYPE ty_reason VALUE 'BAD_WEIGHT',
|
||||
bad_volume TYPE ty_reason VALUE 'BAD_VOLUME',
|
||||
bad_category TYPE ty_reason VALUE 'BAD_CATEGORY',
|
||||
too_heavy TYPE ty_reason VALUE 'TOO_HEAVY',
|
||||
END OF c_reason.
|
||||
|
||||
METHODS price
|
||||
IMPORTING iv_weight TYPE ty_weight
|
||||
iv_volume TYPE ty_volume
|
||||
iv_category TYPE ty_category
|
||||
iv_dangerous TYPE abap_bool
|
||||
RETURNING VALUE(rs_result) TYPE ty_result.
|
||||
ENDINTERFACE.
|
||||
66
tasks_gen/train/G1057/spec.md
Normal file
66
tasks_gen/train/G1057/spec.md
Normal file
@@ -0,0 +1,66 @@
|
||||
# 1. Goal
|
||||
A freight forwarder prices air freight shipments. The sales desk calls one class
|
||||
for each shipment. The class returns the chargeable weight, the freight, the
|
||||
surcharges and the total charge of the shipment.
|
||||
|
||||
# 2. Open questions
|
||||
None.
|
||||
|
||||
# 3. Context
|
||||
- The interface {{P}}IF_AIR_FREIGHT exists in package $TMP. It is active.
|
||||
- The interface defines the input types, the result structure, the goods
|
||||
categories, the reason codes and one method. Read the interface before you
|
||||
start.
|
||||
- The method receives the actual weight in kilograms, the volume in cubic
|
||||
centimetres, the goods category and a flag that marks a dangerous goods
|
||||
shipment.
|
||||
- The result structure has one field for the chargeable weight, one field for
|
||||
each amount and one field for the reason.
|
||||
|
||||
# 4. Contract
|
||||
- Create the class {{P}}AIR_FREIGHT_PRICER in package $TMP.
|
||||
- The class is public, final and has a public constructor without parameters.
|
||||
- The class implements {{P}}IF_AIR_FREIGHT.
|
||||
- Do not add other public methods.
|
||||
|
||||
# 5. Business rules
|
||||
Apply the rules in this sequence.
|
||||
1. If the actual weight is not positive, return BAD_WEIGHT.
|
||||
2. If the volume is not positive, return BAD_VOLUME.
|
||||
3. If the category is not one of the categories of the interface, return
|
||||
BAD_CATEGORY.
|
||||
4. The volumetric weight is the volume divided by 6000. The chargeable weight
|
||||
is the larger of the actual weight and the volumetric weight, rounded up to
|
||||
the next whole kilogram. A value that is already a whole number does not
|
||||
change.
|
||||
5. If the chargeable weight is more than 3000 kg, return TOO_HEAVY.
|
||||
6. The base rate per kilogram depends on the chargeable weight:
|
||||
- up to 45 kg: 9.00
|
||||
- more than 45 kg and up to 100 kg: 7.20
|
||||
- more than 100 kg and up to 500 kg: 5.60
|
||||
- more than 500 kg: 4.30
|
||||
7. The category factor is 1.00 for the general category, 1.25 for the
|
||||
perishable category and 1.50 for the valuable category.
|
||||
8. The freight is the chargeable weight multiplied by the base rate and by the
|
||||
category factor.
|
||||
9. If the shipment is dangerous, the dangerous goods surcharge is 40 per cent
|
||||
of the freight. Otherwise the dangerous goods surcharge is zero.
|
||||
10. The fuel surcharge is 12 per cent of the freight plus the dangerous goods
|
||||
surcharge.
|
||||
11. The security fee is 15.00.
|
||||
12. The total is the freight plus the dangerous goods surcharge plus the fuel
|
||||
surcharge plus the security fee.
|
||||
13. Round each amount to two decimal places before you use it in the next step.
|
||||
14. If one of the rules 1 to 5 fails, return the reason and set every numeric
|
||||
field of the result to zero. If no rule fails, return OK.
|
||||
|
||||
# 6. Constraints
|
||||
- Release target: SAP_BASIS 816 (ABAP Platform 2025).
|
||||
- Coding standards: Clean ABAP. Method length below 40 statements. No global
|
||||
variables. No comment that restates the code.
|
||||
- Out of scope: do not change {{P}}IF_AIR_FREIGHT.
|
||||
|
||||
# 7. Acceptance
|
||||
- The class is active and has no syntax error.
|
||||
- The hidden tests pass.
|
||||
- Write your own ABAP Unit tests for the class.
|
||||
51
tasks_gen/train/G1057/task.json
Normal file
51
tasks_gen/train/G1057/task.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"id": "G1057",
|
||||
"category": "F",
|
||||
"object_type": "CLAS",
|
||||
"difficulty": 2,
|
||||
"release_target": "v816",
|
||||
"expected_outcome": "implement",
|
||||
"budget": {
|
||||
"max_tool_calls": 60,
|
||||
"max_activations": 15
|
||||
},
|
||||
"seed": [
|
||||
{
|
||||
"type": "INTF",
|
||||
"name": "{{P}}IF_AIR_FREIGHT",
|
||||
"file": "seed/if_air_freight.intf.abap",
|
||||
"description": "Air freight pricing contract: input types, result structure, categories, reason codes and method"
|
||||
}
|
||||
],
|
||||
"contract": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"implements": "{{P}}IF_AIR_FREIGHT"
|
||||
}
|
||||
],
|
||||
"out_of_scope": [
|
||||
"{{P}}IF_AIR_FREIGHT"
|
||||
],
|
||||
"hidden_tests": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}AIR_FRT_HIDDEN",
|
||||
"file": "hidden/air_frt_hidden.clas.abap",
|
||||
"description": "Hidden tests for the air freight pricer"
|
||||
}
|
||||
],
|
||||
"reference": [
|
||||
{
|
||||
"type": "CLAS",
|
||||
"name": "{{P}}AIR_FREIGHT_PRICER",
|
||||
"file": "reference/air_freight_pricer.clas.abap",
|
||||
"description": "Air freight pricer",
|
||||
"testclasses_file": "reference/air_freight_pricer.testclasses.abap"
|
||||
}
|
||||
],
|
||||
"craft_checks": [
|
||||
"method_length",
|
||||
"cyclomatic_complexity"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user