Pārlūkot izejas kodu

fix: TransactionObserver.php

3.x
wallo 1 gadu atpakaļ
vecāks
revīzija
6dac2af526

+ 0
- 6
app/Observers/JournalEntryObserver.php Parādīt failu

2
 
2
 
3
 namespace App\Observers;
3
 namespace App\Observers;
4
 
4
 
5
-use App\Models\Accounting\Account;
6
 use App\Models\Accounting\JournalEntry;
5
 use App\Models\Accounting\JournalEntry;
7
 
6
 
8
 class JournalEntryObserver
7
 class JournalEntryObserver
15
         //
14
         //
16
     }
15
     }
17
 
16
 
18
-    private function updateEndingBalance(Account $account): void
19
-    {
20
-        //
21
-    }
22
-
23
     /**
17
     /**
24
      * Handle the JournalEntry "deleting" event.
18
      * Handle the JournalEntry "deleting" event.
25
      */
19
      */

+ 5
- 4
app/Observers/TransactionObserver.php Parādīt failu

2
 
2
 
3
 namespace App\Observers;
3
 namespace App\Observers;
4
 
4
 
5
+use App\Enums\Accounting\JournalEntryType;
5
 use App\Enums\Accounting\TransactionType;
6
 use App\Enums\Accounting\TransactionType;
6
 use App\Models\Accounting\Account;
7
 use App\Models\Accounting\Account;
7
 use App\Models\Accounting\JournalEntry;
8
 use App\Models\Accounting\JournalEntry;
33
         $debitAccount->journalEntries()->create([
34
         $debitAccount->journalEntries()->create([
34
             'company_id' => $transaction->company_id,
35
             'company_id' => $transaction->company_id,
35
             'transaction_id' => $transaction->id,
36
             'transaction_id' => $transaction->id,
36
-            'type' => 'debit',
37
+            'type' => JournalEntryType::Debit,
37
             'amount' => $transaction->amount,
38
             'amount' => $transaction->amount,
38
             'description' => $transaction->description,
39
             'description' => $transaction->description,
39
         ]);
40
         ]);
41
         $creditAccount->journalEntries()->create([
42
         $creditAccount->journalEntries()->create([
42
             'company_id' => $transaction->company_id,
43
             'company_id' => $transaction->company_id,
43
             'transaction_id' => $transaction->id,
44
             'transaction_id' => $transaction->id,
44
-            'type' => 'credit',
45
+            'type' => JournalEntryType::Credit,
45
             'amount' => $transaction->amount,
46
             'amount' => $transaction->amount,
46
             'description' => $transaction->description,
47
             'description' => $transaction->description,
47
         ]);
48
         ]);
65
 
66
 
66
         $journalEntries = $transaction->journalEntries;
67
         $journalEntries = $transaction->journalEntries;
67
 
68
 
68
-        $debitEntry = $journalEntries->where('type', 'debit')->first();
69
-        $creditEntry = $journalEntries->where('type', 'credit')->first();
69
+        $debitEntry = $journalEntries->where('type', JournalEntryType::Debit)->first();
70
+        $creditEntry = $journalEntries->where('type', JournalEntryType::Credit)->first();
70
 
71
 
71
         if (! $debitEntry || ! $creditEntry) {
72
         if (! $debitEntry || ! $creditEntry) {
72
             return;
73
             return;

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

497
         },
497
         },
498
         {
498
         {
499
             "name": "aws/aws-sdk-php",
499
             "name": "aws/aws-sdk-php",
500
-            "version": "3.304.0",
500
+            "version": "3.304.1",
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": "29a79bac02997f3053559f6961a0e83622a14f88"
504
+                "reference": "6dac9b3257873a807ac73f6dc4418bdc49a5d9db"
505
             },
505
             },
506
             "dist": {
506
             "dist": {
507
                 "type": "zip",
507
                 "type": "zip",
508
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/29a79bac02997f3053559f6961a0e83622a14f88",
509
-                "reference": "29a79bac02997f3053559f6961a0e83622a14f88",
508
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/6dac9b3257873a807ac73f6dc4418bdc49a5d9db",
509
+                "reference": "6dac9b3257873a807ac73f6dc4418bdc49a5d9db",
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.0"
589
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.304.1"
590
             },
590
             },
591
-            "time": "2024-04-08T18:03:38+00:00"
591
+            "time": "2024-04-09T19:25:27+00:00"
592
         },
592
         },
593
         {
593
         {
594
             "name": "aws/aws-sdk-php-laravel",
594
             "name": "aws/aws-sdk-php-laravel",
3093
         },
3093
         },
