瀏覽代碼

wip refactor

3.x
Andrew Wallo 1 年之前
父節點
當前提交
6b681f53e7
共有 29 個檔案被更改,包括 283 行新增596 行删除
  1. 1
    5
      app/Concerns/CompanyOwned.php
  2. 0
    51
      app/Concerns/HandlesResourceRecordCreation.php
  3. 0
    80
      app/Concerns/HandlesResourceRecordUpdate.php
  4. 28
    0
      app/Concerns/HasDefault.php
  5. 12
    32
      app/Filament/Company/Clusters/Settings/Resources/DiscountResource.php
  6. 0
    30
      app/Filament/Company/Clusters/Settings/Resources/DiscountResource/Pages/CreateDiscount.php
  7. 0
    29
      app/Filament/Company/Clusters/Settings/Resources/DiscountResource/Pages/EditDiscount.php
  8. 9
    7
      app/Filament/Company/Clusters/Settings/Resources/TaxResource.php
  9. 0
    30
      app/Filament/Company/Clusters/Settings/Resources/TaxResource/Pages/CreateTax.php
  10. 0
    29
      app/Filament/Company/Clusters/Settings/Resources/TaxResource/Pages/EditTax.php
  11. 3
    1
      app/Filament/Company/Pages/CreateCompany.php
  12. 0
    21
      app/Filament/Company/Resources/Banking/AccountResource/Pages/CreateAccount.php
  13. 0
    20
      app/Filament/Company/Resources/Banking/AccountResource/Pages/EditAccount.php
  14. 2
    0
      app/Models/Setting/Discount.php
  15. 2
    0
      app/Models/Setting/Tax.php
  16. 0
    42
      app/Repositories/Setting/CurrencyRepository.php
  17. 34
    31
      app/Services/ChartOfAccountsService.php
  18. 7
    10
      app/Services/CompanyDefaultService.php
  19. 4
    0
      app/Services/TransactionService.php
  20. 52
    52
      composer.lock
  21. 0
    11
      database/factories/Accounting/TransactionFactory.php
  22. 7
    10
      database/factories/CompanyFactory.php
  23. 9
    9
      database/factories/Setting/CompanyDefaultFactory.php
  24. 15
    6
      database/factories/Setting/DiscountFactory.php
  25. 13
    5
      database/factories/Setting/TaxFactory.php
  26. 6
    9
      database/seeders/DatabaseSeeder.php
  27. 4
    1
      database/seeders/TestDatabaseSeeder.php
  28. 73
    73
      package-lock.json
  29. 2
    2
      resources/views/components/panel-shift-dropdown.blade.php

+ 1
- 5
app/Concerns/CompanyOwned.php 查看文件

