Andrew Wallo 4 miesięcy temu
rodzic
commit
df72b68c27

+ 2
- 3
app/Filament/Company/Resources/Common/OfferingResource.php Wyświetl plik

@@ -12,7 +12,6 @@ use App\Filament\Forms\Components\Banner;
12 12
 use App\Filament\Forms\Components\CreateAccountSelect;
13 13
 use App\Filament\Forms\Components\CreateAdjustmentSelect;
14 14
 use App\Models\Common\Offering;
15
-use App\Utilities\Currency\CurrencyAccessor;
16 15
 use Filament\Forms;
17 16
 use Filament\Forms\Form;
18 17
 use Filament\Resources\Resource;
@@ -103,7 +102,7 @@ class OfferingResource extends Resource
103 102
             ])->columns();
104 103
     }
105 104
 
106
-    public static function getSellableSection(bool $showByDefault = false): Forms\Components\Section
105
+    public static function getSellableSection(): Forms\Components\Section
107 106
     {
108 107
         return Forms\Components\Section::make('Sale Information')
109 108
             ->schema([
@@ -178,7 +177,7 @@ class OfferingResource extends Resource
178 177
                 Tables\Columns\TextColumn::make('type')
179 178
                     ->searchable(),
180 179
                 Tables\Columns\TextColumn::make('price')
181
-                    ->currency(CurrencyAccessor::getDefaultCurrency(), true)
180
+                    ->currency()
182 181
                     ->sortable()
183 182
                     ->description(function (Offering $record) {
184 183
                         $adjustments = $record->adjustments()

+ 0
- 2
app/Filament/Company/Resources/Purchases/BillResource.php Wyświetl plik

@@ -282,11 +282,9 @@ class BillResource extends Resource
282 282
                                     ->maxValue(9999999999.99)
283 283
                                     ->default(1),
284 284
                                 Forms\Components\TextInput::make('unit_price')
285
-                                    ->label('Price')
286 285
                                     ->hiddenLabel()
287 286
                                     ->money(useAffix: false)
288 287
                                     ->live()
289
-                                    ->maxValue(9999999999.99)
290 288
                                     ->default(0),
291 289
                                 Forms\Components\Group::make([
292 290
                                     CreateAdjustmentSelect::make('purchaseTaxes')

+ 5
- 4
app/Filament/Company/Resources/Sales/EstimateResource.php Wyświetl plik

@@ -259,7 +259,7 @@ class EstimateResource extends Resource
259 259
                                                 return;
260 260
                                             }
261 261
 
262
-                                            $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, CurrencyAccessor::getDefaultCurrency());
262
+                                            $unitPrice = CurrencyConverter::convertCentsToFormatSimple($offeringRecord->price, 'USD');
263 263
 
264 264
                                             $set('description', $offeringRecord->description);
265 265
                                             $set('unit_price', $unitPrice);
@@ -281,9 +281,8 @@ class EstimateResource extends Resource
281 281
                                     ->default(1),
282 282
                                 Forms\Components\TextInput::make('unit_price')
283 283
                                     ->hiddenLabel()
284
-                                    ->numeric()
284
+                                    ->money(useAffix: false)
285 285
                                     ->live()
286
-                                    ->maxValue(9999999999.99)
287 286
                                     ->default(0),
288 287
                                 Forms\Components\Group::make([
289 288
                                     CreateAdjustmentSelect::make('salesTaxes')
@@ -324,7 +323,9 @@ class EstimateResource extends Resource
324 323
                                     ->extraAttributes(['class' => 'text-left sm:text-right'])
325 324
                                     ->content(function (Forms\Get $get) {
326 325
                                         $quantity = max((float) ($get('quantity') ?? 0), 0);
327
-                                        $unitPrice = max((float) ($get('unit_price') ?? 0), 0);
326
+                                        $unitPrice = CurrencyConverter::isValidAmount($get('unit_price'), 'USD')
327
+                                            ? CurrencyConverter::convertToFloat($get('unit_price'), 'USD')
328
+                                            : 0;
328 329
                                         $salesTaxes = $get('salesTaxes') ?? [];
329 330
                                         $salesDiscounts = $get('salesDiscounts') ?? [];
330 331
                                         $currencyCode = $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency();

+ 0
- 1
app/Filament/Company/Resources/Sales/InvoiceResource.php Wyświetl plik

@@ -296,7 +296,6 @@ class InvoiceResource extends Resource
296 296
                                     ->hiddenLabel()
297 297
                                     ->money(useAffix: false)
298 298
                                     ->live()
299
-                                    ->maxValue(9999999999.99)
300 299
                                     ->default(0),
301 300
                                 Forms\Components\Group::make([
302 301
                                     CreateAdjustmentSelect::make('salesTaxes')

+ 5
- 4
app/Filament/Company/Resources/Sales/RecurringInvoiceResource.php Wyświetl plik

@@ -185,7 +185,7 @@ class RecurringInvoiceResource extends Resource
185 185
                                                 return;
186 186
                                             }
187 187
 
188
-                                            $unitPrice = CurrencyConverter::convertToFloat($offeringRecord->price, CurrencyAccessor::getDefaultCurrency());
188
+                                            $unitPrice = CurrencyConverter::convertCentsToFormatSimple($offeringRecord->price, 'USD');
189 189
 
190 190
                                             $set('description', $offeringRecord->description);
191 191
                                             $set('unit_price', $unitPrice);
@@ -207,9 +207,8 @@ class RecurringInvoiceResource extends Resource
207 207
                                     ->default(1),
208 208
                                 Forms\Components\TextInput::make('unit_price')
209 209
                                     ->hiddenLabel()
210
-                                    ->numeric()
210
+                                    ->money(useAffix: false)
211 211
                                     ->live()
212
-                                    ->maxValue(9999999999.99)
213 212
                                     ->default(0),
214 213
                                 Forms\Components\Group::make([
215 214
                                     CreateAdjustmentSelect::make('salesTaxes')
@@ -250,7 +249,9 @@ class RecurringInvoiceResource extends Resource
250 249
                                     ->extraAttributes(['class' => 'text-left sm:text-right'])
251 250
                                     ->content(function (Forms\Get $get) {
252 251
                                         $quantity = max((float) ($get('quantity') ?? 0), 0);
253
-                                        $unitPrice = max((float) ($get('unit_price') ?? 0), 0);
252
+                                        $unitPrice = CurrencyConverter::isValidAmount($get('unit_price'), 'USD')
253
+                                            ? CurrencyConverter::convertToFloat($get('unit_price'), 'USD')
254
+                                            : 0;
254 255
                                         $salesTaxes = $get('salesTaxes') ?? [];
255 256
                                         $salesDiscounts = $get('salesDiscounts') ?? [];
256 257
                                         $currencyCode = $get('../../currency_code') ?? CurrencyAccessor::getDefaultCurrency();

Ładowanie…
Anuluj
Zapisz