Files
abap-llm/tasks_gen/train/G1034/seed/storage_pricer.clas.abap

76 lines
2.0 KiB
ABAP

CLASS {{p}}storage_pricer DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
TYPES ty_amount TYPE p LENGTH 8 DECIMALS 2.
TYPES ty_sqm TYPE i.
TYPES ty_months TYPE i.
TYPES:
BEGIN OF ty_booking,
size_sqm TYPE ty_sqm,
months TYPE ty_months,
climate TYPE abap_bool,
insurance TYPE abap_bool,
END OF ty_booking.
METHODS calculate_price
IMPORTING is_booking TYPE ty_booking
RETURNING VALUE(rv_price) TYPE ty_amount.
ENDCLASS.
CLASS {{p}}storage_pricer IMPLEMENTATION.
METHOD calculate_price.
" price of the booking
DATA lv_rate TYPE p LENGTH 8 DECIMALS 2.
DATA lv_rent TYPE p LENGTH 12 DECIMALS 2.
DATA lv_disc TYPE p LENGTH 12 DECIMALS 2.
DATA lv_ins TYPE p LENGTH 12 DECIMALS 2.
DATA lv_sum TYPE p LENGTH 12 DECIMALS 2.
DATA lv_tmp TYPE p LENGTH 12 DECIMALS 2.
rv_price = 0.
IF is_booking-size_sqm > 0.
IF is_booking-months > 0.
IF is_booking-size_sqm <= 5.
lv_rate = '14.00'.
ELSE.
IF is_booking-size_sqm <= 15.
lv_rate = '11.50'.
ELSE.
lv_rate = '9.00'.
ENDIF.
ENDIF.
IF is_booking-climate = 'X'.
lv_rate = lv_rate + '4.50'.
ENDIF.
lv_rent = is_booking-size_sqm * is_booking-months * lv_rate.
lv_disc = 0.
IF is_booking-months >= 24.
lv_disc = lv_rent * 15 / 100.
ELSE.
IF is_booking-months >= 12.
lv_disc = lv_rent * 10 / 100.
ELSE.
IF is_booking-months >= 6.
lv_disc = lv_rent * 5 / 100.
ENDIF.
ENDIF.
ENDIF.
lv_ins = 0.
IF is_booking-insurance = 'X'.
lv_ins = is_booking-size_sqm * is_booking-months * '0.90'.
ENDIF.
lv_tmp = lv_rent - lv_disc.
lv_sum = lv_tmp + lv_ins + '19.00'.
rv_price = lv_sum.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.