Andrew Wallo 1 年之前
父節點
當前提交
1f53d5607e

+ 1
- 0
app/DTO/ReportDTO.php 查看文件

@@ -11,5 +11,6 @@ class ReportDTO
11 11
         public array $categories,
12 12
         public ?AccountBalanceDTO $overallTotal = null,
13 13
         public array $fields = [],
14
+        public ?string $reportType = null,
14 15
     ) {}
15 16
 }

+ 2
- 2
app/Filament/Company/Pages/Reports/TrialBalance.php 查看文件

@@ -90,11 +90,11 @@ class TrialBalance extends BaseReportPage
90 90
 
91 91
     public function exportCSV(): StreamedResponse
92 92
     {
93
-        return $this->exportService->exportToCsv($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
93
+        return $this->exportService->exportToCsv($this->company, $this->report, endDate: $this->getFilterState('asOfDate'));
94 94
     }
95 95
 
96 96
     public function exportPDF(): StreamedResponse
97 97
     {
98
-        return $this->exportService->exportToPdf($this->company, $this->report, $this->getFilterState('startDate'), $this->getFilterState('endDate'));
98
+        return $this->exportService->exportToPdf($this->company, $this->report, endDate: $this->getFilterState('asOfDate'));
99 99
     }
100 100
 }

+ 30
- 13
app/Services/ExportService.php 查看文件

@@ -12,14 +12,20 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
12 12
 
13 13
 class ExportService
