Parcourir la source

Merge pull request #175 from andrewdwallo/development-3.x

Development 3.x
3.x
Andrew Wallo il y a 4 mois
Parent
révision
2106d2f63f
Aucun compte lié à l'adresse e-mail de l'auteur

+ 2
- 2
app/DTO/DocumentDTO.php Voir le fichier

@@ -33,7 +33,7 @@ readonly class DocumentDTO
33 33
         public string $total,
34 34
         public ?string $amountDue,
35 35
         public CompanyDTO $company,
36
-        public ClientDTO $client,
36
+        public ?ClientDTO $client,
37 37
         public iterable $lineItems,
38 38
         public DocumentLabelDTO $label,
39 39
         public DocumentColumnLabelDTO $columnLabel,
@@ -84,7 +84,7 @@ readonly class DocumentDTO
84 84
             total: self::formatToMoney($document->total, $currencyCode),
85 85
             amountDue: $amountDue,
86 86
             company: CompanyDTO::fromModel($document->company),
87
-            client: ClientDTO::fromModel($document->client),
87
+            client: $document->client ? ClientDTO::fromModel($document->client) : null,
88 88
             lineItems: $document->lineItems->map(fn ($item) => LineItemDTO::fromModel($item)),
89 89
             label: $document::documentType()->getLabels(),
90 90
             columnLabel: DocumentColumnLabelDTO::fromModel($settings),

+ 1
- 1
app/Filament/Company/Resources/Accounting/TransactionResource/Pages/ViewTransaction.php Voir le fichier

@@ -123,7 +123,7 @@ class ViewTransaction extends ViewRecord
123 123
                             ->label('Payee')
124 124
                             ->hidden(static fn (Transaction $record): bool => ! $record->payeeable_type)
