Browse Source

wip always use USD for inputs

3.x
Andrew Wallo 4 months ago
parent
commit
9ea3e4cbad

+ 4
- 4
app/Filament/Company/Resources/Purchases/BillResource/RelationManagers/PaymentsRelationManager.php View File

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

+ 4
- 4
app/Filament/Company/Resources/Sales/InvoiceResource/RelationManagers/PaymentsRelationManager.php View File

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

+ 2
- 3
app/Providers/MacroServiceProvider.php View File

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

Loading…
Cancel
Save