瀏覽代碼

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

Development 3.x
3.x
Andrew Wallo 4 月之前
父節點
當前提交
89bb3dc449
No account linked to committer's email address

+ 1
- 3
app/Filament/Company/Resources/Purchases/VendorResource.php 查看文件

@@ -220,9 +220,7 @@ class VendorResource extends Resource
220 220
                 ]),
221 221
             ])
222 222
             ->bulkActions([
223
-                Tables\Actions\BulkActionGroup::make([
224
-                    Tables\Actions\DeleteBulkAction::make(),
225
-                ]),
223
+                //
226 224
             ]);
227 225
     }
228 226
 

+ 1
- 3
app/Filament/Company/Resources/Sales/ClientResource.php 查看文件

@@ -309,9 +309,7 @@ class ClientResource extends Resource
309 309
                 ]),
310 310
             ])
311 311
             ->bulkActions([
312
-                Tables\Actions\BulkActionGroup::make([
313
-                    Tables\Actions\DeleteBulkAction::make(),
314
-                ]),
312
+                //
315 313
             ]);
316 314
     }
317 315
 

+ 18
- 13
app/Models/Common/Client.php 查看文件

@@ -173,18 +173,15 @@ class Client extends Model
173 173
 
174 174
         if (isset($data['shippingAddress'])) {
175 175
             $shippingData = $data['shippingAddress'];
176
-            $shippingAddress = [
177
-                'type' => AddressType::Shipping,
178
-                'recipient' => $shippingData['recipient'] ?? null,
179
-                'phone' => $shippingData['phone'] ?? null,
180
-                'notes' => $shippingData['notes'] ?? null,
181
-            ];
182 176
 
183 177
             if ($shippingData['same_as_billing'] ?? false) {
184 178
                 $billingAddress = $this->billingAddress;
185 179
                 if ($billingAddress) {
186 180
                     $shippingAddress = [
187
-                        ...$shippingAddress,
181
+                        'type' => AddressType::Shipping,
182
+                        'recipient' => $shippingData['recipient'] ?? null,
183
+                        'phone' => $shippingData['phone'] ?? null,
184
+                        'notes' => $shippingData['notes'] ?? null,
188 185
                         'parent_address_id' => $billingAddress->id,
189 186
                         'address_line_1' => $billingAddress->address_line_1,
190 187
                         'address_line_2' => $billingAddress->address_line_2,
@@ -193,10 +190,18 @@ class Client extends Model
193 190
                         'city' => $billingAddress->city,
194 191
                         'postal_code' => $billingAddress->postal_code,
195 192
                     ];
193
+
194
+                    $this->shippingAddress()->updateOrCreate(
195
+                        ['type' => AddressType::Shipping],
196
+                        $shippingAddress
197
+                    );
196 198
                 }
197 199
             } elseif (isset($shippingData['address_line_1'])) {
198 200
                 $shippingAddress = [
199
-                    ...$shippingAddress,
201
+                    'type' => AddressType::Shipping,
202
+                    'recipient' => $shippingData['recipient'] ?? null,
203
+                    'phone' => $shippingData['phone'] ?? null,
204
+                    'notes' => $shippingData['notes'] ?? null,
200 205
                     'parent_address_id' => null,
201 206
                     'address_line_1' => $shippingData['address_line_1'],
202 207
                     'address_line_2' => $shippingData['address_line_2'] ?? null,
@@ -205,12 +210,12 @@ class Client extends Model
205 210
                     'city' => $shippingData['city'] ?? null,
206 211
                     'postal_code' => $shippingData['postal_code'] ?? null,
207 212
                 ];
208
-            }
209 213
 
210
-            $this->shippingAddress()->updateOrCreate(
211
-                ['type' => AddressType::Shipping],
212
-                $shippingAddress
213
-            );
214
+                $this->shippingAddress()->updateOrCreate(
215
+                    ['type' => AddressType::Shipping],
216
+                    $shippingAddress
217
+                );
218
+            }
214 219
         }
215 220
 
216 221
         return $this;

+ 65
- 0
app/Policies/ClientPolicy.php 查看文件