125 125
                             ->url(static function (Transaction $record): ?string {
126
-                                if (! $record->payeeable_type) {
126
+                                if (! $record->payeeable_type || ! $record->payeeable_id) {
127 127
                                     return null;
128 128
                                 }
129 129
 

+ 1
- 1
app/Filament/Company/Resources/Purchases/BillResource/Pages/ViewBill.php Voir le fichier

@@ -54,7 +54,7 @@ class ViewBill extends ViewRecord
54 54
                             ->badge(),
55 55
                         TextEntry::make('vendor.name')
56 56
                             ->label('Vendor')
57
-                            ->url(static fn (Bill $record) => VendorResource::getUrl('view', ['record' => $record->vendor_id]))
57
+                            ->url(static fn (Bill $record) => $record->vendor_id ? VendorResource::getUrl('view', ['record' => $record->vendor_id]) : null)
58 58
                             ->link(),
59 59
                         TextEntry::make('total')
60 60
                             ->label('Total')

+ 1
- 1
app/Filament/Company/Resources/Sales/EstimateResource/Pages/ViewEstimate.php Voir le fichier

@@ -92,7 +92,7 @@ class ViewEstimate extends ViewRecord
92 92
                                     ->badge(),
93 93
                                 TextEntry::make('client.name')
94 94
                                     ->label('Client')
95
-                                    ->url(static fn (Estimate $record) => ClientResource::getUrl('view', ['record' => $record->client_id]))
95
+                                    ->url(static fn (Estimate $record) => $record->client_id ? ClientResource::getUrl('view', ['record' => $record->client_id]) : null)
96 96
                                     ->link(),
97 97
                                 TextEntry::make('expiration_date')
98 98
                                     ->label('Expiration date')

+ 1
- 1
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ViewInvoice.php Voir le fichier

@@ -89,7 +89,7 @@ class ViewInvoice extends ViewRecord
89 89
                                     ->badge(),
90 90
                                 TextEntry::make('client.name')
91 91
                                     ->label('Client')
92
-                                    ->url(static fn (Invoice $record) => ClientResource::getUrl('view', ['record' => $record->client_id]))
92
+                                    ->url(static fn (Invoice $record) => $record->client_id ? ClientResource::getUrl('view', ['record' => $record->client_id]) : null)
93 93
                                     ->link(),
94 94
                                 TextEntry::make('amount_due')
95 95
                                     ->label('Amount due')

+ 1
- 1
app/Filament/Company/Resources/Sales/RecurringInvoiceResource/Pages/ViewRecurringInvoice.php Voir le fichier

@@ -108,7 +108,7 @@ class ViewRecurringInvoice extends ViewRecord
108 108
                                     ->label('Client')
109 109
                                     ->color('primary')
110 110
                                     ->weight(FontWeight::SemiBold)
111
-                                    ->url(static fn (RecurringInvoice $record) => ClientResource::getUrl('view', ['record' => $record->client_id]))
111
+                                    ->url(static fn (RecurringInvoice $record) => $record->client_id ? ClientResource::getUrl('view', ['record' => $record->client_id]) : null)
112 112
                                     ->link(),
113 113
                                 TextEntry::make('last_date')
114 114
                                     ->label('Last invoice')

+ 9
- 1
app/Models/Accounting/Invoice.php Voir le fichier

@@ -227,6 +227,10 @@ class Invoice extends Document
227 227
 
228 228
     public function canRecordPayment(): bool
229 229
     {
230
+        if (! $this->client_id) {
231
+            return false;
232
+        }
233
+
230 234
         return ! in_array($this->status, [
231 235
             InvoiceStatus::Draft,
232 236
             InvoiceStatus::Paid,
@@ -236,12 +240,16 @@ class Invoice extends Document
236 240
 
237 241
     public function canBulkRecordPayment(): bool
238 242
     {
243
+        if (! $this->client_id || $this->currency_code !== CurrencyAccessor::getDefaultCurrency()) {
244
+            return false;
245
+        }
246
+
239 247
         return ! in_array($this->status, [
240 248
             InvoiceStatus::Draft,
241 249
             InvoiceStatus::Paid,
242 250
             InvoiceStatus::Void,
243 251
             InvoiceStatus::Overpaid,
244
-        ]) && $this->currency_code === CurrencyAccessor::getDefaultCurrency();
252
+        ]);
245 253
     }
246 254
 
247 255
     public function canBeOverdue(): bool

+ 2
- 2
resources/views/filament/company/components/document-templates/classic.blade.php Voir le fichier

@@ -35,8 +35,8 @@
35 35
             <!-- Billing Details -->
36 36
             <div class="text-sm">
37 37
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
38
-                <p class="text-sm font-bold">{{ $document->client->name }}</p>
39
-                @if($formattedAddress = $document->client->getFormattedAddressHtml())
38
+                <p class="text-sm font-bold">{{ $document->client?->name ?? 'Client Not Found' }}</p>
39
+                @if($document->client && ($formattedAddress = $document->client->getFormattedAddressHtml()))
40 40
                     {!! $formattedAddress !!}
41 41
                 @endif
42 42
             </div>

+ 2
- 2
resources/views/filament/company/components/document-templates/default.blade.php Voir le fichier

@@ -30,8 +30,8 @@
30 30
             <!-- Billing Details -->
31 31
             <div class="text-sm">
32 32
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
33
-                <p class="text-sm font-bold">{{ $document->client->name }}</p>
34
-                @if($formattedAddress = $document->client->getFormattedAddressHtml())
33
+                <p class="text-sm font-bold">{{ $document->client?->name ?? 'Client Not Found' }}</p>
34
+                @if($document->client && ($formattedAddress = $document->client->getFormattedAddressHtml()))
35 35
                     {!! $formattedAddress !!}
36 36
                 @endif
37 37
             </div>

+ 2
- 2
resources/views/filament/company/components/document-templates/modern.blade.php Voir le fichier

@@ -31,9 +31,9 @@
31 31
             <div class="text-sm">
32 32
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
33 33
                 <p class="text-sm font-bold"
34
-                   style="color: {{ $document->accentColor }}">{{ $document->client->name }}</p>
34
+                   style="color: {{ $document->accentColor }}">{{ $document->client?->name ?? 'Client Not Found' }}</p>
35 35
 
36
-                @if($formattedAddress = $document->client->getFormattedAddressHtml())
36
+                @if($document->client && ($formattedAddress = $document->client->getFormattedAddressHtml()))
37 37
                     {!! $formattedAddress !!}
38 38
                 @endif
39 39
             </div>

Chargement…
Annuler
Enregistrer