From 23d8009e00bedf8265db7f1d5d1811fd010a9919 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Tue, 28 Jul 2026 13:17:46 +0000 Subject: [PATCH] Scope Nuclear RAB levy field to electric tariffs only RAB levy funds nuclear electricity generation, so it can't apply to gas/oil/water tariffs. Hide the field for non-electric categories and clear any stray value if a tariff's category changes or is saved as non-electric. Co-Authored-By: Claude Sonnet 5 --- frontend/src/pages/Tariffs.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/Tariffs.tsx b/frontend/src/pages/Tariffs.tsx index f6acf65..a583ab0 100644 --- a/frontend/src/pages/Tariffs.tsx +++ b/frontend/src/pages/Tariffs.tsx @@ -109,13 +109,14 @@ export default function Tariffs() { ? Object.fromEntries(form.windows.map(w => [w.label.toLowerCase(), w.split_pct])) : {} const windows = form.windows.map(({ split_pct: _split_pct, ...w }) => w) + const isElectric = categories.find(c => c.id === form.category_id)?.key === 'electric' const body = { category_id: form.category_id, name: form.name.trim(), supplier: form.supplier || null, effective_from: form.effective_from, effective_to: form.effective_to || null, standing_charge_pence_per_day: form.standing_charge_pence_per_day, ccl_rate_pence_per_unit: form.ccl_rate_pence_per_unit === '' ? null : form.ccl_rate_pence_per_unit, ccl_exempt: form.ccl_exempt, - rab_levy_rate_pence_per_unit: form.rab_levy_rate_pence_per_unit === '' ? null : form.rab_levy_rate_pence_per_unit, + rab_levy_rate_pence_per_unit: !isElectric || form.rab_levy_rate_pence_per_unit === '' ? null : form.rab_levy_rate_pence_per_unit, metering_charge_pence_per_month: form.metering_charge_pence_per_month, other_charges_pence_per_month: form.other_charges_pence_per_month, vat_rate_pct: form.vat_rate_pct, is_time_of_use: form.is_time_of_use, @@ -195,7 +196,12 @@ export default function Tariffs() {
- { + const category_id = parseInt(e.target.value) + const category = categories.find(c => c.id === category_id) + const clearRabLevy = category?.key !== 'electric' + setForm({ ...form, category_id, rab_levy_rate_pence_per_unit: clearRabLevy ? '' : form.rab_levy_rate_pence_per_unit }) + }}> {categories.map(c => )}
@@ -238,11 +244,13 @@ export default function Tariffs() {
-
- - setForm({ ...form, rab_levy_rate_pence_per_unit: e.target.value === '' ? '' : parseFloat(e.target.value) })} /> -
+ {categories.find(c => c.id === form.category_id)?.key === 'electric' && ( +
+ + setForm({ ...form, rab_levy_rate_pence_per_unit: e.target.value === '' ? '' : parseFloat(e.target.value) })} /> +
+ )}