17
             if (empty($model->company_id)) {
17
             if (empty($model->company_id)) {
18
                 $companyId = session('current_company_id');
18
                 $companyId = session('current_company_id');
19
 
19
 
20
-                if (! $companyId && Auth::check() && Auth::user()->currentCompany) {
20
+                if (! $companyId && Auth::check()) {
21
                     $companyId = Auth::user()->currentCompany->id;
21
                     $companyId = Auth::user()->currentCompany->id;
22
                     session(['current_company_id' => $companyId]);
22
                     session(['current_company_id' => $companyId]);
23
                 }
23
                 }
24
 
24
 
25
-                if (! $companyId) {
26
-                    $companyId = Auth::user()->currentCompany->id;
27
-                }
28
-
29
                 if ($companyId) {
25
                 if ($companyId) {
30
                     $model->company_id = $companyId;
26
                     $model->company_id = $companyId;
31
                 } else {
27
                 } else {

+ 0
- 51
app/Concerns/HandlesResourceRecordCreation.php 查看文件

1
-<?php
2
-
3
-namespace App\Concerns;
4
-
5
-use App\Models\User;
6
-use Illuminate\Database\Eloquent\Builder;
7
-use Illuminate\Database\Eloquent\Model;
8
-
9
-trait HandlesResourceRecordCreation
10
-{
11
-    protected function handleRecordCreationWithUniqueField(array $data, Model $model, User $user, ?string $uniqueField = null, ?array $evaluatedTypes = null): Model
12
-    {
13
-        // If evaluatedTypes is provided, ensure the unique field value is within the allowed types
14
-        if ($uniqueField && $evaluatedTypes && ! in_array($data[$uniqueField] ?? '', $evaluatedTypes, true)) {
15
-            $data['enabled'] = false;
16
-            $instance = $model->newInstance($data);
17
-            $instance->save();
18
-
19
-            return $instance;
20
-        }
21
-
22
-        $companyId = $user->currentCompany->id;
23
-        $shouldBeEnabled = (bool) ($data['enabled'] ?? false);
24
-
25
-        $query = $model::query()
26
-            ->where('company_id', $companyId)
27
-            ->where('enabled', true);
28
-
29
-        if ($uniqueField && array_key_exists($uniqueField, $data)) {
30
-            $query->where($uniqueField, $data[$uniqueField]);
31
-        }
32
-
33
-        $this->toggleRecords($query, $shouldBeEnabled);
34
-
35
-        $data['enabled'] = $shouldBeEnabled;
36
-        $instance = $model->newInstance($data);
37
-        $instance->save();
38
-
39
-        return $instance;
40
-    }
41
-
42
-    private function toggleRecords(Builder $query, bool &$shouldBeEnabled): void
43
-    {
44
-        if ($shouldBeEnabled) {
45
-            $existingEnabledRecord = $query->first();
46
-            $existingEnabledRecord?->update(['enabled' => false]);
47
-        } elseif ($query->doesntExist()) {
48
-            $shouldBeEnabled = true;
49
-        }
50
-    }
51
-}

+ 0
- 80
app/Concerns/HandlesResourceRecordUpdate.php 查看文件

1
-<?php
2
-
3
-namespace App\Concerns;
4
-
5
-use App\Models\User;
6
-use BackedEnum;
7
-use Illuminate\Database\Eloquent\Builder;
8
-use Illuminate\Database\Eloquent\Model;
9
-
10
-trait HandlesResourceRecordUpdate
11
-{
12
-    protected function handleRecordUpdateWithUniqueField(Model $record, array $data, User $user, ?string $uniqueField = null, ?array $evaluatedTypes = null): Model
13
-    {
14
-        if (is_array($evaluatedTypes)) {
15
-            $evaluatedTypes = $this->ensureUpdateEnumValues($evaluatedTypes);
16
-        }
17
-
18
-        if ($uniqueField && ! in_array($data[$uniqueField] ?? '', $evaluatedTypes ?? [], true)) {
19
-            $data['enabled'] = false;
20
-
21
-            return tap($record)->update($data);
22
-        }
23
-
24
-        $companyId = $user->currentCompany->id;
25
-        $oldValue = $uniqueField ? $record->{$uniqueField} : null;
26
-        $newValue = $uniqueField ? $data[$uniqueField] : null;
27
-        $enabled = (bool) ($data['enabled'] ?? false);
28
-        $wasOriginallyEnabled = (bool) $record->getAttribute('enabled');
29
-
30
-        if ($oldValue instanceof BackedEnum) {
31
-            $oldValue = $oldValue->value;
32
-        }
33
-
34
-        if ($newValue instanceof BackedEnum) {
35
-            $newValue = $newValue->value;
36
-        }
37
-
38
-        if ($uniqueField && $oldValue !== $newValue && $wasOriginallyEnabled) {
39
-            $newValue = $oldValue;
40
-            $data[$uniqueField] = $oldValue;
41
-        }
42
-
43
-        if ($enabled === true && ! $wasOriginallyEnabled) {
44
-            $this->toggleRecord($companyId, $record, $uniqueField, $newValue, true, false);
45
-        } elseif ($enabled === false && $wasOriginallyEnabled) {
46
-            $enabled = true;
47
-        }
48
-
49
-        $data['enabled'] = $enabled;
50
-
51
-        return tap($record)->update($data);
52
-    }
53
-
54
-    private function ensureUpdateEnumValues(array $evaluatedTypes): array
55
-    {
56
-        return array_map(static function ($type) {
57
-            return $type instanceof BackedEnum ? $type->value : $type;
58
-        }, $evaluatedTypes);
59
-    }
60
-
61
-    protected function toggleRecord(int $companyId, Model $record, ?string $uniqueField, $value, bool $enabled, bool $newStatus): void
62
-    {
63
-        $query = $this->buildQuery($companyId, $record, $uniqueField, $value, $enabled);
64
-
65
-        if ($newStatus && ($otherRecord = $query->first())) {
66
-            $otherRecord->update(['enabled' => true]);
67
-        } else {
68
-            $query->update(['enabled' => false]);
69
-        }
70
-    }
71
-
72
-    protected function buildQuery(int $companyId, Model $record, ?string $uniqueField, $value, bool $enabled): Builder
73
-    {
74
-        return $record::query()
75
-            ->where('company_id', $companyId)
76
-            ->where('id', '!=', $record->getKey())
77
-            ->where('enabled', $enabled)
78
-            ->when($uniqueField, static fn ($q) => $q->where($uniqueField, $value));
79
-    }
80
-}

+ 28
- 0
app/Concerns/HasDefault.php 查看文件

2
 
2
 
3
 namespace App\Concerns;
3
 namespace App\Concerns;
4
 
4
 
5
+use Illuminate\Database\Eloquent\Builder;
6
+use Illuminate\Database\Eloquent\Model;
7
+
5
 trait HasDefault
8
 trait HasDefault
6
 {
9
 {
7
     public function isEnabled(): bool
10
     public function isEnabled(): bool
23
     {
26
     {
24
         return translate('No');
27
         return translate('No');
25
     }
28
     }
29
+
30
+    public static function bootHasDefault(): void
31
+    {
32
+        static::saving(function (Model $model) {
33
+            if ($model->isDirty(['enabled', $model->evaluatedDefault])) {
34
+                if ($model->enabled === true) {
35
+                    static::query()
36
+                        ->whereKeyNot($model->getKey())
37
+                        ->where('enabled', true)
38
+                        ->when(filled($model->evaluatedDefault), static fn (Builder $query) => $query->where($model->evaluatedDefault, $model->{$model->evaluatedDefault}))
39
+                        ->update(['enabled' => false]);
40
+                } else {
41
+                    $enabledRecordDoesNotExist = static::query()
42
+                        ->whereKeyNot($model->getKey())
43
+                        ->where('enabled', true)
44
+                        ->when(filled($model->evaluatedDefault), static fn (Builder $query) => $query->where($model->evaluatedDefault, $model->{$model->evaluatedDefault}))
45
+                        ->doesntExist();
46
+
47
+                    if ($enabledRecordDoesNotExist) {
48
+                        $model->enabled = true;
49
+                    }
50
+                }
51
+            }
52
+        });
53
+    }
26
 }
54
 }

+ 12
- 32
app/Filament/Company/Clusters/Settings/Resources/DiscountResource.php 查看文件

50
                             ->localizeLabel()
50
                             ->localizeLabel()
51
                             ->maxLength(255)
51
                             ->maxLength(255)
52
                             ->rule(static function (Forms\Get $get, Forms\Components\Component $component): Closure {
52
                             ->rule(static function (Forms\Get $get, Forms\Components\Component $component): Closure {
53
-                                return static function (string $attribute, $value, Closure $fail) use ($get, $component) {
54
-                                    $existingDiscount = Discount::where('company_id', auth()->user()->currentCompany->id)
55
-                                        ->where('name', $value)
53
+                                return static function (string $attribute, $value, Closure $fail) use ($component, $get) {
54
+                                    $existingDiscount = Discount::where('name', $value)
55
+                                        ->whereKeyNot($component->getRecord()?->getKey())
56
                                         ->where('type', $get('type'))
56
                                         ->where('type', $get('type'))
57
                                         ->first();
57
                                         ->first();
58
 
58
 
59
-                                    if ($existingDiscount && $existingDiscount->getKey() !== $component->getRecord()?->getKey()) {
59
+                                    if ($existingDiscount) {
60
                                         $message = translate('The :Type :record ":name" already exists.', [
60
                                         $message = translate('The :Type :record ":name" already exists.', [
61
                                             'Type' => $existingDiscount->type->getLabel(),
61
                                             'Type' => $existingDiscount->type->getLabel(),
62
                                             'record' => strtolower(static::getModelLabel()),
62
                                             'record' => strtolower(static::getModelLabel()),
90
                             ->nullable(),
90
                             ->nullable(),
91
                         Forms\Components\DateTimePicker::make('start_date')
91
                         Forms\Components\DateTimePicker::make('start_date')
92
                             ->localizeLabel()
92
                             ->localizeLabel()
93
-                            ->minDate(static function ($context, ?Discount $record = null) {
94
-                                if ($context === 'create' || $record?->start_date?->isFuture()) {
95
-                                    return today()->addDay();
96
-                                }
97
-
98
-                                return $record?->start_date;
99
-                            })
100
-                            ->maxDate(static function (callable $get, ?Discount $record = null) {
101
-                                $end_date = $get('end_date') ?? $record?->end_date;
102
-
103
-                                return $end_date ?: today()->addYear();
104
-                            })
105
-                            ->format('Y-m-d H:i:s')
106
-                            ->displayFormat('F d, Y H:i')
93
+                            ->beforeOrEqual('end_date')
107
                             ->seconds(false)
94
                             ->seconds(false)
108
-                            ->live()
109
-                            ->disabled(static fn ($context, ?Discount $record = null) => $context === 'edit' && $record?->start_date?->isPast() ?? false)
95
+                            ->disabled(static fn (string $operation, ?Discount $record = null) => $operation === 'edit' && $record?->start_date?->isPast() ?? false)
110
                             ->helperText(static fn (Forms\Components\DateTimePicker $component) => $component->isDisabled() ? 'Start date cannot be changed after the discount has begun.' : null),
96
                             ->helperText(static fn (Forms\Components\DateTimePicker $component) => $component->isDisabled() ? 'Start date cannot be changed after the discount has begun.' : null),
111
                         Forms\Components\DateTimePicker::make('end_date')
97
                         Forms\Components\DateTimePicker::make('end_date')
112
-                            ->live()
113
                             ->localizeLabel()
98
                             ->localizeLabel()
114
-                            ->minDate(static function (callable $get, ?Discount $record = null) {
115
-                                $start_date = $get('start_date') ?? $record?->start_date;
116
-
117
-                                return $start_date ?: today()->addDay();
118
-                            })
119
-                            ->maxDate(today()->addYear())
120
-                            ->format('Y-m-d H:i:s')
121
-                            ->displayFormat('F d, Y H:i')
99
+                            ->afterOrEqual('start_date')
122
                             ->seconds(false),
100
                             ->seconds(false),
123
                         ToggleButton::make('enabled')
101
                         ToggleButton::make('enabled')
124
                             ->localizeLabel('Default')
102
                             ->localizeLabel('Default')
137
                     ->weight(FontWeight::Medium)
115
                     ->weight(FontWeight::Medium)
138
                     ->icon(static fn (Discount $record) => $record->isEnabled() ? 'heroicon-o-lock-closed' : null)
116
                     ->icon(static fn (Discount $record) => $record->isEnabled() ? 'heroicon-o-lock-closed' : null)
139
                     ->tooltip(static function (Discount $record) {
117
                     ->tooltip(static function (Discount $record) {
140
-                        $tooltipMessage = translate('Default :Type :Record', [
118
+                        if ($record->isDisabled()) {
119
+                            return null;
120
+                        }
121
+
122
+                        return translate('Default :Type :Record', [
141
                             'Type' => $record->type->getLabel(),
123
                             'Type' => $record->type->getLabel(),
142
                             'Record' => static::getModelLabel(),
124
                             'Record' => static::getModelLabel(),
143
                         ]);
125
                         ]);
144
-
145
-                        return $record->isEnabled() ? $tooltipMessage : null;
146
                     })
126
                     })
147
                     ->iconPosition('after')
127
                     ->iconPosition('after')
148
                     ->searchable()
128
                     ->searchable()

+ 0
- 30
app/Filament/Company/Clusters/Settings/Resources/DiscountResource/Pages/CreateDiscount.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Clusters\Settings\Resources\DiscountResource\Pages;
3
 namespace App\Filament\Company\Clusters\Settings\Resources\DiscountResource\Pages;
4
 
4
 
5
-use App\Concerns\HandlesResourceRecordCreation;
6
-use App\Enums\Setting\DiscountType;
7
 use App\Filament\Company\Clusters\Settings\Resources\DiscountResource;
5
 use App\Filament\Company\Clusters\Settings\Resources\DiscountResource;
8
-use App\Models\Setting\Discount;
9
 use Filament\Resources\Pages\CreateRecord;
6
 use Filament\Resources\Pages\CreateRecord;
10
-use Filament\Support\Exceptions\Halt;
11
-use Illuminate\Database\Eloquent\Model;
12
 
7
 
13
 class CreateDiscount extends CreateRecord
8
 class CreateDiscount extends CreateRecord
14
 {
9
 {
15
-    use HandlesResourceRecordCreation;
16
-
17
     protected static string $resource = DiscountResource::class;
10
     protected static string $resource = DiscountResource::class;
18
 
11
 
19
     protected function getRedirectUrl(): string
12
     protected function getRedirectUrl(): string
20
     {
13
     {
21
         return $this->getResource()::getUrl('index');
14
         return $this->getResource()::getUrl('index');
22
     }
15
     }
23
-
24
-    protected function mutateFormDataBeforeCreate(array $data): array
25
-    {
26
-        $data['enabled'] = (bool) $data['enabled'];
27
-
28
-        return $data;
29
-    }
30
-
31
-    /**
32
-     * @throws Halt
33
-     */
34
-    protected function handleRecordCreation(array $data): Model
35
-    {
36
-        $user = auth()->user();
37
-
38
-        if (! $user) {
39
-            throw new Halt('No authenticated user found');
40
-        }
41
-
42
-        $evaluatedTypes = [DiscountType::Sales, DiscountType::Purchase];
43
-
44
-        return $this->handleRecordCreationWithUniqueField($data, new Discount, $user, 'type', $evaluatedTypes);
45
-    }
46
 }
16
 }

+ 0
- 29
app/Filament/Company/Clusters/Settings/Resources/DiscountResource/Pages/EditDiscount.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Clusters\Settings\Resources\DiscountResource\Pages;
3
 namespace App\Filament\Company\Clusters\Settings\Resources\DiscountResource\Pages;
4
 
4
 
5
-use App\Concerns\HandlesResourceRecordUpdate;
6
-use App\Enums\Setting\DiscountType;
7
 use App\Filament\Company\Clusters\Settings\Resources\DiscountResource;
5
 use App\Filament\Company\Clusters\Settings\Resources\DiscountResource;
8
 use Filament\Actions;
6
 use Filament\Actions;
9
 use Filament\Resources\Pages\EditRecord;
7
 use Filament\Resources\Pages\EditRecord;
10
-use Filament\Support\Exceptions\Halt;
11
-use Illuminate\Database\Eloquent\Model;
12
 
8
 
13
 class EditDiscount extends EditRecord
9
 class EditDiscount extends EditRecord
14
 {
10
 {
15
-    use HandlesResourceRecordUpdate;
16
-
17
     protected static string $resource = DiscountResource::class;
11
     protected static string $resource = DiscountResource::class;
18
 
12
 
19
     protected function getHeaderActions(): array
13
     protected function getHeaderActions(): array
27
     {
21
     {
28
         return $this->getResource()::getUrl('index');
22
         return $this->getResource()::getUrl('index');
29
     }
23
     }
30
-
31
-    protected function mutateFormDataBeforeSave(array $data): array
32
-    {
33
-        $data['enabled'] = (bool) $data['enabled'];
34
-
35
-        return $data;
36
-    }
37
-
38
-    /**
39
-     * @throws Halt
40
-     */
41
-    protected function handleRecordUpdate(Model $record, array $data): Model
42
-    {
43
-        $user = auth()->user();
44
-
45
-        if (! $user) {
46
-            throw new Halt('No authenticated user found');
47
-        }
48
-
49
-        $evaluatedTypes = [DiscountType::Sales, DiscountType::Purchase];
50
-
51
-        return $this->handleRecordUpdateWithUniqueField($record, $data, $user, 'type', $evaluatedTypes);
52
-    }
53
 }
24
 }

+ 9
- 7
app/Filament/Company/Clusters/Settings/Resources/TaxResource.php 查看文件

47
                             ->localizeLabel()
47
                             ->localizeLabel()
48
                             ->maxLength(255)
48
                             ->maxLength(255)
49
                             ->rule(static function (Forms\Get $get, Forms\Components\Component $component): Closure {
49
                             ->rule(static function (Forms\Get $get, Forms\Components\Component $component): Closure {
50
-                                return static function (string $attribute, $value, Closure $fail) use ($get, $component) {
51
-                                    $existingTax = Tax::where('company_id', auth()->user()->currentCompany->id)
52
-                                        ->where('name', $value)
50
+                                return static function (string $attribute, $value, Closure $fail) use ($component, $get) {
51
+                                    $existingTax = Tax::where('name', $value)
52
+                                        ->whereKeyNot($component->getRecord()?->getKey())
53
                                         ->where('type', $get('type'))
53
                                         ->where('type', $get('type'))
54
                                         ->first();
54
                                         ->first();
55
 
55
 
56
-                                    if ($existingTax && $existingTax->getKey() !== $component->getRecord()?->getKey()) {
56
+                                    if ($existingTax) {
57
                                         $message = translate('The :Type :record ":name" already exists.', [
57
                                         $message = translate('The :Type :record ":name" already exists.', [
58
                                             'Type' => $existingTax->type->getLabel(),
58
                                             'Type' => $existingTax->type->getLabel(),
59
                                             'record' => strtolower(static::getModelLabel()),
59
                                             'record' => strtolower(static::getModelLabel()),
100
                     ->weight(FontWeight::Medium)
100
                     ->weight(FontWeight::Medium)
101
                     ->icon(static fn (Tax $record) => $record->isEnabled() ? 'heroicon-o-lock-closed' : null)
101
                     ->icon(static fn (Tax $record) => $record->isEnabled() ? 'heroicon-o-lock-closed' : null)
102
                     ->tooltip(static function (Tax $record) {
102
                     ->tooltip(static function (Tax $record) {
103
-                        $tooltipMessage = translate('Default :Type :Record', [
103
+                        if ($record->isDisabled()) {
104
+                            return null;
105
+                        }
106
+
107
+                        return translate('Default :Type :Record', [
104
                             'Type' => $record->type->getLabel(),
108
                             'Type' => $record->type->getLabel(),
105
                             'Record' => static::getModelLabel(),
109
                             'Record' => static::getModelLabel(),
106
                         ]);
110
                         ]);
107
-
108
-                        return $record->isEnabled() ? $tooltipMessage : null;
109
                     })
111
                     })
110
                     ->iconPosition('after')
112
                     ->iconPosition('after')
111
                     ->searchable()
113
                     ->searchable()

+ 0
- 30
app/Filament/Company/Clusters/Settings/Resources/TaxResource/Pages/CreateTax.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Clusters\Settings\Resources\TaxResource\Pages;
3
 namespace App\Filament\Company\Clusters\Settings\Resources\TaxResource\Pages;
4
 
4
 
5
-use App\Concerns\HandlesResourceRecordCreation;
6
-use App\Enums\Setting\TaxType;
7
 use App\Filament\Company\Clusters\Settings\Resources\TaxResource;
5
 use App\Filament\Company\Clusters\Settings\Resources\TaxResource;
8
-use App\Models\Setting\Tax;
9
 use Filament\Resources\Pages\CreateRecord;
6
 use Filament\Resources\Pages\CreateRecord;
10
-use Filament\Support\Exceptions\Halt;
11
-use Illuminate\Database\Eloquent\Model;
12
 
7
 
13
 class CreateTax extends CreateRecord
8
 class CreateTax extends CreateRecord
14
 {
9
 {
15
-    use HandlesResourceRecordCreation;
16
-
17
     protected static string $resource = TaxResource::class;
10
     protected static string $resource = TaxResource::class;
18
 
11
 
19
     protected function getRedirectUrl(): string
12
     protected function getRedirectUrl(): string
20
     {
13
     {
21
         return $this->getResource()::getUrl('index');
14
         return $this->getResource()::getUrl('index');
22
     }
15
     }
23
-
24
-    protected function mutateFormDataBeforeCreate(array $data): array
25
-    {
26
-        $data['enabled'] = (bool) $data['enabled'];
27
-
28
-        return $data;
29
-    }
30
-
31
-    /**
32
-     * @throws Halt
33
-     */
34
-    protected function handleRecordCreation(array $data): Model
35
-    {
36
-        $user = auth()->user();
37
-
38
-        if (! $user) {
39
-            throw new Halt('No authenticated user found');
40
-        }
41
-
42
-        $evaluatedTypes = [TaxType::Sales, TaxType::Purchase];
43
-
44
-        return $this->handleRecordCreationWithUniqueField($data, new Tax, $user, 'type', $evaluatedTypes);
45
-    }
46
 }
16
 }

+ 0
- 29
app/Filament/Company/Clusters/Settings/Resources/TaxResource/Pages/EditTax.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Clusters\Settings\Resources\TaxResource\Pages;
3
 namespace App\Filament\Company\Clusters\Settings\Resources\TaxResource\Pages;
4
 
4
 
5
-use App\Concerns\HandlesResourceRecordUpdate;
6
-use App\Enums\Setting\TaxType;
7
 use App\Filament\Company\Clusters\Settings\Resources\TaxResource;
5
 use App\Filament\Company\Clusters\Settings\Resources\TaxResource;
8
 use Filament\Actions;
6
 use Filament\Actions;
9
 use Filament\Resources\Pages\EditRecord;
7
 use Filament\Resources\Pages\EditRecord;
10
-use Filament\Support\Exceptions\Halt;
11
-use Illuminate\Database\Eloquent\Model;
12
 
8
 
13
 class EditTax extends EditRecord
9
 class EditTax extends EditRecord
14
 {
10
 {
15
-    use HandlesResourceRecordUpdate;
16
-
17
     protected static string $resource = TaxResource::class;
11
     protected static string $resource = TaxResource::class;
18
 
12
 
19
     protected function getHeaderActions(): array
13
     protected function getHeaderActions(): array
27
     {
21
     {
28
         return $this->getResource()::getUrl('index');
22
         return $this->getResource()::getUrl('index');
29
     }
23
     }
30
-
31
-    protected function mutateFormDataBeforeSave(array $data): array
32
-    {
33
-        $data['enabled'] = (bool) $data['enabled'];
34
-
35
-        return $data;
36
-    }
37
-
38
-    /**
39
-     * @throws Halt
40
-     */
41
-    protected function handleRecordUpdate(Model $record, array $data): Model
42
-    {
43
-        $user = auth()->user();
44
-
45
-        if (! $user) {
46
-            throw new Halt('No authenticated user found');
47
-        }
48
-
49
-        $evaluatedTypes = [TaxType::Sales, TaxType::Purchase];
50
-
51
-        return $this->handleRecordUpdateWithUniqueField($record, $data, $user, 'type', $evaluatedTypes);
52
-    }
53
 }
24
 }

+ 3
- 1
app/Filament/Company/Pages/CreateCompany.php 查看文件

21
 
21
 
22
 class CreateCompany extends FilamentCreateCompany
22
 class CreateCompany extends FilamentCreateCompany
23
 {
23
 {
24
+    protected bool $hasTopbar = false;
25
+
24
     public function form(Form $form): Form
26
     public function form(Form $form): Form
25
     {
27
     {
26
         return $form
28
         return $form
85
 
87
 
86
             $user?->switchCompany($company);
88
             $user?->switchCompany($company);
87
 
89
 
88
-            $companyDefaultService = app()->make(CompanyDefaultService::class);
90
+            $companyDefaultService = app(CompanyDefaultService::class);
89
             $user = $company->owner ?? $user;
91
             $user = $company->owner ?? $user;
90
             $companyDefaultService->createCompanyDefaults($company, $user, $data['currencies']['code'], $data['profile']['country'], $data['locale']['language']);
92
             $companyDefaultService->createCompanyDefaults($company, $user, $data['currencies']['code'], $data['profile']['country'], $data['locale']['language']);
91
 
93
 

+ 0
- 21
app/Filament/Company/Resources/Banking/AccountResource/Pages/CreateAccount.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
3
 namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
4
 
4
 
5
-use App\Concerns\HandlesResourceRecordCreation;
6
 use App\Filament\Company\Resources\Banking\AccountResource;
5
 use App\Filament\Company\Resources\Banking\AccountResource;
7
-use App\Models\Banking\BankAccount;
8
 use Filament\Resources\Pages\CreateRecord;
6
 use Filament\Resources\Pages\CreateRecord;
9
-use Filament\Support\Exceptions\Halt;
10
-use Illuminate\Database\Eloquent\Model;
11
-use Illuminate\Support\Facades\Auth;
12
 
7
 
13
 class CreateAccount extends CreateRecord
8
 class CreateAccount extends CreateRecord
14
 {
9
 {
15
-    use HandlesResourceRecordCreation;
16
-
17
     protected static string $resource = AccountResource::class;
10
     protected static string $resource = AccountResource::class;
18
 
11
 
19
     protected function getRedirectUrl(): string
12
     protected function getRedirectUrl(): string
27
 
20
 
28
         return $data;
21
         return $data;
29
     }
22
     }
30
-
31
-    /**
32
-     * @throws Halt
33
-     */
34
-    protected function handleRecordCreation(array $data): Model
35
-    {
36
-        $user = Auth::user();
37
-
38
-        if (! $user) {
39
-            throw new Halt('No authenticated user found');
40
-        }
41
-
42
-        return $this->handleRecordCreationWithUniqueField($data, new BankAccount, $user);
43
-    }
44
 }
23
 }

+ 0
- 20
app/Filament/Company/Resources/Banking/AccountResource/Pages/EditAccount.php 查看文件

2
 
2
 
3
 namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
3
 namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
4
 
4
 
5
-use App\Concerns\HandlesResourceRecordUpdate;
6
 use App\Filament\Company\Resources\Banking\AccountResource;
5
 use App\Filament\Company\Resources\Banking\AccountResource;
7
 use Filament\Resources\Pages\EditRecord;
6
 use Filament\Resources\Pages\EditRecord;
8
-use Filament\Support\Exceptions\Halt;
9
-use Illuminate\Database\Eloquent\Model;
10
-use Illuminate\Support\Facades\Auth;
11
 
7
 
12
 class EditAccount extends EditRecord
8
 class EditAccount extends EditRecord
13
 {
9
 {
14
-    use HandlesResourceRecordUpdate;
15
-
16
     protected static string $resource = AccountResource::class;
10
     protected static string $resource = AccountResource::class;
17
 
11
 
18
     protected function getHeaderActions(): array
12
     protected function getHeaderActions(): array
33
 
27
 
34
         return $data;
28
         return $data;
35
     }
29
     }
36
-
37
-    /**
38
-     * @throws Halt
39
-     */
40
-    protected function handleRecordUpdate(Model $record, array $data): Model
41
-    {
42
-        $user = Auth::user();
43
-
44
-        if (! $user) {
45
-            throw new Halt('No authenticated user found');
46
-        }
47
-
48
-        return $this->handleRecordUpdateWithUniqueField($record, $data, $user);
49
-    }
50
 }
30
 }

+ 2
- 0
app/Models/Setting/Discount.php 查看文件

51
         'enabled' => 'boolean',
51
         'enabled' => 'boolean',
52
     ];
52
     ];
53
 
53
 
54
+    protected ?string $evaluatedDefault = 'type';
55
+
54
     public function defaultSalesDiscount(): HasOne
56
     public function defaultSalesDiscount(): HasOne
55
     {
57
     {
56
         return $this->hasOne(CompanyDefault::class, 'sales_discount_id');
58
         return $this->hasOne(CompanyDefault::class, 'sales_discount_id');

+ 2
- 0
app/Models/Setting/Tax.php 查看文件

47
         'enabled' => 'boolean',
47
         'enabled' => 'boolean',
48
     ];
48
     ];
49
 
49
 
50
+    protected ?string $evaluatedDefault = 'type';
51
+
50
     public function defaultSalesTax(): HasOne
52
     public function defaultSalesTax(): HasOne
51
     {
53
     {
52
         return $this->hasOne(CompanyDefault::class, 'sales_tax_id');
54
         return $this->hasOne(CompanyDefault::class, 'sales_tax_id');

+ 0
- 42
app/Repositories/Setting/CurrencyRepository.php 查看文件

1
-<?php
2
-
3
-namespace App\Repositories\Setting;
4
-
5
-use App\Models\Company;
6
-use App\Models\Setting\Currency;
7
-
8
-class CurrencyRepository
9
-{
10
-    public function ensureCurrencyExists(Company $company, string $currencyCode): Currency
11
-    {
12
-        $hasDefaultCurrency = $this->hasDefaultCurrency($company);
13
-
14
-        $currency = currency($currencyCode);
15
-
16
-        return $company->currencies()
17
-            ->firstOrCreate([
18
-                'code' => $currencyCode,
19
-            ], [
20
-                'name' => $currency->getName(),
21
-                'rate' => $currency->getRate(),
22
-                'precision' => $currency->getPrecision(),
23
-                'symbol' => $currency->getSymbol(),
24
-                'symbol_first' => $currency->isSymbolFirst(),
25
-                'decimal_mark' => $currency->getDecimalMark(),
26
-                'thousands_separator' => $currency->getThousandsSeparator(),
27
-                'enabled' => ! $hasDefaultCurrency,
28
-            ]);
29
-    }
30
-
31
-    public function getDefaultCurrency(Company $company): ?Currency
32
-    {
33
-        return $company->currencies()
34
-            ->where('enabled', true)
35
-            ->first();
36
-    }
37
-
38
-    public function hasDefaultCurrency(Company $company): bool
39
-    {
40
-        return $this->getDefaultCurrency($company) !== null;
41
-    }
42
-}

+ 34
- 31
app/Services/ChartOfAccountsService.php 查看文件

4
 
4
 
5
 use App\Enums\Accounting\AccountType;
5
 use App\Enums\Accounting\AccountType;
6
 use App\Enums\Banking\BankAccountType;
6
 use App\Enums\Banking\BankAccountType;
7
-use App\Models\Accounting\Account;
8
 use App\Models\Accounting\AccountSubtype;
7
 use App\Models\Accounting\AccountSubtype;
9
 use App\Models\Banking\BankAccount;
8
 use App\Models\Banking\BankAccount;
10
 use App\Models\Company;
9
 use App\Models\Company;
11
 use App\Utilities\Currency\CurrencyAccessor;
10
 use App\Utilities\Currency\CurrencyAccessor;
11
+use Exception;
12
 
12
 
13
 class ChartOfAccountsService
13
 class ChartOfAccountsService
14
 {
14
 {
18
 
18
 
19
         foreach ($chartOfAccounts as $type => $subtypes) {
19
         foreach ($chartOfAccounts as $type => $subtypes) {
20
             foreach ($subtypes as $subtypeName => $subtypeConfig) {
20
             foreach ($subtypes as $subtypeName => $subtypeConfig) {
21
-                $subtype = AccountSubtype::create([
22
-                    'company_id' => $company->id,
23
-                    'multi_currency' => $subtypeConfig['multi_currency'] ?? false,
24
-                    'category' => AccountType::from($type)->getCategory()->value,
25
-                    'type' => $type,
26
-                    'name' => $subtypeName,
27
-                    'description' => $subtypeConfig['description'] ?? 'No description available.',
28
-                ]);
21
+                $subtype = $company->accountSubtypes()
22
+                    ->createQuietly([
23
+                        'multi_currency' => $subtypeConfig['multi_currency'] ?? false,
24
+                        'category' => AccountType::from($type)->getCategory()->value,
25
+                        'type' => $type,
26
+                        'name' => $subtypeName,
27
+                        'description' => $subtypeConfig['description'] ?? 'No description available.',
28
+                    ]);
29
+
30
+                try {
31
+                    $this->createDefaultAccounts($company, $subtype, $subtypeConfig);
32
+                } catch (Exception $e) {
33
+                    // Log the error
34
+                    logger()->alert('Failed to create a company with its defaults, blocking critical business functionality.', [
35
+                        'error' => $e->getMessage(),
36
+                        'userId' => $company->owner->id,
37
+                        'companyId' => $company->id,
38
+                    ]);
29
 
39
 
30
-                $this->createDefaultAccounts($company, $subtype, $subtypeConfig);
40
+                    throw $e;
41
+                }
31
             }
42
             }
32
         }
43
         }
33
     }
44
     }
37
         if (isset($subtypeConfig['accounts']) && is_array($subtypeConfig['accounts'])) {
48
         if (isset($subtypeConfig['accounts']) && is_array($subtypeConfig['accounts'])) {
38
             $baseCode = $subtypeConfig['base_code'];
49
             $baseCode = $subtypeConfig['base_code'];
39
 
50
 
51
+            $defaultCurrencyCode = CurrencyAccessor::getDefaultCurrency();
52
+
53
+            if (empty($defaultCurrencyCode)) {
54
+                throw new Exception('No default currency available for creating accounts.');
55
+            }
56
+
40
             foreach ($subtypeConfig['accounts'] as $accountName => $accountDetails) {
57
             foreach ($subtypeConfig['accounts'] as $accountName => $accountDetails) {
41
                 $bankAccount = null;
58
                 $bankAccount = null;
42
 
59
 
44
                     $bankAccount = $this->createBankAccountForMultiCurrency($company, $subtypeConfig['bank_account_type']);
61
                     $bankAccount = $this->createBankAccountForMultiCurrency($company, $subtypeConfig['bank_account_type']);
45
                 }
62
                 }
46
 
63
 
47
-                $account = Account::create([
48
-                    'company_id' => $company->id,
64
+                $company->accounts()->createQuietly([
65
+                    'bank_account_id' => $bankAccount?->id,
49
                     'subtype_id' => $subtype->id,
66
                     'subtype_id' => $subtype->id,
50
                     'category' => $subtype->type->getCategory()->value,
67
                     'category' => $subtype->type->getCategory()->value,
51
                     'type' => $subtype->type->value,
68
                     'type' => $subtype->type->value,
52
                     'code' => $baseCode++,
69
                     'code' => $baseCode++,
53
                     'name' => $accountName,
70
                     'name' => $accountName,
54
-                    'currency_code' => CurrencyAccessor::getDefaultCurrency(),
71
+                    'currency_code' => $defaultCurrencyCode,
55
                     'description' => $accountDetails['description'] ?? 'No description available.',
72
                     'description' => $accountDetails['description'] ?? 'No description available.',
56
                     'default' => true,
73
                     'default' => true,
57
                     'created_by' => $company->owner->id,
74
                     'created_by' => $company->owner->id,
58
                     'updated_by' => $company->owner->id,
75
                     'updated_by' => $company->owner->id,
59
                 ]);
76
                 ]);
60
-
61
-                if ($bankAccount) {
62
-                    $account->bankAccount()->associate($bankAccount);
63
-                }
64
-
65
-                $account->save();
66
             }
77
             }
67
         }
78
         }
68
     }
79
     }
69
 
80
 
70
     private function createBankAccountForMultiCurrency(Company $company, string $bankAccountType): BankAccount
81
     private function createBankAccountForMultiCurrency(Company $company, string $bankAccountType): BankAccount
71
     {
82
     {
72
-        $bankAccountType = BankAccountType::from($bankAccountType) ?? BankAccountType::Other;
83
+        $noDefaultBankAccount = $company->bankAccounts()->where('enabled', true)->doesntExist();
73
 
84
 
74
-        return BankAccount::create([
75
-            'company_id' => $company->id,
76
-            'institution_id' => null,
77
-            'type' => $bankAccountType,
78
-            'number' => null,
79
-            'enabled' => BankAccount::where('company_id', $company->id)->where('enabled', true)->doesntExist(),
85
+        return $company->bankAccounts()->createQuietly([
86
+            'type' => BankAccountType::from($bankAccountType) ?? BankAccountType::Other,
87
+            'enabled' => $noDefaultBankAccount,
80
             'created_by' => $company->owner->id,
88
             'created_by' => $company->owner->id,
81
             'updated_by' => $company->owner->id,
89
             'updated_by' => $company->owner->id,
82
         ]);
90
         ]);
83
     }
91
     }
84
-
85
-    public function getDefaultBankAccount(Company $company): ?BankAccount
86
-    {
87
-        return $company->bankAccounts()->where('enabled', true)->first();
88
-    }
89
 }
92
 }

+ 7
- 10
app/Services/CompanyDefaultService.php 查看文件

13
     {
13
     {
14
         DB::transaction(function () use ($user, $company, $currencyCode, $countryCode, $language) {
14
         DB::transaction(function () use ($user, $company, $currencyCode, $countryCode, $language) {
15
             // Create the company defaults
15
             // Create the company defaults
16
-            $companyDefaultFactory = CompanyDefault::factory()->withDefault($user, $company, $currencyCode, $countryCode, $language);
17
-            $companyDefaults = $companyDefaultFactory->make()->toArray();
18
-
19
-            $companyDefault = CompanyDefault::create($companyDefaults);
16
+            $companyDefaultInstance = CompanyDefault::factory()->withDefault($user, $company, $currencyCode, $countryCode, $language);
20
 
17
 
21
             // Create Chart of Accounts
18
             // Create Chart of Accounts
22
-            $chartOfAccountsService = app()->make(ChartOfAccountsService::class);
19
+            $chartOfAccountsService = app(ChartOfAccountsService::class);
23
             $chartOfAccountsService->createChartOfAccounts($company);
20
             $chartOfAccountsService->createChartOfAccounts($company);
24
 
21
 
25
             // Get the default bank account and update the company default record
22
             // Get the default bank account and update the company default record
26
-            $defaultBankAccount = $chartOfAccountsService->getDefaultBankAccount($company);
23
+            $defaultBankAccount = $company->bankAccounts()->where('enabled', true)->firstOrFail();
27
 
24
 
28
-            $companyDefault->update([
29
-                'bank_account_id' => $defaultBankAccount?->id,
30
-            ]);
31
-        }, 5);
25
+            $companyDefaultInstance->state([
26
+                'bank_account_id' => $defaultBankAccount->id,
27
+            ])->createQuietly();
28
+        });
32
     }
29
     }
33
 }
30
 }

+ 4
- 0
app/Services/TransactionService.php 查看文件

229
                 'type' => JournalEntryType::Debit,
229
                 'type' => JournalEntryType::Debit,
230
                 'amount' => $convertedTransactionAmount,
230
                 'amount' => $convertedTransactionAmount,
231
                 'description' => $transaction->description,
231
                 'description' => $transaction->description,
232
+                'created_by' => $transaction->created_by,
233
+                'updated_by' => $transaction->updated_by,
232
             ]);
234
             ]);
233
 
235
 
234
             $creditAccount->journalEntries()->create([
236
             $creditAccount->journalEntries()->create([
237
                 'type' => JournalEntryType::Credit,
239
                 'type' => JournalEntryType::Credit,
238
                 'amount' => $convertedTransactionAmount,
240
                 'amount' => $convertedTransactionAmount,
239
                 'description' => $transaction->description,
241
                 'description' => $transaction->description,
242
+                'created_by' => $transaction->created_by,
243
+                'updated_by' => $transaction->updated_by,
240
             ]);
244
             ]);
241
         });
245
         });
242
     }
246
     }

+ 52
- 52
composer.lock 查看文件

497
         },
497
         },
498
         {
498
         {
499
             "name": "aws/aws-sdk-php",
499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.322.8",
500
+            "version": "3.323.1",
501
             "source": {
501
             "source": {
502
                 "type": "git",
502
                 "type": "git",
503
                 "url": "https://github.com/aws/aws-sdk-php.git",
503
                 "url": "https://github.com/aws/aws-sdk-php.git",
504
-                "reference": "fb5099160e49b676277ae787ff721628e5e4dd5a"
504
+                "reference": "1b393c41a73e1ef4c493c60c5eee0bb4b0632264"
505
             },
505
             },
506
             "dist": {
506
             "dist": {
507
                 "type": "zip",
507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/fb5099160e49b676277ae787ff721628e5e4dd5a",
509
-                "reference": "fb5099160e49b676277ae787ff721628e5e4dd5a",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/1b393c41a73e1ef4c493c60c5eee0bb4b0632264",
509
+                "reference": "1b393c41a73e1ef4c493c60c5eee0bb4b0632264",
510
                 "shasum": ""
510
                 "shasum": ""
511
             },
511
             },
512
             "require": {
512
             "require": {
589
             "support": {
589
             "support": {
590
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
590
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
591
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
591
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
592
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.322.8"
592
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.323.1"
593
             },
593
             },
594
-            "time": "2024-09-30T19:09:25+00:00"
594
+            "time": "2024-10-04T18:07:17+00:00"
595
         },
595
         },
596
         {
596
         {
597
             "name": "aws/aws-sdk-php-laravel",
597
             "name": "aws/aws-sdk-php-laravel",
2903
         },
2903
         },
2904
         {
2904
         {
2905
             "name": "laravel/framework",
2905
             "name": "laravel/framework",
2906
-            "version": "v11.25.0",
2906
+            "version": "v11.26.0",
2907
             "source": {
2907
             "source": {
2908
                 "type": "git",
2908
                 "type": "git",
2909
                 "url": "https://github.com/laravel/framework.git",
2909
                 "url": "https://github.com/laravel/framework.git",
2910
-                "reference": "b487a9089c0b1c71ac63bb6bc44fb4b00dc6da2e"
2910
+                "reference": "b8cb8998701d5b3cfe68539d3c3da1fc59ddd82b"
2911
             },
2911
             },
2912
             "dist": {
2912
             "dist": {
2913
                 "type": "zip",
2913
                 "type": "zip",
2914
-                "url": "https://api.github.com/repos/laravel/framework/zipball/b487a9089c0b1c71ac63bb6bc44fb4b00dc6da2e",
2915
-                "reference": "b487a9089c0b1c71ac63bb6bc44fb4b00dc6da2e",
2914
+                "url": "https://api.github.com/repos/laravel/framework/zipball/b8cb8998701d5b3cfe68539d3c3da1fc59ddd82b",
2915
+                "reference": "b8cb8998701d5b3cfe68539d3c3da1fc59ddd82b",
2916
                 "shasum": ""
2916
                 "shasum": ""
2917
             },
2917
             },
2918
             "require": {
2918
             "require": {
2931
                 "fruitcake/php-cors": "^1.3",
2931
                 "fruitcake/php-cors": "^1.3",
2932
                 "guzzlehttp/guzzle": "^7.8",
2932
                 "guzzlehttp/guzzle": "^7.8",
2933
                 "guzzlehttp/uri-template": "^1.0",
2933
                 "guzzlehttp/uri-template": "^1.0",
2934
-                "laravel/prompts": "^0.1.18|^0.2.0",
2934
+                "laravel/prompts": "^0.1.18|^0.2.0|^0.3.0",
2935
                 "laravel/serializable-closure": "^1.3",
2935
                 "laravel/serializable-closure": "^1.3",
2936
                 "league/commonmark": "^2.2.1",
2936
                 "league/commonmark": "^2.2.1",
2937
                 "league/flysystem": "^3.8.0",
2937
                 "league/flysystem": "^3.8.0",
3108
                 "issues": "https://github.com/laravel/framework/issues",
3108
                 "issues": "https://github.com/laravel/framework/issues",
3109
                 "source": "https://github.com/laravel/framework"
3109
                 "source": "https://github.com/laravel/framework"
3110
             },
3110
             },
3111
-            "time": "2024-09-26T11:21:58+00:00"
3111
+            "time": "2024-10-01T14:29:34+00:00"
3112
         },
3112
         },
3113
         {
3113
         {
3114
             "name": "laravel/prompts",
3114
             "name": "laravel/prompts",
3170
         },
3170
         },
3171
         {
3171
         {
3172
             "name": "laravel/sanctum",
3172
             "name": "laravel/sanctum",
3173
-            "version": "v4.0.2",
3173
+            "version": "v4.0.3",
3174
             "source": {
3174
             "source": {
3175
                 "type": "git",
3175
                 "type": "git",
3176
                 "url": "https://github.com/laravel/sanctum.git",
3176
                 "url": "https://github.com/laravel/sanctum.git",
3177
-                "reference": "9cfc0ce80cabad5334efff73ec856339e8ec1ac1"
3177
+                "reference": "54aea9d13743ae8a6cdd3c28dbef128a17adecab"
3178
             },
3178
             },
3179
             "dist": {
3179
             "dist": {
3180
                 "type": "zip",
3180
                 "type": "zip",
3181
-                "url": "https://api.github.com/repos/laravel/sanctum/zipball/9cfc0ce80cabad5334efff73ec856339e8ec1ac1",
3182
-                "reference": "9cfc0ce80cabad5334efff73ec856339e8ec1ac1",
3181
+                "url": "https://api.github.com/repos/laravel/sanctum/zipball/54aea9d13743ae8a6cdd3c28dbef128a17adecab",
3182
+                "reference": "54aea9d13743ae8a6cdd3c28dbef128a17adecab",
3183
                 "shasum": ""
3183
                 "shasum": ""
3184
             },
3184
             },
3185
             "require": {
3185
             "require": {
3230
                 "issues": "https://github.com/laravel/sanctum/issues",
3230
                 "issues": "https://github.com/laravel/sanctum/issues",
3231
                 "source": "https://github.com/laravel/sanctum"
3231
                 "source": "https://github.com/laravel/sanctum"
3232
             },
3232
             },
3233
-            "time": "2024-04-10T19:39:58+00:00"
3233
+            "time": "2024-09-27T14:55:41+00:00"
3234
         },
3234
         },
3235
         {
3235
         {
3236
             "name": "laravel/serializable-closure",
3236
             "name": "laravel/serializable-closure",
4686
         },
4686
         },
4687
         {
4687
         {
4688
             "name": "nette/schema",
4688
             "name": "nette/schema",
4689
-            "version": "v1.3.0",
4689
+            "version": "v1.3.1",
4690
             "source": {
4690
             "source": {
4691
                 "type": "git",
4691
                 "type": "git",
4692
                 "url": "https://github.com/nette/schema.git",
4692
                 "url": "https://github.com/nette/schema.git",
4693
-                "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188"
4693
+                "reference": "9522dad6211c4d995a01a9ac529da88d0b0ba7b5"
4694
             },
4694
             },
4695
             "dist": {
4695
             "dist": {
4696
                 "type": "zip",
4696
                 "type": "zip",
4697
-                "url": "https://api.github.com/repos/nette/schema/zipball/a6d3a6d1f545f01ef38e60f375d1cf1f4de98188",
4698
-                "reference": "a6d3a6d1f545f01ef38e60f375d1cf1f4de98188",
4697
+                "url": "https://api.github.com/repos/nette/schema/zipball/9522dad6211c4d995a01a9ac529da88d0b0ba7b5",
4698
+                "reference": "9522dad6211c4d995a01a9ac529da88d0b0ba7b5",
4699
                 "shasum": ""
4699
                 "shasum": ""
4700
             },
4700
             },
4701
             "require": {
4701
             "require": {
4702
                 "nette/utils": "^4.0",
4702
                 "nette/utils": "^4.0",
4703
-                "php": "8.1 - 8.3"
4703
+                "php": "8.1 - 8.4"
4704
             },
4704
             },
4705
             "require-dev": {
4705
             "require-dev": {
4706
-                "nette/tester": "^2.4",
4706
+                "nette/tester": "^2.5.2",
4707
                 "phpstan/phpstan-nette": "^1.0",
4707
                 "phpstan/phpstan-nette": "^1.0",
4708
                 "tracy/tracy": "^2.8"
4708
                 "tracy/tracy": "^2.8"
4709
             },
4709
             },
4742
             ],
4742
             ],
4743
             "support": {
4743
             "support": {
4744
                 "issues": "https://github.com/nette/schema/issues",
4744
                 "issues": "https://github.com/nette/schema/issues",
4745
-                "source": "https://github.com/nette/schema/tree/v1.3.0"
4745
+                "source": "https://github.com/nette/schema/tree/v1.3.1"
4746
             },
4746
             },
4747
-            "time": "2023-12-11T11:54:22+00:00"
4747
+            "time": "2024-10-05T03:01:50+00:00"
4748
         },
4748
         },
4749
         {
4749
         {
4750
             "name": "nette/utils",
4750
             "name": "nette/utils",
9154
     "packages-dev": [
9154
     "packages-dev": [
9155
         {
9155
         {
9156
             "name": "brianium/paratest",
9156
             "name": "brianium/paratest",
9157
-            "version": "v7.5.5",
9157
+            "version": "v7.5.6",
9158
             "source": {
9158
             "source": {
9159
                 "type": "git",
9159
                 "type": "git",
9160
                 "url": "https://github.com/paratestphp/paratest.git",
9160
                 "url": "https://github.com/paratestphp/paratest.git",
9161
-                "reference": "f29c7d671afc5c4e1140bd7b9f2749e827902a1e"
9161
+                "reference": "8134d62d5b6f98b145f00db1421f39eb1fd0687b"
9162
             },
9162
             },
9163
             "dist": {
9163
             "dist": {
9164
                 "type": "zip",
9164
                 "type": "zip",
9165
-                "url": "https://api.github.com/repos/paratestphp/paratest/zipball/f29c7d671afc5c4e1140bd7b9f2749e827902a1e",
9166
-                "reference": "f29c7d671afc5c4e1140bd7b9f2749e827902a1e",
9165
+                "url": "https://api.github.com/repos/paratestphp/paratest/zipball/8134d62d5b6f98b145f00db1421f39eb1fd0687b",
9166
+                "reference": "8134d62d5b6f98b145f00db1421f39eb1fd0687b",
9167
                 "shasum": ""
9167
                 "shasum": ""
9168
             },
9168
             },
9169
             "require": {
9169
             "require": {
9187
                 "ext-pcov": "*",
9187
                 "ext-pcov": "*",
9188
                 "ext-posix": "*",
9188
                 "ext-posix": "*",
9189
                 "infection/infection": "^0.29.6",
9189
                 "infection/infection": "^0.29.6",
9190
-                "phpstan/phpstan": "^1.12.4",
9190
+                "phpstan/phpstan": "^1.12.5",
9191
                 "phpstan/phpstan-deprecation-rules": "^1.2.1",
9191
                 "phpstan/phpstan-deprecation-rules": "^1.2.1",
9192
                 "phpstan/phpstan-phpunit": "^1.4.0",
9192
                 "phpstan/phpstan-phpunit": "^1.4.0",
9193
-                "phpstan/phpstan-strict-rules": "^1.6.0",
9193
+                "phpstan/phpstan-strict-rules": "^1.6.1",
9194
                 "squizlabs/php_codesniffer": "^3.10.3",
9194
                 "squizlabs/php_codesniffer": "^3.10.3",
9195
                 "symfony/filesystem": "^6.4.9 || ^7.1.2"
9195
                 "symfony/filesystem": "^6.4.9 || ^7.1.2"
9196
             },
9196
             },
9232
             ],
9232
             ],
9233
             "support": {
9233
             "support": {
9234
                 "issues": "https://github.com/paratestphp/paratest/issues",
9234
                 "issues": "https://github.com/paratestphp/paratest/issues",
9235
-                "source": "https://github.com/paratestphp/paratest/tree/v7.5.5"
9235
+                "source": "https://github.com/paratestphp/paratest/tree/v7.5.6"
9236
             },
9236
             },
9237
             "funding": [
9237
             "funding": [
9238
                 {
9238
                 {
9244
                     "type": "paypal"
9244
                     "type": "paypal"
9245
                 }
9245
                 }
9246
             ],
9246
             ],
9247
-            "time": "2024-09-20T12:57:46+00:00"
9247
+            "time": "2024-10-02T05:22:28+00:00"
9248
         },
9248
         },
9249
         {
9249
         {
9250
             "name": "fakerphp/faker",
9250
             "name": "fakerphp/faker",
9619
         },
9619
         },
9620
         {
9620
         {
9621
             "name": "laravel/sail",
9621
             "name": "laravel/sail",
9622
-            "version": "v1.33.0",
9622
+            "version": "v1.34.0",
9623
             "source": {
9623
             "source": {
9624
                 "type": "git",
9624
                 "type": "git",
9625
                 "url": "https://github.com/laravel/sail.git",
9625
                 "url": "https://github.com/laravel/sail.git",
9626
-                "reference": "d54af9d5745e3680d8a6463ffd9f314aa53eb2d1"
9626
+                "reference": "511e9c95b0f3ee778dc9e11e242bcd2af8e002cd"
9627
             },
9627
             },
9628
             "dist": {
9628
             "dist": {
9629
                 "type": "zip",
9629
                 "type": "zip",
9630
-                "url": "https://api.github.com/repos/laravel/sail/zipball/d54af9d5745e3680d8a6463ffd9f314aa53eb2d1",
9631
-                "reference": "d54af9d5745e3680d8a6463ffd9f314aa53eb2d1",
9630
+                "url": "https://api.github.com/repos/laravel/sail/zipball/511e9c95b0f3ee778dc9e11e242bcd2af8e002cd",
9631
+                "reference": "511e9c95b0f3ee778dc9e11e242bcd2af8e002cd",
9632
                 "shasum": ""
9632
                 "shasum": ""
9633
             },
9633
             },
9634
             "require": {
9634
             "require": {
9678
                 "issues": "https://github.com/laravel/sail/issues",
9678
                 "issues": "https://github.com/laravel/sail/issues",
9679
                 "source": "https://github.com/laravel/sail"
9679
                 "source": "https://github.com/laravel/sail"
9680
             },
9680
             },
9681
-            "time": "2024-09-22T19:04:21+00:00"
9681
+            "time": "2024-09-27T14:58:09+00:00"
9682
         },
9682
         },
9683
         {
9683
         {
9684
             "name": "mockery/mockery",
9684
             "name": "mockery/mockery",
9922
         },
9922
         },
9923
         {
9923
         {
9924
             "name": "pestphp/pest",
9924
             "name": "pestphp/pest",
9925
-            "version": "v3.2.4",
9925
+            "version": "v3.2.5",
9926
             "source": {
9926
             "source": {
9927
                 "type": "git",
9927
                 "type": "git",
9928
                 "url": "https://github.com/pestphp/pest.git",
9928
                 "url": "https://github.com/pestphp/pest.git",
9929
-                "reference": "5fe79d9c18a674e9cce2f36f365516c26ae87b49"
9929
+                "reference": "1e0bb88b734b3b5999a38fa479683c5dc3ee6f2f"
9930
             },
9930
             },
9931
             "dist": {
9931
             "dist": {
9932
                 "type": "zip",
9932
                 "type": "zip",
9933
-                "url": "https://api.github.com/repos/pestphp/pest/zipball/5fe79d9c18a674e9cce2f36f365516c26ae87b49",
9934
-                "reference": "5fe79d9c18a674e9cce2f36f365516c26ae87b49",
9933
+                "url": "https://api.github.com/repos/pestphp/pest/zipball/1e0bb88b734b3b5999a38fa479683c5dc3ee6f2f",
9934
+                "reference": "1e0bb88b734b3b5999a38fa479683c5dc3ee6f2f",
9935
                 "shasum": ""
9935
                 "shasum": ""
9936
             },
9936
             },
9937
             "require": {
9937
             "require": {
9951
             },
9951
             },
9952
             "require-dev": {
9952
             "require-dev": {
9953
                 "pestphp/pest-dev-tools": "^3.0.0",
9953
                 "pestphp/pest-dev-tools": "^3.0.0",
9954
-                "pestphp/pest-plugin-type-coverage": "^3.0.0",
9954
+                "pestphp/pest-plugin-type-coverage": "^3.0.1",
9955
                 "symfony/process": "^7.1.5"
9955
                 "symfony/process": "^7.1.5"
9956
             },
9956
             },
9957
             "bin": [
9957
             "bin": [
10017
             ],
10017
             ],
10018
             "support": {
10018
             "support": {
10019
                 "issues": "https://github.com/pestphp/pest/issues",
10019
                 "issues": "https://github.com/pestphp/pest/issues",
10020
-                "source": "https://github.com/pestphp/pest/tree/v3.2.4"
10020
+                "source": "https://github.com/pestphp/pest/tree/v3.2.5"
10021
             },
10021
             },
10022
             "funding": [
10022
             "funding": [
10023
                 {
10023
                 {
10029
                     "type": "github"
10029
                     "type": "github"
10030
                 }
10030
                 }
10031
             ],
10031
             ],
10032
-            "time": "2024-09-26T22:53:39+00:00"
10032
+            "time": "2024-10-01T10:55:18+00:00"
10033
         },
10033
         },
10034
         {
10034
         {
10035
             "name": "pestphp/pest-plugin",
10035
             "name": "pestphp/pest-plugin",
11260
         },
11260
         },
11261
         {
11261
         {
11262
             "name": "rector/rector",
11262
             "name": "rector/rector",
11263
-            "version": "1.2.5",
11263
+            "version": "1.2.6",
11264
             "source": {
11264
             "source": {
11265
                 "type": "git",
11265
                 "type": "git",
11266
                 "url": "https://github.com/rectorphp/rector.git",
11266
                 "url": "https://github.com/rectorphp/rector.git",
11267
-                "reference": "e98aa793ca3fcd17e893cfaf9103ac049775d339"
11267
+                "reference": "6ca85da28159dbd3bb36211c5104b7bc91278e99"
11268
             },
11268
             },
11269
             "dist": {
11269
             "dist": {
11270
                 "type": "zip",
11270
                 "type": "zip",
11271
-                "url": "https://api.github.com/repos/rectorphp/rector/zipball/e98aa793ca3fcd17e893cfaf9103ac049775d339",
11272
-                "reference": "e98aa793ca3fcd17e893cfaf9103ac049775d339",
11271
+                "url": "https://api.github.com/repos/rectorphp/rector/zipball/6ca85da28159dbd3bb36211c5104b7bc91278e99",
11272
+                "reference": "6ca85da28159dbd3bb36211c5104b7bc91278e99",
11273
                 "shasum": ""
11273
                 "shasum": ""
11274
             },
11274
             },
11275
             "require": {
11275
             "require": {
11276
                 "php": "^7.2|^8.0",
11276
                 "php": "^7.2|^8.0",
11277
-                "phpstan/phpstan": "^1.12.2"
11277
+                "phpstan/phpstan": "^1.12.5"
11278
             },
11278
             },
11279
             "conflict": {
11279
             "conflict": {
11280
                 "rector/rector-doctrine": "*",
11280
                 "rector/rector-doctrine": "*",
11307
             ],
11307
             ],
11308
             "support": {
11308
             "support": {
11309
                 "issues": "https://github.com/rectorphp/rector/issues",
11309
                 "issues": "https://github.com/rectorphp/rector/issues",
11310
-                "source": "https://github.com/rectorphp/rector/tree/1.2.5"
11310
+                "source": "https://github.com/rectorphp/rector/tree/1.2.6"
11311
             },
11311
             },
11312
             "funding": [
11312
             "funding": [
11313
                 {
11313
                 {
11315
                     "type": "github"
11315
                     "type": "github"
11316
                 }
11316
                 }
11317
             ],
11317
             ],
11318
-            "time": "2024-09-08T17:43:24+00:00"
11318
+            "time": "2024-10-03T08:56:44+00:00"
11319
         },
11319
         },
11320
         {
11320
         {
11321
             "name": "sebastian/cli-parser",
11321
             "name": "sebastian/cli-parser",

+ 0
- 11
database/factories/Accounting/TransactionFactory.php 查看文件

9
 use App\Models\Banking\BankAccount;
9
 use App\Models\Banking\BankAccount;
10
 use App\Models\Company;
10
 use App\Models\Company;
11
 use App\Models\Setting\CompanyDefault;
11
 use App\Models\Setting\CompanyDefault;
12
-use App\Services\TransactionService;
13
 use Illuminate\Database\Eloquent\Factories\Factory;
12
 use Illuminate\Database\Eloquent\Factories\Factory;
14
-use Illuminate\Support\Facades\DB;
15
 
13
 
16
 /**
14
 /**
17
  * @extends Factory<Transaction>
15
  * @extends Factory<Transaction>
45
         ];
43
         ];
46
     }
44
     }
47
 
45
 
48
-    public function configure(): static
49
-    {
50
-        return $this->afterCreating(function (Transaction $transaction) {
51
-            if (DB::getDefaultConnection() === 'sqlite') {
52
-                app(TransactionService::class)->createJournalEntries($transaction);
53
-            }
54
-        });
55
-    }
56
-
57
     public function forCompanyAndBankAccount(Company $company, BankAccount $bankAccount): static
46
     public function forCompanyAndBankAccount(Company $company, BankAccount $bankAccount): static
58
     {
47
     {
59
         return $this->state(function (array $attributes) use ($bankAccount, $company) {
48
         return $this->state(function (array $attributes) use ($bankAccount, $company) {

+ 7
- 10
database/factories/CompanyFactory.php 查看文件

2
 
2
 
3
 namespace Database\Factories;
3
 namespace Database\Factories;
4
 
4
 
5
+use App\Models\Accounting\Transaction;
5
 use App\Models\Company;
6
 use App\Models\Company;
6
 use App\Models\Setting\CompanyProfile;
7
 use App\Models\Setting\CompanyProfile;
7
 use App\Models\User;
8
 use App\Models\User;
8
 use App\Services\CompanyDefaultService;
9
 use App\Services\CompanyDefaultService;
9
-use Database\Factories\Accounting\TransactionFactory;
10
 use Illuminate\Database\Eloquent\Factories\Factory;
10
 use Illuminate\Database\Eloquent\Factories\Factory;
11
-use Illuminate\Support\Facades\DB;
12
 
11
 
13
 class CompanyFactory extends Factory
12
 class CompanyFactory extends Factory
14
 {
13
 {
36
     public function withCompanyProfile(): self
35
     public function withCompanyProfile(): self
37
     {
36
     {
38
         return $this->afterCreating(function (Company $company) {
37
         return $this->afterCreating(function (Company $company) {
39
-            CompanyProfile::factory()->forCompany($company)->create();
38
+            CompanyProfile::factory()->forCompany($company)->withCountry('US')->create();
40
         });
39
         });
41
     }
40
     }
42
 
41
 
46
     public function withCompanyDefaults(): self
45
     public function withCompanyDefaults(): self
47
     {
46
     {
48
         return $this->afterCreating(function (Company $company) {
47
         return $this->afterCreating(function (Company $company) {
49
-            DB::transaction(function () use ($company) {
50
-                $countryCode = $company->profile->country;
51
-                $companyDefaultService = app(CompanyDefaultService::class);
52
-                $companyDefaultService->createCompanyDefaults($company, $company->owner, 'USD', $countryCode, 'en');
53
-            });
48
+            $countryCode = $company->profile->country;
49
+            $companyDefaultService = app(CompanyDefaultService::class);
50
+            $companyDefaultService->createCompanyDefaults($company, $company->owner, 'USD', $countryCode, 'en');
54
         });
51
         });
55
     }
52
     }
56
 
53
 
59
         return $this->afterCreating(function (Company $company) use ($count) {
56
         return $this->afterCreating(function (Company $company) use ($count) {
60
             $defaultBankAccount = $company->default->bankAccount;
57
             $defaultBankAccount = $company->default->bankAccount;
61
 
58
 
62
-            TransactionFactory::new()
59
+            Transaction::factory()
63
                 ->forCompanyAndBankAccount($company, $defaultBankAccount)
60
                 ->forCompanyAndBankAccount($company, $defaultBankAccount)
64
                 ->count($count)
61
                 ->count($count)
65
-                ->createQuietly([
62
+                ->create([
66
                     'created_by' => $company->user_id,
63
                     'created_by' => $company->user_id,
67
                     'updated_by' => $company->user_id,
64
                     'updated_by' => $company->user_id,
68
                 ]);
65
                 ]);

+ 9
- 9
database/factories/Setting/CompanyDefaultFactory.php 查看文件

70
 
70
 
71
     private function createCurrency(Company $company, User $user, string $currencyCode): Currency
71
     private function createCurrency(Company $company, User $user, string $currencyCode): Currency
72
     {
72
     {
73
-        return Currency::factory()->forCurrency($currencyCode)->create([
73
+        return Currency::factory()->forCurrency($currencyCode)->createQuietly([
74
             'company_id' => $company->id,
74
             'company_id' => $company->id,
75
             'created_by' => $user->id,
75
             'created_by' => $user->id,
76
             'updated_by' => $user->id,
76
             'updated_by' => $user->id,
79
 
79
 
80
     private function createSalesTax(Company $company, User $user): Tax
80
     private function createSalesTax(Company $company, User $user): Tax
81
     {
81
     {
82
-        return Tax::factory()->salesTax()->create([
82
+        return Tax::factory()->salesTax()->createQuietly([
83
             'company_id' => $company->id,
83
             'company_id' => $company->id,
84
             'created_by' => $user->id,
84
             'created_by' => $user->id,
85
             'updated_by' => $user->id,
85
             'updated_by' => $user->id,
88
 
88
 
89
     private function createPurchaseTax(Company $company, User $user): Tax
89
     private function createPurchaseTax(Company $company, User $user): Tax
90
     {
90
     {
91
-        return Tax::factory()->purchaseTax()->create([
91
+        return Tax::factory()->purchaseTax()->createQuietly([
92
             'company_id' => $company->id,
92
             'company_id' => $company->id,
93
             'created_by' => $user->id,
93
             'created_by' => $user->id,
94
             'updated_by' => $user->id,
94
             'updated_by' => $user->id,
97
 
97
 
98
     private function createSalesDiscount(Company $company, User $user): Discount
98
     private function createSalesDiscount(Company $company, User $user): Discount
99
     {
99
     {
100
-        return Discount::factory()->salesDiscount()->create([
100
+        return Discount::factory()->salesDiscount()->createQuietly([
101
             'company_id' => $company->id,
101
             'company_id' => $company->id,
102
             'created_by' => $user->id,
102
             'created_by' => $user->id,
103
             'updated_by' => $user->id,
103
             'updated_by' => $user->id,
106
 
106
 
107
     private function createPurchaseDiscount(Company $company, User $user): Discount
107
     private function createPurchaseDiscount(Company $company, User $user): Discount
108
     {
108
     {
109
-        return Discount::factory()->purchaseDiscount()->create([
109
+        return Discount::factory()->purchaseDiscount()->createQuietly([
110
             'company_id' => $company->id,
110
             'company_id' => $company->id,
111
             'created_by' => $user->id,
111
             'created_by' => $user->id,
112
             'updated_by' => $user->id,
112
             'updated_by' => $user->id,
115
 
115
 
116
     private function createAppearance(Company $company, User $user): void
116
     private function createAppearance(Company $company, User $user): void
117
     {
117
     {
118
-        Appearance::factory()->create([
118
+        Appearance::factory()->createQuietly([
119
             'company_id' => $company->id,
119
             'company_id' => $company->id,
120
             'created_by' => $user->id,
120
             'created_by' => $user->id,
121
             'updated_by' => $user->id,
121
             'updated_by' => $user->id,
124
 
124
 
125
     private function createDocumentDefaults(Company $company, User $user): void
125
     private function createDocumentDefaults(Company $company, User $user): void
126
     {
126
     {
127
-        DocumentDefault::factory()->invoice()->create([
127
+        DocumentDefault::factory()->invoice()->createQuietly([
128
             'company_id' => $company->id,
128
             'company_id' => $company->id,
129
             'created_by' => $user->id,
129
             'created_by' => $user->id,
130
             'updated_by' => $user->id,
130
             'updated_by' => $user->id,
131
         ]);
131
         ]);
132
 
132
 
133
-        DocumentDefault::factory()->bill()->create([
133
+        DocumentDefault::factory()->bill()->createQuietly([
134
             'company_id' => $company->id,
134
             'company_id' => $company->id,
135
             'created_by' => $user->id,
135
             'created_by' => $user->id,
136
             'updated_by' => $user->id,
136
             'updated_by' => $user->id,
139
 
139
 
140
     private function createLocalization(Company $company, User $user, string $countryCode, string $language): void
140
     private function createLocalization(Company $company, User $user, string $countryCode, string $language): void
141
     {
141
     {
142
-        Localization::factory()->withCountry($countryCode, $language)->create([
142
+        Localization::factory()->withCountry($countryCode, $language)->createQuietly([
143
             'company_id' => $company->id,
143
             'company_id' => $company->id,
144
             'created_by' => $user->id,
144
             'created_by' => $user->id,
145
             'updated_by' => $user->id,
145
             'updated_by' => $user->id,

+ 15
- 6
database/factories/Setting/DiscountFactory.php 查看文件

7
 use App\Enums\Setting\DiscountType;
7
 use App\Enums\Setting\DiscountType;
8
 use App\Models\Setting\Discount;
8
 use App\Models\Setting\Discount;
9
 use Illuminate\Database\Eloquent\Factories\Factory;
9
 use Illuminate\Database\Eloquent\Factories\Factory;
10
+use Illuminate\Support\Carbon;
10
 
11
 
11
 /**
12
 /**
12
  * @extends Factory<Discount>
13
  * @extends Factory<Discount>
26
     public function definition(): array
27
     public function definition(): array
27
     {
28
     {
28
         $startDate = $this->faker->dateTimeBetween('now', '+1 year');
29
         $startDate = $this->faker->dateTimeBetween('now', '+1 year');
29
-        $endDate = $this->faker->dateTimeBetween($startDate, strtotime('+1 year'));
30
+        $endDate = $this->faker->dateTimeBetween($startDate, Carbon::parse($startDate)->addYear());
31
+
32
+        $computation = $this->faker->randomElement(DiscountComputation::class);
33
+
34
+        if ($computation === DiscountComputation::Fixed) {
35
+            $rate = $this->faker->numberBetween(5, 100) * 100; // $5 - $100
36
+        } else {
37
+            $rate = $this->faker->numberBetween(3, 50) * 10000; // 3% - 50%
38
+        }
30
 
39
 
31
         return [
40
         return [
41
+            'name' => $this->faker->unique()->word,
32
             'description' => $this->faker->sentence,
42
             'description' => $this->faker->sentence,
33
-            'rate' => $this->faker->biasedNumberBetween(300, 5000) * 100, // 3% - 50%
34
-            'computation' => $this->faker->randomElement(DiscountComputation::class),
43
+            'rate' => $rate,
44
+            'computation' => $computation,
45
+            'type' => $this->faker->randomElement(DiscountType::class),
35
             'scope' => $this->faker->randomElement(DiscountScope::class),
46
             'scope' => $this->faker->randomElement(DiscountScope::class),
36
             'start_date' => $startDate,
47
             'start_date' => $startDate,
37
             'end_date' => $endDate,
48
             'end_date' => $endDate,
38
-            'enabled' => true,
49
+            'enabled' => false,
39
         ];
50
         ];
40
     }
51
     }
41
 
52
 
43
     {
54
     {
44
         return $this->state([
55
         return $this->state([
45
             'name' => 'Summer Sale',
56
             'name' => 'Summer Sale',
46
-            'rate' => $this->faker->biasedNumberBetween(300, 1200) * 100, // 3% - 12%
47
             'type' => DiscountType::Sales,
57
             'type' => DiscountType::Sales,
48
         ]);
58
         ]);
49
     }
59
     }
52
     {
62
     {
53
         return $this->state([
63
         return $this->state([
54
             'name' => 'Bulk Purchase',
64
             'name' => 'Bulk Purchase',
55
-            'rate' => $this->faker->biasedNumberBetween(300, 1200) * 100, // 3% - 12%
56
             'type' => DiscountType::Purchase,
65
             'type' => DiscountType::Purchase,
57
         ]);
66
         ]);
58
     }
67
     }

+ 13
- 5
database/factories/Setting/TaxFactory.php 查看文件

25
      */
25
      */
26
     public function definition(): array
26
     public function definition(): array
27
     {
27
     {
28
+        $computation = $this->faker->randomElement(TaxComputation::class);
29
+
30
+        if ($computation === TaxComputation::Fixed) {
31
+            $rate = $this->faker->biasedNumberBetween(1, 10) * 100; // $1 - $10
32
+        } else {
33
+            $rate = $this->faker->biasedNumberBetween(3, 25) * 10000; // 3% - 25%
34
+        }
35
+
28
         return [
36
         return [
37
+            'name' => $this->faker->unique()->word,
29
             'description' => $this->faker->sentence,
38
             'description' => $this->faker->sentence,
30
-            'rate' => $this->faker->biasedNumberBetween(300, 5000) * 100, // 3% - 50%
31
-            'computation' => $this->faker->randomElement(TaxComputation::class),
39
+            'rate' => $rate,
40
+            'computation' => $computation,
41
+            'type' => $this->faker->randomElement(TaxType::class),
32
             'scope' => $this->faker->randomElement(TaxScope::class),
42
             'scope' => $this->faker->randomElement(TaxScope::class),
33
-            'enabled' => true,
43
+            'enabled' => false,
34
         ];
44
         ];
35
     }
45
     }
36
 
46
 
38
     {
48
     {
39
         return $this->state([
49
         return $this->state([
40
             'name' => 'State Sales Tax',
50
             'name' => 'State Sales Tax',
41
-            'rate' => $this->faker->biasedNumberBetween(300, 1200) * 100, // 3% - 12%
42
             'type' => TaxType::Sales,
51
             'type' => TaxType::Sales,
43
         ]);
52
         ]);
44
     }
53
     }
47
     {
56
     {
48
         return $this->state([
57
         return $this->state([
49
             'name' => 'State Purchase Tax',
58
             'name' => 'State Purchase Tax',
50
-            'rate' => $this->faker->biasedNumberBetween(300, 1200) * 100, // 3% - 12%
51
             'type' => TaxType::Purchase,
59
             'type' => TaxType::Purchase,
52
         ]);
60
         ]);
53
     }
61
     }

+ 6
- 9
database/seeders/DatabaseSeeder.php 查看文件

14
     public function run(): void
14
     public function run(): void
15
     {
15
     {
16
         // Create a single admin user and their personal company
16
         // Create a single admin user and their personal company
17
-        $adminUser = User::factory()
17
+        User::factory()
18
             ->withPersonalCompany(function (CompanyFactory $factory) {
18
             ->withPersonalCompany(function (CompanyFactory $factory) {
19
-                return $factory->withTransactions();
19
+                return $factory
20
+                    ->state([
21
+                        'name' => 'ERPSAAS',
22
+                    ])
23
+                    ->withTransactions();
20
             })
24
             })
21
             ->create([
25
             ->create([
22
                 'name' => 'Admin',
26
                 'name' => 'Admin',
23
                 'email' => 'admin@gmail.com',
27
                 'email' => 'admin@gmail.com',
24
                 'password' => bcrypt('password'),
28
                 'password' => bcrypt('password'),
25
                 'current_company_id' => 1,  // Assuming this will be the ID of the created company
29
                 'current_company_id' => 1,  // Assuming this will be the ID of the created company
26
-                'created_at' => now(),
27
             ]);
30
             ]);
28
-
29
-        // Optionally, set additional properties or create related entities specific to this company
30
-        $adminUser->ownedCompanies->first()->update([
31
-            'name' => 'ERPSAAS',
32
-            'created_at' => now(),
33
-        ]);
34
     }
31
     }
35
 }
32
 }

+ 4
- 1
database/seeders/TestDatabaseSeeder.php 查看文件

3
 namespace Database\Seeders;
3
 namespace Database\Seeders;
4
 
4
 
5
 use App\Models\User;
5
 use App\Models\User;
6
+use Illuminate\Database\Console\Seeds\WithoutModelEvents;
6
 use Illuminate\Database\Seeder;
7
 use Illuminate\Database\Seeder;
7
 
8
 
8
 class TestDatabaseSeeder extends Seeder
9
 class TestDatabaseSeeder extends Seeder
9
 {
10
 {
11
+    use WithoutModelEvents;
12
+
10
     public function run(): void
13
     public function run(): void
11
     {
14
     {
12
         User::factory()
15
         User::factory()
13
             ->withPersonalCompany()
16
             ->withPersonalCompany()
14
-            ->createQuietly([
17
+            ->create([
15
                 'name' => 'Test Company Owner',
18
                 'name' => 'Test Company Owner',
16
                 'email' => 'test@gmail.com',
19
                 'email' => 'test@gmail.com',
17
                 'password' => bcrypt('password'),
20
                 'password' => bcrypt('password'),

+ 73
- 73
package-lock.json 查看文件

541
             }
541
             }
542
         },
542
         },
543
         "node_modules/@rollup/rollup-android-arm-eabi": {
543
         "node_modules/@rollup/rollup-android-arm-eabi": {
544
-            "version": "4.22.5",
545
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.5.tgz",
546
-            "integrity": "sha512-SU5cvamg0Eyu/F+kLeMXS7GoahL+OoizlclVFX3l5Ql6yNlywJJ0OuqTzUx0v+aHhPHEB/56CT06GQrRrGNYww==",
544
+            "version": "4.24.0",
545
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz",
546
+            "integrity": "sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==",
547
             "cpu": [
547
             "cpu": [
548
                 "arm"
548
                 "arm"
549
             ],
549
             ],
555
             ]
555
             ]
556
         },
556
         },
557
         "node_modules/@rollup/rollup-android-arm64": {
557
         "node_modules/@rollup/rollup-android-arm64": {
558
-            "version": "4.22.5",
559
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.5.tgz",
560
-            "integrity": "sha512-S4pit5BP6E5R5C8S6tgU/drvgjtYW76FBuG6+ibG3tMvlD1h9LHVF9KmlmaUBQ8Obou7hEyS+0w+IR/VtxwNMQ==",
558
+            "version": "4.24.0",
559
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz",
560
+            "integrity": "sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==",
561
             "cpu": [
561
             "cpu": [
562
                 "arm64"
562
                 "arm64"
563
             ],
563
             ],
569
             ]
569
             ]
570
         },
570
         },
571
         "node_modules/@rollup/rollup-darwin-arm64": {
571
         "node_modules/@rollup/rollup-darwin-arm64": {
572
-            "version": "4.22.5",
573
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.5.tgz",
574
-            "integrity": "sha512-250ZGg4ipTL0TGvLlfACkIxS9+KLtIbn7BCZjsZj88zSg2Lvu3Xdw6dhAhfe/FjjXPVNCtcSp+WZjVsD3a/Zlw==",
572
+            "version": "4.24.0",
573
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz",
574
+            "integrity": "sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==",
575
             "cpu": [
575
             "cpu": [
576
                 "arm64"
576
                 "arm64"
577
             ],
577
             ],
583
             ]
583
             ]
584
         },
584
         },
585
         "node_modules/@rollup/rollup-darwin-x64": {
585
         "node_modules/@rollup/rollup-darwin-x64": {
586
-            "version": "4.22.5",
587
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.5.tgz",
588
-            "integrity": "sha512-D8brJEFg5D+QxFcW6jYANu+Rr9SlKtTenmsX5hOSzNYVrK5oLAEMTUgKWYJP+wdKyCdeSwnapLsn+OVRFycuQg==",
586
+            "version": "4.24.0",
587
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz",
588
+            "integrity": "sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==",
589
             "cpu": [
589
             "cpu": [
590
                 "x64"
590
                 "x64"
591
             ],
591
             ],
597
             ]
597
             ]
598
         },
598
         },
599
         "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
599
         "node_modules/@rollup/rollup-linux-arm-gnueabihf": {
600
-            "version": "4.22.5",
601
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.5.tgz",
602
-            "integrity": "sha512-PNqXYmdNFyWNg0ma5LdY8wP+eQfdvyaBAojAXgO7/gs0Q/6TQJVXAXe8gwW9URjbS0YAammur0fynYGiWsKlXw==",
600
+            "version": "4.24.0",
601
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz",
602
+            "integrity": "sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==",
603
             "cpu": [
603
             "cpu": [
604
                 "arm"
604
                 "arm"
605
             ],
605
             ],
611
             ]
611
             ]
612
         },
612
         },
613
         "node_modules/@rollup/rollup-linux-arm-musleabihf": {
613
         "node_modules/@rollup/rollup-linux-arm-musleabihf": {
614
-            "version": "4.22.5",
615
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.5.tgz",
616
-            "integrity": "sha512-kSSCZOKz3HqlrEuwKd9TYv7vxPYD77vHSUvM2y0YaTGnFc8AdI5TTQRrM1yIp3tXCKrSL9A7JLoILjtad5t8pQ==",
614
+            "version": "4.24.0",
615
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz",
616
+            "integrity": "sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==",
617
             "cpu": [
617
             "cpu": [
618
                 "arm"
618
                 "arm"
619
             ],
619
             ],
625
             ]
625
             ]
626
         },
626
         },
627
         "node_modules/@rollup/rollup-linux-arm64-gnu": {
627
         "node_modules/@rollup/rollup-linux-arm64-gnu": {
628
-            "version": "4.22.5",
629
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.5.tgz",
630
-            "integrity": "sha512-oTXQeJHRbOnwRnRffb6bmqmUugz0glXaPyspp4gbQOPVApdpRrY/j7KP3lr7M8kTfQTyrBUzFjj5EuHAhqH4/w==",
628
+            "version": "4.24.0",
629
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz",
630
+            "integrity": "sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==",
631
             "cpu": [
631
             "cpu": [
632
                 "arm64"
632
                 "arm64"
633
             ],
633
             ],
639
             ]
639
             ]
640
         },
