fixed tax calculate issue

This commit is contained in:
Cihan Şentürk 2025-08-04 15:26:09 +03:00
parent 51d2097cd6
commit 502c7b0d31
2 changed files with 5 additions and 15 deletions

View File

@ -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),
];
}
}

View File

@ -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);
},
},