Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix aptc save button and zero input handling #4473

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading