An online store sells a product for $45 per item. It costs $20 per item to produce. The store also pays $200 per month for shipping. They get a bulk order discount of $10 off per item for orders over 50 items. Write an expression for the total profit (n items > 50).
Handling bulk discounts is a core feature of pricing engines.
function calculateMonthlyProfit(itemsSold: number): number {
const basePrice = 45;
const costPerItem = 20;
const fixedCost = 200;
// Logic: Apply discount if applicable
let price = basePrice;
if (itemsSold > 50) {
price -= 10; // Discounted price is $35
}
// Revenue = Price * Quantity
const revenue = price * itemsSold;
// Total Cost = (Variable * Quantity) + Fixed
const totalCost = (costPerItem * itemsSold) + fixedCost;
return revenue - totalCost;
}
// 100 items (Bulk Discount Applies):
console.log(calculateMonthlyProfit(100));
// Revenue: 35 * 100 = 3500
// Cost: (20 * 100) + 200 = 2200
// Profit: 1300