Andrew Wallo 11 个月前
父节点
当前提交
0b1e09ecae

+ 21
- 5
app/Filament/Company/Pages/Reports/AccountTransactions.php 查看文件

@@ -6,6 +6,7 @@ use App\Contracts\ExportableReport;
6 6
 use App\DTO\ReportDTO;
7 7
 use App\Filament\Company\Pages\Accounting\Transactions;
8 8
 use App\Models\Accounting\Account;
9
+use App\Models\Accounting\JournalEntry;
9 10
 use App\Services\ExportService;
10 11
 use App\Services\ReportService;
11 12
 use App\Support\Column;
@@ -18,6 +19,7 @@ use Filament\Support\Enums\MaxWidth;
18 19
 use Filament\Tables\Actions\Action;
19 20
 use Guava\FilamentClusters\Forms\Cluster;
20 21
 use Illuminate\Contracts\Support\Htmlable;
22
+use Illuminate\Database\Eloquent\Builder;
21 23
 use Illuminate\Support\Collection;
22 24
 use Symfony\Component\HttpFoundation\StreamedResponse;
23 25
 
@@ -162,12 +164,26 @@ class AccountTransactions extends BaseReportPage
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,23 +200,26 @@ class BalanceSheetReportTransformer extends SummaryReportTransformer
200 200
                 $totalEquitySummary = $accountCategory->summary->endingBalance ?? 0;
201 201
                 $totalEquitySummary = money($totalEquitySummary, CurrencyAccessor::getDefaultCurrency())->getAmount();
202 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 225
             // Add the category with its types and summary to the final array

正在加载...
取消
保存