Andrew Wallo před 6 měsíci
rodič
revize
4c2584286d

+ 14
- 6
app/Filament/Company/Resources/Purchases/BillResource.php Zobrazit soubor

@@ -375,9 +375,13 @@ class BillResource extends Resource
375 375
                                 Forms\Components\Select::make('bank_account_id')
376 376
                                     ->label('Account')
377 377
                                     ->required()
378
-                                    ->options(BankAccount::query()
379
-                                        ->get()
380
-                                        ->pluck('account.name', 'id'))
378
+                                    ->options(function () {
379
+                                        return BankAccount::query()
380
+                                            ->join('accounts', 'bank_accounts.account_id', '=', 'accounts.id')
381
+                                            ->select(['bank_accounts.id', 'accounts.name'])
382
+                                            ->pluck('accounts.name', 'bank_accounts.id')
383
+                                            ->toArray();
384
+                                    })
381 385
                                     ->searchable(),
382 386
                                 Forms\Components\Textarea::make('notes')
383 387
                                     ->label('Notes'),
@@ -484,9 +488,13 @@ class BillResource extends Resource
484 488
                             Forms\Components\Select::make('bank_account_id')
485 489
                                 ->label('Account')
486 490
                                 ->required()
487
-                                ->options(BankAccount::query()
488
-                                    ->get()
489
-                                    ->pluck('account.name', 'id'))
491
+                                ->options(function () {
492
+                                    return BankAccount::query()
493
+                                        ->join('accounts', 'bank_accounts.account_id', '=', 'accounts.id')
494
+                                        ->select(['bank_accounts.id', 'accounts.name'])
495
+                                        ->pluck('accounts.name', 'bank_accounts.id')
496
+                                        ->toArray();
497
+                                })
490 498
                                 ->searchable(),
491 499
                             Forms\Components\Textarea::make('notes')
492 500
                                 ->label('Notes'),

+ 7
- 3
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php Zobrazit soubor

@@ -93,9 +93,13 @@ class PaymentsRelationManager extends RelationManager
93 93
                 Forms\Components\Select::make('bank_account_id')
94 94
                     ->label('Account')
95 95
                     ->required()
96
-                    ->options(BankAccount::query()
97
-                        ->get()
98
-                        ->pluck('account.name', 'id'))
96
+                    ->options(function () {
97
+                        return BankAccount::query()
98
+                            ->join('accounts', 'bank_accounts.account_id', '=', 'accounts.id')
99
+                            ->select(['bank_accounts.id', 'accounts.name'])
100
+                            ->pluck('accounts.name', 'bank_accounts.id')
101
+                            ->toArray();
102
+                    })
99 103
                     ->searchable(),
100 104
                 Forms\Components\Textarea::make('notes')
101 105
                     ->label('Notes'),

+ 7
- 3
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php Zobrazit soubor

@@ -100,9 +100,13 @@ class PaymentsRelationManager extends RelationManager
100 100
                 Forms\Components\Select::make('bank_account_id')
101 101
                     ->label('Account')
102 102
                     ->required()
103
-                    ->options(BankAccount::query()
104
-                        ->get()
105
-                        ->pluck('account.name', 'id'))
103
+                    ->options(function () {
104
+                        return BankAccount::query()
105
+                            ->join('accounts', 'bank_accounts.account_id', '=', 'accounts.id')
106
+                            ->select(['bank_accounts.id', 'accounts.name'])
107
+                            ->pluck('accounts.name', 'bank_accounts.id')
108
+                            ->toArray();
109
+                    })
106 110
                     ->searchable(),
107 111
                 Forms\Components\Textarea::make('notes')
108 112
                     ->label('Notes'),

+ 1
- 1
app/Listeners/CreateConnectedAccount.php Zobrazit soubor

@@ -57,7 +57,7 @@ class CreateConnectedAccount
57 57
 
58 58
     public function processConnectedBankAccount($plaidAccount, Company $company, Institution $institution, $authResponse, $accessToken): void
59 59
     {
60
-        $identifierHash = md5($institution->external_institution_id . $plaidAccount->name . $plaidAccount->mask);
60
+        $identifierHash = md5($company->id . $institution->external_institution_id . $plaidAccount->name . $plaidAccount->mask);
61 61
 
62 62
         $company->connectedBankAccounts()->updateOrCreate([
63 63
             'identifier' => $identifierHash,

+ 7
- 6
app/Livewire/Company/Service/ConnectedAccount/ListInstitutions.php Zobrazit soubor

@@ -108,14 +108,15 @@ class ListInstitutions extends Component implements HasActions, HasForms
108 108
         $options = ['new' => 'New Account'];
109 109
 
110 110
         if ($institutionId) {
111
-            $options += BankAccount::query()
112
-                ->where('company_id', $this->user->currentCompany->id)
113
-                ->where('institution_id', $institutionId)
111
+            $accountOptions = BankAccount::query()
112
+                ->join('accounts', 'bank_accounts.account_id', '=', 'accounts.id')
113
+                ->where('bank_accounts.institution_id', $institutionId)
114 114
                 ->whereDoesntHave('connectedBankAccount')
115
-                ->with('account')
116
-                ->get()
117
-                ->pluck('account.name', 'id')
115
+                ->select(['bank_accounts.id', 'accounts.name'])
116
+                ->pluck('accounts.name', 'bank_accounts.id')
118 117
                 ->toArray();
118
+
119
+            $options += $accountOptions;
119 120
         }
120 121
 
121 122
         return $options;

+ 4
- 1
app/Services/TransactionService.php Zobrazit soubor

@@ -46,7 +46,10 @@ class TransactionService
46 46
     {
47 47
         $transactionType = $startingBalance >= 0 ? TransactionType::Deposit : TransactionType::Withdrawal;
48 48
         $accountName = $startingBalance >= 0 ? "Owner's Investment" : "Owner's Drawings";
49
-        $chartAccount = $account->where('category', AccountCategory::Equity)->where('name', $accountName)->first();
49
+        $chartAccount = $company->accounts()
50
+            ->where('category', AccountCategory::Equity)
51
+            ->where('name', $accountName)
52
+            ->firstOrFail();
50 53
 
51 54
         $postedAt = Carbon::parse($startDate)->subDay()->toDateTimeString();
52 55
 

Načítá se…
Zrušit
Uložit