3094
         {
3094
         {
3095
             "name": "laravel/framework",
3095
             "name": "laravel/framework",
3096
-            "version": "v11.2.0",
3096
+            "version": "v11.3.0",
3097
             "source": {
3097
             "source": {
3098
                 "type": "git",
3098
                 "type": "git",
3099
                 "url": "https://github.com/laravel/framework.git",
3099
                 "url": "https://github.com/laravel/framework.git",
3100
-                "reference": "a1750156b671f37cba702380107e2d22161c31e3"
3100
+                "reference": "cbcb0ee3da8c5f98497d9a282609732251a7dd1e"
3101
             },
3101
             },
3102
             "dist": {
3102
             "dist": {
3103
                 "type": "zip",
3103
                 "type": "zip",
3104
-                "url": "https://api.github.com/repos/laravel/framework/zipball/a1750156b671f37cba702380107e2d22161c31e3",
3105
-                "reference": "a1750156b671f37cba702380107e2d22161c31e3",
3104
+                "url": "https://api.github.com/repos/laravel/framework/zipball/cbcb0ee3da8c5f98497d9a282609732251a7dd1e",
3105
+                "reference": "cbcb0ee3da8c5f98497d9a282609732251a7dd1e",
3106
                 "shasum": ""
3106
                 "shasum": ""
3107
             },
3107
             },
3108
             "require": {
3108
             "require": {
3294
                 "issues": "https://github.com/laravel/framework/issues",
3294
                 "issues": "https://github.com/laravel/framework/issues",
3295
                 "source": "https://github.com/laravel/framework"
3295
                 "source": "https://github.com/laravel/framework"
3296
             },
3296
             },
3297
-            "time": "2024-04-02T14:01:33+00:00"
3297
+            "time": "2024-04-09T15:19:11+00:00"
3298
         },
3298
         },
3299
         {
3299
         {
3300
             "name": "laravel/prompts",
3300
             "name": "laravel/prompts",
3301
-            "version": "v0.1.17",
3301
+            "version": "v0.1.18",
3302
             "source": {
3302
             "source": {
3303
                 "type": "git",
3303
                 "type": "git",
3304
                 "url": "https://github.com/laravel/prompts.git",
3304
                 "url": "https://github.com/laravel/prompts.git",
3305
-                "reference": "8ee9f87f7f9eadcbe21e9e72cd4176b2f06cd5b5"
3305
+                "reference": "3b5e6b03f1f1175574b5a32331d99c9819da9848"
3306
             },
3306
             },
3307
             "dist": {
3307
             "dist": {
3308
                 "type": "zip",
3308
                 "type": "zip",
3309
-                "url": "https://api.github.com/repos/laravel/prompts/zipball/8ee9f87f7f9eadcbe21e9e72cd4176b2f06cd5b5",
3310
-                "reference": "8ee9f87f7f9eadcbe21e9e72cd4176b2f06cd5b5",
3309
+                "url": "https://api.github.com/repos/laravel/prompts/zipball/3b5e6b03f1f1175574b5a32331d99c9819da9848",
3310
+                "reference": "3b5e6b03f1f1175574b5a32331d99c9819da9848",
3311
                 "shasum": ""
3311
                 "shasum": ""
3312
             },
3312
             },
3313
             "require": {
3313
             "require": {
3349
             ],
3349
             ],
3350
             "support": {
3350
             "support": {
3351
                 "issues": "https://github.com/laravel/prompts/issues",
3351
                 "issues": "https://github.com/laravel/prompts/issues",
3352
-                "source": "https://github.com/laravel/prompts/tree/v0.1.17"
3352
+                "source": "https://github.com/laravel/prompts/tree/v0.1.18"
3353
             },
3353
             },
3354
-            "time": "2024-03-13T16:05:43+00:00"
3354
+            "time": "2024-04-04T17:41:50+00:00"
3355
         },
3355
         },
3356
         {
3356
         {
3357
             "name": "laravel/sanctum",
3357
             "name": "laravel/sanctum",

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

1066
             "dev": true
1066
             "dev": true
1067
         },
1067
         },
1068
         "node_modules/electron-to-chromium": {
1068
         "node_modules/electron-to-chromium": {
1069
-            "version": "1.4.730",
1070
-            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.730.tgz",
1071
-            "integrity": "sha512-oJRPo82XEqtQAobHpJIR3zW5YO3sSRRkPz2an4yxi1UvqhsGm54vR/wzTFV74a3soDOJ8CKW7ajOOX5ESzddwg==",
1069
+            "version": "1.4.731",
1070
+            "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.731.tgz",
1071
+            "integrity": "sha512-+TqVfZjpRz2V/5SPpmJxq9qK620SC5SqCnxQIOi7i/U08ZDcTpKbT7Xjj9FU5CbXTMUb4fywbIr8C7cGv4hcjw==",
1072
             "dev": true
1072
             "dev": true
1073
         },
1073
         },
1074
         "node_modules/emoji-regex": {
1074
         "node_modules/emoji-regex": {

Notiek ielāde…
Atcelt
Saglabāt