Преглед на файлове

refactor: add queue for transactions update

3.x
wallo преди 1 година
родител
ревизия
23102c4fb5
променени са 5 файла, в които са добавени 23 реда и са изтрити 19 реда
  1. 2
    1
      app/Http/Controllers/PlaidWebhookController.php
  2. 4
    3
      app/Jobs/ProcessTransactionUpdate.php
  3. 2
    0
      app/Models/Banking/ConnectedBankAccount.php
  4. 12
    12
      composer.lock
  5. 3
    3
      package-lock.json

+ 2
- 1
app/Http/Controllers/PlaidWebhookController.php Целия файл

36
         })->first();
36
         })->first();
37
 
37
 
38
         if ($company && $newTransactions > 0) {
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 Целия файл

40
     {
40
     {
41
         $connectedBankAccounts = $this->company->connectedBankAccounts()
41
         $connectedBankAccounts = $this->company->connectedBankAccounts()
42
             ->where('item_id', $this->item_id)
42
             ->where('item_id', $this->item_id)
43
-            ->where('import_transactions', true);
43
+            ->where('import_transactions', true)
44
+            ->get();
44
 
45
 
45
         foreach ($connectedBankAccounts as $connectedBankAccount) {
46
         foreach ($connectedBankAccounts as $connectedBankAccount) {
46
             /** @var ConnectedBankAccount $connectedBankAccount */
47
             /** @var ConnectedBankAccount $connectedBankAccount */
71
                 $allTransactions = [...$allTransactions, ...$transactionsResponse->transactions];
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
             $newTransactions = array_filter($allTransactions, static function ($transaction) use ($existingTransactionIds) {
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
             if (count($newTransactions) > 0) {
80
             if (count($newTransactions) > 0) {

+ 2
- 0
app/Models/Banking/ConnectedBankAccount.php Целия файл

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

+ 12
- 12
composer.lock Целия файл

497
         },
497
         },
498
         {
498
         {
499
             "name": "aws/aws-sdk-php",
499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.304.5",
500
+            "version": "3.304.6",
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": "c9a02677b00e28133915afd451a1c8c3726474b7"
504
+                "reference": "02abf9b8e2afbdf281e28757c582049d3db16df7"
505
             },
505
             },
506
             "dist": {
506
             "dist": {
507
                 "type": "zip",
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
                 "shasum": ""
510
                 "shasum": ""
511
             },
511
             },
512
             "require": {
512
             "require": {
586
             "support": {
586
             "support": {
587
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
587
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
588
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
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
             "name": "aws/aws-sdk-php-laravel",
594
             "name": "aws/aws-sdk-php-laravel",
10636
         },
10636
         },
10637
         {
10637
         {
10638
             "name": "phpunit/phpunit",
10638
             "name": "phpunit/phpunit",
10639
-            "version": "10.5.18",
10639
+            "version": "10.5.19",
10640
             "source": {
10640
             "source": {
10641
                 "type": "git",
10641
                 "type": "git",
10642
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
10642
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
10643
-                "reference": "835df1709ac6c968ba34bf23f3c30e5d5a266de8"
10643
+                "reference": "c726f0de022368f6ed103e452a765d3304a996a4"
10644
             },
10644
             },
10645
             "dist": {
10645
             "dist": {
10646
                 "type": "zip",
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
                 "shasum": ""
10649
                 "shasum": ""
10650
             },
10650
             },
10651
             "require": {
10651
             "require": {
10717
             "support": {
10717
             "support": {
10718
                 "issues": "https://github.com/sebastianbergmann/phpunit/issues",
10718
                 "issues": "https://github.com/sebastianbergmann/phpunit/issues",
10719
                 "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
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
             "funding": [
10722
             "funding": [
10723
                 {
10723
                 {
10733
                     "type": "tidelift"
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
             "name": "sebastian/cli-parser",
10739
             "name": "sebastian/cli-parser",

+ 3
- 3
package-lock.json Целия файл

1079
             "dev": true
1079
             "dev": true
1080
         },
1080
         },
1081
         "node_modules/electron-to-chromium": {
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
             "dev": true
1085
             "dev": true
1086
         },
1086
         },
1087
         "node_modules/emoji-regex": {
1087
         "node_modules/emoji-regex": {

Loading…
Отказ
Запис