640
         },
641
         "node_modules/@rollup/rollup-linux-arm64-musl": {
641
         "node_modules/@rollup/rollup-linux-arm64-musl": {
642
-            "version": "4.22.5",
643
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.5.tgz",
644
-            "integrity": "sha512-qnOTIIs6tIGFKCHdhYitgC2XQ2X25InIbZFor5wh+mALH84qnFHvc+vmWUpyX97B0hNvwNUL4B+MB8vJvH65Fw==",
642
+            "version": "4.24.0",
643
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz",
644
+            "integrity": "sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==",
645
             "cpu": [
645
             "cpu": [
646
                 "arm64"
646
                 "arm64"
647
             ],
647
             ],
653
             ]
653
             ]
654
         },
654
         },
655
         "node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
655
         "node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
656
-            "version": "4.22.5",
657
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.5.tgz",
658
-            "integrity": "sha512-TMYu+DUdNlgBXING13rHSfUc3Ky5nLPbWs4bFnT+R6Vu3OvXkTkixvvBKk8uO4MT5Ab6lC3U7x8S8El2q5o56w==",
656
+            "version": "4.24.0",
657
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz",
658
+            "integrity": "sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==",
659
             "cpu": [
659
             "cpu": [
660
                 "ppc64"
660
                 "ppc64"
661
             ],
661
             ],
