Skip to content

Commit

Permalink
fix: money formatting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
frikishaan committed Feb 12, 2024
1 parent ce51c7e commit 55b6124
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/Filament/Resources/AccountResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public static function form(Form $form): Form
Section::make()
->schema([
TextInput::make('total_sales')
->mask(RawJs::make('$money($input)'))
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
->prefix('$')
->disabled()
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function form(Form $form): Form
TextInput::make('estimated_revenue')
->label('Estimated revenue')
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
]);
}

Expand Down
4 changes: 4 additions & 0 deletions app/Filament/Resources/DealResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ public static function form(Form $form): Form
TextInput::make('estimated_revenue')
->label('Estimated revenue')
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
->disabled(fn(?Deal $record) => in_array($record?->status, [2, 3])),
TextInput::make('actual_revenue')
->label('Actual revenue')
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
->disabled(fn(?Deal $record) => in_array($record?->status, [2, 3]))
])
->columnSpan(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function form(Form $form): Form
$set('total_amount', (string)($get('price_per_unit') * $state))),
TextInput::make('price_per_unit')
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
->required()
->helperText('Price per unit of product')
Expand All @@ -56,6 +57,8 @@ public function form(Form $form): Form
TextInput::make('total_amount')
->label('Total amount')
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
->disabled()
->default(0)
]);
Expand Down
2 changes: 2 additions & 0 deletions app/Filament/Resources/LeadResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public static function form(Form $form): Form
TextInput::make('estimated_revenue')
->label('Estimated revenue')
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric()
->disabled(fn(?Lead $record) => in_array($record?->status, [3, 4]))
])
->columnSpan(1)
Expand Down
6 changes: 4 additions & 2 deletions app/Filament/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ public static function form(Form $form): Form
->required()
->helperText('Type of product'),
TextInput::make('price')
->required()
->mask(RawJs::make('$money($input)')),
->required()
->mask(RawJs::make('$money($input)'))
->stripCharacters(',')
->numeric(),
Toggle::make('is_available')
->label('Is available for purchase?')
->inline()
Expand Down

0 comments on commit 55b6124

Please sign in to comment.