|
|
@@ -25,10 +25,14 @@ def calculate_estimated_price(material_id: int, file_sizes: List[int], file_quan
|
|
|
if file_quantities is None or len(file_quantities) != len(file_sizes):
|
|
|
file_quantities = [1] * len(file_sizes)
|
|
|
|
|
|
- estimated_total = 0.0
|
|
|
- file_costs = []
|
|
|
- base_fee = 5.0 # Minimum setup fee per file
|
|
|
-
|
|
|
+ # Volume discount: 5% for each next item, max 20% total
|
|
|
+ total_qty = sum(file_quantities)
|
|
|
+ discount_multiplier = 1.0
|
|
|
+ discount_percent = 0.0
|
|
|
+ if total_qty > 1:
|
|
|
+ discount_percent = min((total_qty - 1) * 0.05, 0.20)
|
|
|
+ discount_multiplier = 1.0 - discount_percent
|
|
|
+
|
|
|
for size, qty in zip(file_sizes, file_quantities):
|
|
|
total_size_mb = size / (1024 * 1024)
|
|
|
# Empirical conversion: ~8cm3 per 1MB of STL (binary)
|
|
|
@@ -41,7 +45,8 @@ def calculate_estimated_price(material_id: int, file_sizes: List[int], file_quan
|
|
|
material_cost = estimated_volume_cm3 * price_per_cm3
|
|
|
operation_cost = estimated_hours * price_per_hour
|
|
|
|
|
|
- file_cost = round(base_fee + material_cost + operation_cost, 2)
|
|
|
+ # Apply volume discount to unit price
|
|
|
+ file_cost = round((base_fee + material_cost + operation_cost) * discount_multiplier, 2)
|
|
|
file_costs.append(file_cost)
|
|
|
estimated_total += file_cost * qty
|
|
|
|
|
|
@@ -49,7 +54,9 @@ def calculate_estimated_price(material_id: int, file_sizes: List[int], file_quan
|
|
|
"price_per_cm3": price_per_cm3,
|
|
|
"price_per_hour": price_per_hour,
|
|
|
"speed_coeff": speed_coeff,
|
|
|
- "base_fee": base_fee
|
|
|
+ "base_fee": base_fee,
|
|
|
+ "discount_percent": round(discount_percent * 100, 0),
|
|
|
+ "total_qty": total_qty
|
|
|
}
|
|
|
|
|
|
if return_details:
|