667
             ]
667
             ]
668
         },
668
         },
669
         "node_modules/@rollup/rollup-linux-riscv64-gnu": {
669
         "node_modules/@rollup/rollup-linux-riscv64-gnu": {
670
-            "version": "4.22.5",
671
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.5.tgz",
672
-            "integrity": "sha512-PTQq1Kz22ZRvuhr3uURH+U/Q/a0pbxJoICGSprNLAoBEkyD3Sh9qP5I0Asn0y0wejXQBbsVMRZRxlbGFD9OK4A==",
670
+            "version": "4.24.0",
671
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz",
672
+            "integrity": "sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==",
673
             "cpu": [
673
             "cpu": [
674
                 "riscv64"
674
                 "riscv64"
675
             ],
675
             ],
681
             ]
681
             ]
682
         },
682
         },
683
         "node_modules/@rollup/rollup-linux-s390x-gnu": {
683
         "node_modules/@rollup/rollup-linux-s390x-gnu": {
684
-            "version": "4.22.5",
685
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.5.tgz",
686
-            "integrity": "sha512-bR5nCojtpuMss6TDEmf/jnBnzlo+6n1UhgwqUvRoe4VIotC7FG1IKkyJbwsT7JDsF2jxR+NTnuOwiGv0hLyDoQ==",
684
+            "version": "4.24.0",
685
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz",
686
+            "integrity": "sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==",
687
             "cpu": [
687
             "cpu": [
688
                 "s390x"
688
                 "s390x"
689
             ],
689
             ],
695
             ]
695
             ]
