Coverage for app/delivery_fee/settings.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-11-27 09:26 +0000

1""" 

2This module contains all the configuration for the delivery fee. 

3""" 

4from datetime import time 

5from app.delivery_fee.fee_calculation_steps import ( 

6 CartValueFee, 

7 DeliveryDistanceFee, 

8 NumberOfItemsFee, 

9) 

10from app.delivery_fee.fee_transformers import ( 

11 RushHourFeeTransformer, 

12 ReduceFeeTransformer, 

13 LimitFeeTransformer, 

14) 

15 

16 

17######################################################################################### 

18# Fee Calculation Steps 

19######################################################################################### 

20 

21# Settings for fee calculation steps. 

22CART_VALUE_CONFIG_OPTIONS = CartValueFee.ConfigOptions( 

23 cart_value_surcharge_threshold=10e2, # 10€ (inclusive) 

24) 

25DELIVERY_DISTANCE_CONFIG_OPTIONS = DeliveryDistanceFee.ConfigOptions( 

26 delivery_distance_low_threshold=1e3, # 1km (inclusive) 

27 delivery_distance_surcharge_for_low_threshold=2e2, # 2€ 

28 additional_fee=1e2, # 1€ 

29 additional_fee_applied_per_meters_traveled=500, # 500m (inclusive) 

30) 

31NUMBER_OF_ITEMS_CONFIG_OPTIONS = NumberOfItemsFee.ConfigOptions( 

32 number_of_items_surcharge_threshold=4, # 4 items (exclusive) 

33 surcharge_per_item_over_threshold=50, # 50 cents 

34 bulk_charge=1.2e2, # 1.20€ 

35 bulk_charge_threshold=12, # 12 items (inclusive) 

36) 

37 

38 

39# Here order of the calculation steps does not matters. 

40ALL_CALCULATION_STEPS = [ 

41 CartValueFee(CART_VALUE_CONFIG_OPTIONS), 

42 DeliveryDistanceFee(DELIVERY_DISTANCE_CONFIG_OPTIONS), 

43 NumberOfItemsFee(NUMBER_OF_ITEMS_CONFIG_OPTIONS), 

44] 

45 

46 

47######################################################################################### 

48# Transformation Steps 

49######################################################################################### 

50 

51# Settings for fee transformers. 

52FRIDAY_RUSH_HOUR_CONFIG_OPTIONS = RushHourFeeTransformer.ConfigOptions( 

53 rush_day="Friday", 

54 rush_hour_start=time(hour=12+3, minute=0), # 3:00:00 PM (inclusive) 

55 rush_hour_end=time(hour=12+7, minute=59, second=59, 

56 microsecond=999999), # 7:59:59.999999 PM (inclusive) 

57 rush_hour_fee_factor=1.2, # 20% (increase) 

58) 

59LIMIT_FEE_CONFIG_OPTIONS = LimitFeeTransformer.ConfigOptions( 

60 highest_limit_of_delivery_fee=15e2, # 15€ (inclusive) 

61) 

62 

63EXCLUDE_FEE_CONFIG_OPTIONS = ReduceFeeTransformer.ConfigOptions( 

64 exclusion_cart_value_threshold=200e2, # 200€ (inclusive) 

65 exclusion_delivery_fee_factor=1, # 100% (decrease) 

66) 

67 

68 

69# Here order of the transformers matters. 

70ALL_FEE_TRANSFORMERS = [ 

71 RushHourFeeTransformer(FRIDAY_RUSH_HOUR_CONFIG_OPTIONS), 

72 ReduceFeeTransformer(EXCLUDE_FEE_CONFIG_OPTIONS), 

73 LimitFeeTransformer(LIMIT_FEE_CONFIG_OPTIONS), 

74]