Andrew Wallo 6 月之前
父節點
當前提交
4c2584286d

+ 14
- 6
app/Filament/Company/Resources/Purchases/BillResource.php 查看文件

375
                                 Forms\Components\Select::make('bank_account_id')
375
                                 Forms\Components\Select::make('bank_account_id')
376
                                     ->label('Account')
376
                                     ->label('Account')
377
                                     ->required()
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
                                     ->searchable(),
385
                                     ->searchable(),
382
                                 Forms\Components\Textarea::make('notes')
386
                                 Forms\Components\Textarea::make('notes')
383
                                     ->label('Notes'),
387
                                     ->label('Notes'),
484
                             Forms\Components\Select::make('bank_account_id')
488
                             Forms\Components\Select::make('bank_account_id')
485
                                 ->label('Account')
489
                                 ->label('Account')
486
                                 ->required()
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
                                 ->searchable(),
498
                                 ->searchable(),
491
                             Forms\Components\Textarea::make('notes')
499
                             Forms\Components\Textarea::make('notes')
492
                                 ->label('Notes'),
500
                                 ->label('Notes'),

+ 7
- 3
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php 查看文件

93
                 Forms\Components\Select::make('bank_account_id')
93
                 Forms\Components\Select::make('bank_account_id')
94
                     ->label('Account')
94
                     ->label('Account')
95
                     ->required()
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
                     ->searchable(),
103
                     ->searchable(),
100
                 Forms\Components\Textarea::make('notes')
104
                 Forms\Components\Textarea::make('notes')
101
                     ->label('Notes'),
105
                     ->label('Notes'),

+ 7
- 3
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php 查看文件

100
                 Forms\Components\Select::make('bank_account_id')
100
                 Forms\Components\Select::make('bank_account_id')
101
                     ->label('Account')
101
                     ->label('Account')
102
                     ->required()
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
                     ->searchable(),
110
                     ->searchable(),
107
                 Forms\Components\Textarea::make('notes')
111
                 Forms\Components\Textarea::make('notes')
108
                     ->label('Notes'),
112
                     ->label('Notes'),

+ 1
- 1
app/Listeners/CreateConnectedAccount.php 查看文件

57
 
57
 
58
     public function processConnectedBankAccount($plaidAccount, Company $company, Institution $institution, $authResponse, $accessToken): void
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
         $company->connectedBankAccounts()->updateOrCreate([
62
         $company->connectedBankAccounts()->updateOrCreate([
63
             'identifier' => $identifierHash,
63
             'identifier' => $identifierHash,

+ 7
- 6
app/Livewire/Company/Service/ConnectedAccount/ListInstitutions.php 查看文件

108
         $options = ['new' => 'New Account'];
108
         $options = ['new' => 'New Account'];
109
 
109
 
110
         if ($institutionId) {
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
                 ->whereDoesntHave('connectedBankAccount')
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
                 ->toArray();
117
                 ->toArray();
118
+
119
+            $options += $accountOptions;
119
         }
120
         }
120
 
121
 
121
         return $options;
122
         return $options;

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

46
     {
46
     {
47
         $transactionType = $startingBalance >= 0 ? TransactionType::Deposit : TransactionType::Withdrawal;
47
         $transactionType = $startingBalance >= 0 ? TransactionType::Deposit : TransactionType::Withdrawal;
48
         $accountName = $startingBalance >= 0 ? "Owner's Investment" : "Owner's Drawings";
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
         $postedAt = Carbon::parse($startDate)->subDay()->toDateTimeString();
54
         $postedAt = Carbon::parse($startDate)->subDay()->toDateTimeString();
52
 
55
 

Loading…
取消
儲存