diff --git a/components/calcValues.vue b/components/calcValues.vue index 67fb81e..aaa41c1 100644 --- a/components/calcValues.vue +++ b/components/calcValues.vue @@ -101,13 +101,14 @@ const changeParametres = () => { if (full_sections == 0) { length = total_length_mm - fence_length - fence_length } - if ((total_length_mm - ((full_sections * length) + (full_sections * fence_length) + fence_length)) < fence_length) { + let total_length_calc = (full_sections * length) + (full_sections * fence_length) + fence_length + if ((total_length_mm - total_length_calc) > 0 && (total_length_mm - total_length_calc) < fence_length) { full_sections -= 1 } } - - if (((full_sections * length) + (full_sections * fence_length) + fence_length) < total_length_mm) { - form_state.extra_section = total_length_mm - ((full_sections * length) + (full_sections * fence_length) + fence_length) - fence_length + let total_length_calc = (full_sections * length) + (full_sections * fence_length) + fence_length + if (total_length_calc < total_length_mm) { + form_state.extra_section = total_length_mm - total_length_calc - fence_length } else { form_state.extra_section = 0 }