Parcourir la source

wip always use USD for inputs

3.x
Andrew Wallo il y a 4 mois
Parent
révision
9ea3e4cbad

+ 4
- 4
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php Voir le fichier

@@ -79,13 +79,13 @@ class PaymentsRelationManager extends RelationManager
79 79
 
80 80
                                 $billCurrency = $ownerRecord->currency_code;
81 81
 
82
-                                if (! CurrencyConverter::isValidAmount($state, $billCurrency)) {
82
+                                if (! CurrencyConverter::isValidAmount($state, 'USD')) {
83 83
                                     return null;
84 84
                                 }
85 85
 
86 86
                                 $amountDue = $ownerRecord->getRawOriginal('amount_due');
87 87
 
88
-                                $amount = CurrencyConverter::convertToCents($state, $billCurrency);
88
+                                $amount = CurrencyConverter::convertToCents($state, 'USD');
89 89
 
90 90
                                 if ($amount <= 0) {
91 91
                                     return 'Please enter a valid positive amount';
@@ -122,7 +122,7 @@ class PaymentsRelationManager extends RelationManager
122 122
                         $bill = $livewire->getOwnerRecord();
123 123
                         $billCurrency = $bill->currency_code;
124 124
 
125
-                        if (empty($amount) || empty($bankAccountId) || ! CurrencyConverter::isValidAmount($amount, $billCurrency)) {
125
+                        if (empty($amount) || empty($bankAccountId) || ! CurrencyConverter::isValidAmount($amount, 'USD')) {
126 126
                             return null;
127 127
                         }
128 128
 
@@ -139,7 +139,7 @@ class PaymentsRelationManager extends RelationManager
139 139
                         }
140 140
 
141 141
                         // Convert amount from bill currency to bank currency
142
-                        $amountInBillCurrencyCents = CurrencyConverter::convertToCents($amount, $billCurrency);
142
+                        $amountInBillCurrencyCents = CurrencyConverter::convertToCents($amount, 'USD');
143 143
                         $amountInBankCurrencyCents = CurrencyConverter::convertBalance(
144 144
                             $amountInBillCurrencyCents,
145 145
                             $billCurrency,

+ 4
- 4
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php Voir le fichier

@@ -88,13 +88,13 @@ class PaymentsRelationManager extends RelationManager
88 88
 
89 89
                                 $invoiceCurrency = $ownerRecord->currency_code;
90 90
 
91
-                                if (! CurrencyConverter::isValidAmount($state, $invoiceCurrency)) {
91
+                                if (! CurrencyConverter::isValidAmount($state, 'USD')) {
92 92
                                     return null;
93 93
                                 }
94 94
 
95 95
                                 $amountDue = $ownerRecord->getRawOriginal('amount_due');
96 96
 
97
-                                $amount = CurrencyConverter::convertToCents($state, $invoiceCurrency);
97
+                                $amount = CurrencyConverter::convertToCents($state, 'USD');
98 98
 
99 99
                                 if ($amount <= 0) {
100 100
                                     return 'Please enter a valid positive amount';
@@ -135,7 +135,7 @@ class PaymentsRelationManager extends RelationManager
135 135
                         $invoice = $livewire->getOwnerRecord();
136 136
                         $invoiceCurrency = $invoice->currency_code;
137 137
 
138
-                        if (empty($amount) || empty($bankAccountId) || ! CurrencyConverter::isValidAmount($amount, $invoiceCurrency)) {
138
+                        if (empty($amount) || empty($bankAccountId) || ! CurrencyConverter::isValidAmount($amount, 'USD')) {
139 139
                             return null;
140 140
                         }
141 141
 
@@ -152,7 +152,7 @@ class PaymentsRelationManager extends RelationManager
152 152
                         }
153 153
 
154 154
                         // Convert amount from invoice currency to bank currency
155
-                        $amountInInvoiceCurrencyCents = CurrencyConverter::convertToCents($amount, $invoiceCurrency);
155
+                        $amountInInvoiceCurrencyCents = CurrencyConverter::convertToCents($amount, 'USD');
156 156
                         $amountInBankCurrencyCents = CurrencyConverter::convertBalance(
157 157
                             $amountInInvoiceCurrencyCents,
158 158
                             $invoiceCurrency,

+ 2
- 3
app/Providers/MacroServiceProvider.php Voir le fichier

@@ -66,13 +66,12 @@ class MacroServiceProvider extends ServiceProvider
66 66
             }
67 67
 
68 68
             $this->mask(RawJs::make('$money($input)'))
69
-                ->afterStateHydrated(function (TextInput $component, ?int $state) use ($currency) {
69
+                ->afterStateHydrated(function (TextInput $component, ?int $state) {
70 70
                     if (blank($state)) {
71 71
                         return;
72 72
                     }
73 73
 
74
-                    $currencyCode = $component->evaluate($currency);
75
-                    $formatted = CurrencyConverter::convertCentsToFormatSimple($state, $currencyCode);
74
+                    $formatted = CurrencyConverter::convertCentsToFormatSimple($state, 'USD');
76 75
                     $component->state($formatted);
77 76
                 })
78 77
                 ->dehydrateStateUsing(function (?string $state): ?int {

Chargement…
Annuler
Enregistrer