696
         },
696
         },
697
         "node_modules/@rollup/rollup-linux-x64-gnu": {
697
         "node_modules/@rollup/rollup-linux-x64-gnu": {
698
-            "version": "4.22.5",
699
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.5.tgz",
700
-            "integrity": "sha512-N0jPPhHjGShcB9/XXZQWuWBKZQnC1F36Ce3sDqWpujsGjDz/CQtOL9LgTrJ+rJC8MJeesMWrMWVLKKNR/tMOCA==",
698
+            "version": "4.24.0",
699
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz",
700
+            "integrity": "sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==",
701
             "cpu": [
701
             "cpu": [
702
                 "x64"
702
                 "x64"
703
             ],
703
             ],
709
             ]
709
             ]
710
         },
710
         },
711
         "node_modules/@rollup/rollup-linux-x64-musl": {
711
         "node_modules/@rollup/rollup-linux-x64-musl": {
712
-            "version": "4.22.5",
713
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.5.tgz",
714
-            "integrity": "sha512-uBa2e28ohzNNwjr6Uxm4XyaA1M/8aTgfF2T7UIlElLaeXkgpmIJ2EitVNQxjO9xLLLy60YqAgKn/AqSpCUkE9g==",
712
+            "version": "4.24.0",
713
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz",
714
+            "integrity": "sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==",
715
             "cpu": [
715
             "cpu": [
716
                 "x64"
716
                 "x64"
717
             ],
717
             ],
723
             ]
723
             ]
