Compare commits
2 Commits
90a5e17f2b
...
a3c5a66d3f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3c5a66d3f | ||
|
|
2038c4df3e |
@@ -353,16 +353,14 @@ export function OrderWizard({
|
||||
})
|
||||
const totalItem = base + modulesSum
|
||||
if (prod.billing_interval === 'one_time') {
|
||||
oneTime += totalItem
|
||||
const allowDiscount = (cat as any).allow_update_discount !== false
|
||||
const finalItemTotal = allowDiscount ? (totalItem * updatePriceModifier.multiplier) : totalItem
|
||||
oneTime += finalItemTotal
|
||||
} else {
|
||||
monthly += totalItem
|
||||
}
|
||||
})
|
||||
}
|
||||
// Apply update modifier to oneTime total
|
||||
if (updatePriceModifier.multiplier !== 1) {
|
||||
oneTime = oneTime * updatePriceModifier.multiplier
|
||||
}
|
||||
return { monthlyTotal: monthly, oneTimeTotal: oneTime }
|
||||
}, [selections, products, categories, moduleQuantities, updatePriceModifier])
|
||||
|
||||
|
||||
@@ -183,10 +183,14 @@ export function buildOrderSnapshot(
|
||||
multiplier = 0.90
|
||||
}
|
||||
|
||||
// Multiply only one_time item totals by multiplier
|
||||
// Multiply only one_time item totals by multiplier if category allows it
|
||||
items.forEach(item => {
|
||||
if (item.billing_interval === 'one_time') {
|
||||
item.item_total = item.item_total * multiplier
|
||||
const cat = categories.find(c => c.id === item.category_id);
|
||||
const allowDiscount = cat ? (cat as any).allow_update_discount !== false : true;
|
||||
if (allowDiscount) {
|
||||
item.item_total = item.item_total * multiplier;
|
||||
}
|
||||
}
|
||||
})
|
||||
subtotal = items.reduce((acc, item) => acc + item.item_total, 0)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Migration: Add allow_update_discount to categories
|
||||
-- Purpose: Add a boolean flag to categories to control if their products are eligible for the update discount.
|
||||
|
||||
ALTER TABLE public.categories ADD COLUMN IF NOT EXISTS allow_update_discount BOOLEAN DEFAULT true NOT NULL;
|
||||
|
||||
NOTIFY pgrst, 'reload schema';
|
||||
Reference in New Issue
Block a user