Pārlūkot izejas kodu

refactor: add queue for transactions update

3.x
wallo 1 gadu atpakaļ
vecāks
revīzija
23102c4fb5

+ 2
- 1
app/Http/Controllers/PlaidWebhookController.php Parādīt failu

@@ -36,7 +36,8 @@ class PlaidWebhookController extends Controller
36 36
         })->first();
37 37
 
38 38
         if ($company && $newTransactions > 0) {
39
-            ProcessTransactionUpdate::dispatch($company, $itemID);
39
+            ProcessTransactionUpdate::dispatch($company, $itemID)
40
+                ->onQueue('transactions');
40 41
         }
41 42
     }
42 43
 }

+ 4
- 3
app/Jobs/ProcessTransactionUpdate.php Parādīt failu

@@ -40,7 +40,8 @@ class ProcessTransactionUpdate implements ShouldQueue
40 40
     {
41 41
         $connectedBankAccounts = $this->company->connectedBankAccounts()
42 42
             ->where('item_id', $this->item_id)
43
-            ->where('import_transactions', true);
43
+            ->where('import_transactions', true)
44
+            ->get();
44 45
 
45 46
         foreach ($connectedBankAccounts as $connectedBankAccount) {
46 47
             /** @var ConnectedBankAccount $connectedBankAccount */
@@ -71,9 +72,9 @@ class ProcessTransactionUpdate implements ShouldQueue
71 72
                 $allTransactions = [...$allTransactions, ...$transactionsResponse->transactions];
72 73
             }
73 74
 
74
-            $existingTransactionIds = $bankAccount->transactions()->pluck('transaction_id')->toArray();
75
+            $existingTransactionIds = $bankAccount->transactions()->pluck('plaid_transaction_id')->toArray();
75 76
             $newTransactions = array_filter($allTransactions, static function ($transaction) use ($existingTransactionIds) {
76
-                return ! in_array($transaction->transaction_id, $existingTransactionIds) && $transaction->pending === false;
77
+                return ! in_array($transaction->transaction_id, $existingTransactionIds, true) && $transaction->pending === false;
77 78
             });
78 79
 
79 80
             if (count($newTransactions) > 0) {

+ 2
- 0
app/Models/Banking/ConnectedBankAccount.php Parādīt failu

@@ -2,6 +2,7 @@
2 2
 
3 3
 namespace App\Models\Banking;
4 4
 
5
+use App\Casts\MoneyCast;
5 6
 use App\Concerns\Blamable;
6 7
 use App\Concerns\CompanyOwned;
7 8
 use App\Enums\Banking\BankAccountType;
@@ -39,6 +40,7 @@ class ConnectedBankAccount extends Model
39 40
     ];
40 41
 
41 42
     protected $casts = [
43
+        'current_balance' => MoneyCast::class,
42 44
         'import_transactions' => 'boolean',
43 45
         'type' => BankAccountType::class,
44 46
         'access_token' => 'encrypted',

+ 12
- 12
composer.lock Parādīt failu

@@ -497,16 +497,16 @@
497 497
         },
498 498
         {
499 499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.304.5",
500
+            "version": "3.304.6",
501 501
             "source": {
502 502
                 "type": "git",
503 503
                 "url": "https://github.com/aws/aws-sdk-php.git",
504
-                "reference": "c9a02677b00e28133915afd451a1c8c3726474b7"
504
+                "reference": "02abf9b8e2afbdf281e28757c582049d3db16df7"
505 505
             },
506 506
             "dist": {
507 507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c9a02677b00e28133915afd451a1c8c3726474b7",
509
-                "reference": "c9a02677b00e28133915afd451a1c8c3726474b7",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/02abf9b8e2afbdf281e28757c582049d3db16df7",
509
+                "reference": "02abf9b8e2afbdf281e28757c582049d3db16df7",
510 510
                 "shasum": ""
511 511
             },
512 512
             "require": {
@@ -586,9 +586,9 @@
586 586
             "support": {
587 587
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
588 588
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
589
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.304.5"
589
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.304.6"
590 590
             },
591
-            "time": "2024-04-16T19:20:23+00:00"
591
+            "time": "2024-04-17T18:27:31+00:00"
592 592
         },
593 593
         {
594 594
             "name": "aws/aws-sdk-php-laravel",
@@ -10636,16 +10636,16 @@
10636 10636
         },
10637 10637
         {
10638 10638
             "name": "phpunit/phpunit",
10639
-            "version": "10.5.18",
10639
+            "version": "10.5.19",
10640 10640
             "source": {
10641 10641
                 "type": "git",
10642 10642
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
10643
-                "reference": "835df1709ac6c968ba34bf23f3c30e5d5a266de8"
10643
+                "reference": "c726f0de022368f6ed103e452a765d3304a996a4"
10644 10644
             },
10645 10645
             "dist": {
10646 10646
                 "type": "zip",
10647
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/835df1709ac6c968ba34bf23f3c30e5d5a266de8",
10648
-                "reference": "835df1709ac6c968ba34bf23f3c30e5d5a266de8",
10647
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c726f0de022368f6ed103e452a765d3304a996a4",
10648
+                "reference": "c726f0de022368f6ed103e452a765d3304a996a4",
10649 10649
                 "shasum": ""
10650 10650
             },
10651 10651
             "require": {
@@ -10717,7 +10717,7 @@
10717 10717
             "support": {
10718 10718
                 "issues": "https://github.com/sebastianbergmann/phpunit/issues",
10719 10719
                 "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
10720
-                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.18"
10720
+                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.19"
10721 10721
             },
10722 10722
             "funding": [
10723 10723
                 {
@@ -10733,7 +10733,7 @@
10733 10733
                     "type": "tidelift"
10734 10734
                 }
10735 10735
             ],
10736
-            "time": "2024-04-14T07:05:31+00:00"
10736
+            "time": "2024-04-17T14:06:18+00:00"
10737 10737
         },
10738 10738
         {
10739 10739
             "name": "sebastian/cli-parser",

+ 3
- 3
package-lock.json Parādīt failu

@@ -1079,9 +1079,9 @@
1079 1079
             "dev": true
1080 1080
         },
1081 1081
         "node_modules/electron-to-chromium": {
1082
-            "version": "1.4.738",
1083
-            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.738.tgz",
1084
-            "integrity": "sha512-lwKft2CLFztD+vEIpesrOtCrko/TFnEJlHFdRhazU7Y/jx5qc4cqsocfVrBg4So4gGe9lvxnbLIoev47WMpg+A==",
1082
+            "version": "1.4.739",
1083
+            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.739.tgz",
1084
+            "integrity": "sha512-koRkawXOuN9w/ymhTNxGfB8ta4MRKVW0nzifU17G1UwTWlBg0vv7xnz4nxDnRFSBe9nXMGRgICcAzqXc0PmLeA==",
1085 1085
             "dev": true
1086 1086
         },
1087 1087
         "node_modules/emoji-regex": {

Notiek ielāde…
Atcelt
Saglabāt