Skip to content

Commit

Permalink
fix aptc save button and zero input handling (#4473)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlienparker authored and kristinmerbach committed Sep 4, 2024
1 parent 545e897 commit 5c0272c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="d-flex mb-2 mt-2">
<div class="mr-4">
<label class="required" for="aptc_applied_total"> <%= l10n("amount") %></label>
<input type="number" step=".01" min="0" max="<%= locals[:available_aptc] %>" name="aptc_applied_total" id="aptc_applied_total" data-initial-amount="<%= number_with_precision(locals[:available_aptc].to_f * locals[:hbx_enrollment].elected_aptc_pct, precision: 2) %>" class="form-control tax_credit_field_container" value="<%= number_with_precision(locals[:available_aptc].to_f * locals[:hbx_enrollment].elected_aptc_pct, precision: 2) %>" placeholder="0" required>
<input type="number" step=".01" min="0" max="<%= locals[:available_aptc] %>" name="aptc_applied_total" id="aptc_applied_total" data-initial-amount="<%= number_with_precision(locals[:available_aptc].to_f * locals[:hbx_enrollment].elected_aptc_pct, precision: 2) %>" class="form-control tax_credit_field_container" value="<%= number_with_precision(locals[:available_aptc].to_f * locals[:hbx_enrollment].elected_aptc_pct, precision: 2) %>" placeholder="0.00" required>
</div>
<div class="mr-4">
<label class="required" for="update_tax_credit_percentage"> <%= l10n("percentage") %></label>
Expand All @@ -45,7 +45,7 @@
</div>
<p class="d-flex">
<label for="new_enrollment_premium" class="mr-1"> <%= l10n("new_monthly_premium") %></label>
<span id="calculated_amount_applied"><%= locals[:hbx_enrollment].total_premium.to_f - (locals[:available_aptc].to_f * locals[:hbx_enrollment].elected_aptc_pct.to_f) %></span>
<span id="calculated_amount_applied"><%= number_to_currency(locals[:hbx_enrollment].total_premium.to_f - (locals[:available_aptc].to_f * locals[:hbx_enrollment].elected_aptc_pct.to_f)) %></span>
</p>
<div class="mt-4">
<%= button_tag l10n("discard_changes"), class: "btn outline mr-2", id: "btn-discard-tax-credit", disabled: false, type: :reset %>
Expand Down Expand Up @@ -82,7 +82,7 @@
}

function handlePercentageInput() {
const percentageValue = parseFloat(updateTaxCreditPercentage.value);
const percentageValue = updateTaxCreditPercentage.value ? parseFloat(updateTaxCreditPercentage.value) : 0;
if (!isNaN(percentageValue)) {
if (percentageValue > 100) {
updateTaxCreditPercentage.value = 100;
Expand All @@ -104,7 +104,7 @@
}

function handleTotalInput() {
const totalValue = parseFloat(aptcAppliedTotal.value);
const totalValue = aptcAppliedTotal.value ? parseFloat(aptcAppliedTotal.value) : 0;
if (totalValue > maxTaxCredit) {
updateTaxCreditPercentage.value = 100;
aptcAppliedTotal.value = maxTaxCredit;
Expand Down

0 comments on commit 5c0272c

Please sign in to comment.