@@ -0,0 +1,65 @@
1
+<?php
2
+
3
+namespace App\Policies;
4
+
5
+use App\Models\Common\Client;
6
+use App\Models\User;
7
+
8
+class ClientPolicy
9
+{
10
+    /**
11
+     * Determine whether the user can view any models.
12
+     */
13
+    public function viewAny(User $user): bool
14
+    {
15
+        return true;
16
+    }
17
+
18
+    /**
19
+     * Determine whether the user can view the model.
20
+     */
21
+    public function view(User $user, Client $client): bool
22
+    {
23
+        return true;
24
+    }
25
+
26
+    /**
27
+     * Determine whether the user can create models.
28
+     */
29
+    public function create(User $user): bool
30
+    {
31
+        return true;
32
+    }
33
+
34
+    /**
35
+     * Determine whether the user can update the model.
36
+     */
37
+    public function update(User $user, Client $client): bool
38
+    {
39
+        return true;
40
+    }
41
+
42
+    /**
43
+     * Determine whether the user can delete the model.
44
+     */
45
+    public function delete(User $user, Client $client): bool
46
+    {
47
+        return false;
48
+    }
49
+
50
+    /**
51
+     * Determine whether the user can restore the model.
52
+     */
53
+    public function restore(User $user, Client $client): bool
54
+    {
55
+        return false;
56
+    }
57
+
58
+    /**
59
+     * Determine whether the user can permanently delete the model.
60
+     */
61
+    public function forceDelete(User $user, Client $client): bool
62
+    {
63
+        return false;
64
+    }
65
+}

+ 65
- 0
app/Policies/VendorPolicy.php 查看文件

@@ -0,0 +1,65 @@
1
+<?php
2
+
3
+namespace App\Policies;
4
+
5
+use App\Models\Common\Vendor;
6
+use App\Models\User;
7
+
8
+class VendorPolicy
9
+{
10
+    /**
11
+     * Determine whether the user can view any models.
12
+     */
13
+    public function viewAny(User $user): bool
14
+    {
15
+        return true;
16
+    }
17
+
18
+    /**
19
+     * Determine whether the user can view the model.
20
+     */
21
+    public function view(User $user, Vendor $client): bool
22
+    {
23
+        return true;
24
+    }
25
+
26
+    /**
27
+     * Determine whether the user can create models.
28
+     */
29
+    public function create(User $user): bool
30
+    {
31
+        return true;
32
+    }
33
+
34
+    /**
35
+     * Determine whether the user can update the model.
36
+     */
37
+    public function update(User $user, Vendor $client): bool
38
+    {
39
+        return true;
40
+    }
41
+
42
+    /**
43
+     * Determine whether the user can delete the model.
44
+     */
45
+    public function delete(User $user, Vendor $client): bool
46
+    {
47
+        return false;
48
+    }
49
+
50
+    /**
51
+     * Determine whether the user can restore the model.
52
+     */
53
+    public function restore(User $user, Vendor $client): bool
54
+    {
55
+        return false;
56
+    }
57
+
58
+    /**
59
+     * Determine whether the user can permanently delete the model.
60
+     */
61
+    public function forceDelete(User $user, Vendor $client): bool
62
+    {
63
+        return false;
64
+    }
65
+}

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

@@ -968,6 +968,7 @@ class ReportService
968 968
                 ->whereNotIn('status', [InvoiceStatus::Draft, InvoiceStatus::Void])
969 969
                 ->whereNotNull('approved_at')
970 970
                 ->whereNotNull('paid_at')
971
+                ->whereHas('client')
971 972
                 ->with(['client:id,name'])
972 973
                 ->get()
973 974
                 ->groupBy('client_id'),
@@ -975,6 +976,7 @@ class ReportService
975 976
                 ->whereBetween('date', [$startDate, $endDate])
976 977
                 ->whereNotIn('status', [BillStatus::Void])
977 978
                 ->whereNotNull('paid_at')
979
+                ->whereHas('vendor')
978 980
                 ->with(['vendor:id,name'])
979 981
                 ->get()
980 982
                 ->groupBy('vendor_id'),

Loading…
取消
儲存