Kaynağa Gözat

account transactions report wip and change to snappypdf

3.x
Andrew Wallo 1 yıl önce
ebeveyn
işleme
922818a1cc

+ 28
- 8
app/Filament/Company/Pages/Reports/AccountTransactions.php Dosyayı Görüntüle

@@ -4,14 +4,16 @@ namespace App\Filament\Company\Pages\Reports;
4 4
 
5 5
 use App\Contracts\ExportableReport;
6 6
 use App\DTO\ReportDTO;
7
+use App\Models\Accounting\Account;
7 8
 use App\Services\ExportService;
8 9
 use App\Services\ReportService;
9 10
 use App\Support\Column;
10
-use App\Transformers\AccountBalanceReportTransformer;
11 11
 use App\Transformers\AccountTransactionReportTransformer;
12
+use Filament\Forms\Components\Select;
12 13
 use Filament\Forms\Form;
13 14
 use Filament\Support\Enums\Alignment;
14 15
 use Guava\FilamentClusters\Forms\Cluster;
16
+use Illuminate\Support\Collection;
15 17
 use Symfony\Component\HttpFoundation\StreamedResponse;
16 18
 
17 19
 class AccountTransactions extends BaseReportPage
@@ -26,6 +28,8 @@ class AccountTransactions extends BaseReportPage
26 28
 
27 29
     protected ExportService $exportService;
28 30
 
31
+    public ?string $account_id = 'all';
32
+
29 33
     public function boot(ReportService $reportService, ExportService $exportService): void
30 34
     {
31 35
         $this->reportService = $reportService;
@@ -59,24 +63,40 @@ class AccountTransactions extends BaseReportPage
59 63
     public function form(Form $form): Form
60 64
     {
61 65
         return $form
62
-            ->inlineLabel()
63
-            ->columns([
64
-                'lg' => 1,
65
-                '2xl' => 2,
66
-            ])
66
+            ->columns(3)
67 67
             ->live()
68 68
             ->schema([
69
+                Select::make('account_id')
70
+                    ->label('Account')
71
+                    ->options($this->getAccountOptions())
72
+                    ->searchable()
73
+                    ->required(),
69 74
                 $this->getDateRangeFormComponent(),
70 75
                 Cluster::make([
71 76
                     $this->getStartDateFormComponent(),
72 77
                     $this->getEndDateFormComponent(),
73
-                ])->hiddenLabel(),
78
+                ])->label("\u{200B}"), // its too bad hiddenLabel removes spacing of the label
74 79
             ]);
75 80
     }
76 81
 
82
+    protected function getAccountOptions(): array
83
+    {
84
+        $accounts = Account::query()
85
+            ->get()
86
+            ->groupBy(fn (Account $account) => $account->category->getPluralLabel())
87
+            ->map(fn (Collection $accounts, string $category) => $accounts->pluck('name', 'id'))
88
+            ->toArray();
89
+
90
+        $allAccountsOption = [
91
+            'All Accounts' => ['all' => 'All Accounts'],
92
+        ];
93
+
94
+        return $allAccountsOption + $accounts;
95
+    }
96
+
77 97
     protected function buildReport(array $columns): ReportDTO
78 98
     {
79
-        return $this->reportService->buildAccountTransactionsReport($this->startDate, $this->endDate, $columns);
99
+        return $this->reportService->buildAccountTransactionsReport($this->startDate, $this->endDate, $columns, $this->account_id);
80 100
     }
81 101
 
82 102
     protected function getTransformer(ReportDTO $reportDTO): ExportableReport

+ 5
- 5
app/Services/ExportService.php Dosyayı Görüntüle

@@ -4,7 +4,7 @@ namespace App\Services;
4 4
 
5 5
 use App\Contracts\ExportableReport;
6 6
 use App\Models\Company;
7
-use Barryvdh\DomPDF\Facade\Pdf;
7
+use Barryvdh\Snappy\Facades\SnappyPdf;
8 8
 use Illuminate\Support\Carbon;
9 9
 use Symfony\Component\HttpFoundation\StreamedResponse;
10 10
 
@@ -24,7 +24,7 @@ class ExportService
24 24
             'Content-Disposition' => 'attachment; filename="' . $filename . '"',
25 25
         ];
26 26
 
27
-        $callback = function () use ($report, $company, $formattedStartDate, $formattedEndDate, $separateCategoryHeaders) {
27
+        $callback = function () use ($report, $company, $formattedStartDate, $formattedEndDate) {
28 28
             $file = fopen('php://output', 'wb');
29 29
 
30 30
             fputcsv($file, [$report->getTitle()]);
@@ -73,15 +73,15 @@ class ExportService
73 73
 
74 74
         $filename = $company->name . ' ' . $report->getTitle() . ' ' . $formattedStartDate . ' to ' . $formattedEndDate . ' ' . $timestamp . '.pdf';
75 75
 
76
-        $pdf = Pdf::loadView($report->getPdfView(), [
76
+        $pdf = SnappyPdf::loadView($report->getPdfView(), [
77 77
             'company' => $company,
78 78
             'report' => $report,
79 79
             'startDate' => Carbon::parse($startDate)->format('M d, Y'),
80 80
             'endDate' => Carbon::parse($endDate)->format('M d, Y'),
81
-        ])->setPaper('letter');
81
+        ]);
82 82
 
83 83
         return response()->streamDownload(function () use ($pdf) {
84
-            echo $pdf->stream();
84
+            echo $pdf->inline();
85 85
         }, $filename);
86 86
     }
87 87
 }

+ 38
- 31
app/Services/ReportService.php Dosyayı Görüntüle

@@ -13,6 +13,7 @@ use App\Support\Column;
13 13
 use App\Utilities\Currency\CurrencyAccessor;
14 14
 use Illuminate\Database\Eloquent\Builder;
