Andrew Wallo 4 个月前
父节点
当前提交
df72b68c27

+ 2
- 3
app/Filament/Company/Resources/Common/OfferingResource.php 查看文件

12
 use App\Filament\Forms\Components\CreateAccountSelect;
12
 use App\Filament\Forms\Components\CreateAccountSelect;
13
 use App\Filament\Forms\Components\CreateAdjustmentSelect;
13
 use App\Filament\Forms\Components\CreateAdjustmentSelect;
14
 use App\Models\Common\Offering;
14
 use App\Models\Common\Offering;
15
-use App\Utilities\Currency\CurrencyAccessor;
16
 use Filament\Forms;
15
 use Filament\Forms;
17
 use Filament\Forms\Form;
16
 use Filament\Forms\Form;
18
 use Filament\Resources\Resource;
17
 use Filament\Resources\Resource;
103
             ])->columns();
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
         return Forms\Components\Section::make('Sale Information')
107
         return Forms\Components\Section::make('Sale Information')
109
             ->schema([
108
             ->schema([
178
                 Tables\Columns\TextColumn::make('type')
177
                 Tables\Columns\TextColumn::make('type')
179
                     ->searchable(),
178
                     ->searchable(),
180
                 Tables\Columns\TextColumn::make('price')
179
                 Tables\Columns\TextColumn::make('price')
181
-                    ->currency(CurrencyAccessor::getDefaultCurrency(), true)
180
+                    ->currency()
182
                     ->sortable()
181
                     ->sortable()
183
                     ->description(function (Offering $record) {
182
                     ->description(function (Offering $record) {
184
                         $adjustments = $record->adjustments()
183
                         $adjustments = $record->adjustments()

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

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

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

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

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

296
                                     ->hiddenLabel()
296
                                     ->hiddenLabel()
297
                                     ->money(useAffix: false)
297
                                     ->money(useAffix: false)
298
                                     ->live()
298
                                     ->live()
299
-                                    ->maxValue(9999999999.99)
300
                                     ->default(0),
299
                                     ->default(0),
301
                                 Forms\Components\Group::make([
300
                                 Forms\Components\Group::make([
302
                                     CreateAdjustmentSelect::make('salesTaxes')
301
                                     CreateAdjustmentSelect::make('salesTaxes')

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

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

正在加载...
取消
保存