Better information in dashboard tiles and prevent division by zero in Excel calculations.

This commit is contained in:
2025-02-03 11:55:52 +01:00
parent ba92198750
commit 588b56d71e
2 changed files with 13 additions and 10 deletions

View File

@@ -93,6 +93,7 @@ class ExcelController extends Controller
$row = 2; $row = 2;
foreach ($invoices as $invoice) { foreach ($invoices as $invoice) {
if ($invoice->sum != 0) {
foreach ($invoice->items as $item) { foreach ($invoice->items as $item) {
if (!isset($net[$item->tax])) { if (!isset($net[$item->tax])) {
$net[$item->tax] = 0; $net[$item->tax] = 0;
@@ -103,6 +104,7 @@ class ExcelController extends Controller
$tax[$item->tax] += $item->amount * $item->price * $item->tax / 100; $tax[$item->tax] += $item->amount * $item->price * $item->tax / 100;
$gross[$item->tax] += $item->total; $gross[$item->tax] += $item->total;
} }
}
$worksheet->setCellValue('A' . $row, $invoice->number); $worksheet->setCellValue('A' . $row, $invoice->number);
$worksheet->setCellValue('B' . $row, $invoice->customer->name); $worksheet->setCellValue('B' . $row, $invoice->customer->name);
$worksheet->setCellValue('C' . $row, $invoice->address->name); $worksheet->setCellValue('C' . $row, $invoice->address->name);
@@ -114,6 +116,7 @@ class ExcelController extends Controller
$worksheet->setCellValue('F' . $row, $invoice->sum); $worksheet->setCellValue('F' . $row, $invoice->sum);
$worksheet->setCellValue('G' . $row, Date::PHPToExcel(\DateTime::createFromFormat('!d.m.Y', $invoice->created))); $worksheet->setCellValue('G' . $row, Date::PHPToExcel(\DateTime::createFromFormat('!d.m.Y', $invoice->created)));
$worksheet->getCell('G' . $row)->getStyle()->getNumberFormat()->setFormatCode('dd.mm.yyyy'); $worksheet->getCell('G' . $row)->getStyle()->getNumberFormat()->setFormatCode('dd.mm.yyyy');
$row++; $row++;
} }

View File

@@ -23,7 +23,7 @@
<a href="{{ route('payment.create') }}" <a href="{{ route('payment.create') }}"
class="flex max-w even:bg-gray-100 odd:bg-white"> class="flex max-w even:bg-gray-100 odd:bg-white">
<div class="w-1/4">{{ $invoice->number }}</div> <div class="w-1/4">{{ $invoice->number }}</div>
<div class="w-1/4">{{ $invoice->address->name }}</div> <div class="w-1/4">{{ $invoice->customer->name }}</div>
<div class="w-1/4 text-right">{{ \Illuminate\Support\Number::currency($invoice->sum) }}</div> <div class="w-1/4 text-right">{{ \Illuminate\Support\Number::currency($invoice->sum) }}</div>
<div class="w-1/4 text-right">{{ $invoice->created }}</div> <div class="w-1/4 text-right">{{ $invoice->created }}</div>
</a> </a>
@@ -39,7 +39,7 @@
<a href="{{ route('invoice.edit', $invoice->id) }}" <a href="{{ route('invoice.edit', $invoice->id) }}"
class="flex max-w even:bg-gray-100 odd:bg-white"> class="flex max-w even:bg-gray-100 odd:bg-white">
<div class="w-1/2">{{ $invoice->number }}</div> <div class="w-1/2">{{ $invoice->number }}</div>
<div class="w-1/2">{{ $invoice->address->name }}</div> <div class="w-1/2">{{ $invoice->customer->name }}</div>
</a> </a>
@endforeach @endforeach
</div> </div>