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

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

466
                                     ->live(onBlur: true)
466
                                     ->live(onBlur: true)
467
                                     ->helperText(function (Bill $record, $state) {
467
                                     ->helperText(function (Bill $record, $state) {
468
                                         $billCurrency = $record->currency_code;
468
                                         $billCurrency = $record->currency_code;
469
-                                        if (! CurrencyConverter::isValidAmount($state, $billCurrency)) {
469
+                                        if (! CurrencyConverter::isValidAmount($state, 'USD')) {
470
                                             return null;
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
                                         if ($amount <= 0) {
476
                                         if ($amount <= 0) {
477
                                             return 'Please enter a valid positive amount';
477
                                             return 'Please enter a valid positive amount';
486
                                         };
486
                                         };
487
                                     })
487
                                     })
488
                                     ->rules([
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
                                                 $fail('Please enter a valid amount');
491
                                                 $fail('Please enter a valid amount');
492
                                             }
492
                                             }
493
                                         },
493
                                         },

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

83
                                     return null;
83
                                     return null;
84
                                 }
84
                                 }
85
 
85
 
86
-                                $amountDue = $ownerRecord->getRawOriginal('amount_due');
86
+                                $amountDue = $ownerRecord->amount_due;
87
 
87
 
88
                                 $amount = CurrencyConverter::convertToCents($state, 'USD');
88
                                 $amount = CurrencyConverter::convertToCents($state, 'USD');
89
 
89
 
91
                                     return 'Please enter a valid positive amount';
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
                                 $newAmountDue = $amountDue - $amount + $currentPaymentAmount;
96
                                 $newAmountDue = $amountDue - $amount + $currentPaymentAmount;
97
 
97
 
102
                                 };
102
                                 };
103
                             })
103
                             })
104
                             ->rules([
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
                                         $fail('Please enter a valid amount');
107
                                         $fail('Please enter a valid amount');
111
                                     }
108
                                     }
112
                                 },
109
                                 },

+ 5
- 5
app/Filament/Company/Resources/Sales/InvoiceResource.php 查看文件

518
                                     ->live(onBlur: true)
518
                                     ->live(onBlur: true)
519
                                     ->helperText(function (Invoice $record, $state) {
519
                                     ->helperText(function (Invoice $record, $state) {
520
                                         $invoiceCurrency = $record->currency_code;
520
                                         $invoiceCurrency = $record->currency_code;
521
-                                        if (! CurrencyConverter::isValidAmount($state, $invoiceCurrency)) {
521
+                                        if (! CurrencyConverter::isValidAmount($state, 'USD')) {
522
                                             return null;
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
                                         if ($amount <= 0) {
529
                                         if ($amount <= 0) {
530
                                             return 'Please enter a valid positive amount';
530
                                             return 'Please enter a valid positive amount';
543
                                         };
543
                                         };
544
                                     })
544
                                     })
545
                                     ->rules([
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
                                                 $fail('Please enter a valid amount');
548
                                                 $fail('Please enter a valid amount');
549
                                             }
549
                                             }
550
                                         },
550
                                         },

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

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

Loading…
取消
儲存