From a60f5b6d4f2b0e280dd92a1c2419ccb52359c5e5 Mon Sep 17 00:00:00 2001 From: ivladu-plenty Date: Wed, 2 Nov 2022 16:11:38 +0200 Subject: [PATCH] fix/minimum order quantity does not apply --- resources/js/src/app/components/item/QuantityInput.vue | 8 +++++--- resources/js/src/app/helper/number.js | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/js/src/app/components/item/QuantityInput.vue b/resources/js/src/app/components/item/QuantityInput.vue index fd9054dc48..aabe946920 100644 --- a/resources/js/src/app/components/item/QuantityInput.vue +++ b/resources/js/src/app/components/item/QuantityInput.vue @@ -277,7 +277,7 @@ export default { } else { - diff = formatFloat(value % this.compInterval, this.compDecimals, true); + diff = formatFloat(value % this.compInterval, this.compDecimals, false); } if (diff > 0 && diff !== this.compInterval) @@ -294,7 +294,7 @@ export default { } // cut fraction - value = formatFloat(value, this.compDecimals); + value = formatFloat(value, this.compDecimals, false); if (value !== this.compValue) { @@ -312,7 +312,9 @@ export default { if (!isNullOrUndefined(this.min) && this.variationBasketQuantity >= this.min && this.variationBasketQuantity !== 0) { // set the minimum value to the interval, if the item is already in the basket - this.compMin = this.compInterval; + if (Number.isInteger(this.compMin)) { + this.compMin = this.compInterval; + } } else if (this.variationBasketQuantity === 0) { diff --git a/resources/js/src/app/helper/number.js b/resources/js/src/app/helper/number.js index 2e7a713e4c..e203e812f6 100644 --- a/resources/js/src/app/helper/number.js +++ b/resources/js/src/app/helper/number.js @@ -71,5 +71,8 @@ export function formatFloat(value, decimals, round) // return NaN return 1 / 0; } + + value = Math.floor(value * 100) / 100; + return parseFloat(value.toFixed(decimals)); }