feat: check category eligibility for update discount in frontend and backend
Some checks failed
Staging Build / build (push) Has been cancelled

This commit is contained in:
DanielS
2026-07-10 00:18:23 +02:00
parent 2038c4df3e
commit a3c5a66d3f
2 changed files with 9 additions and 7 deletions

View File

@@ -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)