浏览代码

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

Development 3.x
3.x
Andrew Wallo 4 个月前
父节点
当前提交
89bb3dc449
没有帐户链接到提交者的电子邮件

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

220
                 ]),
220
                 ]),
221
             ])
221
             ])
222
             ->bulkActions([
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
                 ]),
309
                 ]),
310
             ])
310
             ])
311
             ->bulkActions([
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
 
173
 
174
         if (isset($data['shippingAddress'])) {
174
         if (isset($data['shippingAddress'])) {
175
             $shippingData = $data['shippingAddress'];
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
             if ($shippingData['same_as_billing'] ?? false) {
177
             if ($shippingData['same_as_billing'] ?? false) {
184
                 $billingAddress = $this->billingAddress;
178
                 $billingAddress = $this->billingAddress;
185
                 if ($billingAddress) {
179
                 if ($billingAddress) {
186
                     $shippingAddress = [
180
                     $shippingAddress = [
187
-                        ...$shippingAddress,
181
+                        'type' => AddressType::Shipping,
182
+                        'recipient' => $shippingData['recipient'] ?? null,
183
+                        'phone' => $shippingData['phone'] ?? null,
184
+                        'notes' => $shippingData['notes'] ?? null,
188
                         'parent_address_id' => $billingAddress->id,
185
                         'parent_address_id' => $billingAddress->id,
189
                         'address_line_1' => $billingAddress->address_line_1,
186
                         'address_line_1' => $billingAddress->address_line_1,
190
                         'address_line_2' => $billingAddress->address_line_2,
187
                         'address_line_2' => $billingAddress->address_line_2,
193
                         'city' => $billingAddress->city,
190
                         'city' => $billingAddress->city,
194
                         'postal_code' => $billingAddress->postal_code,
191
                         'postal_code' => $billingAddress->postal_code,
195
                     ];
192
                     ];
193
+
194
+                    $this->shippingAddress()->updateOrCreate(
195
+                        ['type' => AddressType::Shipping],
196
+                        $shippingAddress
197
+                    );
196
                 }
198
                 }
197
             } elseif (isset($shippingData['address_line_1'])) {
199
             } elseif (isset($shippingData['address_line_1'])) {
198
                 $shippingAddress = [
200
                 $shippingAddress = [
199
-                    ...$shippingAddress,
201
+                    'type' => AddressType::Shipping,
202
+                    'recipient' => $shippingData['recipient'] ?? null,
203
+                    'phone' => $shippingData['phone'] ?? null,
204
+                    'notes' => $shippingData['notes'] ?? null,
200
                     'parent_address_id' => null,
205
                     'parent_address_id' => null,
201
                     'address_line_1' => $shippingData['address_line_1'],
206
                     'address_line_1' => $shippingData['address_line_1'],
202
                     'address_line_2' => $shippingData['address_line_2'] ?? null,
207
                     'address_line_2' => $shippingData['address_line_2'] ?? null,
205
                     'city' => $shippingData['city'] ?? null,
210
                     'city' => $shippingData['city'] ?? null,
206
                     'postal_code' => $shippingData['postal_code'] ?? null,
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
         return $this;
221
         return $this;

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

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 查看文件

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

正在加载...
取消
保存