724
         },
724
         },
725
         "node_modules/@rollup/rollup-win32-arm64-msvc": {
725
         "node_modules/@rollup/rollup-win32-arm64-msvc": {
726
-            "version": "4.22.5",
727
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.5.tgz",
728
-            "integrity": "sha512-RXT8S1HP8AFN/Kr3tg4fuYrNxZ/pZf1HemC5Tsddc6HzgGnJm0+Lh5rAHJkDuW3StI0ynNXukidROMXYl6ew8w==",
726
+            "version": "4.24.0",
727
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz",
728
+            "integrity": "sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==",
729
             "cpu": [
729
             "cpu": [
730
                 "arm64"
730
                 "arm64"
731
             ],
731
             ],
737
             ]
737
             ]
738
         },
738
         },
739
         "node_modules/@rollup/rollup-win32-ia32-msvc": {
739
         "node_modules/@rollup/rollup-win32-ia32-msvc": {
740
-            "version": "4.22.5",
741
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.5.tgz",
742
-            "integrity": "sha512-ElTYOh50InL8kzyUD6XsnPit7jYCKrphmddKAe1/Ytt74apOxDq5YEcbsiKs0fR3vff3jEneMM+3I7jbqaMyBg==",
740
+            "version": "4.24.0",
741
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz",
742
+            "integrity": "sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==",
743
             "cpu": [
743
             "cpu": [
744
                 "ia32"
744
                 "ia32"
745
             ],
745
             ],
751
             ]
751
             ]
752
         },
752
         },
753
         "node_modules/@rollup/rollup-win32-x64-msvc": {
753
         "node_modules/@rollup/rollup-win32-x64-msvc": {
754
-            "version": "4.22.5",
755
-            "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.5.tgz",
756
-            "integrity": "sha512-+lvL/4mQxSV8MukpkKyyvfwhH266COcWlXE/1qxwN08ajovta3459zrjLghYMgDerlzNwLAcFpvU+WWE5y6nAQ==",
754
+            "version": "4.24.0",
755
+            "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz",
756
+            "integrity": "sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==",
757
             "cpu": [
757
             "cpu": [
758
                 "x64"
758
                 "x64"
759
             ],
759
             ],
998
             }
998
             }
999
         },
999
         },
1000
         "node_modules/caniuse-lite": {
1000
         "node_modules/caniuse-lite": {
1001
-            "version": "1.0.30001664",
1002
-            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz",
1003
-            "integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==",
1001
+            "version": "1.0.30001667",
1002
+            "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001667.tgz",
1003
+            "integrity": "sha512-7LTwJjcRkzKFmtqGsibMeuXmvFDfZq/nzIjnmgCGzKKRVzjD72selLDK1oPF/Oxzmt4fNcPvTDvGqSDG4tCALw==",
1004
             "dev": true,
1004
             "dev": true,
1005
             "funding": [
1005
             "funding": [
1006
                 {
1006
                 {
1159
             "license": "MIT"
1159
             "license": "MIT"
1160
         },
1160
         },
1161
         "node_modules/electron-to-chromium": {
1161
         "node_modules/electron-to-chromium": {
1162
-            "version": "1.5.30",
1163
-            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.30.tgz",
1164
-            "integrity": "sha512-sXI35EBN4lYxzc/pIGorlymYNzDBOqkSlVRe6MkgBsW/hW1tpC/HDJ2fjG7XnjakzfLEuvdmux0Mjs6jHq4UOA==",
1162
+            "version": "1.5.32",
1163
+            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.32.tgz",
1164
+            "integrity": "sha512-M+7ph0VGBQqqpTT2YrabjNKSQ2fEl9PVx6AK3N558gDH9NO8O6XN9SXXFWRo9u9PbEg/bWq+tjXQr+eXmxubCw==",
1165
             "dev": true,
1165
             "dev": true,
1166
             "license": "ISC"
1166
             "license": "ISC"
1167
         },
1167
         },
2171
             }
2171
             }
2172
         },
2172
         },