14 14
 {
15
-    public function exportToCsv(Company $company, ExportableReport $report, string $startDate, string $endDate): StreamedResponse
15
+    public function exportToCsv(Company $company, ExportableReport $report, ?string $startDate = null, ?string $endDate = null): StreamedResponse
16 16
     {
17
-        $formattedStartDate = Carbon::parse($startDate)->toDateString();
18
-        $formattedEndDate = Carbon::parse($endDate)->toDateString();
17
+        if ($startDate && $endDate) {
18
+            $formattedStartDate = Carbon::parse($startDate)->toDateString();
19
+            $formattedEndDate = Carbon::parse($endDate)->toDateString();
20
+            $dateLabel = $formattedStartDate . ' to ' . $formattedEndDate;
21
+        } else {
22
+            $formattedAsOfDate = Carbon::parse($endDate)->toDateString();
23
+            $dateLabel = $formattedAsOfDate;
24
+        }
19 25
 
20 26
         $timestamp = Carbon::now()->format('Y-m-d_H-i-s');
21 27
 
22
-        $filename = $company->name . ' ' . $report->getTitle() . ' ' . $formattedStartDate . ' to ' . $formattedEndDate . ' ' . $timestamp . '.csv';
28
+        $filename = $company->name . ' ' . $report->getTitle() . ' ' . $dateLabel . ' ' . $timestamp . '.csv';
23 29
 
24 30
         $headers = [
25 31
             'Content-Type' => 'text/csv',
@@ -29,12 +35,17 @@ class ExportService
29 35
         $callback = function () use ($startDate, $endDate, $report, $company) {
30 36
             $file = fopen('php://output', 'wb');
31 37
 
32
-            $defaultStartDateFormat = Carbon::parse($startDate)->toDefaultDateFormat();
33
-            $defaultEndDateFormat = Carbon::parse($endDate)->toDefaultDateFormat();
38
+            if ($startDate && $endDate) {
39
+                $defaultStartDateFormat = Carbon::parse($startDate)->toDefaultDateFormat();
40
+                $defaultEndDateFormat = Carbon::parse($endDate)->toDefaultDateFormat();
41
+                $dateLabel = 'Date Range: ' . $defaultStartDateFormat . ' to ' . $defaultEndDateFormat;
42
+            } else {
43
+                $dateLabel = 'As of ' . Carbon::parse($endDate)->toDefaultDateFormat();
44
+            }
34 45
 
35 46
             fputcsv($file, [$report->getTitle()]);
36 47
             fputcsv($file, [$company->name]);
37
-            fputcsv($file, ['Date Range: ' . $defaultStartDateFormat . ' to ' . $defaultEndDateFormat]);
48
+            fputcsv($file, [$dateLabel]);
38 49
             fputcsv($file, []);
39 50
 
40 51
             fputcsv($file, $report->getHeaders());
@@ -92,20 +103,26 @@ class ExportService
92 103
         return response()->streamDownload($callback, $filename, $headers);
93 104
     }
94 105
 
95
-    public function exportToPdf(Company $company, ExportableReport $report, string $startDate, string $endDate): StreamedResponse
106
+    public function exportToPdf(Company $company, ExportableReport $report, ?string $startDate = null, ?string $endDate = null): StreamedResponse
96 107
     {
97
-        $formattedStartDate = Carbon::parse($startDate)->toDateString();
98
-        $formattedEndDate = Carbon::parse($endDate)->toDateString();
108
+        if ($startDate && $endDate) {
109
+            $formattedStartDate = Carbon::parse($startDate)->toDateString();
110
+            $formattedEndDate = Carbon::parse($endDate)->toDateString();
111
+            $dateLabel = $formattedStartDate . ' to ' . $formattedEndDate;
112
+        } else {
113
+            $formattedAsOfDate = Carbon::parse($endDate)->toDateString();
114
+            $dateLabel = $formattedAsOfDate;
115
+        }
99 116
 
100 117
         $timestamp = Carbon::now()->format('Y-m-d_H-i-s');
101 118
 
102
-        $filename = $company->name . ' ' . $report->getTitle() . ' ' . $formattedStartDate . ' to ' . $formattedEndDate . ' ' . $timestamp . '.pdf';
119
+        $filename = $company->name . ' ' . $report->getTitle() . ' ' . $dateLabel . ' ' . $timestamp . '.pdf';
103 120
 
104 121
         $pdf = SnappyPdf::loadView($report->getPdfView(), [
105 122
             'company' => $company,
106 123
             'report' => $report,
107
-            'startDate' => Carbon::parse($startDate)->toDefaultDateFormat(),
108
-            'endDate' => Carbon::parse($endDate)->toDefaultDateFormat(),
124
+            'startDate' => $startDate ? Carbon::parse($startDate)->toDefaultDateFormat() : null,
125
+            'endDate' => $endDate ? Carbon::parse($endDate)->toDefaultDateFormat() : null,
109 126
         ]);
110 127
 
111 128
         return response()->streamDownload(function () use ($pdf) {

+ 1
- 1
app/Services/ReportService.php 查看文件

@@ -312,7 +312,7 @@ class ReportService
312 312
 
313 313
         $formattedReportTotalBalances = $this->formatBalances($reportTotalBalances);
314 314
 
315
-        return new ReportDTO($accountCategories, $formattedReportTotalBalances, $columns);
315
+        return new ReportDTO($accountCategories, $formattedReportTotalBalances, $columns, $trialBalanceType);
316 316
     }
317 317
 
318 318
     public function getRetainedEarningsBalances(string $startDate, string $endDate): AccountBalanceDTO

+ 4
- 1
app/Transformers/TrialBalanceReportTransformer.php 查看文件

@@ -10,7 +10,10 @@ class TrialBalanceReportTransformer extends BaseReportTransformer
10 10
 {
11 11
     public function getTitle(): string
12 12
     {
13
-        return 'Trial Balance';
13
+        return match ($this->report->reportType) {
14
+            'postClosing' => 'Post-Closing Trial Balance',
15
+            default => 'Standard Trial Balance',
16
+        };
14 17
     }
15 18
 
16 19
     public function getHeaders(): array

+ 24
- 24
composer.lock 查看文件

@@ -497,16 +497,16 @@
497 497
         },
498 498
         {
499 499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.322.7",
500
+            "version": "3.322.8",
501 501
             "source": {
502 502
                 "type": "git",
503 503
                 "url": "https://github.com/aws/aws-sdk-php.git",
504
-                "reference": "ea3563a7f10fa562796f712fa306c1dca41a45d7"
504
+                "reference": "fb5099160e49b676277ae787ff721628e5e4dd5a"
505 505
             },
506 506
             "dist": {
507 507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/ea3563a7f10fa562796f712fa306c1dca41a45d7",
509
-                "reference": "ea3563a7f10fa562796f712fa306c1dca41a45d7",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/fb5099160e49b676277ae787ff721628e5e4dd5a",
509
+                "reference": "fb5099160e49b676277ae787ff721628e5e4dd5a",
510 510
                 "shasum": ""
511 511
             },
512 512
             "require": {
@@ -589,9 +589,9 @@
589 589
             "support": {
590 590
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
591 591
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
592
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.322.7"
592
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.322.8"
593 593
             },
594
-            "time": "2024-09-27T18:34:08+00:00"
594
+            "time": "2024-09-30T19:09:25+00:00"
595 595
         },
596 596
         {
597 597
             "name": "aws/aws-sdk-php-laravel",
@@ -3709,16 +3709,16 @@
3709 3709
         },
3710 3710
         {
3711 3711
             "name": "league/flysystem",
3712
-            "version": "3.28.0",
3712
+            "version": "3.29.0",
3713 3713
             "source": {
3714 3714
                 "type": "git",
3715 3715
                 "url": "https://github.com/thephpleague/flysystem.git",
3716
-                "reference": "e611adab2b1ae2e3072fa72d62c62f52c2bf1f0c"
3716
+                "reference": "0adc0d9a51852e170e0028a60bd271726626d3f0"
3717 3717
             },
3718 3718
             "dist": {
3719 3719
                 "type": "zip",
3720
-                "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/e611adab2b1ae2e3072fa72d62c62f52c2bf1f0c",
3721
-                "reference": "e611adab2b1ae2e3072fa72d62c62f52c2bf1f0c",
3720
+                "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0adc0d9a51852e170e0028a60bd271726626d3f0",
3721
+                "reference": "0adc0d9a51852e170e0028a60bd271726626d3f0",
3722 3722
                 "shasum": ""
3723 3723
             },
3724 3724
             "require": {
@@ -3786,22 +3786,22 @@
3786 3786
             ],
3787 3787
             "support": {
3788 3788
                 "issues": "https://github.com/thephpleague/flysystem/issues",
3789
-                "source": "https://github.com/thephpleague/flysystem/tree/3.28.0"
3789
+                "source": "https://github.com/thephpleague/flysystem/tree/3.29.0"
3790 3790
             },
3791
-            "time": "2024-05-22T10:09:12+00:00"
3791
+            "time": "2024-09-29T11:59:11+00:00"
3792 3792
         },
3793 3793
         {
3794 3794
             "name": "league/flysystem-local",
3795
-            "version": "3.28.0",
3795
+            "version": "3.29.0",
3796 3796
             "source": {
3797 3797
                 "type": "git",
3798 3798
                 "url": "https://github.com/thephpleague/flysystem-local.git",
3799
-                "reference": "13f22ea8be526ea58c2ddff9e158ef7c296e4f40"
3799
+                "reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27"
3800 3800
             },
3801 3801
             "dist": {
3802 3802
                 "type": "zip",
3803
-                "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/13f22ea8be526ea58c2ddff9e158ef7c296e4f40",
3804
-                "reference": "13f22ea8be526ea58c2ddff9e158ef7c296e4f40",
3803
+                "url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e0e8d52ce4b2ed154148453d321e97c8e931bd27",
3804
+                "reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27",
3805 3805
                 "shasum": ""
3806 3806
             },
3807 3807
             "require": {
@@ -3835,9 +3835,9 @@
3835 3835
                 "local"
3836 3836
             ],
3837 3837
             "support": {
3838
-                "source": "https://github.com/thephpleague/flysystem-local/tree/3.28.0"
3838
+                "source": "https://github.com/thephpleague/flysystem-local/tree/3.29.0"
3839 3839
             },
3840
-            "time": "2024-05-06T20:05:52+00:00"
3840
+            "time": "2024-08-09T21:24:39+00:00"
3841 3841
         },
3842 3842
         {
3843 3843
             "name": "league/mime-type-detection",
@@ -4834,16 +4834,16 @@
4834 4834
         },
4835 4835
         {
4836 4836
             "name": "nikic/php-parser",
4837
-            "version": "v5.2.0",
4837
+            "version": "v5.3.0",
4838 4838
             "source": {
4839 4839
                 "type": "git",
4840 4840
                 "url": "https://github.com/nikic/PHP-Parser.git",
4841
-                "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb"
4841
+                "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a"
4842 4842
             },
4843 4843
             "dist": {
4844 4844
                 "type": "zip",
4845
-                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb",
4846
-                "reference": "23c79fbbfb725fb92af9bcf41065c8e9a0d49ddb",
4845
+                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3abf7425cd284141dc5d8d14a9ee444de3345d1a",
4846
+                "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a",
4847 4847
                 "shasum": ""
4848 4848
             },
4849 4849
             "require": {
@@ -4886,9 +4886,9 @@
4886 4886
             ],
4887 4887
             "support": {
4888 4888
                 "issues": "https://github.com/nikic/PHP-Parser/issues",
4889
-                "source": "https://github.com/nikic/PHP-Parser/tree/v5.2.0"
4889
+                "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.0"
4890 4890
             },
4891
-            "time": "2024-09-15T16:40:33+00:00"
4891
+            "time": "2024-09-29T13:56:26+00:00"
4892 4892
         },
4893 4893
         {
4894 4894
             "name": "nunomaduro/termwind",

+ 3
- 3
package-lock.json 查看文件

@@ -1159,9 +1159,9 @@
1159 1159
             "license": "MIT"
1160 1160
         },
1161 1161
         "node_modules/electron-to-chromium": {
1162
-            "version": "1.5.29",
1163
-            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz",
1164
-            "integrity": "sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==",
1162
+            "version": "1.5.30",
1163
+            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.30.tgz",
1164
+            "integrity": "sha512-sXI35EBN4lYxzc/pIGorlymYNzDBOqkSlVRe6MkgBsW/hW1tpC/HDJ2fjG7XnjakzfLEuvdmux0Mjs6jHq4UOA==",
1165 1165
             "dev": true,
1166 1166
             "license": "ISC"
1167 1167
         },

+ 19
- 8
resources/js/TopNavigation.js 查看文件

@@ -1,6 +1,5 @@
1 1
 document.addEventListener('DOMContentLoaded', () => {
2 2
     handleTopbarAndSidebarHover();
3
-
4 3
     handleScroll();
5 4
 });
6 5
 
@@ -10,18 +9,25 @@ const handleTopbarAndSidebarHover = () => {
10 9
 
11 10
     const addHoveredClass = () => {
12 11
         topbarNav.classList.add('topbar-hovered');
13
-        sidebarHeader.classList.add('topbar-hovered');
12
+        if (sidebarHeader) {
13
+            sidebarHeader.classList.add('topbar-hovered');
14
+        }
14 15
     };
15 16
 
16 17
     const removeHoveredClass = () => {
17 18
         topbarNav.classList.remove('topbar-hovered');
18
-        sidebarHeader.classList.remove('topbar-hovered');
19
+        if (sidebarHeader) {
20
+            sidebarHeader.classList.remove('topbar-hovered');
21
+        }
19 22
     };
20 23
 
21 24
     topbarNav.addEventListener('mouseenter', addHoveredClass);
22
-    sidebarHeader.addEventListener('mouseenter', addHoveredClass);
23 25
     topbarNav.addEventListener('mouseleave', removeHoveredClass);
24
-    sidebarHeader.addEventListener('mouseleave', removeHoveredClass);
26
+
27
+    if (sidebarHeader) {
28
+        sidebarHeader.addEventListener('mouseenter', addHoveredClass);
29
+        sidebarHeader.addEventListener('mouseleave', removeHoveredClass);
30
+    }
25 31
 };
26 32
 
27 33
 const handleScroll = () => {
@@ -31,11 +37,16 @@ const handleScroll = () => {
31 37
     window.addEventListener('scroll', () => {
32 38
         if (window.scrollY > 0) {
33 39
             topbarNav.classList.add('topbar-scrolled');
34
-            sidebarHeader.classList.add('topbar-scrolled');
40
+            if (sidebarHeader) {
41
+                sidebarHeader.classList.add('topbar-scrolled');
42
+            }
35 43
         } else {
36 44
             topbarNav.classList.remove('topbar-scrolled');
37
-            sidebarHeader.classList.remove('topbar-scrolled');
45
+            if (sidebarHeader) {
46
+                sidebarHeader.classList.remove('topbar-scrolled');
47
+            }
38 48
         }
39 49
     });
40
-}
50
+};
51
+
41 52
 

+ 5
- 1
resources/views/components/company/reports/report-pdf.blade.php 查看文件

@@ -93,7 +93,11 @@
93 93
 <div class="header">
94 94
     <div class="title">{{ $report->getTitle() }}</div>
95 95
     <div class="company-name">{{ $company->name }}</div>
96
-    <div class="date-range">Date Range: {{ $startDate }} to {{ $endDate }}</div>
96
+    @if($startDate && $endDate)
97
+        <div class="date-range">Date Range: {{ $startDate }} to {{ $endDate }}</div>
98
+    @else
99
+        <div class="date-range">As of {{ $endDate }}</div>
100
+    @endif
97 101
 </div>
98 102
 <table class="table-class">
99 103
     <thead class="table-head">

Loading…
取消
儲存