15 15
 use Illuminate\Database\Eloquent\Collection;
16
+use Illuminate\Database\Eloquent\Relations\Relation;
16 17
 
17 18
 class ReportService
18 19
 {
@@ -92,26 +93,38 @@ class ReportService
92 93
         }, $balanceFields, $columns);
93 94
     }
94 95
 
95
-    public function buildAccountTransactionsReport(string $startDate, string $endDate, array $columns = []): ReportDTO
96
+    public function buildAccountTransactionsReport(string $startDate, string $endDate, ?array $columns = null, ?string $accountId = 'all'): ReportDTO
96 97
     {
97
-        $accounts = Account::whereHas('journalEntries.transaction', static function (Builder $query) use ($startDate, $endDate) {
98
+        $columns ??= [];
99
+        $query = Account::whereHas('journalEntries.transaction', function (Builder $query) use ($startDate, $endDate) {
98 100
             $query->whereBetween('posted_at', [$startDate, $endDate]);
99 101
         })
100
-            ->with(['journalEntries' => static function ($query) use ($startDate, $endDate) {
101
-                $query->whereHas('transaction', static function (Builder $query) use ($startDate, $endDate) {
102
+            ->with(['journalEntries' => function (Relation $query) use ($startDate, $endDate) {
103
+                $query->whereHas('transaction', function (Builder $query) use ($startDate, $endDate) {
102 104
                     $query->whereBetween('posted_at', [$startDate, $endDate]);
103 105
                 })
104
-                    ->with(['transaction' => static function ($query) {
105
-                        $query->select('id', 'posted_at', 'description');
106
+                    ->with(['transaction' => function (Relation $query) {
107
+                        $query->select(['id', 'description', 'posted_at']);
106 108
                     }])
107
-                    ->select('id', 'account_id', 'transaction_id', 'type', 'amount');
109
+                    ->select(['account_id', 'transaction_id'])
110
+                    ->selectRaw('SUM(CASE WHEN type = "debit" THEN amount ELSE 0 END) AS total_debit')
111
+                    ->selectRaw('SUM(CASE WHEN type = "credit" THEN amount ELSE 0 END) AS total_credit')
112
+                    ->selectRaw('(SELECT MIN(posted_at) FROM transactions WHERE transactions.id = journal_entries.transaction_id) AS earliest_posted_at')
113
+                    ->groupBy('account_id', 'transaction_id')
114
+                    ->orderBy('earliest_posted_at');
108 115
             }])
109
-            ->select(['id', 'name', 'category', 'subtype_id', 'currency_code'])
110
-            ->get()
111
-            ->lazy();
116
+            ->select(['id', 'name', 'category', 'subtype_id', 'currency_code']);
117
+
118
+        if ($accountId !== 'all') {
119
+            $query->where('id', $accountId);
120
+        }
121
+
122
+        $accounts = $query->get();
112 123
 
113 124
         $reportCategories = [];
114 125
 
126
+        $defaultCurrency = CurrencyAccessor::getDefaultCurrency();
127
+
115 128
         foreach ($accounts as $account) {
116 129
             $accountTransactions = [];
117 130
             $startingBalance = $this->accountService->getStartingBalance($account, $startDate, true);
@@ -125,30 +138,24 @@ class ReportService
125 138
                 description: '',
126 139
                 debit: '',
127 140
                 credit: '',
128
-                balance: $startingBalance?->format() ?? 0,
141
+                balance: $startingBalance?->formatInDefaultCurrency() ?? 0,
129 142
             );
130 143
 
131
-            $journalEntriesGroupedByTransaction = $account->journalEntries->groupBy('transaction_id');
132
-
133
-            foreach ($journalEntriesGroupedByTransaction as $transactionId => $journalEntries) {
134
-                $transaction = $journalEntries->first()->transaction;
135
-
136
-                $debitAmount = $journalEntries->sumDebits()->getAmount();
137
-                $creditAmount = $journalEntries->sumCredits()->getAmount();
144
+            foreach ($account->journalEntries as $journalEntry) {
145
+                $transaction = $journalEntry->transaction;
146
+                $totalDebit += $journalEntry->total_debit;
147
+                $totalCredit += $journalEntry->total_credit;
138 148
 
139 149
                 // Adjust balance
140
-                $currentBalance += $debitAmount;
141
-                $currentBalance -= $creditAmount;
142
-
143
-                $totalDebit += $debitAmount;
144
-                $totalCredit += $creditAmount;
150
+                $currentBalance += $journalEntry->total_debit;
151
+                $currentBalance -= $journalEntry->total_credit;
145 152
 
146 153
                 $accountTransactions[] = new AccountTransactionDTO(
147 154
                     date: $transaction->posted_at->format('Y-m-d'),
148
-                    description: $transaction->description,
149
-                    debit: $debitAmount ? money($debitAmount, $account->currency_code)->format() : '',
150
-                    credit: $creditAmount ? money($creditAmount, $account->currency_code)->format() : '',
151
-                    balance: money($currentBalance, $account->currency_code)->format(),
155
+                    description: $transaction->description ?? '',
156
+                    debit: $journalEntry->total_debit ? money($journalEntry->total_debit, $defaultCurrency)->format() : '',
157
+                    credit: $journalEntry->total_credit ? money($journalEntry->total_credit, $defaultCurrency)->format() : '',
158
+                    balance: money($currentBalance, $defaultCurrency)->format(),
152 159
                 );
153 160
             }
154 161
 
@@ -157,9 +164,9 @@ class ReportService
157 164
             $accountTransactions[] = new AccountTransactionDTO(
158 165
                 date: 'Totals and Ending Balance',
159 166
                 description: '',
160
-                debit: money($totalDebit, $account->currency_code)->format(),
161
-                credit: money($totalCredit, $account->currency_code)->format(),
162
-                balance: money($currentBalance, $account->currency_code)->format(),
167
+                debit: money($totalDebit, $defaultCurrency)->format(),
168
+                credit: money($totalCredit, $defaultCurrency)->format(),
169
+                balance: money($currentBalance, $defaultCurrency)->format(),
163 170
             );
164 171
 
165 172
             $accountTransactions[] = new AccountTransactionDTO(
@@ -167,7 +174,7 @@ class ReportService
167 174
                 description: '',
168 175
                 debit: '',
169 176
                 credit: '',
170
-                balance: money($balanceChange, $account->currency_code)->format(),
177
+                balance: money($balanceChange, $defaultCurrency)->format(),
171 178
             );
172 179
 
173 180
             $reportCategories[] = [

+ 9
- 3
app/Utilities/Currency/CurrencyAccessor.php Dosyayı Görüntüle

@@ -5,6 +5,7 @@ namespace App\Utilities\Currency;
5 5
 use Akaunting\Money\Currency as ISOCurrencies;
6 6
 use App\Facades\Forex;
7 7
 use App\Models\Setting\Currency;
8
+use Illuminate\Support\Facades\Cache;
8 9
 
9 10
 class CurrencyAccessor
10 11
 {
@@ -52,8 +53,13 @@ class CurrencyAccessor
52 53
 
53 54
     public static function getDefaultCurrency(): ?string
54 55
     {
55
-        return Currency::query()
56
-            ->where('enabled', true)
57
-            ->value('code');
56
+        $companyId = auth()->user()->currentCompany->id;
57
+        $cacheKey = "default_currency_{$companyId}";
58
+
59
+        return Cache::rememberForever($cacheKey, function () {
60
+            return Currency::query()
61
+                ->where('enabled', true)
62
+                ->value('code');
63
+        });
58 64
     }
59 65
 }

+ 5
- 0
app/ValueObjects/Money.php Dosyayı Görüntüle

@@ -44,6 +44,11 @@ class Money
44 44
         return money($this->getEffectiveAmount(), $this->getCurrencyCode())->format();
45 45
     }
46 46
 
47
+    public function formatInDefaultCurrency(): string
48
+    {
49
+        return money($this->getEffectiveAmount(), CurrencyAccessor::getDefaultCurrency())->format();
50
+    }
51
+
47 52
     public function formatSimple(): string
48 53
     {
49 54
         return money($this->getEffectiveAmount(), $this->getCurrencyCode())->formatSimple();

+ 1
- 1
composer.json Dosyayı Görüntüle

@@ -16,7 +16,7 @@
16 16
         "andrewdwallo/filament-selectify": "^2.0",
17 17
         "andrewdwallo/transmatic": "^1.1",
18 18
         "awcodes/filament-table-repeater": "^3.0",
19
-        "barryvdh/laravel-dompdf": "^2.1",
19
+        "barryvdh/laravel-snappy": "^1.0",
20 20
         "bezhansalleh/filament-panel-switch": "^1.0",
21 21
         "filament/filament": "^3.2.29",
22 22
         "guava/filament-clusters": "^1.1",

+ 93
- 242
composer.lock Dosyayı Görüntüle

@@ -4,7 +4,7 @@
4 4
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 5
         "This file is @generated automatically"
6 6
     ],
7
-    "content-hash": "839a55c8a598b13dc96d8033cf66341a",
7
+    "content-hash": "e020649d2f98dbf69606fac31a762af8",
8 8
     "packages": [
9 9
         {
10 10
             "name": "akaunting/laravel-money",
@@ -668,48 +668,46 @@
668 668
             "time": "2024-03-18T17:43:45+00:00"
669 669
         },
670 670
         {
671
-            "name": "barryvdh/laravel-dompdf",
672
-            "version": "v2.2.0",
671
+            "name": "barryvdh/laravel-snappy",
672
+            "version": "v1.0.3",
673 673
             "source": {
674 674
                 "type": "git",
675
-                "url": "https://github.com/barryvdh/laravel-dompdf.git",
676
-                "reference": "c96f90c97666cebec154ca1ffb67afed372114d8"
675
+                "url": "https://github.com/barryvdh/laravel-snappy.git",
676
+                "reference": "716dcb6db24de4ce8e6ae5941cfab152af337ea0"
677 677
             },
678 678
             "dist": {
679 679
                 "type": "zip",
680
-                "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/c96f90c97666cebec154ca1ffb67afed372114d8",
681
-                "reference": "c96f90c97666cebec154ca1ffb67afed372114d8",
680
+                "url": "https://api.github.com/repos/barryvdh/laravel-snappy/zipball/716dcb6db24de4ce8e6ae5941cfab152af337ea0",
681
+                "reference": "716dcb6db24de4ce8e6ae5941cfab152af337ea0",
682 682
                 "shasum": ""
683 683
             },
684 684
             "require": {
685
-                "dompdf/dompdf": "^2.0.7",
686
-                "illuminate/support": "^6|^7|^8|^9|^10|^11",
687
-                "php": "^7.2 || ^8.0"
685
+                "illuminate/filesystem": "^9|^10|^11.0",
686
+                "illuminate/support": "^9|^10|^11.0",
687
+                "knplabs/knp-snappy": "^1.4.4",
688
+                "php": ">=7.2"
688 689
             },
689 690
             "require-dev": {
690
-                "larastan/larastan": "^1.0|^2.7.0",
691
-                "orchestra/testbench": "^4|^5|^6|^7|^8|^9",
692
-                "phpro/grumphp": "^1 || ^2.5",
693
-                "squizlabs/php_codesniffer": "^3.5"
691
+                "orchestra/testbench": "^7|^8|^9.0"
694 692
             },
695 693
             "type": "library",
696 694
             "extra": {
697 695
                 "branch-alias": {
698
-                    "dev-master": "2.0-dev"
696
+                    "dev-master": "1.0-dev"
699 697
                 },
700 698
                 "laravel": {
701 699
                     "providers": [
702
-                        "Barryvdh\\DomPDF\\ServiceProvider"
700
+                        "Barryvdh\\Snappy\\ServiceProvider"
703 701
                     ],
704 702
                     "aliases": {
705
-                        "Pdf": "Barryvdh\\DomPDF\\Facade\\Pdf",
706
-                        "PDF": "Barryvdh\\DomPDF\\Facade\\Pdf"
703
+                        "PDF": "Barryvdh\\Snappy\\Facades\\SnappyPdf",
704
+                        "SnappyImage": "Barryvdh\\Snappy\\Facades\\SnappyImage"
707 705
                     }
708 706
                 }
709 707
             },
710 708
             "autoload": {
711 709
                 "psr-4": {
712
-                    "Barryvdh\\DomPDF\\": "src"
710
+                    "Barryvdh\\Snappy\\": "src/"
713 711
                 }
714 712
             },
715 713
             "notification-url": "https://packagist.org/downloads/",
@@ -722,15 +720,18 @@
722 720
                     "email": "barryvdh@gmail.com"
723 721
                 }
724 722
             ],
725
-            "description": "A DOMPDF Wrapper for Laravel",
723
+            "description": "Snappy PDF/Image for Laravel",
726 724
             "keywords": [
727
-                "dompdf",
725
+                "image",
728 726
                 "laravel",
729
-                "pdf"
727
+                "pdf",
728
+                "snappy",
729
+                "wkhtmltoimage",
730
+                "wkhtmltopdf"
730 731
             ],
731 732
             "support": {
732
-                "issues": "https://github.com/barryvdh/laravel-dompdf/issues",
733
-                "source": "https://github.com/barryvdh/laravel-dompdf/tree/v2.2.0"
733
+                "issues": "https://github.com/barryvdh/laravel-snappy/issues",
734
+                "source": "https://github.com/barryvdh/laravel-snappy/tree/v1.0.3"
734 735
             },
735 736
             "funding": [
736 737
                 {
@@ -742,7 +743,7 @@
742 743
                     "type": "github"
743 744
                 }
744 745
             ],
745
-            "time": "2024-04-25T13:16:04+00:00"
746
+            "time": "2024-03-09T19:20:39+00:00"
746 747
         },
747 748
         {
748 749
             "name": "bezhansalleh/filament-panel-switch",
@@ -1793,68 +1794,6 @@
1793 1794
             ],
1794 1795
             "time": "2024-02-05T11:56:58+00:00"
1795 1796
         },
1796
-        {
1797
-            "name": "dompdf/dompdf",
1798
-            "version": "v2.0.8",
1799
-            "source": {
1800
-                "type": "git",
1801
-                "url": "https://github.com/dompdf/dompdf.git",
1802
-                "reference": "c20247574601700e1f7c8dab39310fca1964dc52"
1803
-            },
1804
-            "dist": {
1805
-                "type": "zip",
1806
-                "url": "https://api.github.com/repos/dompdf/dompdf/zipball/c20247574601700e1f7c8dab39310fca1964dc52",
1807
-                "reference": "c20247574601700e1f7c8dab39310fca1964dc52",
1808
-                "shasum": ""
1809
-            },
1810
-            "require": {
1811
-                "ext-dom": "*",
1812
-                "ext-mbstring": "*",
1813
-                "masterminds/html5": "^2.0",
1814
-                "phenx/php-font-lib": ">=0.5.4 <1.0.0",
1815
-                "phenx/php-svg-lib": ">=0.5.2 <1.0.0",
1816
-                "php": "^7.1 || ^8.0"
1817
-            },
1818
-            "require-dev": {
1819
-                "ext-json": "*",
1820
-                "ext-zip": "*",
1821
-                "mockery/mockery": "^1.3",
1822
-                "phpunit/phpunit": "^7.5 || ^8 || ^9",
1823
-                "squizlabs/php_codesniffer": "^3.5"
1824
-            },
1825
-            "suggest": {
1826
-                "ext-gd": "Needed to process images",
1827
-                "ext-gmagick": "Improves image processing performance",
1828
-                "ext-imagick": "Improves image processing performance",
1829
-                "ext-zlib": "Needed for pdf stream compression"
1830
-            },
1831
-            "type": "library",
1832
-            "autoload": {
1833
-                "psr-4": {
1834
-                    "Dompdf\\": "src/"
1835
-                },
1836
-                "classmap": [
1837
-                    "lib/"
1838
-                ]
1839
-            },
1840
-            "notification-url": "https://packagist.org/downloads/",
1841
-            "license": [
1842
-                "LGPL-2.1"
1843
-            ],
1844
-            "authors": [
1845
-                {
1846
-                    "name": "The Dompdf Community",
1847
-                    "homepage": "https://github.com/dompdf/dompdf/blob/master/AUTHORS.md"
1848
-                }
1849
-            ],
1850
-            "description": "DOMPDF is a CSS 2.1 compliant HTML to PDF converter",
1851
-            "homepage": "https://github.com/dompdf/dompdf",
1852
-            "support": {
1853
-                "issues": "https://github.com/dompdf/dompdf/issues",
1854
-                "source": "https://github.com/dompdf/dompdf/tree/v2.0.8"
1855
-            },
1856
-            "time": "2024-04-29T13:06:17+00:00"
1857
-        },
1858 1797
         {
1859 1798
             "name": "dragonmantank/cron-expression",
1860 1799
             "version": "v3.3.3",
@@ -3159,6 +3098,73 @@
3159 3098
             },
3160 3099
             "time": "2024-06-26T13:09:29+00:00"
3161 3100
         },
3101
+        {
3102
+            "name": "knplabs/knp-snappy",
3103
+            "version": "v1.5.0",
3104
+            "source": {
3105
+                "type": "git",
3106
+                "url": "https://github.com/KnpLabs/snappy.git",
3107
+                "reference": "98468898b50c09f26d56d905b79b0f52a2215da6"
3108
+            },
3109
+            "dist": {
3110
+                "type": "zip",
3111
+                "url": "https://api.github.com/repos/KnpLabs/snappy/zipball/98468898b50c09f26d56d905b79b0f52a2215da6",
3112
+                "reference": "98468898b50c09f26d56d905b79b0f52a2215da6",
3113
+                "shasum": ""
3114
+            },
3115
+            "require": {
3116
+                "php": ">=8.1",
3117
+                "psr/log": "^2.0||^3.0",
3118
+                "symfony/process": "^5.0||^6.0||^7.0"
3119
+            },
3120
+            "require-dev": {
3121
+                "friendsofphp/php-cs-fixer": "^3.0",
3122
+                "pedrotroller/php-cs-custom-fixer": "^2.19",
3123
+                "phpstan/phpstan": "^1.0.0",
3124
+                "phpstan/phpstan-phpunit": "^1.0.0",
3125
+                "phpunit/phpunit": "^8.5"
3126
+            },
3127
+            "type": "library",
3128
+            "extra": {
3129
+                "branch-alias": {
3130
+                    "dev-master": "1.x-dev"
3131
+                }
3132
+            },
3133
+            "autoload": {
3134
+                "psr-4": {
3135
+                    "Knp\\Snappy\\": "src/Knp/Snappy"
3136
+                }
3137
+            },
3138
+            "notification-url": "https://packagist.org/downloads/",
3139
+            "license": [
3140
+                "MIT"
3141
+            ],
3142
+            "authors": [
3143
+                {
3144
+                    "name": "KNP Labs Team",
3145
+                    "homepage": "http://knplabs.com"
3146
+                },
3147
+                {
3148
+                    "name": "Symfony Community",
3149
+                    "homepage": "http://github.com/KnpLabs/snappy/contributors"
3150
+                }
3151
+            ],
3152
+            "description": "PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.",
3153
+            "homepage": "http://github.com/KnpLabs/snappy",
3154
+            "keywords": [
3155
+                "knp",
3156
+                "knplabs",
3157
+                "pdf",
3158
+                "snapshot",
3159
+                "thumbnail",
3160
+                "wkhtmltopdf"
3161
+            ],
3162
+            "support": {
3163
+                "issues": "https://github.com/KnpLabs/snappy/issues",
3164
+                "source": "https://github.com/KnpLabs/snappy/tree/v1.5.0"
3165
+            },
3166
+            "time": "2023-12-18T09:12:11+00:00"
3167
+        },
3162 3168
         {
3163 3169
             "name": "laravel/framework",
3164 3170
             "version": "v11.14.0",
@@ -5442,96 +5448,6 @@
5442 5448
             },
5443 5449
             "time": "2020-10-15T08:29:30+00:00"
5444 5450
         },
5445
-        {
5446
-            "name": "phenx/php-font-lib",
5447
-            "version": "0.5.6",
5448
-            "source": {
5449
-                "type": "git",
5450
-                "url": "https://github.com/dompdf/php-font-lib.git",
5451
-                "reference": "a1681e9793040740a405ac5b189275059e2a9863"
5452
-            },
5453
-            "dist": {
5454
-                "type": "zip",
5455
-                "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/a1681e9793040740a405ac5b189275059e2a9863",
5456
-                "reference": "a1681e9793040740a405ac5b189275059e2a9863",
5457
-                "shasum": ""
5458
-            },
5459
-            "require": {
5460
-                "ext-mbstring": "*"
5461
-            },
5462
-            "require-dev": {
5463
-                "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6"
5464
-            },
5465
-            "type": "library",
5466
-            "autoload": {
5467
-                "psr-4": {
5468
-                    "FontLib\\": "src/FontLib"
5469
-                }
5470
-            },
5471
-            "notification-url": "https://packagist.org/downloads/",
5472
-            "license": [
5473
-                "LGPL-2.1-or-later"
5474
-            ],
5475
-            "authors": [
5476
-                {
5477
-                    "name": "Fabien Ménager",
5478
-                    "email": "fabien.menager@gmail.com"
5479
-                }
5480
-            ],
5481
-            "description": "A library to read, parse, export and make subsets of different types of font files.",
5482
-            "homepage": "https://github.com/PhenX/php-font-lib",
5483
-            "support": {
5484
-                "issues": "https://github.com/dompdf/php-font-lib/issues",
5485
-                "source": "https://github.com/dompdf/php-font-lib/tree/0.5.6"
5486
-            },
5487
-            "time": "2024-01-29T14:45:26+00:00"
5488
-        },
5489
-        {
5490
-            "name": "phenx/php-svg-lib",
5491
-            "version": "0.5.4",
5492
-            "source": {
5493
-                "type": "git",
5494
-                "url": "https://github.com/dompdf/php-svg-lib.git",
5495
-                "reference": "46b25da81613a9cf43c83b2a8c2c1bdab27df691"
5496
-            },
5497
-            "dist": {
5498
-                "type": "zip",
5499
-                "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/46b25da81613a9cf43c83b2a8c2c1bdab27df691",
5500
-                "reference": "46b25da81613a9cf43c83b2a8c2c1bdab27df691",
5501
-                "shasum": ""
5502
-            },
5503
-            "require": {
5504
-                "ext-mbstring": "*",
5505
-                "php": "^7.1 || ^8.0",
5506
-                "sabberworm/php-css-parser": "^8.4"
5507
-            },
5508
-            "require-dev": {
5509
-                "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5"
5510
-            },
5511
-            "type": "library",
5512
-            "autoload": {
5513
-                "psr-4": {
5514
-                    "Svg\\": "src/Svg"
5515
-                }
5516
-            },
5517
-            "notification-url": "https://packagist.org/downloads/",
5518
-            "license": [
5519
-                "LGPL-3.0-or-later"
5520
-            ],
5521
-            "authors": [
5522
-                {
5523
-                    "name": "Fabien Ménager",
5524
-                    "email": "fabien.menager@gmail.com"
5525
-                }
5526
-            ],
5527
-            "description": "A library to read, parse and export to PDF SVG files.",
5528
-            "homepage": "https://github.com/PhenX/php-svg-lib",
5529
-            "support": {
5530
-                "issues": "https://github.com/dompdf/php-svg-lib/issues",
5531
-                "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.4"
5532
-            },
5533
-            "time": "2024-04-08T12:52:34+00:00"
5534
-        },
5535 5451
         {
5536 5452
             "name": "phpoption/phpoption",
5537 5453
             "version": "1.9.2",
@@ -6560,71 +6476,6 @@
6560 6476
             ],
6561 6477
             "time": "2024-02-26T18:08:49+00:00"
6562 6478
         },
6563
-        {
6564
-            "name": "sabberworm/php-css-parser",
6565
-            "version": "v8.6.0",
6566
-            "source": {
6567
-                "type": "git",
6568
-                "url": "https://github.com/MyIntervals/PHP-CSS-Parser.git",
6569
-                "reference": "d2fb94a9641be84d79c7548c6d39bbebba6e9a70"
6570
-            },
6571
-            "dist": {
6572
-                "type": "zip",
6573
-                "url": "https://api.github.com/repos/MyIntervals/PHP-CSS-Parser/zipball/d2fb94a9641be84d79c7548c6d39bbebba6e9a70",
6574
-                "reference": "d2fb94a9641be84d79c7548c6d39bbebba6e9a70",
6575
-                "shasum": ""
6576
-            },
6577
-            "require": {
6578
-                "ext-iconv": "*",
6579
-                "php": ">=5.6.20"
6580
-            },
6581
-            "require-dev": {
6582
-                "phpunit/phpunit": "^5.7.27"
6583
-            },
6584
-            "suggest": {
6585
-                "ext-mbstring": "for parsing UTF-8 CSS"
6586
-            },
6587
-            "type": "library",
6588
-            "extra": {
6589
-                "branch-alias": {
6590
-                    "dev-main": "9.0.x-dev"
6591
-                }
6592
-            },
6593
-            "autoload": {
6594
-                "psr-4": {
6595
-                    "Sabberworm\\CSS\\": "src/"
6596
-                }
6597
-            },
6598
-            "notification-url": "https://packagist.org/downloads/",
6599
-            "license": [
6600
-                "MIT"
6601
-            ],
6602
-            "authors": [
6603
-                {
6604
-                    "name": "Raphael Schweikert"
6605
-                },
6606
-                {
6607
-                    "name": "Oliver Klee",
6608
-                    "email": "github@oliverklee.de"
6609
-                },
6610
-                {
6611
-                    "name": "Jake Hotson",
6612
-                    "email": "jake.github@qzdesign.co.uk"
6613
-                }
6614
-            ],
6615
-            "description": "Parser for CSS Files written in PHP",
6616
-            "homepage": "https://www.sabberworm.com/blog/2010/6/10/php-css-parser",
6617
-            "keywords": [
6618
-                "css",
6619
-                "parser",
6620
-                "stylesheet"
6621
-            ],
6622
-            "support": {
6623
-                "issues": "https://github.com/MyIntervals/PHP-CSS-Parser/issues",
6624
-                "source": "https://github.com/MyIntervals/PHP-CSS-Parser/tree/v8.6.0"
6625
-            },
6626
-            "time": "2024-07-01T07:33:21+00:00"
6627
-        },
6628 6479
         {
6629 6480
             "name": "spatie/color",
6630 6481
             "version": "1.5.3",

+ 0
- 267
config/dompdf.php Dosyayı Görüntüle

@@ -1,267 +0,0 @@
1
-<?php
2
-
3
-return [
4
-
5
-    /*
6
-    |--------------------------------------------------------------------------
7
-    | Settings
8
-    |--------------------------------------------------------------------------
9
-    |
10
-    | Set some default values. It is possible to add all defines that can be set
11
-    | in dompdf_config.inc.php. You can also override the entire config file.
12
-    |
13
-    */
14
-    'show_warnings' => false,   // Throw an Exception on warnings from dompdf
15
-
16
-    'public_path' => null,  // Override the public path if needed
17
-
18
-    /*
19
-     * Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £.
20
-     */
21
-    'convert_entities' => true,
22
-
23
-    'options' => [
24
-        /**
25
-         * The location of the DOMPDF font directory
26
-         *
27
-         * The location of the directory where DOMPDF will store fonts and font metrics
28
-         * Note: This directory must exist and be writable by the webserver process.
29
-         * *Please note the trailing slash.*
30
-         *
31
-         * Notes regarding fonts:
32
-         * Additional .afm font metrics can be added by executing load_font.php from command line.
33
-         *
34
-         * Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
35
-         * be embedded in the pdf file or the PDF may not display correctly. This can significantly
36
-         * increase file size unless font subsetting is enabled. Before embedding a font please
37
-         * review your rights under the font license.
38
-         *
39
-         * Any font specification in the source HTML is translated to the closest font available
40
-         * in the font directory.
41
-         *
42
-         * The pdf standard "Base 14 fonts" are:
43
-         * Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
44
-         * Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
45
-         * Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
46
-         * Symbol, ZapfDingbats.
47
-         */
48
-        'font_dir' => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
49
-
50
-        /**
51
-         * The location of the DOMPDF font cache directory
52
-         *
53
-         * This directory contains the cached font metrics for the fonts used by DOMPDF.
54
-         * This directory can be the same as DOMPDF_FONT_DIR
55
-         *
56
-         * Note: This directory must exist and be writable by the webserver process.
57
-         */
58
-        'font_cache' => storage_path('fonts'),
59
-
60
-        /**
61
-         * The location of a temporary directory.
62
-         *
63
-         * The directory specified must be writeable by the webserver process.
64
-         * The temporary directory is required to download remote images and when
65
-         * using the PDFLib back end.
66
-         */
67
-        'temp_dir' => sys_get_temp_dir(),
68
-
69
-        /**
70
-         * ==== IMPORTANT ====
71
-         *
72
-         * dompdf's "chroot": Prevents dompdf from accessing system files or other
73
-         * files on the webserver.  All local files opened by dompdf must be in a
74
-         * subdirectory of this directory.  DO NOT set it to '/' since this could
75
-         * allow an attacker to use dompdf to read any files on the server.  This
76
-         * should be an absolute path.
77
-         * This is only checked on command line call by dompdf.php, but not by
78
-         * direct class use like:
79
-         * $dompdf = new DOMPDF();  $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
80
-         */
81
-        'chroot' => realpath(base_path()),
82
-
83
-        /**
84
-         * Protocol whitelist
85
-         *
86
-         * Protocols and PHP wrappers allowed in URIs, and the validation rules
87
-         * that determine if a resource may be loaded. Full support is not guaranteed
88
-         * for the protocols/wrappers specified
89
-         * by this array.
90
-         *
91
-         * @var array
92
-         */
93
-        'allowed_protocols' => [
94
-            'file://' => ['rules' => []],
95
-            'http://' => ['rules' => []],
96
-            'https://' => ['rules' => []],
97
-        ],
98
-
99
-        'log_output_file' => null,
100
-
101
-        /**
102
-         * Whether to enable font subsetting or not.
103
-         */
104
-        'enable_font_subsetting' => true,
105
-
106
-        /**
107
-         * The PDF rendering backend to use
108
-         *
109
-         * Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
110
-         * 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
111
-         * fall back on CPDF. 'GD' renders PDFs to graphic files. {@link * Canvas_Factory} ultimately determines which rendering class to instantiate
112
-         * based on this setting.
113
-         *
114
-         * Both PDFLib & CPDF rendering backends provide sufficient rendering
115
-         * capabilities for dompdf, however additional features (e.g. object,
116
-         * image and font support, etc.) differ between backends.  Please see
117
-         * {@link PDFLib_Adapter} for more information on the PDFLib backend
118
-         * and {@link CPDF_Adapter} and lib/class.pdf.php for more information
119
-         * on CPDF. Also see the documentation for each backend at the links
120
-         * below.
121
-         *
122
-         * The GD rendering backend is a little different than PDFLib and
123
-         * CPDF. Several features of CPDF and PDFLib are not supported or do
124
-         * not make any sense when creating image files.  For example,
125
-         * multiple pages are not supported, nor are PDF 'objects'.  Have a
126
-         * look at {@link GD_Adapter} for more information.  GD support is
127
-         * experimental, so use it at your own risk.
128
-         *
129
-         * @link http://www.pdflib.com
130
-         * @link http://www.ros.co.nz/pdf
131
-         * @link http://www.php.net/image
132
-         */
133
-        'pdf_backend' => 'CPDF',
134
-
135
-        /**
136
-         * PDFlib license key
137
-         *
138
-         * If you are using a licensed, commercial version of PDFlib, specify
139
-         * your license key here.  If you are using PDFlib-Lite or are evaluating
140
-         * the commercial version of PDFlib, comment out this setting.
141
-         *
142
-         * @link http://www.pdflib.com
143
-         *
144
-         * If pdflib present in web server and auto or selected explicitly above,
145
-         * a real license code must exist!
146
-         */
147
-        //"DOMPDF_PDFLIB_LICENSE" => "your license key here",
148
-
149
-        /**
150
-         * html target media view which should be rendered into pdf.
151
-         * List of types and parsing rules for future extensions:
152
-         * http://www.w3.org/TR/REC-html40/types.html
153
-         *   screen, tty, tv, projection, handheld, print, braille, aural, all
154
-         * Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
155
-         * Note, even though the generated pdf file is intended for print output,
156
-         * the desired content might be different (e.g. screen or projection view of html file).
157
-         * Therefore allow specification of content here.
158
-         */
159
-        'default_media_type' => 'screen',
160
-
161
-        /**
162
-         * The default paper size.
163
-         *
164
-         * North America standard is "letter"; other countries generally "a4"
165
-         *
166
-         * @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
167
-         */
168
-        'default_paper_size' => 'a4',
169
-
170
-        /**
171
-         * The default paper orientation.
172
-         *
173
-         * The orientation of the page (portrait or landscape).
174
-         */
175
-        'default_paper_orientation' => 'portrait',
176
-
177
-        /**
178
-         * The default font family
179
-         *
180
-         * Used if no suitable fonts can be found. This must exist in the font folder.
181
-         */
182
-        'default_font' => 'sans-serif',
183
-
184
-        /**
185
-         * Image DPI setting
186
-         *
187
-         * This setting determines the default DPI setting for images and fonts.  The
188
-         * DPI may be overridden for inline images by explicitly setting the
189
-         * image's width & height style attributes (i.e. if the image's native
190
-         * width is 600 pixels and you specify the image's width as 72 points,
191
-         * the image will have a DPI of 600 in the rendered PDF.  The DPI of
192
-         * background images can not be overridden and is controlled entirely
193
-         * via this parameter.
194
-         *
195
-         * For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
196
-         * If a size in html is given as px (or without unit as image size),
197
-         * this tells the corresponding size in pt.
198
-         * This adjusts the relative sizes to be similar to the rendering of the
199
-         * html page in a reference browser.
200
-         *
201
-         * In pdf, always 1 pt = 1/72 inch
202
-         *
203
-         * Rendering resolution of various browsers in px per inch:
204
-         * Windows Firefox and Internet Explorer:
205
-         *   SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
206
-         * Linux Firefox:
207
-         *   about:config *resolution: Default:96
208
-         *   (xorg screen dimension in mm and Desktop font dpi settings are ignored)
209
-         *
210
-         * Take care about extra font/image zoom factor of browser.
211
-         *
212
-         * In images, <img> size in pixel attribute, img css style, are overriding
213
-         * the real image dimension in px for rendering.
214
-         */
215
-        'dpi' => 96,
216
-
217
-        /**
218
-         * Enable inline PHP
219
-         *
220
-         * If this setting is set to true then DOMPDF will automatically evaluate
221
-         * inline PHP contained within <script type="text/php"> ... </script> tags.
222
-         *
223
-         * Enabling this for documents you do not trust (e.g. arbitrary remote html
224
-         * pages) is a security risk.  Set this option to false if you wish to process
225
-         * untrusted documents.
226
-         */
227
-        'enable_php' => true,
228
-
229
-        /**
230
-         * Enable inline Javascript
231
-         *
232
-         * If this setting is set to true then DOMPDF will automatically insert
233
-         * JavaScript code contained within <script type="text/javascript"> ... </script> tags.
234
-         */
235
-        'enable_javascript' => true,
236
-
237
-        /**
238
-         * Enable remote file access
239
-         *
240
-         * If this setting is set to true, DOMPDF will access remote sites for
241
-         * images and CSS files as required.
242
-         * This is required for part of test case www/test/image_variants.html through www/examples.php
243
-         *
244
-         * Attention!
245
-         * This can be a security risk, in particular in combination with DOMPDF_ENABLE_PHP and
246
-         * allowing remote access to dompdf.php or on allowing remote html code to be passed to
247
-         * $dompdf = new DOMPDF(, $dompdf->load_html(...,
248
-         * This allows anonymous users to download legally doubtful internet content which on
249
-         * tracing back appears to being downloaded by your server, or allows malicious php code
250
-         * in remote html pages to be executed by your server with your account privileges.
251
-         */
252
-        'enable_remote' => true,
253
-
254
-        /**
255
-         * A ratio applied to the fonts height to be more like browsers' line height
256
-         */
257
-        'font_height_ratio' => 1.1,
258
-
259
-        /**
260
-         * Use the HTML5 Lib parser
261
-         *
262
-         * @deprecated This feature is now always on in dompdf 2.x
263
-         */
264
-        'enable_html5_parser' => true,
265
-    ],
266
-
267
-];

+ 64
- 0
config/snappy.php Dosyayı Görüntüle

@@ -0,0 +1,64 @@
1
+<?php
2
+
3
+return [
4
+
5
+    /*
6
+    |--------------------------------------------------------------------------
7
+    | Snappy PDF / Image Configuration
8
+    |--------------------------------------------------------------------------
9
+    |
10
+    | This option contains settings for PDF generation.
11
+    |
12
+    | Enabled:
13
+    |
14
+    |    Whether to load PDF / Image generation.
15
+    |
16
+    | Binary:
17
+    |
18
+    |    The file path of the wkhtmltopdf / wkhtmltoimage executable.
19
+    |
20
+    | Timeout:
21
+    |
22
+    |    The amount of time to wait (in seconds) before PDF / Image generation is stopped.
23
+    |    Setting this to false disables the timeout (unlimited processing time).
24
+    |
25
+    | Options:
26
+    |
27
+    |    The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
28
+    |    See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
29
+    |
30
+    | Env:
31
+    |
32
+    |    The environment variables to set while running the wkhtmltopdf process.
33
+    |
34
+    */
35
+
36
+    'pdf' => [
37
+        'enabled' => true,
38
+        'binary' => env('WKHTMLTOPDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
39
+        'timeout' => false,
40
+        'options' => [
41
+            'no-pdf-compression' => true,
42
+            'disable-smart-shrinking' => true,
43
+            'disable-javascript' => true,
44
+            'margin-top' => '10mm',
45
+            'margin-right' => '7.5mm',
46
+            'margin-bottom' => '15mm',
47
+            'margin-left' => '7.5mm',
48
+            'page-size' => 'Letter',
49
+            'footer-right' => 'Page [page] / [toPage]',
50
+            'footer-font-size' => '8',
51
+            'footer-spacing' => '5',
52
+        ],
53
+        'env' => [],
54
+    ],
55
+
56
+    'image' => [
57
+        'enabled' => true,
58
+        'binary' => env('WKHTMLTOIMAGE_BINARY', '/usr/local/bin/wkhtmltoimage'),
59
+        'timeout' => false,
60
+        'options' => [],
61
+        'env' => [],
62
+    ],
63
+
64
+];

+ 0
- 5
resources/views/components/company/reports/report-pdf.blade.php Dosyayı Görüntüle

@@ -5,11 +5,6 @@
5 5
     <meta name="viewport" content="width=device-width, initial-scale=1">
6 6
     <title>{{ $report->getTitle() }}</title>
7 7
     <style>
8
-        @page {
9
-            size: auto;
10
-            margin: 10mm 7.5mm;
11
-        }
12
-
13 8
         .header {
14 9
             color: #374151;
15 10
             margin-bottom: 1rem;

+ 1
- 1
resources/views/filament/company/pages/reports/account-transactions.blade.php Dosyayı Görüntüle

@@ -12,7 +12,7 @@
12 12
                                 :trigger-action="$this->toggleColumnsAction"
13 13
                             />
14 14
                         @endif
15
-                        <x-filament::button type="submit" class="flex-shrink-0">
15
+                        <x-filament::button type="submit" class="flex-shrink-0 mt-6">
16 16
                             Update Report
17 17
                         </x-filament::button>
18 18
                     </div>

Loading…
İptal
Kaydet