Skip to content
Snippets Groups Projects
Commit 3027da01 authored by Emmanuel Raviart's avatar Emmanuel Raviart
Browse files

Fix tax scales edition

parent 2b94c422
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@
isAmountScaleParameter,
isRateScaleParameter,
ScaleType,
type BracketAtInstant,
type LinearAverageRateScaleParameter,
type MarginalAmountScaleParameter,
type MarginalRateScaleParameter,
......@@ -51,23 +52,15 @@
let { data } = $derived($page)
let isAmountScale = $derived(isAmountScaleParameter(parameter))
let { unitByName, units } = $derived(data)
function addInstantReferencesAndScale() {
const newScaleAtInstant =
instantReferencesAndScaleArray.length === 0
? [
isAmountScale
? { amount: { value: null }, threshold: { value: null } }
: {
base: { value: null },
rate: { value: null },
threshold: { value: null },
},
]
: structuredClone(instantReferencesAndScaleArray[0][1])
? [{} as BracketAtInstant]
: structuredClone(
$state.snapshot(instantReferencesAndScaleArray[0].scaleAtInstant),
)
instantReferencesAndScaleArray = [
{
instant: new Date().toISOString().split("T")[0],
......@@ -287,19 +280,18 @@
<div class="mb-2 mt-4 flex-col">
{#if isAmountScaleParameter(parameter)}
{#if (parameter as MarginalAmountScaleParameter | SingleAmountScaleParameter).amount_unit !== undefined}
{@const amountScaleParameter = parameter as
| MarginalAmountScaleParameter
| SingleAmountScaleParameter}
{#if amountScaleParameter.amount_unit !== undefined}
<label class="flex text-base">
Unité de montant&nbps;:
<select
class="border-1 mx-auto ml-1 flex rounded p-1 text-sm"
required={showErrors}
bind:value={(
parameter as
| MarginalAmountScaleParameter
| SingleAmountScaleParameter
).amount_unit}
bind:value={amountScaleParameter.amount_unit}
>
{#if (parameter as MarginalAmountScaleParameter | SingleAmountScaleParameter).amount_unit === undefined}
{#if amountScaleParameter.amount_unit === undefined}
<option selected value={undefined}>Non précisée</option>
{/if}
{#each units as unit}
......@@ -313,19 +305,19 @@
{/if}
</label>
{/if}
{:else if (parameter as LinearAverageRateScaleParameter | MarginalRateScaleParameter).rate_unit !== undefined}
{:else}
{@const rateScaleParameter = parameter as
| LinearAverageRateScaleParameter
| MarginalRateScaleParameter}
{#if rateScaleParameter.rate_unit !== undefined}
<label class="flex text-base">
Unité de taux&nbsp;:
<select
class="border-1 mx-auto ml-1 flex rounded p-1 text-sm"
required={showErrors}
bind:value={(
parameter as
| LinearAverageRateScaleParameter
| MarginalRateScaleParameter
).rate_unit}
bind:value={rateScaleParameter.rate_unit}
>
{#if (parameter as LinearAverageRateScaleParameter | MarginalRateScaleParameter).rate_unit === undefined}
{#if rateScaleParameter.rate_unit === undefined}
<option selected value={undefined}>Non précisée</option>
{/if}
{#each units as unit}
......@@ -339,6 +331,7 @@
{/if}
</label>
{/if}
{/if}
<div class="mb-2 flex">
<label class="flex text-base">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment