Bläddra i källkod

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

Development 3.x
3.x
Andrew Wallo 5 månader sedan
förälder
incheckning
6b4b004425
Inget konto är kopplat till bidragsgivarens mejladress
45 ändrade filer med 162 tillägg och 131 borttagningar
  1. 7
    4
      README.md
  2. 1
    3
      app/Casts/DocumentMoneyCast.php
  3. 17
    0
      app/Concerns/HandlePageRedirect.php
  4. 0
    11
      app/Concerns/RedirectToListPage.php
  5. 0
    11
      app/Concerns/RedirectToViewPage.php
  6. 2
    1
      app/Filament/Company/Clusters/Settings/Pages/CompanyProfile.php
  7. 1
    1
      app/Filament/Company/Clusters/Settings/Pages/Localization.php
  8. 2
    2
      app/Filament/Company/Clusters/Settings/Resources/AdjustmentResource/Pages/CreateAdjustment.php
  9. 2
    2
      app/Filament/Company/Clusters/Settings/Resources/AdjustmentResource/Pages/EditAdjustment.php
  10. 2
    2
      app/Filament/Company/Clusters/Settings/Resources/CurrencyResource/Pages/CreateCurrency.php
  11. 2
    2
      app/Filament/Company/Clusters/Settings/Resources/CurrencyResource/Pages/EditCurrency.php
  12. 2
    2
      app/Filament/Company/Clusters/Settings/Resources/DocumentDefaultResource/Pages/EditDocumentDefault.php
  13. 1
    1
      app/Filament/Company/Pages/Reports/BaseReportPage.php
  14. 2
    2
      app/Filament/Company/Resources/Banking/AccountResource/Pages/CreateAccount.php
  15. 2
    2
      app/Filament/Company/Resources/Banking/AccountResource/Pages/EditAccount.php
  16. 2
    2
      app/Filament/Company/Resources/Common/OfferingResource/Pages/CreateOffering.php
  17. 2
    2
      app/Filament/Company/Resources/Common/OfferingResource/Pages/EditOffering.php
  18. 2
    2
      app/Filament/Company/Resources/Purchases/BillResource/Pages/CreateBill.php
  19. 2
    2
      app/Filament/Company/Resources/Purchases/BillResource/Pages/EditBill.php
  20. 2
    2
      app/Filament/Company/Resources/Purchases/VendorResource/Pages/CreateVendor.php
  21. 2
    2
      app/Filament/Company/Resources/Purchases/VendorResource/Pages/EditVendor.php
  22. 2
    2
      app/Filament/Company/Resources/Sales/ClientResource/Pages/CreateClient.php
  23. 2
    2
      app/Filament/Company/Resources/Sales/ClientResource/Pages/EditClient.php
  24. 2
    2
      app/Filament/Company/Resources/Sales/EstimateResource/Pages/CreateEstimate.php
  25. 2
    2
      app/Filament/Company/Resources/Sales/EstimateResource/Pages/EditEstimate.php
  26. 2
    2
      app/Filament/Company/Resources/Sales/InvoiceResource/Pages/CreateInvoice.php
  27. 2
    2
      app/Filament/Company/Resources/Sales/InvoiceResource/Pages/EditInvoice.php
  28. 2
    2
      app/Filament/Company/Resources/Sales/RecurringInvoiceResource/Pages/EditRecurringInvoice.php
  29. 16
    0
      app/Filament/Forms/Components/AddressFields.php
  30. 0
    1
      app/Filament/Forms/Components/CountrySelect.php
  31. 1
    1
      app/Filament/Pages/Auth/Login.php
  32. 1
    1
      app/Filament/User/Clusters/Account.php
  33. 7
    0
      app/Helpers/helpers.php
  34. 1
    1
      app/Models/User.php
  35. 6
    6
      app/Policies/CompanyPolicy.php
  36. 1
    1
      app/Providers/Filament/CompanyPanelProvider.php
  37. 1
    1
      app/Services/CurrencyService.php
  38. 1
    1
      app/Services/PlaidService.php
  39. 1
    1
      composer.json
  40. 11
    9
      database/factories/Accounting/BillFactory.php
  41. 11
    8
      database/factories/Accounting/EstimateFactory.php
  42. 11
    9
      database/factories/Accounting/InvoiceFactory.php
  43. 11
    8
      database/factories/Accounting/RecurringInvoiceFactory.php
  44. 13
    9
      database/seeders/DatabaseSeeder.php
  45. 0
    2
      tests/TestCase.php

+ 7
- 4
README.md Visa fil

@@ -26,10 +26,13 @@ The demo environment provides a complete experience of the application with the
26 26
 - **Login Credentials**: Pre-filled for convenience (email: admin@erpsaas.com, password: password)
27 27
 - **Multi-Company Setup**: 5 pre-configured companies with different currencies:
28 28
     - ERPSAAS (USD)
29
-    - European Retail GmbH (EUR)
30
-    - UK Services Ltd (GBP)
31
-    - Canadian Manufacturing Inc (CAD)
32
-    - Australian Hospitality Pty (AUD)
29
+    - British Crown Analytics (GBP)
30
+    - Swiss Precision Group (CHF)
31
+    - Tokyo Future Technologies (JPY)
32
+    - Sydney Harbor Systems (AUD)
33
+    - Mumbai Software Services (INR)
34
+    - Singapore Digital Hub (SGD)
35
+    - Dubai Business Consulting (AED)
33 36
 - **Feature Access**: Full accounting functionality with simplified user management
34 37
 - **Limitations**: Plaid, Live Currency, Profile customization, password reset, and registration are disabled
35 38
 

+ 1
- 3
app/Casts/DocumentMoneyCast.php Visa fil

@@ -33,14 +33,12 @@ class DocumentMoneyCast implements CastsAttributes
33 33
      */
34 34
     public function set(Model $model, string $key, mixed $value, array $attributes): mixed
35 35
     {
36
-        $currency_code = $attributes['currency_code'] ?? CurrencyAccessor::getDefaultCurrency();
37
-
38 36
         if (is_numeric($value)) {
39 37
             $value = (string) $value;
40 38
         } elseif (! is_string($value)) {
41 39
             throw new UnexpectedValueException('Expected string or numeric value for money cast');
42 40
         }
43 41
 
44
-        return CurrencyConverter::prepareForAccessor($value, $currency_code);
42
+        return CurrencyConverter::prepareForAccessor($value, 'USD');
45 43
     }
46 44
 }

+ 17
- 0
app/Concerns/HandlePageRedirect.php Visa fil

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace App\Concerns;
4
+
5
+trait HandlePageRedirect
6
+{
7
+    protected function getRedirectUrl(): string
8
+    {
9
+        $resource = $this->getResource();
10
+
11
+        if ($resource::hasPage('view') && $this->record) {
12
+            return $resource::getUrl('view', ['record' => $this->record]);
13
+        }
14
+
15
+        return $resource::getUrl('index');
16
+    }
17
+}

+ 0
- 11
app/Concerns/RedirectToListPage.php Visa fil

@@ -1,11 +0,0 @@
1
-<?php
2
-
3
-namespace App\Concerns;
4
-
5
-trait RedirectToListPage
6
-{
7
-    protected function getRedirectUrl(): string
8
-    {
9
-        return $this->getResource()::getUrl('index');
10
-    }
11
-}

+ 0
- 11
app/Concerns/RedirectToViewPage.php Visa fil

@@ -1,11 +0,0 @@
1
-<?php
2
-
3
-namespace App\Concerns;
4
-
5
-trait RedirectToViewPage
6
-{
7
-    protected function getRedirectUrl(): string
8
-    {
9
-        return $this->getResource()::getUrl('view', ['record' => $this->record]);
10
-    }
11
-}

+ 2
- 1
app/Filament/Company/Clusters/Settings/Pages/CompanyProfile.php Visa fil

@@ -201,7 +201,8 @@ class CompanyProfile extends Page
201 201
                 Hidden::make('type')
202 202
                     ->default('general'),
203 203
                 AddressFields::make()
204
-                    ->softRequired(),
204
+                    ->softRequired()
205
+                    ->disabledCountry(is_demo_environment()),
205 206
             ])
206 207
             ->columns(2);
207 208
     }

+ 1
- 1
app/Filament/Company/Clusters/Settings/Pages/Localization.php Visa fil

@@ -126,7 +126,7 @@ class Localization extends Page
126 126
                     ->softRequired()
127 127
                     ->localizeLabel()
128 128
                     ->options(LocalizationModel::getAllLanguages())
129
-                    ->disabled(app()->environment('demo'))
129
+                    ->disabled(is_demo_environment())
130 130
                     ->searchable(),
131 131
                 Select::make('timezone')
132 132
                     ->softRequired()

+ 2
- 2
app/Filament/Company/Clusters/Settings/Resources/AdjustmentResource/Pages/CreateAdjustment.php Visa fil

@@ -2,13 +2,13 @@
2 2
 
3 3
 namespace App\Filament\Company\Clusters\Settings\Resources\AdjustmentResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Clusters\Settings\Resources\AdjustmentResource;
7 7
 use Filament\Resources\Pages\CreateRecord;
8 8
 
9 9
 class CreateAdjustment extends CreateRecord
10 10
 {
11
-    use RedirectToListPage;
11
+    use HandlePageRedirect;
12 12
 
13 13
     protected static string $resource = AdjustmentResource::class;
14 14
 }

+ 2
- 2
app/Filament/Company/Clusters/Settings/Resources/AdjustmentResource/Pages/EditAdjustment.php Visa fil

@@ -2,13 +2,13 @@
2 2
 
3 3
 namespace App\Filament\Company\Clusters\Settings\Resources\AdjustmentResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Clusters\Settings\Resources\AdjustmentResource;
7 7
 use Filament\Resources\Pages\EditRecord;
8 8
 
9 9
 class EditAdjustment extends EditRecord
10 10
 {
11
-    use RedirectToListPage;
11
+    use HandlePageRedirect;
12 12
 
13 13
     protected static string $resource = AdjustmentResource::class;
14 14
 

+ 2
- 2
app/Filament/Company/Clusters/Settings/Resources/CurrencyResource/Pages/CreateCurrency.php Visa fil

@@ -2,13 +2,13 @@
2 2
 
3 3
 namespace App\Filament\Company\Clusters\Settings\Resources\CurrencyResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Clusters\Settings\Resources\CurrencyResource;
7 7
 use Filament\Resources\Pages\CreateRecord;
8 8
 
9 9
 class CreateCurrency extends CreateRecord
10 10
 {
11
-    use RedirectToListPage;
11
+    use HandlePageRedirect;
12 12
 
13 13
     protected static string $resource = CurrencyResource::class;
14 14
 }

+ 2
- 2
app/Filament/Company/Clusters/Settings/Resources/CurrencyResource/Pages/EditCurrency.php Visa fil

@@ -2,13 +2,13 @@
2 2
 
3 3
 namespace App\Filament\Company\Clusters\Settings\Resources\CurrencyResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Clusters\Settings\Resources\CurrencyResource;
7 7
 use Filament\Resources\Pages\EditRecord;
8 8
 
9 9
 class EditCurrency extends EditRecord
10 10
 {
11
-    use RedirectToListPage;
11
+    use HandlePageRedirect;
12 12
 
13 13
     protected static string $resource = CurrencyResource::class;
14 14
 

+ 2
- 2
app/Filament/Company/Clusters/Settings/Resources/DocumentDefaultResource/Pages/EditDocumentDefault.php Visa fil

@@ -2,14 +2,14 @@
2 2
 
3 3
 namespace App\Filament\Company\Clusters\Settings\Resources\DocumentDefaultResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Clusters\Settings\Resources\DocumentDefaultResource;
7 7
 use Filament\Resources\Pages\EditRecord;
8 8
 use Illuminate\Contracts\Support\Htmlable;
9 9
 
10 10
 class EditDocumentDefault extends EditRecord
11 11
 {
12
-    use RedirectToListPage;
12
+    use HandlePageRedirect;
13 13
 
14 14
     protected static string $resource = DocumentDefaultResource::class;
15 15
 

+ 1
- 1
app/Filament/Company/Pages/Reports/BaseReportPage.php Visa fil

@@ -227,7 +227,7 @@ abstract class BaseReportPage extends Page
227 227
                     ->action(fn () => $this->exportCSV()),
228 228
                 Action::make('exportPDF')
229 229
                     ->label('PDF')
230
-                    ->hidden(app()->environment('demo'))
230
+                    ->hidden(is_demo_environment())
231 231
                     ->action(fn () => $this->exportPDF()),
232 232
             ])
233 233
                 ->label('Export')

+ 2
- 2
app/Filament/Company/Resources/Banking/AccountResource/Pages/CreateAccount.php Visa fil

@@ -2,13 +2,13 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Banking\AccountResource;
7 7
 use Filament\Resources\Pages\CreateRecord;
8 8
 
9 9
 class CreateAccount extends CreateRecord
10 10
 {
11
-    use RedirectToListPage;
11
+    use HandlePageRedirect;
12 12
 
13 13
     protected static string $resource = AccountResource::class;
14 14
 

+ 2
- 2
app/Filament/Company/Resources/Banking/AccountResource/Pages/EditAccount.php Visa fil

@@ -2,14 +2,14 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Banking\AccountResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Banking\AccountResource;
7 7
 use Filament\Actions;
8 8
 use Filament\Resources\Pages\EditRecord;
9 9
 
10 10
 class EditAccount extends EditRecord
11 11
 {
12
-    use RedirectToListPage;
12
+    use HandlePageRedirect;
13 13
 
14 14
     protected static string $resource = AccountResource::class;
15 15
 

+ 2
- 2
app/Filament/Company/Resources/Common/OfferingResource/Pages/CreateOffering.php Visa fil

@@ -2,14 +2,14 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Common\OfferingResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Common\OfferingResource;
7 7
 use Filament\Resources\Pages\CreateRecord;
8 8
 use Illuminate\Database\Eloquent\Model;
9 9
 
10 10
 class CreateOffering extends CreateRecord
11 11
 {
12
-    use RedirectToListPage;
12
+    use HandlePageRedirect;
13 13
 
14 14
     protected static string $resource = OfferingResource::class;
15 15
 

+ 2
- 2
app/Filament/Company/Resources/Common/OfferingResource/Pages/EditOffering.php Visa fil

@@ -2,7 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Common\OfferingResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Common\OfferingResource;
7 7
 use Filament\Actions;
8 8
 use Filament\Resources\Pages\EditRecord;
@@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Model;
10 10
 
11 11
 class EditOffering extends EditRecord
12 12
 {
13
-    use RedirectToListPage;
13
+    use HandlePageRedirect;
14 14
 
15 15
     protected static string $resource = OfferingResource::class;
16 16
 

+ 2
- 2
app/Filament/Company/Resources/Purchases/BillResource/Pages/CreateBill.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Purchases\BillResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Purchases\BillResource;
8 8
 use App\Models\Accounting\Bill;
9 9
 use App\Models\Common\Vendor;
@@ -14,8 +14,8 @@ use Livewire\Attributes\Url;
14 14
 
15 15
 class CreateBill extends CreateRecord
16 16
 {
17
+    use HandlePageRedirect;
17 18
     use ManagesLineItems;
18
-    use RedirectToViewPage;
19 19
 
20 20
     protected static string $resource = BillResource::class;
21 21
 

+ 2
- 2
app/Filament/Company/Resources/Purchases/BillResource/Pages/EditBill.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Purchases\BillResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Purchases\BillResource;
8 8
 use App\Models\Accounting\Bill;
9 9
 use Filament\Actions;
@@ -13,8 +13,8 @@ use Illuminate\Database\Eloquent\Model;
13 13
 
14 14
 class EditBill extends EditRecord
15 15
 {
16
+    use HandlePageRedirect;
16 17
     use ManagesLineItems;
17
-    use RedirectToViewPage;
18 18
 
19 19
     protected static string $resource = BillResource::class;
20 20
 

+ 2
- 2
app/Filament/Company/Resources/Purchases/VendorResource/Pages/CreateVendor.php Visa fil

@@ -2,14 +2,14 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Purchases\VendorResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Purchases\VendorResource;
7 7
 use Filament\Resources\Pages\CreateRecord;
8 8
 use Filament\Support\Enums\MaxWidth;
9 9
 
10 10
 class CreateVendor extends CreateRecord
11 11
 {
12
-    use RedirectToListPage;
12
+    use HandlePageRedirect;
13 13
 
14 14
     protected static string $resource = VendorResource::class;
15 15
 

+ 2
- 2
app/Filament/Company/Resources/Purchases/VendorResource/Pages/EditVendor.php Visa fil

@@ -2,7 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Purchases\VendorResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToViewPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Purchases\VendorResource;
7 7
 use Filament\Actions;
8 8
 use Filament\Resources\Pages\EditRecord;
@@ -10,7 +10,7 @@ use Filament\Support\Enums\MaxWidth;
10 10
 
11 11
 class EditVendor extends EditRecord
12 12
 {
13
-    use RedirectToViewPage;
13
+    use HandlePageRedirect;
14 14
 
15 15
     protected static string $resource = VendorResource::class;
16 16
 

+ 2
- 2
app/Filament/Company/Resources/Sales/ClientResource/Pages/CreateClient.php Visa fil

@@ -2,7 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\ClientResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToListPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Enums\Common\AddressType;
7 7
 use App\Filament\Company\Resources\Sales\ClientResource;
8 8
 use App\Models\Common\Address;
@@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Model;
13 13
 
14 14
 class CreateClient extends CreateRecord
15 15
 {
16
-    use RedirectToListPage;
16
+    use HandlePageRedirect;
17 17
 
18 18
     protected static string $resource = ClientResource::class;
19 19
 

+ 2
- 2
app/Filament/Company/Resources/Sales/ClientResource/Pages/EditClient.php Visa fil

@@ -2,7 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\ClientResource\Pages;
4 4
 
5
-use App\Concerns\RedirectToViewPage;
5
+use App\Concerns\HandlePageRedirect;
6 6
 use App\Filament\Company\Resources\Sales\ClientResource;
7 7
 use App\Models\Common\Client;
8 8
 use Filament\Actions;
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
12 12
 
13 13
 class EditClient extends EditRecord
14 14
 {
15
-    use RedirectToViewPage;
15
+    use HandlePageRedirect;
16 16
 
17 17
     protected static string $resource = ClientResource::class;
18 18
 

+ 2
- 2
app/Filament/Company/Resources/Sales/EstimateResource/Pages/CreateEstimate.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\EstimateResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToListPage;
7 7
 use App\Filament\Company\Resources\Sales\EstimateResource;
8 8
 use App\Models\Accounting\Estimate;
9 9
 use App\Models\Common\Client;
@@ -14,8 +14,8 @@ use Livewire\Attributes\Url;
14 14
 
15 15
 class CreateEstimate extends CreateRecord
16 16
 {
17
+    use HandlePageRedirect;
17 18
     use ManagesLineItems;
18
-    use RedirectToListPage;
19 19
 
20 20
     protected static string $resource = EstimateResource::class;
21 21
 

+ 2
- 2
app/Filament/Company/Resources/Sales/EstimateResource/Pages/EditEstimate.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\EstimateResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Sales\EstimateResource;
8 8
 use App\Models\Accounting\Estimate;
9 9
 use Filament\Actions;
@@ -13,8 +13,8 @@ use Illuminate\Database\Eloquent\Model;
13 13
 
14 14
 class EditEstimate extends EditRecord
15 15
 {
16
+    use HandlePageRedirect;
16 17
     use ManagesLineItems;
17
-    use RedirectToViewPage;
18 18
 
19 19
     protected static string $resource = EstimateResource::class;
20 20
 

+ 2
- 2
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/CreateInvoice.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\InvoiceResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Sales\InvoiceResource;
8 8
 use App\Models\Accounting\Invoice;
9 9
 use App\Models\Common\Client;
@@ -14,8 +14,8 @@ use Livewire\Attributes\Url;
14 14
 
15 15
 class CreateInvoice extends CreateRecord
16 16
 {
17
+    use HandlePageRedirect;
17 18
     use ManagesLineItems;
18
-    use RedirectToViewPage;
19 19
 
20 20
     protected static string $resource = InvoiceResource::class;
21 21
 

+ 2
- 2
app/Filament/Company/Resources/Sales/InvoiceResource/Pages/EditInvoice.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\InvoiceResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Sales\InvoiceResource;
8 8
 use App\Models\Accounting\Invoice;
9 9
 use Filament\Actions;
@@ -13,8 +13,8 @@ use Illuminate\Database\Eloquent\Model;
13 13
 
14 14
 class EditInvoice extends EditRecord
15 15
 {
16
+    use HandlePageRedirect;
16 17
     use ManagesLineItems;
17
-    use RedirectToViewPage;
18 18
 
19 19
     protected static string $resource = InvoiceResource::class;
20 20
 

+ 2
- 2
app/Filament/Company/Resources/Sales/RecurringInvoiceResource/Pages/EditRecurringInvoice.php Visa fil

@@ -2,8 +2,8 @@
2 2
 
3 3
 namespace App\Filament\Company\Resources\Sales\RecurringInvoiceResource\Pages;
4 4
 
5
+use App\Concerns\HandlePageRedirect;
5 6
 use App\Concerns\ManagesLineItems;
6
-use App\Concerns\RedirectToViewPage;
7 7
 use App\Filament\Company\Resources\Sales\RecurringInvoiceResource;
8 8
 use App\Models\Accounting\Estimate;
9 9
 use Filament\Actions;
@@ -13,8 +13,8 @@ use Illuminate\Database\Eloquent\Model;
13 13
 
14 14
 class EditRecurringInvoice extends EditRecord
15 15
 {
16
+    use HandlePageRedirect;
16 17
     use ManagesLineItems;
17
-    use RedirectToViewPage;
18 18
 
19 19
     protected static string $resource = RecurringInvoiceResource::class;
20 20
 

+ 16
- 0
app/Filament/Forms/Components/AddressFields.php Visa fil

@@ -2,6 +2,7 @@
2 2
 
3 3
 namespace App\Filament\Forms\Components;
4 4
 
5
+use Closure;
5 6
 use Filament\Forms\Components\Field;
6 7
 use Filament\Forms\Components\Grid;
7 8
 use Filament\Forms\Components\TextInput;
@@ -10,6 +11,8 @@ class AddressFields extends Grid
10 11
 {
11 12
     protected bool $isSoftRequired = false;
12 13
 
14
+    protected bool | Closure $isCountryDisabled = false;
15
+
13 16
     protected function setUp(): void
14 17
     {
15 18
         parent::setUp();
@@ -23,6 +26,7 @@ class AddressFields extends Grid
23 26
                 ->label('Address line 2')
24 27
                 ->maxLength(255),
25 28
             CountrySelect::make('country_code')
29
+                ->disabled(fn () => $this->isCountryDisabled())
26 30
                 ->clearStateField()
27 31
                 ->required(),
28 32
             StateSelect::make('state_id'),
@@ -55,4 +59,16 @@ class AddressFields extends Grid
55 59
             }
56 60
         }
57 61
     }
62
+
63
+    public function disabledCountry(bool | Closure $condition = true): static
64
+    {
65
+        $this->isCountryDisabled = $condition;
66
+
67
+        return $this;
68
+    }
69
+
70
+    public function isCountryDisabled(): bool
71
+    {
72
+        return $this->evaluate($this->isCountryDisabled);
73
+    }
58 74
 }

+ 0
- 1
app/Filament/Forms/Components/CountrySelect.php Visa fil

@@ -17,7 +17,6 @@ class CountrySelect extends Select
17 17
         $this
18 18
             ->localizeLabel('Country')
19 19
             ->searchable()
20
-            ->disabled(app()->environment('demo'))
21 20
             ->options($options = Country::getAvailableCountryOptions())
22 21
             ->getSearchResultsUsing(static fn (string $search): array => Country::getSearchResultsUsing($search))
23 22
             ->getOptionLabelUsing(static fn (string $value): ?string => $options[$value] ?? $value);

+ 1
- 1
app/Filament/Pages/Auth/Login.php Visa fil

@@ -10,7 +10,7 @@ class Login extends BaseLogin
10 10
     {
11 11
         parent::mount();
12 12
 
13
-        if (app()->environment('demo')) {
13
+        if (is_demo_environment()) {
14 14
             $this->form->fill([
15 15
                 'email' => 'admin@erpsaas.com',
16 16
                 'password' => 'password',

+ 1
- 1
app/Filament/User/Clusters/Account.php Visa fil

@@ -20,7 +20,7 @@ class Account extends Cluster
20 20
 
21 21
     public static function canAccess(): bool
22 22
     {
23
-        return ! app()->environment('demo');
23
+        return ! is_demo_environment();
24 24
     }
25 25
 
26 26
     /**

app/Helpers/format.php → app/Helpers/helpers.php Visa fil

@@ -122,3 +122,10 @@ if (! function_exists('rateFormat')) {
122 122
         return null;
123 123
     }
124 124
 }
125
+
126
+if (! function_exists('is_demo_environment')) {
127
+    function is_demo_environment(): bool
128
+    {
129
+        return app()->environment('demo');
130
+    }
131
+}

+ 1
- 1
app/Models/User.php Visa fil

@@ -71,7 +71,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar, HasDefaul
71 71
 
72 72
     public function canAccessPanel(Panel $panel): bool
73 73
     {
74
-        if ($panel->getId() === 'user' && app()->environment('demo')) {
74
+        if ($panel->getId() === 'user' && is_demo_environment()) {
75 75
             return false;
76 76
         }
77 77
 

+ 6
- 6
app/Policies/CompanyPolicy.php Visa fil

@@ -31,7 +31,7 @@ class CompanyPolicy
31 31
      */
32 32
     public function create(User $user): bool
33 33
     {
34
-        if (app()->environment('demo')) {
34
+        if (is_demo_environment()) {
35 35
             return false;
36 36
         }
37 37
 
@@ -43,7 +43,7 @@ class CompanyPolicy
43 43
      */
44 44
     public function update(User $user, Company $company): bool
45 45
     {
46
-        if (app()->environment('demo')) {
46
+        if (is_demo_environment()) {
47 47
             return false;
48 48
         }
49 49
 
@@ -55,7 +55,7 @@ class CompanyPolicy
55 55
      */
56 56
     public function addCompanyEmployee(User $user, Company $company): bool
57 57
     {
58
-        if (app()->environment('demo')) {
58
+        if (is_demo_environment()) {
59 59
             return false;
60 60
         }
61 61
 
@@ -67,7 +67,7 @@ class CompanyPolicy
67 67
      */
68 68
     public function updateCompanyEmployee(User $user, Company $company): bool
69 69
     {
70
-        if (app()->environment('demo')) {
70
+        if (is_demo_environment()) {
71 71
             return false;
72 72
         }
73 73
 
@@ -79,7 +79,7 @@ class CompanyPolicy
79 79
      */
80 80
     public function removeCompanyEmployee(User $user, Company $company): bool
81 81
     {
82
-        if (app()->environment('demo')) {
82
+        if (is_demo_environment()) {
83 83
             return false;
84 84
         }
85 85
 
@@ -91,7 +91,7 @@ class CompanyPolicy
91 91
      */
92 92
     public function delete(User $user, Company $company): bool
93 93
     {
94
-        if (app()->environment('demo')) {
94
+        if (is_demo_environment()) {
95 95
             return false;
96 96
         }
97 97
 

+ 1
- 1
app/Providers/Filament/CompanyPanelProvider.php Visa fil

@@ -79,7 +79,7 @@ class CompanyPanelProvider extends PanelProvider
79 79
      */
80 80
     public function panel(Panel $panel): Panel
81 81
     {
82
-        $isDemoEnvironment = app()->environment('demo');
82
+        $isDemoEnvironment = is_demo_environment();
83 83
 
84 84
         return $panel
85 85
             ->default()

+ 1
- 1
app/Services/CurrencyService.php Visa fil

@@ -21,7 +21,7 @@ class CurrencyService implements CurrencyHandler
21 21
      */
22 22
     public function isEnabled(): bool
23 23
     {
24
-        if (app()->environment('demo')) {
24
+        if (is_demo_environment()) {
25 25
             return false;
26 26
         }
27 27
 

+ 1
- 1
app/Services/PlaidService.php Visa fil

@@ -63,7 +63,7 @@ class PlaidService
63 63
      */
64 64
     public function isEnabled(): bool
65 65
     {
66
-        if (app()->environment('demo') || empty($this->clientId) || empty($this->clientSecret)) {
66
+        if (is_demo_environment() || empty($this->clientId) || empty($this->clientSecret)) {
67 67
             return false;
68 68
         }
69 69
 

+ 1
- 1
composer.json Visa fil

@@ -48,7 +48,7 @@
48 48
             "Database\\Seeders\\": "database/seeders/"
49 49
         },
50 50
         "files": [
51
-            "app/Helpers/format.php"
51
+            "app/Helpers/helpers.php"
52 52
         ]
53 53
     },
54 54
     "autoload-dev": {

+ 11
- 9
database/factories/Accounting/BillFactory.php Visa fil

@@ -162,7 +162,7 @@ class BillFactory extends Factory
162 162
                     'posted_at' => $postedAt,
163 163
                     'amount' => CurrencyConverter::convertCentsToFormatSimple($amount, $bill->currency_code),
164 164
                     'payment_method' => $this->faker->randomElement(PaymentMethod::class),
165
-                    'bank_account_id' => BankAccount::inRandomOrder()->value('id'),
165
+                    'bank_account_id' => BankAccount::where('company_id', $bill->company_id)->inRandomOrder()->value('id'),
166 166
                     'notes' => $this->faker->sentence,
167 167
                 ];
168 168
 
@@ -224,16 +224,18 @@ class BillFactory extends Factory
224 224
             return;
225 225
         }
226 226
 
227
-        $subtotal = $bill->lineItems()->sum('subtotal') / 100;
228
-        $taxTotal = $bill->lineItems()->sum('tax_total') / 100;
229
-        $discountTotal = $bill->lineItems()->sum('discount_total') / 100;
230
-        $grandTotal = $subtotal + $taxTotal - $discountTotal;
227
+        $subtotalCents = $bill->lineItems()->sum('subtotal');
228
+        $taxTotalCents = $bill->lineItems()->sum('tax_total');
229
+        $discountTotalCents = $bill->lineItems()->sum('discount_total');
230
+
231
+        $grandTotalCents = $subtotalCents + $taxTotalCents - $discountTotalCents;
232
+        $currencyCode = $bill->currency_code;
231 233
 
232 234
         $bill->update([
233
-            'subtotal' => $subtotal,
234
-            'tax_total' => $taxTotal,
235
-            'discount_total' => $discountTotal,
236
-            'total' => $grandTotal,
235
+            'subtotal' => CurrencyConverter::convertCentsToFormatSimple($subtotalCents, $currencyCode),
236
+            'tax_total' => CurrencyConverter::convertCentsToFormatSimple($taxTotalCents, $currencyCode),
237
+            'discount_total' => CurrencyConverter::convertCentsToFormatSimple($discountTotalCents, $currencyCode),
238
+            'total' => CurrencyConverter::convertCentsToFormatSimple($grandTotalCents, $currencyCode),
237 239
         ]);
238 240
     }
239 241
 }

+ 11
- 8
database/factories/Accounting/EstimateFactory.php Visa fil

@@ -8,6 +8,7 @@ use App\Models\Accounting\Estimate;
8 8
 use App\Models\Common\Client;
9 9
 use App\Models\Company;
10 10
 use App\Models\Setting\DocumentDefault;
11
+use App\Utilities\Currency\CurrencyConverter;
11 12
 use Illuminate\Database\Eloquent\Factories\Factory;
12 13
 use Illuminate\Support\Carbon;
13 14
 
@@ -204,16 +205,18 @@ class EstimateFactory extends Factory
204 205
             return;
205 206
         }
206 207
 
207
-        $subtotal = $estimate->lineItems()->sum('subtotal') / 100;
208
-        $taxTotal = $estimate->lineItems()->sum('tax_total') / 100;
209
-        $discountTotal = $estimate->lineItems()->sum('discount_total') / 100;
210
-        $grandTotal = $subtotal + $taxTotal - $discountTotal;
208
+        $subtotalCents = $estimate->lineItems()->sum('subtotal');
209
+        $taxTotalCents = $estimate->lineItems()->sum('tax_total');
210
+        $discountTotalCents = $estimate->lineItems()->sum('discount_total');
211
+
212
+        $grandTotalCents = $subtotalCents + $taxTotalCents - $discountTotalCents;
213
+        $currencyCode = $estimate->currency_code;
211 214
 
212 215
         $estimate->update([
213
-            'subtotal' => $subtotal,
214
-            'tax_total' => $taxTotal,
215
-            'discount_total' => $discountTotal,
216
-            'total' => $grandTotal,
216
+            'subtotal' => CurrencyConverter::convertCentsToFormatSimple($subtotalCents, $currencyCode),
217
+            'tax_total' => CurrencyConverter::convertCentsToFormatSimple($taxTotalCents, $currencyCode),
218
+            'discount_total' => CurrencyConverter::convertCentsToFormatSimple($discountTotalCents, $currencyCode),
219
+            'total' => CurrencyConverter::convertCentsToFormatSimple($grandTotalCents, $currencyCode),
217 220
         ]);
218 221
     }
219 222
 }

+ 11
- 9
database/factories/Accounting/InvoiceFactory.php Visa fil

@@ -180,7 +180,7 @@ class InvoiceFactory extends Factory
180 180
                     'posted_at' => $postedAt,
181 181
                     'amount' => CurrencyConverter::convertCentsToFormatSimple($amount, $invoice->currency_code),
182 182
                     'payment_method' => $this->faker->randomElement(PaymentMethod::class),
183
-                    'bank_account_id' => BankAccount::inRandomOrder()->value('id'),
183
+                    'bank_account_id' => BankAccount::where('company_id', $invoice->company_id)->inRandomOrder()->value('id'),
184 184
                     'notes' => $this->faker->sentence,
185 185
                 ];
186 186
 
@@ -249,16 +249,18 @@ class InvoiceFactory extends Factory
249 249
             return;
250 250
         }
251 251
 
252
-        $subtotal = $invoice->lineItems()->sum('subtotal') / 100;
253
-        $taxTotal = $invoice->lineItems()->sum('tax_total') / 100;
254
-        $discountTotal = $invoice->lineItems()->sum('discount_total') / 100;
255
-        $grandTotal = $subtotal + $taxTotal - $discountTotal;
252
+        $subtotalCents = $invoice->lineItems()->sum('subtotal');
253
+        $taxTotalCents = $invoice->lineItems()->sum('tax_total');
254
+        $discountTotalCents = $invoice->lineItems()->sum('discount_total');
255
+
256
+        $grandTotalCents = $subtotalCents + $taxTotalCents - $discountTotalCents;
257
+        $currencyCode = $invoice->currency_code;
256 258
 
257 259
         $invoice->update([
258
-            'subtotal' => $subtotal,
259
-            'tax_total' => $taxTotal,
260
-            'discount_total' => $discountTotal,
261
-            'total' => $grandTotal,
260
+            'subtotal' => CurrencyConverter::convertCentsToFormatSimple($subtotalCents, $currencyCode),
261
+            'tax_total' => CurrencyConverter::convertCentsToFormatSimple($taxTotalCents, $currencyCode),
262
+            'discount_total' => CurrencyConverter::convertCentsToFormatSimple($discountTotalCents, $currencyCode),
263
+            'total' => CurrencyConverter::convertCentsToFormatSimple($grandTotalCents, $currencyCode),
262 264
         ]);
263 265
     }
264 266
 }

+ 11
- 8
database/factories/Accounting/RecurringInvoiceFactory.php Visa fil

@@ -14,6 +14,7 @@ use App\Models\Accounting\DocumentLineItem;
14 14
 use App\Models\Accounting\RecurringInvoice;
15 15
 use App\Models\Common\Client;
16 16
 use App\Models\Company;
17
+use App\Utilities\Currency\CurrencyConverter;
17 18
 use Illuminate\Database\Eloquent\Factories\Factory;
18 19
 use Illuminate\Support\Carbon;
19 20
 
@@ -298,16 +299,18 @@ class RecurringInvoiceFactory extends Factory
298 299
             return;
299 300
         }
300 301
 
301
-        $subtotal = $recurringInvoice->lineItems()->sum('subtotal') / 100;
302
-        $taxTotal = $recurringInvoice->lineItems()->sum('tax_total') / 100;
303
-        $discountTotal = $recurringInvoice->lineItems()->sum('discount_total') / 100;
304
-        $grandTotal = $subtotal + $taxTotal - $discountTotal;
302
+        $subtotalCents = $recurringInvoice->lineItems()->sum('subtotal');
303
+        $taxTotalCents = $recurringInvoice->lineItems()->sum('tax_total');
304
+        $discountTotalCents = $recurringInvoice->lineItems()->sum('discount_total');
305
+
306
+        $grandTotalCents = $subtotalCents + $taxTotalCents - $discountTotalCents;
307
+        $currencyCode = $recurringInvoice->currency_code;
305 308
 
306 309
         $recurringInvoice->update([
307
-            'subtotal' => $subtotal,
308
-            'tax_total' => $taxTotal,
309
-            'discount_total' => $discountTotal,
310
-            'total' => $grandTotal,
310
+            'subtotal' => CurrencyConverter::convertCentsToFormatSimple($subtotalCents, $currencyCode),
311
+            'tax_total' => CurrencyConverter::convertCentsToFormatSimple($taxTotalCents, $currencyCode),
312
+            'discount_total' => CurrencyConverter::convertCentsToFormatSimple($discountTotalCents, $currencyCode),
313
+            'total' => CurrencyConverter::convertCentsToFormatSimple($grandTotalCents, $currencyCode),
311 314
         ]);
312 315
     }
313 316
 }

+ 13
- 9
database/seeders/DatabaseSeeder.php Visa fil

@@ -21,14 +21,14 @@ class DatabaseSeeder extends Seeder
21 21
                     ->state([
22 22
                         'name' => 'ERPSAAS',
23 23
                     ])
24
-                    ->withTransactions()
24
+                    ->withTransactions(250)
25 25
                     ->withOfferings()
26 26
                     ->withClients()
27 27
                     ->withVendors()
28
-                    ->withInvoices(50)
28
+                    ->withInvoices(30)
29 29
                     ->withRecurringInvoices()
30
-                    ->withEstimates(50)
31
-                    ->withBills(50);
30
+                    ->withEstimates(30)
31
+                    ->withBills(30);
32 32
             })
33 33
             ->create([
34 34
                 'name' => 'Admin',
@@ -37,11 +37,15 @@ class DatabaseSeeder extends Seeder
37 37
                 'current_company_id' => 1,  // Assuming this will be the ID of the created company
38 38
             ]);
39 39
 
40
+        // Only use en locale for now
40 41
         $additionalCompanies = [
41
-            ['name' => 'European Retail GmbH', 'country' => 'DE', 'currency' => 'EUR', 'locale' => 'en'],
42
-            ['name' => 'UK Services Ltd', 'country' => 'GB', 'currency' => 'GBP', 'locale' => 'en'],
43
-            ['name' => 'Canadian Manufacturing Inc', 'country' => 'CA', 'currency' => 'CAD', 'locale' => 'en'],
44
-            ['name' => 'Australian Hospitality Pty', 'country' => 'AU', 'currency' => 'AUD', 'locale' => 'en'],
42
+            ['name' => 'British Crown Analytics', 'country' => 'GB', 'currency' => 'GBP', 'locale' => 'en'],
43
+            ['name' => 'Swiss Precision Group', 'country' => 'CH', 'currency' => 'CHF', 'locale' => 'en'],
44
+            ['name' => 'Tokyo Future Technologies', 'country' => 'JP', 'currency' => 'JPY', 'locale' => 'en'],
45
+            ['name' => 'Sydney Harbor Systems', 'country' => 'AU', 'currency' => 'AUD', 'locale' => 'en'],
46
+            ['name' => 'Mumbai Software Services', 'country' => 'IN', 'currency' => 'INR', 'locale' => 'en'],
47
+            ['name' => 'Singapore Digital Hub', 'country' => 'SG', 'currency' => 'SGD', 'locale' => 'en'],
48
+            ['name' => 'Dubai Business Consulting', 'country' => 'AE', 'currency' => 'AED', 'locale' => 'en'],
45 49
         ];
46 50
 
47 51
         foreach ($additionalCompanies as $companyData) {
@@ -57,7 +61,7 @@ class DatabaseSeeder extends Seeder
57 61
                 ->withOfferings()
58 62
                 ->withClients()
59 63
                 ->withVendors()
60
-                ->withInvoices(20)
64
+                ->withInvoices(15)
61 65
                 ->withRecurringInvoices()
62 66
                 ->withEstimates(15)
63 67
                 ->withBills(15)

+ 0
- 2
tests/TestCase.php Visa fil

@@ -51,9 +51,7 @@ abstract class TestCase extends BaseTestCase
51 51
     {
52 52
         Offering::factory()
53 53
             ->for($this->testCompany)
54
-            ->sellable()
55 54
             ->withSalesAdjustments()
56
-            ->purchasable()
57 55
             ->withPurchaseAdjustments()
58 56
             ->create();
59 57
 

Laddar…
Avbryt
Spara