From 502c7b0d319d4e95597699eb6710afdb78ee1b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= Date: Mon, 4 Aug 2025 15:26:09 +0300 Subject: [PATCH] fixed tax calculate issue --- .../Document/CreateDocumentItemsAndTotals.php | 4 ++-- resources/assets/js/views/common/documents.js | 16 +++------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/app/Jobs/Document/CreateDocumentItemsAndTotals.php b/app/Jobs/Document/CreateDocumentItemsAndTotals.php index 4de617889..473b15a60 100644 --- a/app/Jobs/Document/CreateDocumentItemsAndTotals.php +++ b/app/Jobs/Document/CreateDocumentItemsAndTotals.php @@ -238,11 +238,11 @@ class CreateDocumentItemsAndTotals extends Job implements HasOwner, HasSource, S // Set taxes foreach ((array) $document_item->item_taxes as $item_tax) { if (array_key_exists($item_tax['tax_id'], $taxes)) { - $taxes[$item_tax['tax_id']]['amount'] += number_format($item_tax['amount'], $this->document->currency->precision); + $taxes[$item_tax['tax_id']]['amount'] += round((float) $item_tax['amount'], $this->document->currency->precision); } else { $taxes[$item_tax['tax_id']] = [ 'name' => $item_tax['name'], - 'amount' => number_format($item_tax['amount'], $this->document->currency->precision), + 'amount' => round((float) $item_tax['amount'], $this->document->currency->precision), ]; } } diff --git a/resources/assets/js/views/common/documents.js b/resources/assets/js/views/common/documents.js index 4e148dd11..3e220ae97 100644 --- a/resources/assets/js/views/common/documents.js +++ b/resources/assets/js/views/common/documents.js @@ -888,24 +888,14 @@ const app = new Vue({ this.onSubmit(); }, - numberFormat(number, decimals = 0, decPoint = '.', thousandsSep = ',') { + numberFormat(number, decimals = 0) { number = parseFloat(number); - if (isNaN(number)) return '0'; + if (isNaN(number)) return parseFloat('0'); - // Ondalık basamakları ayarla number = number.toFixed(decimals); - // Sayıyı parçalara ayır - let parts = number.split('.'); - let integerPart = parts[0]; - let decimalPart = parts[1] || ''; - - // Binlik ayıracı ekle - integerPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSep); - - // Sonucu birleştir - return decimals > 0 ? parseFloat(integerPart + decPoint + decimalPart) : parseFloat(integerPart); + return parseFloat(number); }, },