Andrew Wallo 4 місяці тому
джерело
коміт
a4820ea80c

+ 5
- 5
app/Filament/Company/Resources/Purchases/BillResource.php Переглянути файл

@@ -466,12 +466,12 @@ class BillResource extends Resource
466 466
                                     ->live(onBlur: true)
467 467
                                     ->helperText(function (Bill $record, $state) {
468 468
                                         $billCurrency = $record->currency_code;
469
-                                        if (! CurrencyConverter::isValidAmount($state, $billCurrency)) {
469
+                                        if (! CurrencyConverter::isValidAmount($state, 'USD')) {
470 470
                                             return null;
471 471
                                         }
472 472
 
473
-                                        $amountDue = $record->getRawOriginal('amount_due');
474
-                                        $amount = CurrencyConverter::convertToCents($state, $billCurrency);
473
+                                        $amountDue = $record->amount_due;
474
+                                        $amount = CurrencyConverter::convertToCents($state, 'USD');
475 475
 
476 476
                                         if ($amount <= 0) {
477 477
                                             return 'Please enter a valid positive amount';
@@ -486,8 +486,8 @@ class BillResource extends Resource
486 486
                                         };
487 487
                                     })
488 488
                                     ->rules([
489
-                                        static fn (Bill $record): Closure => static function (string $attribute, $value, Closure $fail) use ($record) {
490
-                                            if (! CurrencyConverter::isValidAmount($value, $record->currency_code)) {
489
+                                        static fn (): Closure => static function (string $attribute, $value, Closure $fail) {
490
+                                            if (! CurrencyConverter::isValidAmount($value, 'USD')) {
491 491
                                                 $fail('Please enter a valid amount');
492 492
                                             }
493 493
                                         },

+ 4
- 7
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php Переглянути файл

@@ -83,7 +83,7 @@ class PaymentsRelationManager extends RelationManager
83 83
                                     return null;
84 84
                                 }
85 85
 
86
-                                $amountDue = $ownerRecord->getRawOriginal('amount_due');
86
+                                $amountDue = $ownerRecord->amount_due;
87 87
 
88 88
                                 $amount = CurrencyConverter::convertToCents($state, 'USD');
89 89
 
@@ -91,7 +91,7 @@ class PaymentsRelationManager extends RelationManager
91 91
                                     return 'Please enter a valid positive amount';
92 92
                                 }
93 93
 
94
-                                $currentPaymentAmount = $record?->getRawOriginal('amount') ?? 0;
94
+                                $currentPaymentAmount = $record?->amount ?? 0;
95 95
 
96 96
                                 $newAmountDue = $amountDue - $amount + $currentPaymentAmount;
97 97
 
@@ -102,11 +102,8 @@ class PaymentsRelationManager extends RelationManager
102 102
                                 };
103 103
                             })
104 104
                             ->rules([
105
-                                static fn (RelationManager $livewire): Closure => static function (string $attribute, $value, Closure $fail) use ($livewire) {
106
-                                    /** @var Bill $bill */
107
-                                    $bill = $livewire->getOwnerRecord();
108
-
109
-                                    if (! CurrencyConverter::isValidAmount($value, $bill->currency_code)) {
105
+                                static fn (): Closure => static function (string $attribute, $value, Closure $fail) {
106
+                                    if (! CurrencyConverter::isValidAmount($value, 'USD')) {
110 107
                                         $fail('Please enter a valid amount');
111 108
                                     }
112 109
                                 },

+ 5
- 5
app/Filament/Company/Resources/Sales/InvoiceResource.php Переглянути файл

@@ -518,13 +518,13 @@ class InvoiceResource extends Resource
518 518
                                     ->live(onBlur: true)
519 519
                                     ->helperText(function (Invoice $record, $state) {
520 520
                                         $invoiceCurrency = $record->currency_code;
521
-                                        if (! CurrencyConverter::isValidAmount($state, $invoiceCurrency)) {
521
+                                        if (! CurrencyConverter::isValidAmount($state, 'USD')) {
522 522
                                             return null;
523 523
                                         }
524 524
 
525
-                                        $amountDue = $record->getRawOriginal('amount_due');
525
+                                        $amountDue = $record->amount_due;
526 526
 
527
-                                        $amount = CurrencyConverter::convertToCents($state, $invoiceCurrency);
527
+                                        $amount = CurrencyConverter::convertToCents($state, 'USD');
528 528
 
529 529
                                         if ($amount <= 0) {
530 530
                                             return 'Please enter a valid positive amount';
@@ -543,8 +543,8 @@ class InvoiceResource extends Resource
543 543
                                         };
544 544
                                     })
545 545
                                     ->rules([
546
-                                        static fn (Invoice $record): Closure => static function (string $attribute, $value, Closure $fail) use ($record) {
547
-                                            if (! CurrencyConverter::isValidAmount($value, $record->currency_code)) {
546
+                                        static fn (): Closure => static function (string $attribute, $value, Closure $fail) {
547
+                                            if (! CurrencyConverter::isValidAmount($value, 'USD')) {
548 548
                                                 $fail('Please enter a valid amount');
549 549
                                             }
550 550
                                         },

+ 1
- 1
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php Переглянути файл

@@ -92,7 +92,7 @@ class PaymentsRelationManager extends RelationManager
92 92
                                     return null;
93 93
                                 }
94 94
 
95
-                                $amountDue = $ownerRecord->getRawOriginal('amount_due');
95
+                                $amountDue = $ownerRecord->amount_due;
96 96
 
97 97
                                 $amount = CurrencyConverter::convertToCents($state, 'USD');
98 98
 

Завантаження…
Відмінити
Зберегти