Andrew Wallo преди 11 месеца
родител
ревизия
0b1e09ecae
променени са 2 файла, в които са добавени 39 реда и са изтрити 20 реда
  1. 21
    5
      app/Filament/Company/Pages/Reports/AccountTransactions.php
  2. 18
    15
      app/Transformers/BalanceSheetReportTransformer.php

+ 21
- 5
app/Filament/Company/Pages/Reports/AccountTransactions.php Целия файл

6
 use App\DTO\ReportDTO;
6
 use App\DTO\ReportDTO;
7
 use App\Filament\Company\Pages\Accounting\Transactions;
7
 use App\Filament\Company\Pages\Accounting\Transactions;
8
 use App\Models\Accounting\Account;
8
 use App\Models\Accounting\Account;
9
+use App\Models\Accounting\JournalEntry;
9
 use App\Services\ExportService;
10
 use App\Services\ExportService;
10
 use App\Services\ReportService;
11
 use App\Services\ReportService;
11
 use App\Support\Column;
12
 use App\Support\Column;
18
 use Filament\Tables\Actions\Action;
19
 use Filament\Tables\Actions\Action;
19
 use Guava\FilamentClusters\Forms\Cluster;
20
 use Guava\FilamentClusters\Forms\Cluster;
20
 use Illuminate\Contracts\Support\Htmlable;
21
 use Illuminate\Contracts\Support\Htmlable;
22
+use Illuminate\Database\Eloquent\Builder;
21
 use Illuminate\Support\Collection;
23
 use Illuminate\Support\Collection;
22
 use Symfony\Component\HttpFoundation\StreamedResponse;
24
 use Symfony\Component\HttpFoundation\StreamedResponse;
23
 
25
 
162
         ];
164
         ];
163
     }
165
     }
164
 
166
 
165
-    public function tableHasEmptyState(): bool
167
+    public function hasNoTransactionsForSelectedAccount(): bool
166
     {
168
     {
167
-        if ($this->report) {
168
-            return empty($this->report->getCategories());
169
-        } else {
170
-            return true;
169
+        $query = JournalEntry::query();
170
+        $selectedAccountId = $this->getFilterState('selectedAccount');
171
+
172
+        if ($selectedAccountId !== 'all') {
173
+            $query->where('account_id', $selectedAccountId);
171
         }
174
         }
175
+
176
+        if ($this->getFilterState('startDate') && $this->getFilterState('endDate')) {
177
+            $query->whereHas('transaction', function (Builder $query) {
178
+                $query->whereBetween('posted_at', [$this->getFormattedStartDate(), $this->getFormattedEndDate()]);
179
+            });
180
+        }
181
+
182
+        return $query->doesntExist();
183
+    }
184
+
185
+    public function tableHasEmptyState(): bool
186
+    {
187
+        return $this->hasNoTransactionsForSelectedAccount();
172
     }
188
     }
173
 }
189
 }

+ 18
- 15
app/Transformers/BalanceSheetReportTransformer.php Целия файл

200
                 $totalEquitySummary = $accountCategory->summary->endingBalance ?? 0;
200
                 $totalEquitySummary = $accountCategory->summary->endingBalance ?? 0;
201
                 $totalEquitySummary = money($totalEquitySummary, CurrencyAccessor::getDefaultCurrency())->getAmount();
201
                 $totalEquitySummary = money($totalEquitySummary, CurrencyAccessor::getDefaultCurrency())->getAmount();
202
                 $totalOtherEquity = $totalEquitySummary - $totalTypeSummaries;
202
                 $totalOtherEquity = $totalEquitySummary - $totalTypeSummaries;
203
-                $totalOtherEquity = money($totalOtherEquity, CurrencyAccessor::getDefaultCurrency(), true)->format();
204
 
203
 
205
-                // Add "Total Other Equity" as a new "type"
206
-                $otherEquitySummary = [];
207
-                foreach ($columns as $column) {
208
-                    $otherEquitySummary[$column->getName()] = match ($column->getName()) {
209
-                        'account_name' => 'Total Other Equity',
210
-                        'ending_balance' => $totalOtherEquity,
211
-                        default => '',
212
-                    };
213
-                }
204
+                if ($totalOtherEquity != 0) {
205
+                    $totalOtherEquityFormatted = money($totalOtherEquity, CurrencyAccessor::getDefaultCurrency(), true)->format();
214
 
206
 
215
-                $types['Total Other Equity'] = new ReportTypeDTO(
216
-                    header: [],
217
-                    data: [],
218
-                    summary: $otherEquitySummary,
219
-                );
207
+                    // Add "Total Other Equity" as a new "type"
208
+                    $otherEquitySummary = [];
209
+                    foreach ($columns as $column) {
210
+                        $otherEquitySummary[$column->getName()] = match ($column->getName()) {
211
+                            'account_name' => 'Total Other Equity',
212
+                            'ending_balance' => $totalOtherEquityFormatted,
213
+                            default => '',
214
+                        };
215
+                    }
216
+
217
+                    $types['Total Other Equity'] = new ReportTypeDTO(
218
+                        header: [],
219
+                        data: [],
220
+                        summary: $otherEquitySummary,
221
+                    );
222
+                }
220
             }
223
             }
221
 
224
 
222
             // Add the category with its types and summary to the final array
225
             // Add the category with its types and summary to the final array

Loading…
Отказ
Запис