瀏覽代碼

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

Development 3.x
3.x
Andrew Wallo 4 月之前
父節點
當前提交
2106d2f63f
沒有連結到貢獻者的電子郵件帳戶。

+ 2
- 2
app/DTO/DocumentDTO.php 查看文件

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

+ 1
- 1
app/Filament/Company/Resources/Accounting/TransactionResource/Pages/ViewTransaction.php 查看文件

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

+ 1
- 1
app/Filament/Company/Resources/Purchases/BillResource/Pages/ViewBill.php 查看文件

54
                             ->badge(),
54
                             ->badge(),
55
                         TextEntry::make('vendor.name')
55
                         TextEntry::make('vendor.name')
56
                             ->label('Vendor')
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
                             ->link(),
58
                             ->link(),
59
                         TextEntry::make('total')
59
                         TextEntry::make('total')
60
                             ->label('Total')
60
                             ->label('Total')

+ 1
- 1
app/Filament/Company/Resources/Sales/EstimateResource/Pages/ViewEstimate.php 查看文件

92
                                     ->badge(),
92
                                     ->badge(),
93
                                 TextEntry::make('client.name')
93
                                 TextEntry::make('client.name')
94
                                     ->label('Client')
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
                                     ->link(),
96
                                     ->link(),
97
                                 TextEntry::make('expiration_date')
97
                                 TextEntry::make('expiration_date')
98
                                     ->label('Expiration date')
98
                                     ->label('Expiration date')

+ 1
- 1
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/ViewInvoice.php 查看文件

89
                                     ->badge(),
89
                                     ->badge(),
90
                                 TextEntry::make('client.name')
90
                                 TextEntry::make('client.name')
91
                                     ->label('Client')
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
                                     ->link(),
93
                                     ->link(),
94
                                 TextEntry::make('amount_due')
94
                                 TextEntry::make('amount_due')
95
                                     ->label('Amount due')
95
                                     ->label('Amount due')

+ 1
- 1
app/Filament/Company/Resources/Sales/RecurringInvoiceResource/Pages/ViewRecurringInvoice.php 查看文件

108
                                     ->label('Client')
108
                                     ->label('Client')
109
                                     ->color('primary')
109
                                     ->color('primary')
110
                                     ->weight(FontWeight::SemiBold)
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
                                     ->link(),
112
                                     ->link(),
113
                                 TextEntry::make('last_date')
113
                                 TextEntry::make('last_date')
114
                                     ->label('Last invoice')
114
                                     ->label('Last invoice')

+ 9
- 1
app/Models/Accounting/Invoice.php 查看文件

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

+ 2
- 2
resources/views/filament/company/components/document-templates/classic.blade.php 查看文件

35
             <!-- Billing Details -->
35
             <!-- Billing Details -->
36
             <div class="text-sm">
36
             <div class="text-sm">
37
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
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
                     {!! $formattedAddress !!}
40
                     {!! $formattedAddress !!}
41
                 @endif
41
                 @endif
42
             </div>
42
             </div>

+ 2
- 2
resources/views/filament/company/components/document-templates/default.blade.php 查看文件

30
             <!-- Billing Details -->
30
             <!-- Billing Details -->
31
             <div class="text-sm">
31
             <div class="text-sm">
32
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
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
                     {!! $formattedAddress !!}
35
                     {!! $formattedAddress !!}
36
                 @endif
36
                 @endif
37
             </div>
37
             </div>

+ 2
- 2
resources/views/filament/company/components/document-templates/modern.blade.php 查看文件

31
             <div class="text-sm">
31
             <div class="text-sm">
32
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
32
                 <h3 class="text-gray-600 font-medium mb-1">BILL TO</h3>
33
                 <p class="text-sm font-bold"
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
                     {!! $formattedAddress !!}
37
                     {!! $formattedAddress !!}
38
                 @endif
38
                 @endif
39
             </div>
39
             </div>

Loading…
取消
儲存