2173
         "node_modules/rollup": {
2173
         "node_modules/rollup": {
2174
-            "version": "4.22.5",
2175
-            "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.5.tgz",
2176
-            "integrity": "sha512-WoinX7GeQOFMGznEcWA1WrTQCd/tpEbMkc3nuMs9BT0CPjMdSjPMTVClwWd4pgSQwJdP65SK9mTCNvItlr5o7w==",
2174
+            "version": "4.24.0",
2175
+            "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.24.0.tgz",
2176
+            "integrity": "sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==",
2177
             "dev": true,
2177
             "dev": true,
2178
             "license": "MIT",
2178
             "license": "MIT",
2179
             "dependencies": {
2179
             "dependencies": {
2187
                 "npm": ">=8.0.0"
2187
                 "npm": ">=8.0.0"
2188
             },
2188
             },
2189
             "optionalDependencies": {
2189
             "optionalDependencies": {
2190
-                "@rollup/rollup-android-arm-eabi": "4.22.5",
2191
-                "@rollup/rollup-android-arm64": "4.22.5",
2192
-                "@rollup/rollup-darwin-arm64": "4.22.5",
2193
-                "@rollup/rollup-darwin-x64": "4.22.5",
2194
-                "@rollup/rollup-linux-arm-gnueabihf": "4.22.5",
2195
-                "@rollup/rollup-linux-arm-musleabihf": "4.22.5",
2196
-                "@rollup/rollup-linux-arm64-gnu": "4.22.5",
2197
-                "@rollup/rollup-linux-arm64-musl": "4.22.5",
2198
-                "@rollup/rollup-linux-powerpc64le-gnu": "4.22.5",
2199
-                "@rollup/rollup-linux-riscv64-gnu": "4.22.5",
2200
-                "@rollup/rollup-linux-s390x-gnu": "4.22.5",
2201
-                "@rollup/rollup-linux-x64-gnu": "4.22.5",
2202
-                "@rollup/rollup-linux-x64-musl": "4.22.5",
2203
-                "@rollup/rollup-win32-arm64-msvc": "4.22.5",
2204
-                "@rollup/rollup-win32-ia32-msvc": "4.22.5",
2205
-                "@rollup/rollup-win32-x64-msvc": "4.22.5",
2190
+                "@rollup/rollup-android-arm-eabi": "4.24.0",
2191
+                "@rollup/rollup-android-arm64": "4.24.0",
2192
+                "@rollup/rollup-darwin-arm64": "4.24.0",
2193
+                "@rollup/rollup-darwin-x64": "4.24.0",
2194
+                "@rollup/rollup-linux-arm-gnueabihf": "4.24.0",
2195
+                "@rollup/rollup-linux-arm-musleabihf": "4.24.0",
2196
+                "@rollup/rollup-linux-arm64-gnu": "4.24.0",
2197
+                "@rollup/rollup-linux-arm64-musl": "4.24.0",
2198
+                "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0",
2199
+                "@rollup/rollup-linux-riscv64-gnu": "4.24.0",
2200
+                "@rollup/rollup-linux-s390x-gnu": "4.24.0",
2201
+                "@rollup/rollup-linux-x64-gnu": "4.24.0",
2202
+                "@rollup/rollup-linux-x64-musl": "4.24.0",
2203
+                "@rollup/rollup-win32-arm64-msvc": "4.24.0",
2204
+                "@rollup/rollup-win32-ia32-msvc": "4.24.0",
2205
+                "@rollup/rollup-win32-x64-msvc": "4.24.0",
2206
                 "fsevents": "~2.3.2"
2206
                 "fsevents": "~2.3.2"
2207
             }
2207
             }
2208
         },
2208
         },

+ 2
- 2
resources/views/components/panel-shift-dropdown.blade.php 查看文件

61
                         <x-panel-shift-dropdown.content-handler :item="$item"/>
61
                         <x-panel-shift-dropdown.content-handler :item="$item"/>
62
                     @endforeach
62
                     @endforeach
63
                 @endif
63
                 @endif
64
-                @if($panelId === 'company-settings')
64
+                @if($panelId === 'company-settings' && $currentTenant)
65
                     <x-panel-shift-dropdown.company-settings :current-tenant="$currentTenant"
65
                     <x-panel-shift-dropdown.company-settings :current-tenant="$currentTenant"
66
                                                              icon="heroicon-m-building-office-2"/>
66
                                                              icon="heroicon-m-building-office-2"/>
67
                 @endif
67
                 @endif
68
-                @if($panelId === 'company-switcher')
68
+                @if($panelId === 'company-switcher' && $currentTenant)
69
                     <x-panel-shift-dropdown.company-switcher :current-tenant="$currentTenant"
69
                     <x-panel-shift-dropdown.company-switcher :current-tenant="$currentTenant"
70
                                                              icon="heroicon-m-adjustments-horizontal"/>
70
                                                              icon="heroicon-m-adjustments-horizontal"/>
71
                 @endif
71
                 @endif

Loading…
取消
儲存