From af3726cb91113dedd590e3d472978fcee6d7f9e2 Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Thu, 7 Nov 2024 18:20:53 -0600 Subject: [PATCH] fix: sales quantity should use rounded float numbers --- app/Models/Transaction.php | 2 +- app/Rules/QuantityValidationRule.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 8b58b82..a4793d0 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -125,7 +125,7 @@ class Transaction extends Model public function scopeBeforeDate($query, $date) { - return $query->whereDate('date', '<', $date); + return $query->whereDate('date', '<=', $date); } public function scopeMyTransactions() diff --git a/app/Rules/QuantityValidationRule.php b/app/Rules/QuantityValidationRule.php index 91bebe2..0dea105 100644 --- a/app/Rules/QuantityValidationRule.php +++ b/app/Rules/QuantityValidationRule.php @@ -50,7 +50,7 @@ class QuantityValidationRule implements ValidationRule $maxQuantity = $purchase_qty - $sales_qty; - if ($value > $maxQuantity) { + if (round($value, 3) > round($maxQuantity, 3)) { $fail(__('The quantity must not be greater than the available quantity.')); } }